mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-09 23:16:00 -06:00
(#641) Added polyline point visualization
This commit is contained in:
parent
3eade62961
commit
dc03844a55
@ -1194,6 +1194,40 @@ cvf::ref<cvf::DrawableGeo> RivCrossSectionGeometryGenerator::createLineAlongPoly
|
||||
return polylineGeo;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::DrawableGeo> RivCrossSectionGeometryGenerator::createPointsFromPolylineDrawable()
|
||||
{
|
||||
std::vector<cvf::Vec3f> vertices;
|
||||
|
||||
cvf::Vec3d displayOffset = m_hexGrid->displayOffset();
|
||||
|
||||
for (size_t pLineIdx = 0; pLineIdx < m_polyLines.size(); ++pLineIdx)
|
||||
{
|
||||
const std::vector<cvf::Vec3d>& m_polyLine = m_polyLines[pLineIdx];
|
||||
for (size_t i = 0; i < m_polyLine.size(); ++i)
|
||||
{
|
||||
vertices.push_back(cvf::Vec3f(m_polyLine[i] - displayOffset));
|
||||
}
|
||||
}
|
||||
|
||||
if (vertices.size() == 0) return NULL;
|
||||
|
||||
cvf::ref<cvf::PrimitiveSetDirect> primSet = new cvf::PrimitiveSetDirect(cvf::PT_POINTS);
|
||||
primSet->setStartIndex(0);
|
||||
primSet->setIndexCount(vertices.size());
|
||||
|
||||
cvf::ref<cvf::DrawableGeo> geo = new cvf::DrawableGeo;
|
||||
|
||||
cvf::ref<cvf::Vec3fArray> vx = new cvf::Vec3fArray(vertices);
|
||||
geo->setVertexArray(vx.p());
|
||||
geo->addPrimitiveSet(primSet.p());
|
||||
|
||||
return geo;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Remove the lines from the polyline that is nearly parallel to the extrusion direction
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -142,6 +142,7 @@ public:
|
||||
cvf::ref<cvf::DrawableGeo> generateSurface();
|
||||
cvf::ref<cvf::DrawableGeo> createMeshDrawable();
|
||||
cvf::ref<cvf::DrawableGeo> createLineAlongPolylineDrawable();
|
||||
cvf::ref<cvf::DrawableGeo> createPointsFromPolylineDrawable();
|
||||
|
||||
// Mapping between cells and geometry
|
||||
const std::vector<size_t>& triangleToCellIndex() const;
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include "cvfPrimitiveSetDirect.h"
|
||||
#include "cvfRenderState_FF.h"
|
||||
#include "cvfRenderStateDepth.h"
|
||||
#include "cvfRenderStatePoint.h"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -342,18 +343,56 @@ void RivCrossSectionPartMgr::generatePartGeometry()
|
||||
}
|
||||
|
||||
// Highlight line
|
||||
|
||||
m_highlightLineAlongPolyline = NULL;
|
||||
m_highlightPointsForPolyline = NULL;
|
||||
|
||||
if (m_rimCrossSection->type == RimCrossSection::CS_POLYLINE)
|
||||
{
|
||||
cvf::ref<cvf::DrawableGeo> polylineGeo = m_crossSectionGenerator->createLineAlongPolylineDrawable();
|
||||
if (polylineGeo.notNull())
|
||||
{
|
||||
cvf::ref<cvf::DrawableGeo> polylineGeo = m_crossSectionGenerator->createLineAlongPolylineDrawable();
|
||||
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_highlightLineAlongPolyline = part;
|
||||
}
|
||||
}
|
||||
|
||||
cvf::ref<cvf::DrawableGeo> polylinePointsGeo = m_crossSectionGenerator->createPointsFromPolylineDrawable();
|
||||
if (polylinePointsGeo.notNull())
|
||||
{
|
||||
if (useBufferObjects)
|
||||
{
|
||||
polylineGeo->setRenderMode(cvf::DrawableGeo::BUFFER_OBJECT);
|
||||
polylinePointsGeo->setRenderMode(cvf::DrawableGeo::BUFFER_OBJECT);
|
||||
}
|
||||
|
||||
cvf::ref<cvf::Part> part = new cvf::Part;
|
||||
part->setName("Cross Section Polyline");
|
||||
part->setDrawable(polylineGeo.p());
|
||||
part->setDrawable(polylinePointsGeo.p());
|
||||
|
||||
part->updateBoundingBox();
|
||||
part->setPriority(10000);
|
||||
@ -369,9 +408,13 @@ void RivCrossSectionPartMgr::generatePartGeometry()
|
||||
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_highlightLineAlongPolyline = part;
|
||||
m_highlightPointsForPolyline = part;
|
||||
}
|
||||
}
|
||||
|
||||
@ -443,12 +486,24 @@ void RivCrossSectionPartMgr::appendMeshLinePartsToModel(cvf::ModelBasicList* mod
|
||||
m_crossSectionGridLines->setTransform(scaleTransform);
|
||||
model->addPart(m_crossSectionGridLines.p());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivCrossSectionPartMgr::appendPolylinePartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform)
|
||||
{
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -55,6 +55,7 @@ public:
|
||||
|
||||
void appendNativeCrossSectionFacesToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform);
|
||||
void appendMeshLinePartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform);
|
||||
void appendPolylinePartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform);
|
||||
|
||||
private:
|
||||
void updatePartEffect();
|
||||
@ -85,4 +86,5 @@ private:
|
||||
cvf::ref<cvf::Vec2fArray> m_crossSectionFacesTextureCoords;
|
||||
|
||||
cvf::ref<cvf::Part> m_highlightLineAlongPolyline;
|
||||
cvf::ref<cvf::Part> m_highlightPointsForPolyline;
|
||||
};
|
||||
|
@ -131,12 +131,8 @@ void RimCrossSection::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
|
||||
updateName();
|
||||
}
|
||||
|
||||
if (changedField == &inputFromViewerEnabled)
|
||||
{
|
||||
// TODO rebuild geo and div
|
||||
}
|
||||
|
||||
if (changedField == &m_userPolyline)
|
||||
if (changedField == &inputFromViewerEnabled
|
||||
|| changedField == &m_userPolyline)
|
||||
{
|
||||
rebuildGeometryAndScheduleCreateDisplayModel();
|
||||
}
|
||||
|
@ -93,6 +93,11 @@ void RimCrossSectionCollection::appendPartsToModel(cvf::ModelBasicList* model, c
|
||||
{
|
||||
cs->crossSectionPartMgr()->appendNativeCrossSectionFacesToModel(model, scaleTransform);
|
||||
cs->crossSectionPartMgr()->appendMeshLinePartsToModel(model, scaleTransform);
|
||||
|
||||
if (cs->inputFromViewerEnabled)
|
||||
{
|
||||
cs->crossSectionPartMgr()->appendPolylinePartsToModel(model, scaleTransform);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user