(#166) Added storage of interpolation metadata

This commit is contained in:
Jacob Støren 2015-11-19 13:33:50 +01:00
parent 74f0251ee9
commit 227eba0325
2 changed files with 59 additions and 9 deletions

View File

@ -1060,8 +1060,8 @@ void RivCrossSectionGeometryGenerator::calculateArrays()
p2Plane.setFromPoints(p2, p2 + m_extrusionDirection*maxSectionHeight, p2 - plane.normal() );
std::vector<ClipVx> triangleVxes;
triangleVxes.reserve(5*3);
std::vector<ClipVx> triangleClipVxes;
triangleClipVxes.reserve(5*3);
std::vector<bool> 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<ClipVx> clippedTriangleVxes;
std::vector<bool> isClippedTriEdgeCellContour;
clipTrianglesBetweenTwoParallelPlanes(triangleVxes, isTriangleEdgeCellContour, p1Plane, p2Plane, &clippedTriangleVxes, &isClippedTriEdgeCellContour);
clipTrianglesBetweenTwoParallelPlanes(triangleClipVxes, isTriangleEdgeCellContour, p1Plane, p2Plane, &clippedTriangleVxes, &isClippedTriEdgeCellContour);
int clippedTriangleCount = static_cast<int>(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

View File

@ -62,14 +62,43 @@ private:
void adjustPolyline();
cvf::ref<cvf::Vec3fArray> m_triangleVxes;
cvf::ref<cvf::Vec3fArray> m_cellBorderLineVxes;
std::vector<size_t> m_triangleToCellIdxMap;
cvf::cref<RigMainGrid> m_mainGrid;
std::vector<cvf::Vec3d> m_polyLine;
cvf::Vec3d m_extrusionDirection;
std::vector<cvf::Vec3d> m_adjustedPolyline;
// Output arrays
cvf::ref<cvf::Vec3fArray> m_triangleVxes;
cvf::ref<cvf::Vec3fArray> m_cellBorderLineVxes;
std::vector<size_t> 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<VxInterPolData> m_triangleVxInterPolationData;
};