mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#923 Intersections : Added viz for extrusion direction by two points
This commit is contained in:
@@ -245,21 +245,29 @@ cvf::ref<cvf::DrawableGeo> RivIntersectionGeometryGenerator::createMeshDrawable(
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::DrawableGeo> RivIntersectionGeometryGenerator::createLineAlongPolylineDrawable()
|
||||
{
|
||||
return createLineAlongPolylineDrawable(m_polyLines);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::DrawableGeo> RivIntersectionGeometryGenerator::createLineAlongPolylineDrawable(const std::vector<std::vector<cvf::Vec3d> >& polyLines)
|
||||
{
|
||||
std::vector<cvf::uint> lineIndices;
|
||||
std::vector<cvf::Vec3f> vertices;
|
||||
|
||||
cvf::Vec3d displayOffset = m_hexGrid->displayOffset();
|
||||
|
||||
for (size_t pLineIdx = 0; pLineIdx < m_polyLines.size(); ++pLineIdx)
|
||||
for (size_t pLineIdx = 0; pLineIdx < polyLines.size(); ++pLineIdx)
|
||||
{
|
||||
const std::vector<cvf::Vec3d>& m_polyLine = m_polyLines[pLineIdx];
|
||||
if (m_polyLine.size() < 2) continue;
|
||||
const std::vector<cvf::Vec3d>& polyLine = polyLines[pLineIdx];
|
||||
if (polyLine.size() < 2) continue;
|
||||
|
||||
for (size_t i = 0; i < m_polyLine.size(); ++i)
|
||||
for (size_t i = 0; i < polyLine.size(); ++i)
|
||||
{
|
||||
vertices.push_back(cvf::Vec3f(m_polyLine[i] - displayOffset));
|
||||
if (i < m_polyLine.size() - 1)
|
||||
vertices.push_back(cvf::Vec3f(polyLine[i] - displayOffset));
|
||||
if (i < polyLine.size() - 1)
|
||||
{
|
||||
lineIndices.push_back(static_cast<cvf::uint>(i));
|
||||
lineIndices.push_back(static_cast<cvf::uint>(i + 1));
|
||||
@@ -288,17 +296,26 @@ cvf::ref<cvf::DrawableGeo> RivIntersectionGeometryGenerator::createLineAlongPoly
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::DrawableGeo> RivIntersectionGeometryGenerator::createPointsFromPolylineDrawable()
|
||||
{
|
||||
return createPointsFromPolylineDrawable(m_polyLines);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::DrawableGeo> RivIntersectionGeometryGenerator::createPointsFromPolylineDrawable(const std::vector<std::vector<cvf::Vec3d> >& polyLines)
|
||||
{
|
||||
std::vector<cvf::Vec3f> vertices;
|
||||
|
||||
cvf::Vec3d displayOffset = m_hexGrid->displayOffset();
|
||||
|
||||
for (size_t pLineIdx = 0; pLineIdx < m_polyLines.size(); ++pLineIdx)
|
||||
for (size_t pLineIdx = 0; pLineIdx < polyLines.size(); ++pLineIdx)
|
||||
{
|
||||
const std::vector<cvf::Vec3d>& m_polyLine = m_polyLines[pLineIdx];
|
||||
for (size_t i = 0; i < m_polyLine.size(); ++i)
|
||||
const std::vector<cvf::Vec3d>& polyLine = polyLines[pLineIdx];
|
||||
for (size_t i = 0; i < polyLine.size(); ++i)
|
||||
{
|
||||
vertices.push_back(cvf::Vec3f(m_polyLine[i] - displayOffset));
|
||||
vertices.push_back(cvf::Vec3f(polyLine[i] - displayOffset));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -315,8 +332,8 @@ cvf::ref<cvf::DrawableGeo> RivIntersectionGeometryGenerator::createPointsFromPol
|
||||
geo->addPrimitiveSet(primSet.p());
|
||||
|
||||
return geo;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Remove the lines from the polyline that is nearly parallel to the extrusion direction
|
||||
|
||||
@@ -61,6 +61,10 @@ public:
|
||||
cvf::ref<cvf::DrawableGeo> createLineAlongPolylineDrawable();
|
||||
cvf::ref<cvf::DrawableGeo> createPointsFromPolylineDrawable();
|
||||
|
||||
cvf::ref<cvf::DrawableGeo> createLineAlongPolylineDrawable(const std::vector<std::vector<cvf::Vec3d> >& polyLines);
|
||||
cvf::ref<cvf::DrawableGeo> createPointsFromPolylineDrawable(const std::vector<std::vector<cvf::Vec3d> >& polyLines);
|
||||
|
||||
|
||||
// Mapping between cells and geometry
|
||||
const std::vector<size_t>& triangleToCellIndex() const;
|
||||
const std::vector<RivIntersectionVertexWeights>& triangleVxToCellCornerInterpolationWeights() const;
|
||||
|
||||
@@ -333,6 +333,19 @@ void RivIntersectionPartMgr::generatePartGeometry()
|
||||
}
|
||||
}
|
||||
|
||||
createPolyLineParts(useBufferObjects);
|
||||
|
||||
createExtrusionDirParts(useBufferObjects);
|
||||
|
||||
updatePartEffect();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivIntersectionPartMgr::createPolyLineParts(bool useBufferObjects)
|
||||
{
|
||||
// Highlight line
|
||||
|
||||
m_highlightLineAlongPolyline = NULL;
|
||||
@@ -408,10 +421,87 @@ void RivIntersectionPartMgr::generatePartGeometry()
|
||||
m_highlightPointsForPolyline = part;
|
||||
}
|
||||
}
|
||||
|
||||
updatePartEffect();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivIntersectionPartMgr::createExtrusionDirParts(bool useBufferObjects)
|
||||
{
|
||||
m_highlightLineAlongExtrusionDir = nullptr;
|
||||
m_highlightPointsForExtrusionDir = nullptr;
|
||||
|
||||
if (m_rimCrossSection->direction() == RimIntersection::CS_TWO_POINTS)
|
||||
{
|
||||
{
|
||||
cvf::ref<cvf::DrawableGeo> polylineGeo = m_crossSectionGenerator->createLineAlongPolylineDrawable(m_rimCrossSection->polyLinesForExtrusionDirection());
|
||||
if (polylineGeo.notNull())
|
||||
{
|
||||
if (useBufferObjects)
|
||||
{
|
||||
polylineGeo->setRenderMode(cvf::DrawableGeo::BUFFER_OBJECT);
|
||||
}
|
||||
|
||||
cvf::ref<cvf::Part> part = new cvf::Part;
|
||||
part->setName("Cross Section Polyline");
|
||||
part->setDrawable(polylineGeo.p());
|
||||
|
||||
part->updateBoundingBox();
|
||||
part->setPriority(10000);
|
||||
|
||||
// Always show this part, also when mesh is turned off
|
||||
//part->setEnableMask(meshFaultBit);
|
||||
|
||||
cvf::ref<cvf::Effect> eff;
|
||||
caf::MeshEffectGenerator lineEffGen(cvf::Color3::MAGENTA);
|
||||
eff = lineEffGen.generateUnCachedEffect();
|
||||
|
||||
cvf::ref<cvf::RenderStateDepth> depth = new cvf::RenderStateDepth;
|
||||
depth->enableDepthTest(false);
|
||||
eff->setRenderState(depth.p());
|
||||
|
||||
part->setEffect(eff.p());
|
||||
|
||||
m_highlightLineAlongExtrusionDir = part;
|
||||
}
|
||||
}
|
||||
|
||||
cvf::ref<cvf::DrawableGeo> polylinePointsGeo = m_crossSectionGenerator->createPointsFromPolylineDrawable(m_rimCrossSection->polyLinesForExtrusionDirection());
|
||||
if (polylinePointsGeo.notNull())
|
||||
{
|
||||
if (useBufferObjects)
|
||||
{
|
||||
polylinePointsGeo->setRenderMode(cvf::DrawableGeo::BUFFER_OBJECT);
|
||||
}
|
||||
|
||||
cvf::ref<cvf::Part> part = new cvf::Part;
|
||||
part->setName("Cross Section Polyline");
|
||||
part->setDrawable(polylinePointsGeo.p());
|
||||
|
||||
part->updateBoundingBox();
|
||||
part->setPriority(10000);
|
||||
|
||||
// Always show this part, also when mesh is turned off
|
||||
//part->setEnableMask(meshFaultBit);
|
||||
|
||||
cvf::ref<cvf::Effect> eff;
|
||||
caf::MeshEffectGenerator lineEffGen(cvf::Color3::MAGENTA);
|
||||
eff = lineEffGen.generateUnCachedEffect();
|
||||
|
||||
cvf::ref<cvf::RenderStateDepth> depth = new cvf::RenderStateDepth;
|
||||
depth->enableDepthTest(false);
|
||||
eff->setRenderState(depth.p());
|
||||
|
||||
cvf::ref<cvf::RenderStatePoint> pointRendState = new cvf::RenderStatePoint(cvf::RenderStatePoint::FIXED_SIZE);
|
||||
pointRendState->setSize(5.0f);
|
||||
eff->setRenderState(pointRendState.p());
|
||||
|
||||
part->setEffect(eff.p());
|
||||
|
||||
m_highlightPointsForExtrusionDir = part;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@@ -485,15 +575,34 @@ void RivIntersectionPartMgr::appendMeshLinePartsToModel(cvf::ModelBasicList* mod
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivIntersectionPartMgr::appendPolylinePartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform)
|
||||
{
|
||||
if (m_highlightLineAlongPolyline.notNull())
|
||||
if (m_rimCrossSection->inputPolyLineFromViewerEnabled)
|
||||
{
|
||||
m_highlightLineAlongPolyline->setTransform(scaleTransform);
|
||||
model->addPart(m_highlightLineAlongPolyline.p());
|
||||
if (m_highlightLineAlongPolyline.notNull())
|
||||
{
|
||||
m_highlightLineAlongPolyline->setTransform(scaleTransform);
|
||||
model->addPart(m_highlightLineAlongPolyline.p());
|
||||
}
|
||||
|
||||
if (m_highlightPointsForPolyline.notNull())
|
||||
{
|
||||
m_highlightPointsForPolyline->setTransform(scaleTransform);
|
||||
model->addPart(m_highlightPointsForPolyline.p());
|
||||
}
|
||||
}
|
||||
if (m_highlightPointsForPolyline.notNull())
|
||||
|
||||
if (m_rimCrossSection->inputExtrusionPointsFromViewerEnabled)
|
||||
{
|
||||
m_highlightPointsForPolyline->setTransform(scaleTransform);
|
||||
model->addPart(m_highlightPointsForPolyline.p());
|
||||
if (m_highlightLineAlongExtrusionDir.notNull())
|
||||
{
|
||||
m_highlightLineAlongExtrusionDir->setTransform(scaleTransform);
|
||||
model->addPart(m_highlightLineAlongExtrusionDir.p());
|
||||
}
|
||||
|
||||
if (m_highlightPointsForExtrusionDir.notNull())
|
||||
{
|
||||
m_highlightPointsForExtrusionDir->setTransform(scaleTransform);
|
||||
model->addPart(m_highlightPointsForExtrusionDir.p());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -60,6 +60,10 @@ public:
|
||||
private:
|
||||
void updatePartEffect();
|
||||
void generatePartGeometry();
|
||||
|
||||
void createPolyLineParts(bool useBufferObjects);
|
||||
void createExtrusionDirParts(bool useBufferObjects);
|
||||
|
||||
void computeData();
|
||||
|
||||
static void calculateEclipseTextureCoordinates(cvf::Vec2fArray* textureCoords,
|
||||
@@ -86,4 +90,7 @@ private:
|
||||
|
||||
cvf::ref<cvf::Part> m_highlightLineAlongPolyline;
|
||||
cvf::ref<cvf::Part> m_highlightPointsForPolyline;
|
||||
|
||||
cvf::ref<cvf::Part> m_highlightLineAlongExtrusionDir;
|
||||
cvf::ref<cvf::Part> m_highlightPointsForExtrusionDir;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user