diff --git a/ApplicationCode/ModelVisualization/RivCrossSectionGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/RivCrossSectionGeometryGenerator.cpp index 47d1cefa07..7abbea18b5 100644 --- a/ApplicationCode/ModelVisualization/RivCrossSectionGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/RivCrossSectionGeometryGenerator.cpp @@ -1060,8 +1060,8 @@ void RivCrossSectionGeometryGenerator::calculateArrays() p2Plane.setFromPoints(p2, p2 + m_extrusionDirection*maxSectionHeight, p2 - plane.normal() ); - std::vector triangleVxes; - triangleVxes.reserve(5*3); + std::vector triangleClipVxes; + triangleClipVxes.reserve(5*3); std::vector isTriangleEdgeCellContour; isTriangleEdgeCellContour.reserve(5*3); @@ -1071,7 +1071,7 @@ void RivCrossSectionGeometryGenerator::calculateArrays() if (m_mainGrid->cells()[globalCellIdx].isInvalid()) continue; - triangleVxes.clear(); + triangleClipVxes.clear(); cvf::Vec3d cellCorners[8]; m_mainGrid->cellCornerVertices(globalCellIdx, cellCorners); @@ -1089,7 +1089,7 @@ void RivCrossSectionGeometryGenerator::calculateArrays() int triangleCount = planeHexIntersectionMC(plane, cellCorners, hexCornersIds, - &triangleVxes, + &triangleClipVxes, &isTriangleEdgeCellContour); @@ -1110,7 +1110,7 @@ void RivCrossSectionGeometryGenerator::calculateArrays() std::vector clippedTriangleVxes; std::vector isClippedTriEdgeCellContour; - clipTrianglesBetweenTwoParallelPlanes(triangleVxes, isTriangleEdgeCellContour, p1Plane, p2Plane, &clippedTriangleVxes, &isClippedTriEdgeCellContour); + clipTrianglesBetweenTwoParallelPlanes(triangleClipVxes, isTriangleEdgeCellContour, p1Plane, p2Plane, &clippedTriangleVxes, &isClippedTriEdgeCellContour); int clippedTriangleCount = static_cast(clippedTriangleVxes.size())/3; @@ -1150,7 +1150,28 @@ void RivCrossSectionGeometryGenerator::calculateArrays() m_triangleToCellIdxMap.push_back(globalCellIdx); + for (int i = 0; i < 3; ++i) + { + ClipVx cvx = clippedTriangleVxes[triVxIdx+i]; + if (cvx.isVxIdsNative) + { + m_triangleVxInterPolationData.push_back( + VxInterPolData(cvx.clippedEdgeVx1Id, cvx.clippedEdgeVx2Id, cvx.normDistFromEdgeVx1, + -1, -1, 0.0, + 0.0)); + } + else + { + ClipVx cvx1 = triangleClipVxes[cvx.clippedEdgeVx1Id]; + ClipVx cvx2 = triangleClipVxes[cvx.clippedEdgeVx2Id]; + m_triangleVxInterPolationData.push_back( + VxInterPolData(cvx1.clippedEdgeVx1Id, cvx1.clippedEdgeVx2Id, cvx1.normDistFromEdgeVx1, + cvx2.clippedEdgeVx1Id, cvx2.clippedEdgeVx2Id, cvx2.normDistFromEdgeVx1, + cvx.normDistFromEdgeVx1)); + + } + } } #endif diff --git a/ApplicationCode/ModelVisualization/RivCrossSectionGeometryGenerator.h b/ApplicationCode/ModelVisualization/RivCrossSectionGeometryGenerator.h index 270387fb27..f3e1dc08c1 100644 --- a/ApplicationCode/ModelVisualization/RivCrossSectionGeometryGenerator.h +++ b/ApplicationCode/ModelVisualization/RivCrossSectionGeometryGenerator.h @@ -62,14 +62,43 @@ private: void adjustPolyline(); - cvf::ref m_triangleVxes; - cvf::ref m_cellBorderLineVxes; - - std::vector m_triangleToCellIdxMap; cvf::cref m_mainGrid; std::vector m_polyLine; cvf::Vec3d m_extrusionDirection; std::vector m_adjustedPolyline; + + // Output arrays + cvf::ref m_triangleVxes; + cvf::ref m_cellBorderLineVxes; + std::vector m_triangleToCellIdxMap; + + struct VxInterPolData + { + explicit VxInterPolData(int vx1, int vx2, double normDistFrom1, + int vx3, int vx4, double normDistFrom3, + double normDistFrom12) + : vx1Id(vx1), + weight1((float)(1.0 - normDistFrom1 - normDistFrom12 + normDistFrom1*normDistFrom12)), + vx2Id(vx2), + weight2((float)(normDistFrom1 - normDistFrom1*normDistFrom12)), + vx3Id(vx3), + weight3((float)(normDistFrom12 - normDistFrom3*normDistFrom12)), + vx4Id(vx4), + weight4((float)(normDistFrom3*normDistFrom12)) + {} + + int vx1Id; + float weight1; + int vx2Id; + float weight2; + + int vx3Id; + float weight3; + int vx4Id; + float weight4; + }; + + std::vector m_triangleVxInterPolationData; };