mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2437 Add fault-labels to 2d Intersection view
This commit is contained in:
@@ -144,6 +144,60 @@ void RivIntersectionGeometryGenerator::calculateFlattenedOrOffsetedPolyline()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class MeshLinesAccumulator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MeshLinesAccumulator(const RivIntersectionHexGridInterface* hexGrid)
|
||||||
|
: m_hexGrid(hexGrid)
|
||||||
|
{}
|
||||||
|
|
||||||
|
std::vector<cvf::Vec3f> cellBorderLineVxes;
|
||||||
|
std::vector<cvf::Vec3f> faultCellBorderLineVxes;
|
||||||
|
std::map<const RigFault*, cvf::Vec3d> faultToHighestFaultMeshVxMap;
|
||||||
|
|
||||||
|
void accumulateMeshLines(const std::vector<int>& cellFaceForEachClippedTriangleEdge,
|
||||||
|
uint triVxIdx,
|
||||||
|
size_t globalCellIdx,
|
||||||
|
const cvf::Vec3d& p0,
|
||||||
|
const cvf::Vec3d& p1)
|
||||||
|
{
|
||||||
|
#define isFace( faceEnum ) (0 <= faceEnum && faceEnum <= 5 )
|
||||||
|
using FaceType = cvf::StructGridInterface::FaceType;
|
||||||
|
|
||||||
|
if ( isFace(cellFaceForEachClippedTriangleEdge[triVxIdx]) )
|
||||||
|
{
|
||||||
|
const RigFault * fault = m_hexGrid->findFaultFromCellIndexAndCellFace(globalCellIdx,
|
||||||
|
(FaceType)cellFaceForEachClippedTriangleEdge[triVxIdx]);
|
||||||
|
if ( fault )
|
||||||
|
{
|
||||||
|
cvf::Vec3d highestVx = p0.z() > p1.z() ? p0 : p1;
|
||||||
|
|
||||||
|
auto itIsInsertedPair = faultToHighestFaultMeshVxMap.insert({fault, highestVx});
|
||||||
|
if (!itIsInsertedPair.second)
|
||||||
|
{
|
||||||
|
if (itIsInsertedPair.first->second.z() < highestVx.z())
|
||||||
|
{
|
||||||
|
itIsInsertedPair.first->second = highestVx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
faultCellBorderLineVxes.emplace_back(p0);
|
||||||
|
faultCellBorderLineVxes.emplace_back(p1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cellBorderLineVxes.emplace_back(p0);
|
||||||
|
cellBorderLineVxes.emplace_back(p1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
cvf::cref<RivIntersectionHexGridInterface> m_hexGrid;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@@ -153,8 +207,9 @@ void RivIntersectionGeometryGenerator::calculateArrays()
|
|||||||
|
|
||||||
m_extrusionDirection.normalize();
|
m_extrusionDirection.normalize();
|
||||||
std::vector<cvf::Vec3f> triangleVertices;
|
std::vector<cvf::Vec3f> triangleVertices;
|
||||||
std::vector<cvf::Vec3f> cellBorderLineVxes;
|
|
||||||
std::vector<cvf::Vec3f> faultCellBorderLineVxes;
|
MeshLinesAccumulator meshAcc(m_hexGrid.p());
|
||||||
|
|
||||||
cvf::Vec3d displayOffset = m_hexGrid->displayOffset();
|
cvf::Vec3d displayOffset = m_hexGrid->displayOffset();
|
||||||
cvf::BoundingBox gridBBox = m_hexGrid->boundingBox();
|
cvf::BoundingBox gridBBox = m_hexGrid->boundingBox();
|
||||||
|
|
||||||
@@ -303,6 +358,7 @@ void RivIntersectionGeometryGenerator::calculateArrays()
|
|||||||
uint triVxIdx = tIdx*3;
|
uint triVxIdx = tIdx*3;
|
||||||
|
|
||||||
// Accumulate triangle vertices
|
// Accumulate triangle vertices
|
||||||
|
|
||||||
cvf::Vec3d p0(clippedTriangleVxes[triVxIdx+0].vx);
|
cvf::Vec3d p0(clippedTriangleVxes[triVxIdx+0].vx);
|
||||||
cvf::Vec3d p1(clippedTriangleVxes[triVxIdx+1].vx);
|
cvf::Vec3d p1(clippedTriangleVxes[triVxIdx+1].vx);
|
||||||
cvf::Vec3d p2(clippedTriangleVxes[triVxIdx+2].vx);
|
cvf::Vec3d p2(clippedTriangleVxes[triVxIdx+2].vx);
|
||||||
@@ -317,49 +373,12 @@ void RivIntersectionGeometryGenerator::calculateArrays()
|
|||||||
|
|
||||||
|
|
||||||
// Accumulate mesh lines
|
// Accumulate mesh lines
|
||||||
#define isFace( faceEnum ) (0 <= faceEnum && faceEnum <= 5 )
|
|
||||||
using FaceType = cvf::StructGridInterface::FaceType;
|
|
||||||
|
|
||||||
if ( isFace(cellFaceForEachClippedTriangleEdge[triVxIdx]) )
|
|
||||||
{
|
|
||||||
if ( m_hexGrid->findFaultFromCellIndexAndCellFace(globalCellIdx, (FaceType)cellFaceForEachClippedTriangleEdge[triVxIdx]) )
|
|
||||||
{
|
|
||||||
faultCellBorderLineVxes.emplace_back(p0);
|
|
||||||
faultCellBorderLineVxes.emplace_back(p1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cellBorderLineVxes.emplace_back(p0);
|
|
||||||
cellBorderLineVxes.emplace_back(p1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( isFace(cellFaceForEachClippedTriangleEdge[triVxIdx+1]) )
|
|
||||||
{
|
|
||||||
if ( m_hexGrid->findFaultFromCellIndexAndCellFace(globalCellIdx, (FaceType)cellFaceForEachClippedTriangleEdge[triVxIdx+1]) )
|
|
||||||
{
|
|
||||||
faultCellBorderLineVxes.emplace_back(p1);
|
|
||||||
faultCellBorderLineVxes.emplace_back(p2);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cellBorderLineVxes.emplace_back(p1);
|
|
||||||
cellBorderLineVxes.emplace_back(p2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( isFace(cellFaceForEachClippedTriangleEdge[triVxIdx+2]) )
|
|
||||||
{
|
|
||||||
if ( m_hexGrid->findFaultFromCellIndexAndCellFace(globalCellIdx, (FaceType)cellFaceForEachClippedTriangleEdge[triVxIdx+2]) )
|
|
||||||
{
|
|
||||||
faultCellBorderLineVxes.emplace_back(p2);
|
|
||||||
faultCellBorderLineVxes.emplace_back(p0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cellBorderLineVxes.emplace_back(p2);
|
|
||||||
cellBorderLineVxes.emplace_back(p0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
meshAcc.accumulateMeshLines(cellFaceForEachClippedTriangleEdge, triVxIdx + 0, globalCellIdx, p0, p1);
|
||||||
|
meshAcc.accumulateMeshLines(cellFaceForEachClippedTriangleEdge, triVxIdx + 1, globalCellIdx, p1, p2);
|
||||||
|
meshAcc.accumulateMeshLines(cellFaceForEachClippedTriangleEdge, triVxIdx + 2, globalCellIdx, p2, p0);
|
||||||
|
|
||||||
|
|
||||||
// Mapping to cell index
|
// Mapping to cell index
|
||||||
|
|
||||||
m_triangleToCellIdxMap.push_back(globalCellIdx);
|
m_triangleToCellIdxMap.push_back(globalCellIdx);
|
||||||
@@ -389,9 +408,15 @@ void RivIntersectionGeometryGenerator::calculateArrays()
|
|||||||
lIdx = idxToNextP;
|
lIdx = idxToNextP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_triangleVxes->assign(triangleVertices);
|
m_triangleVxes->assign(triangleVertices);
|
||||||
m_cellBorderLineVxes->assign(cellBorderLineVxes);
|
m_cellBorderLineVxes->assign(meshAcc.cellBorderLineVxes);
|
||||||
m_faultCellBorderLineVxes->assign(faultCellBorderLineVxes);
|
m_faultCellBorderLineVxes->assign(meshAcc.faultCellBorderLineVxes);
|
||||||
|
|
||||||
|
for (const auto& it : meshAcc.faultToHighestFaultMeshVxMap)
|
||||||
|
{
|
||||||
|
m_faultMeshLabelAndAnchorPositions.push_back( { it.first->name(), it.second } );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,8 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
class RigMainGrid;
|
class RigMainGrid;
|
||||||
class RigActiveCellInfo;
|
class RigActiveCellInfo;
|
||||||
class RigResultAccessor;
|
class RigResultAccessor;
|
||||||
@@ -68,6 +70,8 @@ public:
|
|||||||
cvf::ref<cvf::DrawableGeo> createPointsFromExtrusionLineDrawable(const std::vector<cvf::Vec3d>& extrusionLine);
|
cvf::ref<cvf::DrawableGeo> createPointsFromExtrusionLineDrawable(const std::vector<cvf::Vec3d>& extrusionLine);
|
||||||
|
|
||||||
const std::vector<std::vector<cvf::Vec3d> >& flattenedOrOffsettedPolyLines() { return m_flattenedOrOffsettedPolyLines; }
|
const std::vector<std::vector<cvf::Vec3d> >& flattenedOrOffsettedPolyLines() { return m_flattenedOrOffsettedPolyLines; }
|
||||||
|
const std::vector<std::pair<QString, cvf::Vec3d> > & faultMeshLabelAndAnchorPositions() { return m_faultMeshLabelAndAnchorPositions; }
|
||||||
|
|
||||||
|
|
||||||
// Mapping between cells and geometry
|
// Mapping between cells and geometry
|
||||||
const std::vector<size_t>& triangleToCellIndex() const;
|
const std::vector<size_t>& triangleToCellIndex() const;
|
||||||
@@ -106,5 +110,6 @@ private:
|
|||||||
std::vector<std::vector<cvf::Vec3d> > m_flattenedOrOffsettedPolyLines;
|
std::vector<std::vector<cvf::Vec3d> > m_flattenedOrOffsettedPolyLines;
|
||||||
std::vector<std::vector<cvf::Mat4d> > m_segementTransformPrLinePoint;
|
std::vector<std::vector<cvf::Mat4d> > m_segementTransformPrLinePoint;
|
||||||
|
|
||||||
|
std::vector<std::pair<QString, cvf::Vec3d> > m_faultMeshLabelAndAnchorPositions;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -59,9 +59,11 @@
|
|||||||
#include "cafTensor3.h"
|
#include "cafTensor3.h"
|
||||||
|
|
||||||
#include "cvfDrawableGeo.h"
|
#include "cvfDrawableGeo.h"
|
||||||
|
#include "cvfDrawableText.h"
|
||||||
#include "cvfGeometryTools.h"
|
#include "cvfGeometryTools.h"
|
||||||
#include "cvfModelBasicList.h"
|
#include "cvfModelBasicList.h"
|
||||||
#include "cvfPart.h"
|
#include "cvfPart.h"
|
||||||
|
#include "cvfqtUtils.h"
|
||||||
#include "cvfPrimitiveSetDirect.h"
|
#include "cvfPrimitiveSetDirect.h"
|
||||||
#include "cvfRenderState_FF.h"
|
#include "cvfRenderState_FF.h"
|
||||||
#include "cvfRenderStateDepth.h"
|
#include "cvfRenderStateDepth.h"
|
||||||
@@ -582,9 +584,87 @@ void RivIntersectionPartMgr::generatePartGeometry()
|
|||||||
|
|
||||||
createExtrusionDirParts(useBufferObjects);
|
createExtrusionDirParts(useBufferObjects);
|
||||||
|
|
||||||
|
if (m_isFlattened) createFaultLabelParts(m_crossSectionGenerator->faultMeshLabelAndAnchorPositions());
|
||||||
|
|
||||||
applySingleColorEffect();
|
applySingleColorEffect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RivIntersectionPartMgr::createFaultLabelParts(const std::vector<std::pair<QString, cvf::Vec3d> >& labelAndAnchors)
|
||||||
|
{
|
||||||
|
cvf::Font* font = RiaApplication::instance()->customFont();
|
||||||
|
|
||||||
|
std::vector<cvf::Vec3f> lineVertices;
|
||||||
|
|
||||||
|
cvf::ref<cvf::DrawableText> drawableText = new cvf::DrawableText;
|
||||||
|
{
|
||||||
|
drawableText->setFont(font);
|
||||||
|
drawableText->setCheckPosVisible(false);
|
||||||
|
drawableText->setDrawBorder(false);
|
||||||
|
drawableText->setDrawBackground(false);
|
||||||
|
drawableText->setVerticalAlignment(cvf::TextDrawer::BASELINE);
|
||||||
|
cvf::Color3f defWellLabelColor = RiaApplication::instance()->preferences()->defaultWellLabelColor();
|
||||||
|
drawableText->setTextColor(defWellLabelColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
cvf::BoundingBox bb = m_crossSectionFaces->boundingBox();
|
||||||
|
double labelZOffset = bb.extent().z() / 10;
|
||||||
|
|
||||||
|
for (const auto& labelAndAnchorPair : labelAndAnchors)
|
||||||
|
{
|
||||||
|
cvf::String cvfString = cvfqt::Utils::toString(labelAndAnchorPair.first);
|
||||||
|
cvf::Vec3f textCoord(labelAndAnchorPair.second);
|
||||||
|
|
||||||
|
textCoord.z() += labelZOffset;
|
||||||
|
drawableText->addText(cvfString, textCoord);
|
||||||
|
|
||||||
|
lineVertices.push_back(cvf::Vec3f(labelAndAnchorPair.second));
|
||||||
|
lineVertices.push_back(textCoord);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Labels part
|
||||||
|
{
|
||||||
|
cvf::ref<cvf::Part> part = new cvf::Part;
|
||||||
|
part->setName("Fault mesh label : text ");
|
||||||
|
part->setDrawable(drawableText.p());
|
||||||
|
|
||||||
|
cvf::ref<cvf::Effect> eff = new cvf::Effect;
|
||||||
|
|
||||||
|
part->setEffect(eff.p());
|
||||||
|
part->setPriority(RivPartPriority::PartType::Text);
|
||||||
|
part->updateBoundingBox();
|
||||||
|
|
||||||
|
m_faultMeshLabels = part;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lines to labels part
|
||||||
|
{
|
||||||
|
cvf::ref<cvf::Vec3fArray> vertices = new cvf::Vec3fArray;
|
||||||
|
vertices->assign(lineVertices);
|
||||||
|
cvf::ref<cvf::DrawableGeo> geo = new cvf::DrawableGeo;
|
||||||
|
geo->setVertexArray(vertices.p());
|
||||||
|
|
||||||
|
cvf::ref<cvf::PrimitiveSetDirect> primSet = new cvf::PrimitiveSetDirect(cvf::PT_LINES);
|
||||||
|
primSet->setStartIndex(0);
|
||||||
|
primSet->setIndexCount(vertices->size());
|
||||||
|
geo->addPrimitiveSet(primSet.p());
|
||||||
|
|
||||||
|
cvf::ref<cvf::Part> part = new cvf::Part;
|
||||||
|
part->setName("Anchor lines for fault mesh labels");
|
||||||
|
part->setDrawable(geo.p());
|
||||||
|
|
||||||
|
part->updateBoundingBox();
|
||||||
|
|
||||||
|
caf::MeshEffectGenerator gen(RiaApplication::instance()->preferences()->defaultFaultGridLineColors());
|
||||||
|
cvf::ref<cvf::Effect> eff = gen.generateCachedEffect();
|
||||||
|
|
||||||
|
part->setEffect(eff.p());
|
||||||
|
m_faultMeshLabelLines = part;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
@@ -834,6 +914,19 @@ void RivIntersectionPartMgr::appendMeshLinePartsToModel(cvf::ModelBasicList* mod
|
|||||||
m_crossSectionFaultGridLines->setTransform(scaleTransform);
|
m_crossSectionFaultGridLines->setTransform(scaleTransform);
|
||||||
model->addPart(m_crossSectionFaultGridLines.p());
|
model->addPart(m_crossSectionFaultGridLines.p());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_faultMeshLabelLines.notNull())
|
||||||
|
{
|
||||||
|
m_faultMeshLabelLines->setTransform(scaleTransform);
|
||||||
|
model->addPart(m_faultMeshLabelLines.p());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_faultMeshLabels.notNull())
|
||||||
|
{
|
||||||
|
m_faultMeshLabels->setTransform(scaleTransform);
|
||||||
|
model->addPart(m_faultMeshLabels.p());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,10 @@
|
|||||||
|
|
||||||
#include "cafPdmPointer.h"
|
#include "cafPdmPointer.h"
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace cvf
|
namespace cvf
|
||||||
{
|
{
|
||||||
@@ -110,6 +113,7 @@ public:
|
|||||||
const cvf::ScalarMapper* mapper);
|
const cvf::ScalarMapper* mapper);
|
||||||
private:
|
private:
|
||||||
void generatePartGeometry();
|
void generatePartGeometry();
|
||||||
|
void createFaultLabelParts(const std::vector<std::pair<QString, cvf::Vec3d> >& labelAndAnchors);
|
||||||
void createPolyLineParts(bool useBufferObjects);
|
void createPolyLineParts(bool useBufferObjects);
|
||||||
void createExtrusionDirParts(bool useBufferObjects);
|
void createExtrusionDirParts(bool useBufferObjects);
|
||||||
|
|
||||||
@@ -122,7 +126,10 @@ private:
|
|||||||
cvf::ref<cvf::Part> m_crossSectionFaces;
|
cvf::ref<cvf::Part> m_crossSectionFaces;
|
||||||
cvf::ref<cvf::Part> m_crossSectionGridLines;
|
cvf::ref<cvf::Part> m_crossSectionGridLines;
|
||||||
cvf::ref<cvf::Part> m_crossSectionFaultGridLines;
|
cvf::ref<cvf::Part> m_crossSectionFaultGridLines;
|
||||||
|
cvf::ref<cvf::Part> m_faultMeshLabels;
|
||||||
|
cvf::ref<cvf::Part> m_faultMeshLabelLines;
|
||||||
|
|
||||||
|
|
||||||
cvf::ref<cvf::Vec2fArray> m_crossSectionFacesTextureCoords;
|
cvf::ref<cvf::Vec2fArray> m_crossSectionFacesTextureCoords;
|
||||||
|
|
||||||
cvf::ref<cvf::Part> m_highlightLineAlongPolyline;
|
cvf::ref<cvf::Part> m_highlightLineAlongPolyline;
|
||||||
|
|||||||
Reference in New Issue
Block a user