Geometry tools: Made edgeIntersectStorage optional

This commit is contained in:
Jacob Støren 2013-12-10 22:34:05 +01:00
parent 76d32d1a73
commit df411efe3f
3 changed files with 28 additions and 24 deletions

View File

@ -220,7 +220,7 @@ TEST(CellFaceIntersectionTst, Intersection1)
isOk = GeometryTools::calculateOverlapPolygonOfTwoQuads( isOk = GeometryTools::calculateOverlapPolygonOfTwoQuads(
&polygon, &polygon,
&additionalVertices, &additionalVertices,
edgeIntersectionStorage, &edgeIntersectionStorage,
wrapArrayConst(&nodes), wrapArrayConst(&nodes),
faces[0].data(), faces[0].data(),
faces[1].data(), faces[1].data(),
@ -240,7 +240,7 @@ TEST(CellFaceIntersectionTst, Intersection1)
isOk = GeometryTools::calculateOverlapPolygonOfTwoQuads( isOk = GeometryTools::calculateOverlapPolygonOfTwoQuads(
&polygon, &polygon,
&additionalVertices, &additionalVertices,
edgeIntersectionStorage, &edgeIntersectionStorage,
wrapArrayConst(&nodes), wrapArrayConst(&nodes),
faces[0].data(), faces[0].data(),
faces[2].data(), faces[2].data(),
@ -260,7 +260,7 @@ TEST(CellFaceIntersectionTst, Intersection1)
isOk = GeometryTools::calculateOverlapPolygonOfTwoQuads( isOk = GeometryTools::calculateOverlapPolygonOfTwoQuads(
&polygon, &polygon,
&additionalVertices, &additionalVertices,
edgeIntersectionStorage, &edgeIntersectionStorage,
wrapArrayConst(&nodes), wrapArrayConst(&nodes),
faces[0].data(), faces[0].data(),
faces[3].data(), faces[3].data(),
@ -411,7 +411,7 @@ TEST(CellFaceIntersectionTst, Intersection)
nodes[7] = cvf::Vec3d(0, 1, 0); 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); wrapArrayConst(&nodes), cv1CubeFaceIndices, cv2CubeFaceIndices, 1e-6);
EXPECT_EQ( (size_t)4, polygon.size()); EXPECT_EQ( (size_t)4, polygon.size());
EXPECT_EQ( (size_t)0, additionalVertices.size()); EXPECT_EQ( (size_t)0, additionalVertices.size());
@ -429,7 +429,7 @@ TEST(CellFaceIntersectionTst, Intersection)
nodes[7] = cvf::Vec3d(-0.25, 0.5, 0); nodes[7] = cvf::Vec3d(-0.25, 0.5, 0);
polygon.clear(); polygon.clear();
isOk = GeometryTools::calculateOverlapPolygonOfTwoQuads(&polygon, &additionalVertices, edgeIntersectionStorage, isOk = GeometryTools::calculateOverlapPolygonOfTwoQuads(&polygon, &additionalVertices, &edgeIntersectionStorage,
wrapArrayConst(&nodes), cv1CubeFaceIndices, cv2CubeFaceIndices, 1e-6); wrapArrayConst(&nodes), cv1CubeFaceIndices, cv2CubeFaceIndices, 1e-6);
EXPECT_EQ( (size_t)8, polygon.size()); EXPECT_EQ( (size_t)8, polygon.size());
EXPECT_EQ( (size_t)8, additionalVertices.size()); EXPECT_EQ( (size_t)8, additionalVertices.size());
@ -472,7 +472,7 @@ TEST(CellFaceIntersectionTst, FreeFacePolygon)
nodes[7] = cvf::Vec3d(0, 1, 0); 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); wrapArrayConst(&nodes), cv1CubeFaceIndices, cv2CubeFaceIndices, 1e-6);
EXPECT_EQ( (size_t)4, polygon.size()); EXPECT_EQ( (size_t)4, polygon.size());
EXPECT_EQ( (size_t)0, additionalVertices.size()); EXPECT_EQ( (size_t)0, additionalVertices.size());
@ -506,7 +506,7 @@ TEST(CellFaceIntersectionTst, FreeFacePolygon)
nodes[7] = cvf::Vec3d(-0.25, 0.5, 0); nodes[7] = cvf::Vec3d(-0.25, 0.5, 0);
polygon.clear(); polygon.clear();
isOk = GeometryTools::calculateOverlapPolygonOfTwoQuads(&polygon, &additionalVertices, edgeIntersectionStorage, isOk = GeometryTools::calculateOverlapPolygonOfTwoQuads(&polygon, &additionalVertices, &edgeIntersectionStorage,
wrapArrayConst(&nodes), cv1CubeFaceIndices, cv2CubeFaceIndices, 1e-6); wrapArrayConst(&nodes), cv1CubeFaceIndices, cv2CubeFaceIndices, 1e-6);
EXPECT_EQ( (size_t)8, polygon.size()); EXPECT_EQ( (size_t)8, polygon.size());
EXPECT_EQ( (size_t)8, additionalVertices.size()); EXPECT_EQ( (size_t)8, additionalVertices.size());

View File

@ -61,7 +61,7 @@ public:
template<typename VerticeArrayType, typename IndexType> template<typename VerticeArrayType, typename IndexType>
static bool calculateOverlapPolygonOfTwoQuads( std::vector<IndexType> * polygon, static bool calculateOverlapPolygonOfTwoQuads( std::vector<IndexType> * polygon,
std::vector<cvf::Vec3d>* createdVertexes, std::vector<cvf::Vec3d>* createdVertexes,
EdgeIntersectStorage<IndexType>& edgeIntersectionStorage, EdgeIntersectStorage<IndexType>* edgeIntersectionStorage,
ArrayWrapperConst<VerticeArrayType, cvf::Vec3d> nodes, ArrayWrapperConst<VerticeArrayType, cvf::Vec3d> nodes,
const IndexType cv1CubeFaceIndices[4], const IndexType cv1CubeFaceIndices[4],
const IndexType cv2CubeFaceIndices[4], const IndexType cv2CubeFaceIndices[4],

View File

@ -201,7 +201,7 @@ bool GeometryTools::isPointTouchingIndexedPolygon( const cvf::Vec3d& polygonNor
template<typename VerticeArrayType, typename IndexType> template<typename VerticeArrayType, typename IndexType>
bool GeometryTools::calculateOverlapPolygonOfTwoQuads(std::vector<IndexType> * polygon, bool GeometryTools::calculateOverlapPolygonOfTwoQuads(std::vector<IndexType> * polygon,
std::vector<cvf::Vec3d>* createdVertexes, std::vector<cvf::Vec3d>* createdVertexes,
EdgeIntersectStorage<IndexType>& edgeIntersectionStorage, EdgeIntersectStorage<IndexType>* edgeIntersectionStorage,
ArrayWrapperConst<VerticeArrayType, cvf::Vec3d> nodes, ArrayWrapperConst<VerticeArrayType, cvf::Vec3d> nodes,
const IndexType cv1CubeFaceIndices[4], const IndexType cv1CubeFaceIndices[4],
const IndexType cv2CubeFaceIndices[4], const IndexType cv2CubeFaceIndices[4],
@ -377,13 +377,16 @@ bool GeometryTools::calculateOverlapPolygonOfTwoQuads(std::vector<IndexType> * p
else else
{ {
double fractionAlongEdge2; double fractionAlongEdge2;
bool found = false;
bool found = edgeIntersectionStorage.findIntersection( cv1CubeFaceIndices[cv1Idx], if (edgeIntersectionStorage)
found = edgeIntersectionStorage->findIntersection(
cv1CubeFaceIndices[cv1Idx],
cv1CubeFaceIndices[nextCv1Idx], cv1CubeFaceIndices[nextCv1Idx],
cv2CubeFaceIndices[cv2Idx], cv2CubeFaceIndices[cv2Idx],
cv2CubeFaceIndices[nextCv2Idx], cv2CubeFaceIndices[nextCv2Idx],
&intersectionVxIndex, &intersectStatus, &intersectionVxIndex, &intersectStatus,
&fractionAlongEdge1, &fractionAlongEdge2); &fractionAlongEdge1, &fractionAlongEdge2);
if (!found) if (!found)
{ {
@ -426,7 +429,8 @@ bool GeometryTools::calculateOverlapPolygonOfTwoQuads(std::vector<IndexType> * p
break; break;
} }
edgeIntersectionStorage.addIntersection( cv1CubeFaceIndices[cv1Idx], if(edgeIntersectionStorage)
edgeIntersectionStorage->addIntersection( cv1CubeFaceIndices[cv1Idx],
cv1CubeFaceIndices[nextCv1Idx], cv1CubeFaceIndices[nextCv1Idx],
cv2CubeFaceIndices[cv2Idx], cv2CubeFaceIndices[cv2Idx],
cv2CubeFaceIndices[nextCv2Idx], cv2CubeFaceIndices[nextCv2Idx],