(#633) Cross sections on simulation wells

This commit is contained in:
Jacob Støren 2015-11-26 11:08:38 +01:00
parent faf35d32c6
commit 3e78eebee3
5 changed files with 117 additions and 111 deletions

View File

@ -29,10 +29,10 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivCrossSectionGeometryGenerator::RivCrossSectionGeometryGenerator(const std::vector<cvf::Vec3d> &polyline,
RivCrossSectionGeometryGenerator::RivCrossSectionGeometryGenerator(const std::vector<std::vector<cvf::Vec3d> > &polylines,
const cvf::Vec3d& extrusionDirection,
const RivCrossSectionHexGridIntf* grid)
: m_polyLine(polyline),
: m_polyLines(polylines),
m_extrusionDirection(extrusionDirection),
m_hexGrid(grid)
{
@ -968,136 +968,137 @@ void RivCrossSectionGeometryGenerator::calculateArrays()
if (m_triangleVxes->size()) return;
m_extrusionDirection.normalize();
std::vector<cvf::Vec3d> m_adjustedPolyline;
adjustPolyline(m_polyLine, m_extrusionDirection, &m_adjustedPolyline);
std::vector<cvf::Vec3f> triangleVertices;
std::vector<cvf::Vec3f> cellBorderLineVxes;
cvf::Vec3d displayOffset = m_hexGrid->displayOffset();
cvf::BoundingBox gridBBox = m_hexGrid->boundingBox();
size_t lineCount = m_adjustedPolyline.size();
for (size_t lIdx = 0; lIdx < lineCount - 1; ++lIdx)
for (size_t pLineIdx = 0; pLineIdx < m_polyLines.size(); ++pLineIdx)
{
cvf::Vec3d p1 = m_adjustedPolyline[lIdx];
cvf::Vec3d p2 = m_adjustedPolyline[lIdx+1];
const std::vector<cvf::Vec3d>& m_polyLine = m_polyLines[pLineIdx];
std::vector<cvf::Vec3d> m_adjustedPolyline;
adjustPolyline(m_polyLine, m_extrusionDirection, &m_adjustedPolyline);
cvf::BoundingBox sectionBBox;
sectionBBox.add(p1);
sectionBBox.add(p2);
double maxSectionHeight = gridBBox.radius();
sectionBBox.add(p1 + m_extrusionDirection*maxSectionHeight);
sectionBBox.add(p1 - m_extrusionDirection*maxSectionHeight);
sectionBBox.add(p2 + m_extrusionDirection*maxSectionHeight);
sectionBBox.add(p2 - m_extrusionDirection*maxSectionHeight);
std::vector<size_t> columnCellCandidates;
m_hexGrid->findIntersectingCells(sectionBBox, &columnCellCandidates);
cvf::Plane plane;
plane.setFromPoints(p1, p2, p2 + m_extrusionDirection*maxSectionHeight);
cvf::Plane p1Plane;
p1Plane.setFromPoints(p1, p1 + m_extrusionDirection*maxSectionHeight, p1 + plane.normal());
cvf::Plane p2Plane;
p2Plane.setFromPoints(p2, p2 + m_extrusionDirection*maxSectionHeight, p2 - plane.normal() );
std::vector<ClipVx> hexPlaneCutTriangleVxes;
hexPlaneCutTriangleVxes.reserve(5*3);
std::vector<bool> isTriangleEdgeCellContour;
isTriangleEdgeCellContour.reserve(5*3);
cvf::Vec3d cellCorners[8];
size_t cornerIndices[8];
for (size_t cccIdx = 0; cccIdx < columnCellCandidates.size(); ++cccIdx)
size_t lineCount = m_adjustedPolyline.size();
for (size_t lIdx = 0; lIdx < lineCount - 1; ++lIdx)
{
size_t globalCellIdx = columnCellCandidates[cccIdx];
cvf::Vec3d p1 = m_adjustedPolyline[lIdx];
cvf::Vec3d p2 = m_adjustedPolyline[lIdx+1];
if (!m_hexGrid->useCell(globalCellIdx)) continue;
hexPlaneCutTriangleVxes.clear();
m_hexGrid->cellCornerVertices(globalCellIdx, cellCorners);
m_hexGrid->cellCornerIndices(globalCellIdx, cornerIndices);
cvf::BoundingBox sectionBBox;
sectionBBox.add(p1);
sectionBBox.add(p2);
double maxSectionHeight = gridBBox.radius();
sectionBBox.add(p1 + m_extrusionDirection*maxSectionHeight);
sectionBBox.add(p1 - m_extrusionDirection*maxSectionHeight);
sectionBBox.add(p2 + m_extrusionDirection*maxSectionHeight);
sectionBBox.add(p2 - m_extrusionDirection*maxSectionHeight);
int triangleCount = planeHexIntersectionMC(plane,
cellCorners,
cornerIndices,
&hexPlaneCutTriangleVxes,
&isTriangleEdgeCellContour);
std::vector<ClipVx> clippedTriangleVxes;
std::vector<bool> isClippedTriEdgeCellContour;
std::vector<size_t> columnCellCandidates;
m_hexGrid->findIntersectingCells(sectionBBox, &columnCellCandidates);
clipTrianglesBetweenTwoParallelPlanes(hexPlaneCutTriangleVxes, isTriangleEdgeCellContour, p1Plane, p2Plane,
&clippedTriangleVxes, &isClippedTriEdgeCellContour);
cvf::Plane plane;
plane.setFromPoints(p1, p2, p2 + m_extrusionDirection*maxSectionHeight);
size_t clippedTriangleCount = clippedTriangleVxes.size()/3;
cvf::Plane p1Plane;
p1Plane.setFromPoints(p1, p1 + m_extrusionDirection*maxSectionHeight, p1 + plane.normal());
cvf::Plane p2Plane;
p2Plane.setFromPoints(p2, p2 + m_extrusionDirection*maxSectionHeight, p2 - plane.normal());
for (uint tIdx = 0; tIdx < clippedTriangleCount; ++tIdx)
std::vector<ClipVx> hexPlaneCutTriangleVxes;
hexPlaneCutTriangleVxes.reserve(5*3);
std::vector<bool> isTriangleEdgeCellContour;
isTriangleEdgeCellContour.reserve(5*3);
cvf::Vec3d cellCorners[8];
size_t cornerIndices[8];
for (size_t cccIdx = 0; cccIdx < columnCellCandidates.size(); ++cccIdx)
{
uint triVxIdx = tIdx*3;
size_t globalCellIdx = columnCellCandidates[cccIdx];
// Accumulate triangle vertices
if (!m_hexGrid->useCell(globalCellIdx)) continue;
cvf::Vec3f p0(clippedTriangleVxes[triVxIdx+0].vx - displayOffset);
cvf::Vec3f p1(clippedTriangleVxes[triVxIdx+1].vx - displayOffset);
cvf::Vec3f p2(clippedTriangleVxes[triVxIdx+2].vx - displayOffset);
hexPlaneCutTriangleVxes.clear();
m_hexGrid->cellCornerVertices(globalCellIdx, cellCorners);
m_hexGrid->cellCornerIndices(globalCellIdx, cornerIndices);
triangleVertices.push_back(p0);
triangleVertices.push_back(p1);
triangleVertices.push_back(p2);
int triangleCount = planeHexIntersectionMC(plane,
cellCorners,
cornerIndices,
&hexPlaneCutTriangleVxes,
&isTriangleEdgeCellContour);
std::vector<ClipVx> clippedTriangleVxes;
std::vector<bool> isClippedTriEdgeCellContour;
// Accumulate mesh lines
clipTrianglesBetweenTwoParallelPlanes(hexPlaneCutTriangleVxes, isTriangleEdgeCellContour, p1Plane, p2Plane,
&clippedTriangleVxes, &isClippedTriEdgeCellContour);
if (isClippedTriEdgeCellContour[triVxIdx])
size_t clippedTriangleCount = clippedTriangleVxes.size()/3;
for (uint tIdx = 0; tIdx < clippedTriangleCount; ++tIdx)
{
cellBorderLineVxes.push_back(p0);
cellBorderLineVxes.push_back(p1);
}
if (isClippedTriEdgeCellContour[triVxIdx+1])
{
cellBorderLineVxes.push_back(p1);
cellBorderLineVxes.push_back(p2);
}
if (isClippedTriEdgeCellContour[triVxIdx+2])
{
cellBorderLineVxes.push_back(p2);
cellBorderLineVxes.push_back(p0);
}
uint triVxIdx = tIdx*3;
// Mapping to cell index
// Accumulate triangle vertices
m_triangleToCellIdxMap.push_back(globalCellIdx);
cvf::Vec3f p0(clippedTriangleVxes[triVxIdx+0].vx - displayOffset);
cvf::Vec3f p1(clippedTriangleVxes[triVxIdx+1].vx - displayOffset);
cvf::Vec3f p2(clippedTriangleVxes[triVxIdx+2].vx - displayOffset);
// Interpolation from nodes
for (int i = 0; i < 3; ++i)
{
ClipVx cvx = clippedTriangleVxes[triVxIdx+i];
if (cvx.isVxIdsNative)
triangleVertices.push_back(p0);
triangleVertices.push_back(p1);
triangleVertices.push_back(p2);
// Accumulate mesh lines
if (isClippedTriEdgeCellContour[triVxIdx])
{
m_triVxToCellCornerWeights.push_back(
RivVertexWeights(cvx.clippedEdgeVx1Id, cvx.clippedEdgeVx2Id, cvx.normDistFromEdgeVx1));
cellBorderLineVxes.push_back(p0);
cellBorderLineVxes.push_back(p1);
}
else
if (isClippedTriEdgeCellContour[triVxIdx+1])
{
ClipVx cvx1 = hexPlaneCutTriangleVxes[cvx.clippedEdgeVx1Id];
ClipVx cvx2 = hexPlaneCutTriangleVxes[cvx.clippedEdgeVx2Id];
cellBorderLineVxes.push_back(p1);
cellBorderLineVxes.push_back(p2);
}
if (isClippedTriEdgeCellContour[triVxIdx+2])
{
cellBorderLineVxes.push_back(p2);
cellBorderLineVxes.push_back(p0);
}
m_triVxToCellCornerWeights.push_back(
RivVertexWeights(cvx1.clippedEdgeVx1Id, cvx1.clippedEdgeVx2Id, cvx1.normDistFromEdgeVx1,
cvx2.clippedEdgeVx1Id, cvx2.clippedEdgeVx2Id, cvx2.normDistFromEdgeVx1,
cvx.normDistFromEdgeVx1));
// Mapping to cell index
m_triangleToCellIdxMap.push_back(globalCellIdx);
// Interpolation from nodes
for (int i = 0; i < 3; ++i)
{
ClipVx cvx = clippedTriangleVxes[triVxIdx+i];
if (cvx.isVxIdsNative)
{
m_triVxToCellCornerWeights.push_back(
RivVertexWeights(cvx.clippedEdgeVx1Id, cvx.clippedEdgeVx2Id, cvx.normDistFromEdgeVx1));
}
else
{
ClipVx cvx1 = hexPlaneCutTriangleVxes[cvx.clippedEdgeVx1Id];
ClipVx cvx2 = hexPlaneCutTriangleVxes[cvx.clippedEdgeVx2Id];
m_triVxToCellCornerWeights.push_back(
RivVertexWeights(cvx1.clippedEdgeVx1Id, cvx1.clippedEdgeVx2Id, cvx1.normDistFromEdgeVx1,
cvx2.clippedEdgeVx1Id, cvx2.clippedEdgeVx2Id, cvx2.normDistFromEdgeVx1,
cvx.normDistFromEdgeVx1));
}
}
}
}
}
}
m_triangleVxes->assign(triangleVertices);
m_cellBorderLineVxes->assign(cellBorderLineVxes);
}

View File

@ -124,7 +124,7 @@ private:
class RivCrossSectionGeometryGenerator : public cvf::Object
{
public:
RivCrossSectionGeometryGenerator(const std::vector<cvf::Vec3d> &polyline,
RivCrossSectionGeometryGenerator(const std::vector<std::vector<cvf::Vec3d> > &polylines,
const cvf::Vec3d& extrusionDirection,
const RivCrossSectionHexGridIntf* grid );
@ -145,7 +145,7 @@ private:
std::vector<cvf::Vec3d>* adjustedPolyline);
cvf::cref<RivCrossSectionHexGridIntf> m_hexGrid;
std::vector<cvf::Vec3d> m_polyLine;
const std::vector<std::vector<cvf::Vec3d> > m_polyLines;
cvf::Vec3d m_extrusionDirection;
// Output arrays

View File

@ -412,12 +412,12 @@ void RivCrossSectionPartMgr::appendMeshLinePartsToModel(cvf::ModelBasicList* mod
//--------------------------------------------------------------------------------------------------
void RivCrossSectionPartMgr::computeData()
{
std::vector< std::vector <cvf::Vec3d> > polyLine = m_rimCrossSection->polyLines();
if (polyLine.size() > 0)
std::vector< std::vector <cvf::Vec3d> > polyLines = m_rimCrossSection->polyLines();
if (polyLines.size() > 0)
{
cvf::Vec3d direction = extrusionDirection(polyLine[0]);
cvf::Vec3d direction = extrusionDirection(polyLines[0]);
cvf::ref<RivCrossSectionHexGridIntf> hexGrid = createHexGridInterface();
m_crossSectionGenerator = new RivCrossSectionGeometryGenerator(polyLine[0], direction, hexGrid.p());
m_crossSectionGenerator = new RivCrossSectionGeometryGenerator(polyLines, direction, hexGrid.p());
}
}

View File

@ -29,6 +29,7 @@
#include "RimWellPath.h"
#include "RivCrossSectionPartMgr.h"
#include "RigSimulationWellCenterLineCalculator.h"
namespace caf {
@ -37,7 +38,7 @@ template<>
void caf::AppEnum< RimCrossSection::CrossSectionEnum >::setUp()
{
addItem(RimCrossSection::CS_WELL_PATH, "CS_WELL_PATH", "Well Path");
// addItem(RimCrossSection::CS_SIMULATION_WELL, "CS_SIMULATION_WELL", "Simulation Well");
addItem(RimCrossSection::CS_SIMULATION_WELL, "CS_SIMULATION_WELL", "Simulation Well");
// addItem(RimCrossSection::CS_USER_DEFINED, "CS_USER_DEFINED", "User defined");
setDefault(RimCrossSection::CS_WELL_PATH);
}
@ -111,7 +112,7 @@ void RimCrossSection::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering&
}
else if (type == CS_SIMULATION_WELL)
{
//uiOrdering.add(&simulationWell);
uiOrdering.add(&simulationWell);
}
else
{
@ -211,14 +212,18 @@ std::vector< std::vector <cvf::Vec3d> > RimCrossSection::polyLines() const
std::vector< std::vector <cvf::Vec3d> > lines;
if (type == CS_WELL_PATH)
{
if (wellPath)
if (wellPath())
{
lines.push_back(wellPath->wellPathGeometry()->m_wellPathPoints);
}
}
else if (type == CS_SIMULATION_WELL)
{
if (simulationWell())
{
std::vector< std::vector <RigWellResultPoint> > pipeBranchesCellIds;
RigSimulationWellCenterLineCalculator::calculateWellPipeCenterline(simulationWell(), lines, pipeBranchesCellIds);
}
}
else
{
@ -231,8 +236,10 @@ std::vector< std::vector <cvf::Vec3d> > RimCrossSection::polyLines() const
{
cvf::Vec3d startToEnd = (lines[lIdx].back() - lines[lIdx].front());
startToEnd[2] = 0.0;
cvf::Vec3d newStart = lines[lIdx].front() - startToEnd * 0.1;
cvf::Vec3d newEnd = lines[lIdx].back() + startToEnd * 0.1;
lines[lIdx].insert(lines[lIdx].begin(), newStart);
lines[lIdx].push_back(newEnd);
}

View File

@ -240,8 +240,6 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
}
}
// TODO: Include when cross section from simulation wells are ready
/*
const RivEclipseWellSourceInfo* eclipseWellSourceInfo = dynamic_cast<const RivEclipseWellSourceInfo*>(firstHitPart->sourceInfo());
if (eclipseWellSourceInfo)
{
@ -253,7 +251,7 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
commandIds << "RicNewSimWellCrossSectionFeature";
}
}
*/
}
// View Link commands