mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
(#641) Show user defined polyline using magenta, also visible when mesh is turned off
This commit is contained in:
parent
ee11d4fde7
commit
1208c2f468
@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#include "cvfDrawableGeo.h"
|
#include "cvfDrawableGeo.h"
|
||||||
#include "cvfPrimitiveSetDirect.h"
|
#include "cvfPrimitiveSetDirect.h"
|
||||||
|
#include "cvfPrimitiveSetIndexedUInt.h"
|
||||||
#include "cvfScalarMapper.h"
|
#include "cvfScalarMapper.h"
|
||||||
|
|
||||||
|
|
||||||
@ -1149,6 +1150,50 @@ cvf::ref<cvf::DrawableGeo> RivCrossSectionGeometryGenerator::createMeshDrawable(
|
|||||||
return geo;
|
return geo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
cvf::ref<cvf::DrawableGeo> RivCrossSectionGeometryGenerator::createLineAlongPolylineDrawable()
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
const std::vector<cvf::Vec3d>& m_polyLine = m_polyLines[pLineIdx];
|
||||||
|
if (m_polyLine.size() < 2) continue;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < m_polyLine.size(); ++i)
|
||||||
|
{
|
||||||
|
vertices.push_back(cvf::Vec3f(m_polyLine[i] - displayOffset));
|
||||||
|
if (i < m_polyLine.size() - 1)
|
||||||
|
{
|
||||||
|
lineIndices.push_back(static_cast<cvf::uint>(i));
|
||||||
|
lineIndices.push_back(static_cast<cvf::uint>(i + 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vertices.size() == 0) return NULL;
|
||||||
|
|
||||||
|
cvf::ref<cvf::Vec3fArray> vx = new cvf::Vec3fArray;
|
||||||
|
vx->assign(vertices);
|
||||||
|
cvf::ref<cvf::UIntArray> idxes = new cvf::UIntArray;
|
||||||
|
idxes->assign(lineIndices);
|
||||||
|
|
||||||
|
cvf::ref<cvf::PrimitiveSetIndexedUInt> prim = new cvf::PrimitiveSetIndexedUInt(cvf::PT_LINES);
|
||||||
|
prim->setIndices(idxes.p());
|
||||||
|
|
||||||
|
cvf::ref<cvf::DrawableGeo> polylineGeo = new cvf::DrawableGeo;
|
||||||
|
polylineGeo->setVertexArray(vx.p());
|
||||||
|
polylineGeo->addPrimitiveSet(prim.p());
|
||||||
|
|
||||||
|
return polylineGeo;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
/// Remove the lines from the polyline that is nearly parallel to the extrusion direction
|
/// Remove the lines from the polyline that is nearly parallel to the extrusion direction
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -141,6 +141,7 @@ public:
|
|||||||
// Generate geometry
|
// Generate geometry
|
||||||
cvf::ref<cvf::DrawableGeo> generateSurface();
|
cvf::ref<cvf::DrawableGeo> generateSurface();
|
||||||
cvf::ref<cvf::DrawableGeo> createMeshDrawable();
|
cvf::ref<cvf::DrawableGeo> createMeshDrawable();
|
||||||
|
cvf::ref<cvf::DrawableGeo> createLineAlongPolylineDrawable();
|
||||||
|
|
||||||
// Mapping between cells and geometry
|
// Mapping between cells and geometry
|
||||||
const std::vector<size_t>& triangleToCellIndex() const;
|
const std::vector<size_t>& triangleToCellIndex() const;
|
||||||
|
@ -46,6 +46,8 @@
|
|||||||
#include "cvfModelBasicList.h"
|
#include "cvfModelBasicList.h"
|
||||||
#include "cvfPart.h"
|
#include "cvfPart.h"
|
||||||
#include "cvfPrimitiveSetDirect.h"
|
#include "cvfPrimitiveSetDirect.h"
|
||||||
|
#include "cvfRenderState_FF.h"
|
||||||
|
#include "cvfRenderStateDepth.h"
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -339,6 +341,38 @@ void RivCrossSectionPartMgr::generatePartGeometry()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Highlight line
|
||||||
|
{
|
||||||
|
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->setEnableMask(meshFaultBit);
|
||||||
|
//part->setPriority(priMesh);
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
updatePartEffect();
|
updatePartEffect();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -407,6 +441,12 @@ void RivCrossSectionPartMgr::appendMeshLinePartsToModel(cvf::ModelBasicList* mod
|
|||||||
m_crossSectionGridLines->setTransform(scaleTransform);
|
m_crossSectionGridLines->setTransform(scaleTransform);
|
||||||
model->addPart(m_crossSectionGridLines.p());
|
model->addPart(m_crossSectionGridLines.p());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_highlightLineAlongPolyline.notNull())
|
||||||
|
{
|
||||||
|
m_highlightLineAlongPolyline->setTransform(scaleTransform);
|
||||||
|
model->addPart(m_highlightLineAlongPolyline.p());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -84,4 +84,5 @@ private:
|
|||||||
cvf::ref<cvf::Part> m_crossSectionGridLines;
|
cvf::ref<cvf::Part> m_crossSectionGridLines;
|
||||||
cvf::ref<cvf::Vec2fArray> m_crossSectionFacesTextureCoords;
|
cvf::ref<cvf::Vec2fArray> m_crossSectionFacesTextureCoords;
|
||||||
|
|
||||||
|
cvf::ref<cvf::Part> m_highlightLineAlongPolyline;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user