#923 Intersections : Added viz for extrusion direction by two points

This commit is contained in:
Magne Sjaastad
2016-10-18 14:25:31 +02:00
parent c3816acfbf
commit 522ae9998f
8 changed files with 175 additions and 28 deletions

View File

@@ -103,7 +103,7 @@ bool RicNewPolylineIntersectionFeature::handleEvent(cvf::Object* eventObject)
}
else if (crossSection->inputExtrusionPointsFromViewerEnabled())
{
crossSection->appendPointToCustomExtrusion(rimCase->displayModelOffset() + polylineUiEvent->localIntersectionPoint);
crossSection->appendPointToExtrusionDirection(rimCase->displayModelOffset() + polylineUiEvent->localIntersectionPoint);
// Further Ui processing is stopped when true is returned
return true;

View File

@@ -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

View File

@@ -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;

View File

@@ -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());
}
}
}

View File

@@ -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;
};

View File

@@ -377,6 +377,18 @@ RivIntersectionPartMgr* RimIntersection::crossSectionPartMgr()
return m_crossSectionPartMgr.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector< std::vector <cvf::Vec3d> > RimIntersection::polyLinesForExtrusionDirection() const
{
std::vector< std::vector <cvf::Vec3d> > lines;
lines.push_back(m_customExtrusionPoints);
return lines;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -601,7 +613,7 @@ void RimIntersection::appendPointToPolyLine(const cvf::Vec3d& point)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimIntersection::appendPointToCustomExtrusion(const cvf::Vec3d& point)
void RimIntersection::appendPointToExtrusionDirection(const cvf::Vec3d& point)
{
if (m_customExtrusionPoints().size() > 1) m_customExtrusionPoints.v().clear();

View File

@@ -76,10 +76,12 @@ public:
caf::PdmField< bool > inputExtrusionPointsFromViewerEnabled;
std::vector< std::vector <cvf::Vec3d> > polyLines() const;
void appendPointToPolyLine(const cvf::Vec3d& point);
RivIntersectionPartMgr* crossSectionPartMgr();
void appendPointToPolyLine(const cvf::Vec3d& point);
void appendPointToCustomExtrusion(const cvf::Vec3d& point);
std::vector< std::vector <cvf::Vec3d> > polyLinesForExtrusionDirection() const;
void appendPointToExtrusionDirection(const cvf::Vec3d& point);
cvf::Vec3d extrusionDirection() const;

View File

@@ -132,11 +132,7 @@ void RimIntersectionCollection::appendPartsToModel(cvf::ModelBasicList* model, c
{
cs->crossSectionPartMgr()->appendNativeCrossSectionFacesToModel(model, scaleTransform);
cs->crossSectionPartMgr()->appendMeshLinePartsToModel(model, scaleTransform);
if (cs->inputPolyLineFromViewerEnabled)
{
cs->crossSectionPartMgr()->appendPolylinePartsToModel(model, scaleTransform);
}
cs->crossSectionPartMgr()->appendPolylinePartsToModel(model, scaleTransform);
}
}