diff --git a/ApplicationCode/ModelVisualization/ModelVisualization_UnitTests/RivCellFaceIntersection-Test.cpp b/ApplicationCode/ModelVisualization/ModelVisualization_UnitTests/RivCellFaceIntersection-Test.cpp index 0666ddeea4..eefc79effb 100644 --- a/ApplicationCode/ModelVisualization/ModelVisualization_UnitTests/RivCellFaceIntersection-Test.cpp +++ b/ApplicationCode/ModelVisualization/ModelVisualization_UnitTests/RivCellFaceIntersection-Test.cpp @@ -220,7 +220,7 @@ TEST(CellFaceIntersectionTst, Intersection1) isOk = GeometryTools::calculateOverlapPolygonOfTwoQuads( &polygon, &additionalVertices, - edgeIntersectionStorage, + &edgeIntersectionStorage, wrapArrayConst(&nodes), faces[0].data(), faces[1].data(), @@ -240,7 +240,7 @@ TEST(CellFaceIntersectionTst, Intersection1) isOk = GeometryTools::calculateOverlapPolygonOfTwoQuads( &polygon, &additionalVertices, - edgeIntersectionStorage, + &edgeIntersectionStorage, wrapArrayConst(&nodes), faces[0].data(), faces[2].data(), @@ -260,7 +260,7 @@ TEST(CellFaceIntersectionTst, Intersection1) isOk = GeometryTools::calculateOverlapPolygonOfTwoQuads( &polygon, &additionalVertices, - edgeIntersectionStorage, + &edgeIntersectionStorage, wrapArrayConst(&nodes), faces[0].data(), faces[3].data(), @@ -411,7 +411,7 @@ TEST(CellFaceIntersectionTst, Intersection) nodes[7] = cvf::Vec3d(0, 1, 0); - bool isOk = GeometryTools::calculateOverlapPolygonOfTwoQuads(&polygon, &additionalVertices, edgeIntersectionStorage, + bool isOk = GeometryTools::calculateOverlapPolygonOfTwoQuads(&polygon, &additionalVertices, &edgeIntersectionStorage, wrapArrayConst(&nodes), cv1CubeFaceIndices, cv2CubeFaceIndices, 1e-6); EXPECT_EQ( (size_t)4, polygon.size()); EXPECT_EQ( (size_t)0, additionalVertices.size()); @@ -429,7 +429,7 @@ TEST(CellFaceIntersectionTst, Intersection) nodes[7] = cvf::Vec3d(-0.25, 0.5, 0); polygon.clear(); - isOk = GeometryTools::calculateOverlapPolygonOfTwoQuads(&polygon, &additionalVertices, edgeIntersectionStorage, + isOk = GeometryTools::calculateOverlapPolygonOfTwoQuads(&polygon, &additionalVertices, &edgeIntersectionStorage, wrapArrayConst(&nodes), cv1CubeFaceIndices, cv2CubeFaceIndices, 1e-6); EXPECT_EQ( (size_t)8, polygon.size()); EXPECT_EQ( (size_t)8, additionalVertices.size()); @@ -472,7 +472,7 @@ TEST(CellFaceIntersectionTst, FreeFacePolygon) nodes[7] = cvf::Vec3d(0, 1, 0); - bool isOk = GeometryTools::calculateOverlapPolygonOfTwoQuads(&polygon, &additionalVertices, edgeIntersectionStorage, + bool isOk = GeometryTools::calculateOverlapPolygonOfTwoQuads(&polygon, &additionalVertices, &edgeIntersectionStorage, wrapArrayConst(&nodes), cv1CubeFaceIndices, cv2CubeFaceIndices, 1e-6); EXPECT_EQ( (size_t)4, polygon.size()); EXPECT_EQ( (size_t)0, additionalVertices.size()); @@ -506,7 +506,7 @@ TEST(CellFaceIntersectionTst, FreeFacePolygon) nodes[7] = cvf::Vec3d(-0.25, 0.5, 0); polygon.clear(); - isOk = GeometryTools::calculateOverlapPolygonOfTwoQuads(&polygon, &additionalVertices, edgeIntersectionStorage, + isOk = GeometryTools::calculateOverlapPolygonOfTwoQuads(&polygon, &additionalVertices, &edgeIntersectionStorage, wrapArrayConst(&nodes), cv1CubeFaceIndices, cv2CubeFaceIndices, 1e-6); EXPECT_EQ( (size_t)8, polygon.size()); EXPECT_EQ( (size_t)8, additionalVertices.size()); diff --git a/ApplicationCode/ModelVisualization/cvfGeometryTools.h b/ApplicationCode/ModelVisualization/cvfGeometryTools.h index 1d2962859c..c124762ddd 100644 --- a/ApplicationCode/ModelVisualization/cvfGeometryTools.h +++ b/ApplicationCode/ModelVisualization/cvfGeometryTools.h @@ -61,7 +61,7 @@ public: template static bool calculateOverlapPolygonOfTwoQuads( std::vector * polygon, std::vector* createdVertexes, - EdgeIntersectStorage& edgeIntersectionStorage, + EdgeIntersectStorage* edgeIntersectionStorage, ArrayWrapperConst nodes, const IndexType cv1CubeFaceIndices[4], const IndexType cv2CubeFaceIndices[4], diff --git a/ApplicationCode/ModelVisualization/cvfGeometryTools.inl b/ApplicationCode/ModelVisualization/cvfGeometryTools.inl index 0cbda7cb72..f698490c3d 100644 --- a/ApplicationCode/ModelVisualization/cvfGeometryTools.inl +++ b/ApplicationCode/ModelVisualization/cvfGeometryTools.inl @@ -201,7 +201,7 @@ bool GeometryTools::isPointTouchingIndexedPolygon( const cvf::Vec3d& polygonNor template bool GeometryTools::calculateOverlapPolygonOfTwoQuads(std::vector * polygon, std::vector* createdVertexes, - EdgeIntersectStorage& edgeIntersectionStorage, + EdgeIntersectStorage* edgeIntersectionStorage, ArrayWrapperConst nodes, const IndexType cv1CubeFaceIndices[4], const IndexType cv2CubeFaceIndices[4], @@ -377,15 +377,18 @@ bool GeometryTools::calculateOverlapPolygonOfTwoQuads(std::vector * p else { double fractionAlongEdge2; - - bool found = edgeIntersectionStorage.findIntersection( cv1CubeFaceIndices[cv1Idx], - cv1CubeFaceIndices[nextCv1Idx], - cv2CubeFaceIndices[cv2Idx], - cv2CubeFaceIndices[nextCv2Idx], - &intersectionVxIndex, &intersectStatus, - &fractionAlongEdge1, &fractionAlongEdge2); - if (!found) - { + bool found = false; + if (edgeIntersectionStorage) + found = edgeIntersectionStorage->findIntersection( + cv1CubeFaceIndices[cv1Idx], + cv1CubeFaceIndices[nextCv1Idx], + cv2CubeFaceIndices[cv2Idx], + cv2CubeFaceIndices[nextCv2Idx], + &intersectionVxIndex, &intersectStatus, + &fractionAlongEdge1, &fractionAlongEdge2); + + if (!found) + { intersectStatus = GeometryTools::inPlaneLineIntersect3D(normal, nodes[cv1CubeFaceIndices[cv1Idx]], @@ -426,12 +429,13 @@ bool GeometryTools::calculateOverlapPolygonOfTwoQuads(std::vector * p break; } - edgeIntersectionStorage.addIntersection( cv1CubeFaceIndices[cv1Idx], - cv1CubeFaceIndices[nextCv1Idx], - cv2CubeFaceIndices[cv2Idx], - cv2CubeFaceIndices[nextCv2Idx], - intersectionVxIndex, intersectStatus, - fractionAlongEdge1, fractionAlongEdge2); + if(edgeIntersectionStorage) + edgeIntersectionStorage->addIntersection( cv1CubeFaceIndices[cv1Idx], + cv1CubeFaceIndices[nextCv1Idx], + cv2CubeFaceIndices[cv2Idx], + cv2CubeFaceIndices[nextCv2Idx], + intersectionVxIndex, intersectStatus, + fractionAlongEdge1, fractionAlongEdge2); } }