#2436 Add cube face tracking through the clipping methods used for intersection calculations

This commit is contained in:
Jacob Støren
2018-03-23 10:17:06 +01:00
parent 1a6c529488
commit 3b724e07bd
4 changed files with 184 additions and 104 deletions

View File

@@ -283,8 +283,8 @@ void RivIntersectionBoxGeometryGenerator::calculateArrays()
std::vector<caf::HexGridIntersectionTools::ClipVx> hexPlaneCutTriangleVxes;
hexPlaneCutTriangleVxes.reserve(5*3);
std::vector<bool> isTriangleEdgeCellContour;
isTriangleEdgeCellContour.reserve(5*3);
std::vector<int> cellFaceForEachTriangleEdge;
cellFaceForEachTriangleEdge.reserve(5*3);
cvf::Vec3d cellCorners[8];
size_t cornerIndices[8];
@@ -302,20 +302,20 @@ void RivIntersectionBoxGeometryGenerator::calculateArrays()
cellCorners,
cornerIndices,
&hexPlaneCutTriangleVxes,
&isTriangleEdgeCellContour);
&cellFaceForEachTriangleEdge);
std::vector<caf::HexGridIntersectionTools::ClipVx> clippedTriangleVxes_once;
std::vector<bool> isClippedTriEdgeCellContour_once;
caf::HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes(hexPlaneCutTriangleVxes, isTriangleEdgeCellContour, p1Plane, p2Plane,
&clippedTriangleVxes_once, &isClippedTriEdgeCellContour_once);
std::vector<int> cellFaceForEachClippedTriangleEdge_once;
caf::HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes(hexPlaneCutTriangleVxes, cellFaceForEachTriangleEdge, p1Plane, p2Plane,
&clippedTriangleVxes_once, &cellFaceForEachClippedTriangleEdge_once);
for (caf::HexGridIntersectionTools::ClipVx& clvx : clippedTriangleVxes_once) if (!clvx.isVxIdsNative) clvx.derivedVxLevel = 0;
std::vector<caf::HexGridIntersectionTools::ClipVx> clippedTriangleVxes;
std::vector<bool> isClippedTriEdgeCellContour;
std::vector<int> cellFaceForEachClippedTriangleEdge;
caf::HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes(clippedTriangleVxes_once, isClippedTriEdgeCellContour_once, p3Plane, p4Plane,
&clippedTriangleVxes, &isClippedTriEdgeCellContour);
caf::HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes(clippedTriangleVxes_once, cellFaceForEachClippedTriangleEdge_once, p3Plane, p4Plane,
&clippedTriangleVxes, &cellFaceForEachClippedTriangleEdge);
for (caf::HexGridIntersectionTools::ClipVx& clvx : clippedTriangleVxes) if (!clvx.isVxIdsNative && clvx.derivedVxLevel == -1) clvx.derivedVxLevel = 1;
size_t clippedTriangleCount = clippedTriangleVxes.size()/3;
@@ -336,18 +336,20 @@ void RivIntersectionBoxGeometryGenerator::calculateArrays()
// Accumulate mesh lines
#define isFace( faceEnum ) (0 <= faceEnum && faceEnum <= 5 )
if(isClippedTriEdgeCellContour[triVxIdx])
if(isFace(cellFaceForEachClippedTriangleEdge[triVxIdx]))
{
cellBorderLineVxes.push_back(p0);
cellBorderLineVxes.push_back(p1);
}
if(isClippedTriEdgeCellContour[triVxIdx+1])
if(isFace(cellFaceForEachClippedTriangleEdge[triVxIdx+1]))
{
cellBorderLineVxes.push_back(p1);
cellBorderLineVxes.push_back(p2);
}
if(isClippedTriEdgeCellContour[triVxIdx+2])
if(isFace(cellFaceForEachClippedTriangleEdge[triVxIdx+2]))
{
cellBorderLineVxes.push_back(p2);
cellBorderLineVxes.push_back(p0);

View File

@@ -229,8 +229,8 @@ void RivIntersectionGeometryGenerator::calculateArrays()
std::vector<caf::HexGridIntersectionTools::ClipVx> hexPlaneCutTriangleVxes;
hexPlaneCutTriangleVxes.reserve(5*3);
std::vector<bool> isTriangleEdgeCellContour;
isTriangleEdgeCellContour.reserve(5*3);
std::vector<int> cellFaceForEachTriangleEdge;
cellFaceForEachTriangleEdge.reserve(5*3);
cvf::Vec3d cellCorners[8];
size_t cornerIndices[8];
@@ -247,10 +247,10 @@ void RivIntersectionGeometryGenerator::calculateArrays()
m_hexGrid->cellCornerIndices(globalCellIdx, cornerIndices);
caf::HexGridIntersectionTools::planeHexIntersectionMC(plane,
cellCorners,
cornerIndices,
&hexPlaneCutTriangleVxes,
&isTriangleEdgeCellContour);
cellCorners,
cornerIndices,
&hexPlaneCutTriangleVxes,
&cellFaceForEachTriangleEdge);
if (m_crossSection->type == RimIntersection::CS_AZIMUTHLINE)
{
@@ -284,14 +284,14 @@ void RivIntersectionGeometryGenerator::calculateArrays()
}
std::vector<caf::HexGridIntersectionTools::ClipVx> clippedTriangleVxes;
std::vector<bool> isClippedTriEdgeCellContour;
std::vector<int> cellFaceForEachClippedTriangleEdge;
caf::HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes(hexPlaneCutTriangleVxes,
isTriangleEdgeCellContour,
cellFaceForEachTriangleEdge,
p1Plane,
p2Plane,
&clippedTriangleVxes,
&isClippedTriEdgeCellContour);
&cellFaceForEachClippedTriangleEdge);
size_t clippedTriangleCount = clippedTriangleVxes.size()/3;
@@ -314,18 +314,19 @@ void RivIntersectionGeometryGenerator::calculateArrays()
// Accumulate mesh lines
#define isFace( faceEnum ) (0 <= faceEnum && faceEnum <= 5 )
if (isClippedTriEdgeCellContour[triVxIdx])
if ( isFace( cellFaceForEachClippedTriangleEdge[triVxIdx]) )
{
cellBorderLineVxes.emplace_back(p0);
cellBorderLineVxes.emplace_back(p1);
}
if (isClippedTriEdgeCellContour[triVxIdx+1])
if ( isFace( cellFaceForEachClippedTriangleEdge[triVxIdx+1]) )
{
cellBorderLineVxes.emplace_back(p1);
cellBorderLineVxes.emplace_back(p2);
}
if (isClippedTriEdgeCellContour[triVxIdx+2])
if ( isFace( cellFaceForEachClippedTriangleEdge[triVxIdx+2]) )
{
cellBorderLineVxes.emplace_back(p2);
cellBorderLineVxes.emplace_back(p0);