#1753 Fracture: Reworked visualization of StimPlan fractures to limit surface tesselation to area with actual values instead of relying on transparency. Done to allow picking on items behind the fracture. Refactored and removed obsolete code related to StimPlan fracture visualization.

This commit is contained in:
sigurdp 2018-01-03 11:00:05 +01:00
parent 7d4bb47cc8
commit f940d0a3d5
16 changed files with 239 additions and 429 deletions

View File

@ -50,6 +50,7 @@
#include "cvfPrimitiveSetIndexedUInt.h"
#include "cvfScalarMapperContinuousLinear.h"
#include "cvfRenderStateDepth.h"
#include "cvfAssert.h"
#include <array>
@ -72,10 +73,10 @@ RivWellFracturePartMgr::~RivWellFracturePartMgr()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivWellFracturePartMgr::generateSurfacePart(const caf::DisplayCoordTransform* displayCoordTransform)
cvf::ref<cvf::Part> RivWellFracturePartMgr::createEllipseSurfacePart(const RimEclipseView& activeView)
{
if (m_surfacePart.notNull()) return;
if (!displayCoordTransform) return;
auto displayCoordTransform = activeView.displayCoordTransform();
if (displayCoordTransform.isNull()) return nullptr;
if (m_rimFracture)
{
@ -94,38 +95,176 @@ void RivWellFracturePartMgr::generateSurfacePart(const caf::DisplayCoordTransfor
if (triangleIndices.size() == 0 || displayCoords.size() == 0)
{
return;
return nullptr;
}
cvf::ref<cvf::DrawableGeo> geo = buildDrawableGeoFromTriangles(triangleIndices, displayCoords);
CVF_ASSERT(geo.notNull());
m_surfacePart = new cvf::Part(0, "FractureSurfacePart");
m_surfacePart->setDrawable(geo.p());
m_surfacePart->setSourceInfo(new RivObjectSourceInfo(m_rimFracture));
cvf::ref<cvf::Part> surfacePart = new cvf::Part(0, "FractureSurfacePart_ellipse");
surfacePart->setDrawable(geo.p());
surfacePart->setSourceInfo(new RivObjectSourceInfo(m_rimFracture));
cvf::Color4f fractureColor = cvf::Color4f(activeView.stimPlanColors->defaultColor());
caf::SurfaceEffectGenerator surfaceGen(fractureColor, caf::PO_1);
cvf::ref<cvf::Effect> eff = surfaceGen.generateCachedEffect();
surfacePart->setEffect(eff.p());
return surfacePart;
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivWellFracturePartMgr::generateContainmentMaskPart(const RimEclipseView* activeView)
cvf::ref<cvf::Part> RivWellFracturePartMgr::createStimPlanSurfacePart(const RimEclipseView& activeView)
{
RimFractureTemplate* fracTemplate = m_rimFracture->fractureTemplate();
std::vector<cvf::Vec3f> borderPolygonLocalCS;
CVF_ASSERT(m_rimFracture);
RimStimPlanFractureTemplate* stimPlanFracTemplate = dynamic_cast<RimStimPlanFractureTemplate*>(m_rimFracture->fractureTemplate());
CVF_ASSERT(stimPlanFracTemplate);
auto displayCoordTransform = activeView.displayCoordTransform();
if (displayCoordTransform.isNull()) return nullptr;
// Note that the filtering and result mapping code below couples closely to the triangulation and vertex layout returned by triangleGeometry()
// If this ever changes, the entire code must be revisited
std::vector<cvf::Vec3f> nodeCoords;
std::vector<cvf::uint> triangleIndices;
m_rimFracture->triangleGeometry(&triangleIndices, &nodeCoords);
if (triangleIndices.size() == 0 || nodeCoords.size() == 0)
{
return NULL;
}
// Transforms the node coordinates for display
for (size_t i = 0; i < nodeCoords.size(); i++)
{
cvf::Vec3d doubleCoord(nodeCoords[i]);
doubleCoord = displayCoordTransform->transformToDisplayCoord(doubleCoord);
nodeCoords[i] = cvf::Vec3f(doubleCoord);
}
RimLegendConfig* legendConfig = nullptr;
if (activeView.stimPlanColors() && activeView.stimPlanColors()->isChecked())
{
legendConfig = activeView.stimPlanColors()->activeLegend();
}
// Show selected result on the surface geometry and filter out triangles that have result values near 0
if (legendConfig)
{
// Construct array with per node result values that correspond to the node coordinates of the triangle mesh
// Since some time steps don't have result vales, we initialize the array to well known values before populating it
std::vector<double> perNodeResultValues(nodeCoords.size(), HUGE_VAL);
{
size_t idx = 0;
const std::vector<std::vector<double> > dataToPlot = stimPlanFracTemplate->resultValues(activeView.stimPlanColors->resultName(), activeView.stimPlanColors->unit(), stimPlanFracTemplate->activeTimeStepIndex());
for (const std::vector<double>& unmirroredDataAtDepth : dataToPlot)
{
const std::vector<double> mirroredValuesAtDepth = mirrorDataAtSingleDepth(unmirroredDataAtDepth);
for (double val : mirroredValuesAtDepth)
{
perNodeResultValues[idx++] = val;
}
}
}
CVF_ASSERT(perNodeResultValues.size() == nodeCoords.size());
std::vector<cvf::uint> triIndicesToInclude;
for (size_t i = 0; i < triangleIndices.size(); i += 6)
{
// Include all triangles where at least one of the vertices in the triangle pair has a value above threshold
bool includeThisTrianglePair = false;
for (size_t j = 0; j < 6; j++)
{
if (perNodeResultValues[triangleIndices[i + j]] > 1e-7)
{
includeThisTrianglePair = true;
}
}
if (includeThisTrianglePair)
{
for (size_t j = 0; j < 6; j++)
{
triIndicesToInclude.push_back(triangleIndices[i + j]);
}
}
}
if (triIndicesToInclude.size() == 0)
{
return nullptr;
}
cvf::ref<cvf::DrawableGeo> geo = buildDrawableGeoFromTriangles(triIndicesToInclude, nodeCoords);
cvf::ref<cvf::Part> surfacePart = new cvf::Part(0, "FractureSurfacePart_stimPlan");
surfacePart->setDrawable(geo.p());
surfacePart->setPriority(RivPartPriority::PartType::BaseLevel);
surfacePart->setSourceInfo(new RivObjectSourceInfo(m_rimFracture));
const cvf::ScalarMapper* scalarMapper = legendConfig->scalarMapper();
CVF_ASSERT(scalarMapper);
cvf::ref<cvf::Vec2fArray> textureCoords = new cvf::Vec2fArray(nodeCoords.size());
textureCoords->setAll(cvf::Vec2f(0.5f, 1.0f));
for (size_t i = 0; i < perNodeResultValues.size(); i++)
{
const double val = perNodeResultValues[i];
if (val < HUGE_VAL && val == val)
{
textureCoords->set(i, scalarMapper->mapToTextureCoord(val));
}
}
geo->setTextureCoordArray(textureCoords.p());
caf::ScalarMapperEffectGenerator effGen(scalarMapper, caf::PO_1);
effGen.disableLighting(activeView.isLightingDisabled());
cvf::ref<cvf::Effect> eff = effGen.generateCachedEffect();
surfacePart->setEffect(eff.p());
return surfacePart;
}
// No result is mapped, show the entire StimPlan surface with default color
else
{
cvf::ref<cvf::DrawableGeo> geo = buildDrawableGeoFromTriangles(triangleIndices, nodeCoords);
cvf::ref<cvf::Part> surfacePart = new cvf::Part(0, "FractureSurfacePart_stimPlan");
surfacePart->setDrawable(geo.p());
surfacePart->setPriority(RivPartPriority::PartType::BaseLevel);
surfacePart->setSourceInfo(new RivObjectSourceInfo(m_rimFracture));
cvf::Color4f fractureColor = cvf::Color4f(activeView.stimPlanColors->defaultColor());
caf::SurfaceEffectGenerator surfaceGen(fractureColor, caf::PO_1);
cvf::ref<cvf::Effect> eff = surfaceGen.generateCachedEffect();
surfacePart->setEffect(eff.p());
return surfacePart;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::Part> RivWellFracturePartMgr::createContainmentMaskPart(const RimEclipseView& activeView)
{
std::vector<cvf::Vec3f> borderPolygonLocalCS = m_rimFracture->fractureTemplate()->fractureBorderPolygon(m_rimFracture->fractureUnit());
cvf::Mat4d frMx = m_rimFracture->transformMatrix();
cvf::BoundingBox frBBox;
std::vector<cvf::Vec3d> borderPolygonGlobCs;
std::vector<cvf::Vec3d> borderPolygonLocalCsd;
if (fracTemplate)
{
borderPolygonLocalCS = fracTemplate->fractureBorderPolygon(m_rimFracture->fractureUnit());
}
for (const auto& pv: borderPolygonLocalCS)
{
cvf::Vec3d pvd(pv);
@ -136,20 +275,20 @@ void RivWellFracturePartMgr::generateContainmentMaskPart(const RimEclipseView* a
}
std::vector<size_t> cellCandidates;
activeView->mainGrid()->findIntersectingCells(frBBox, &cellCandidates);
activeView.mainGrid()->findIntersectingCells(frBBox, &cellCandidates);
auto displCoordTrans = activeView->displayCoordTransform();
auto displCoordTrans = activeView.displayCoordTransform();
std::vector<cvf::Vec3f> maskTriangles;
for (size_t resCellIdx : cellCandidates)
{
if (!m_rimFracture->isEclipseCellWithinContainment(activeView->mainGrid(), resCellIdx))
if (!m_rimFracture->isEclipseCellWithinContainment(activeView.mainGrid(), resCellIdx))
{
// Calculate Eclipse cell intersection with fracture plane
std::array<cvf::Vec3d,8> corners;
activeView->mainGrid()->cellCornerVertices(resCellIdx, corners.data());
activeView.mainGrid()->cellCornerVertices(resCellIdx, corners.data());
std::vector<std::vector<cvf::Vec3d> > eclCellPolygons;
bool hasIntersection = RigHexIntersectionTools::planeHexIntersectionPolygons(corners, frMx, eclCellPolygons);
@ -222,193 +361,71 @@ void RivWellFracturePartMgr::generateContainmentMaskPart(const RimEclipseView* a
maskTriangleGeo->addPrimitiveSet(primitives.p());
maskTriangleGeo->computeNormals();
m_containmentMaskPart = new cvf::Part(0, "FractureContainmentMaskPart");
m_containmentMaskPart->setDrawable(maskTriangleGeo.p());
m_containmentMaskPart->setSourceInfo(new RivObjectSourceInfo(m_rimFracture));
cvf::ref<cvf::Part> containmentMaskPart = new cvf::Part(0, "FractureContainmentMaskPart");
containmentMaskPart->setDrawable(maskTriangleGeo.p());
containmentMaskPart->setSourceInfo(new RivObjectSourceInfo(m_rimFracture));
cvf::Color4f maskColor = cvf::Color4f(cvf::Color3f(cvf::Color3::GRAY));
caf::SurfaceEffectGenerator surfaceGen(maskColor, caf::PO_NONE);
cvf::ref<cvf::Effect> eff = surfaceGen.generateCachedEffect();
m_containmentMaskPart->setEffect(eff.p());
containmentMaskPart->setEffect(eff.p());
return containmentMaskPart;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivWellFracturePartMgr::applyFractureUniformColor(const RimEclipseView* activeView)
{
if ( m_surfacePart.notNull() )
{
cvf::Color4f fractureColor = cvf::Color4f(cvf::Color3f(cvf::Color3::BROWN));
if ( activeView )
{
fractureColor = cvf::Color4f(activeView->stimPlanColors->defaultColor());
}
caf::SurfaceEffectGenerator surfaceGen(fractureColor, caf::PO_1);
cvf::ref<cvf::Effect> eff = surfaceGen.generateCachedEffect();
m_surfacePart->setEffect(eff.p());
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivWellFracturePartMgr::applyResultTextureColor(const RimEclipseView* activeView)
cvf::ref<cvf::Part> RivWellFracturePartMgr::createStimPlanMeshPart(const RimEclipseView& activeView)
{
if (m_surfacePart.isNull()) return;
if (m_rimFracture)
{
RimLegendConfig* legendConfig = nullptr;
if (activeView && activeView->stimPlanColors())
{
if (activeView->stimPlanColors()->isChecked())
{
legendConfig = activeView->stimPlanColors()->activeLegend();
}
}
RimFractureTemplate* fracTemplate = m_rimFracture->fractureTemplate();
RimStimPlanFractureTemplate* stimPlanFracTemplate = dynamic_cast<RimStimPlanFractureTemplate*>(fracTemplate);
if (!stimPlanFracTemplate)
{
return;
}
float opacityLevel = activeView->stimPlanColors->opacityLevel();
if (legendConfig)
{
cvf::ScalarMapper* scalarMapper = legendConfig->scalarMapper();
cvf::DrawableGeo* geo = dynamic_cast<cvf::DrawableGeo*> (m_surfacePart->drawable());
cvf::ref<cvf::Vec2fArray> textureCoords = new cvf::Vec2fArray;
textureCoords->resize(geo->vertexCount());
int timeStepIndex = stimPlanFracTemplate->activeTimeStepIndex();
std::vector<std::vector<double> > dataToPlot = stimPlanFracTemplate->resultValues(activeView->stimPlanColors->resultName(),
activeView->stimPlanColors->unit(),
timeStepIndex);
int i = 0;
for (const std::vector<double>& depthData : dataToPlot)
{
std::vector<double> mirroredValuesAtDepth = mirrorDataAtSingleDepth(depthData);
for (double gridXdata : mirroredValuesAtDepth)
{
cvf::Vec2f texCoord = scalarMapper->mapToTextureCoord(gridXdata);
if (gridXdata > 1e-7)
{
texCoord[1] = 0; // Set the Y texture coordinate to the opaque line in the texture
}
textureCoords->set(i, texCoord);
i++;
}
}
geo->setTextureCoordArray(textureCoords.p());
caf::ScalarMapperEffectGenerator effGen(scalarMapper, caf::PO_1);
effGen.setOpacityLevel(0.5);
effGen.discardTransparentFragments(true);
if (activeView && activeView->isLightingDisabled())
{
effGen.disableLighting(true);
}
cvf::ref<cvf::Effect> eff = effGen.generateCachedEffect();
m_surfacePart->setEffect(eff.p());
m_surfacePart->setPriority(RivPartPriority::PartType::Transparent);
}
else
{
applyFractureUniformColor(activeView);
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivWellFracturePartMgr::generateFractureOutlinePolygonPart(const caf::DisplayCoordTransform* displayCoordTransform)
{
m_polygonPart = nullptr;
cvf::ref<cvf::DrawableGeo> polygonGeo = createPolygonDrawable(displayCoordTransform);
if (polygonGeo.notNull())
{
m_polygonPart = new cvf::Part(0, "FractureOutline");
m_polygonPart->setDrawable(polygonGeo.p());
m_polygonPart->updateBoundingBox();
m_polygonPart->setPriority(RivPartPriority::PartType::TransparentMeshLines);
caf::MeshEffectGenerator lineEffGen(cvf::Color3::MAGENTA);
lineEffGen.setLineWidth(3.0f);
cvf::ref<cvf::Effect> eff = lineEffGen.generateCachedEffect();
m_polygonPart->setEffect(eff.p());
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivWellFracturePartMgr::generateStimPlanMeshPart(const caf::DisplayCoordTransform* displayCoordTransform,
const RimEclipseView* activeView)
{
m_stimPlanMeshPart = nullptr;
if (!m_rimFracture->fractureTemplate()) return;
if (!m_rimFracture->fractureTemplate()) return nullptr;
RimStimPlanFractureTemplate* stimPlanFracTemplate = dynamic_cast<RimStimPlanFractureTemplate*>(m_rimFracture->fractureTemplate());
if (!stimPlanFracTemplate) return;
if (!stimPlanFracTemplate) return nullptr;
cvf::ref<cvf::DrawableGeo> stimPlanMeshGeo = createStimPlanMeshDrawable(stimPlanFracTemplate,
displayCoordTransform,
activeView);
cvf::ref<cvf::DrawableGeo> stimPlanMeshGeo = createStimPlanMeshDrawable(stimPlanFracTemplate, activeView);
if (stimPlanMeshGeo.notNull())
{
m_stimPlanMeshPart = new cvf::Part(0, "StimPlanMesh");
m_stimPlanMeshPart->setDrawable(stimPlanMeshGeo.p());
cvf::ref<cvf::Part> stimPlanMeshPart = new cvf::Part(0, "StimPlanMesh");
stimPlanMeshPart->setDrawable(stimPlanMeshGeo.p());
m_stimPlanMeshPart->updateBoundingBox();
m_stimPlanMeshPart->setPriority(RivPartPriority::PartType::TransparentMeshLines);
stimPlanMeshPart->updateBoundingBox();
stimPlanMeshPart->setPriority(RivPartPriority::PartType::TransparentMeshLines);
caf::MeshEffectGenerator lineEffGen(cvf::Color3::BLACK);
lineEffGen.setLineWidth(1.0f);
cvf::ref<cvf::Effect> eff = lineEffGen.generateCachedEffect();
m_stimPlanMeshPart->setEffect(eff.p());
stimPlanMeshPart->setEffect(eff.p());
return stimPlanMeshPart;
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::DrawableGeo> RivWellFracturePartMgr::createStimPlanMeshDrawable(RimStimPlanFractureTemplate* stimPlanFracTemplate,
const caf::DisplayCoordTransform* displayCoordTransform,
const RimEclipseView* activeView)
cvf::ref<cvf::DrawableGeo> RivWellFracturePartMgr::createStimPlanMeshDrawable(RimStimPlanFractureTemplate* stimPlanFracTemplate, const RimEclipseView& activeView) const
{
//TODO: This is needed to avoid errors when loading project with stimPlan fractures with multipled timesteps.
//Should probably be moved, since it now is called twice in some cases...
stimPlanFracTemplate->updateFractureGrid();
auto displayCoordTransform = activeView.displayCoordTransform();
if (displayCoordTransform.isNull()) return nullptr;
std::vector<RigFractureCell> stimPlanCells = stimPlanFracTemplate->fractureGrid()->fractureCells();
std::vector<cvf::Vec3f> stimPlanMeshVertices;
QString resultNameFromColors = activeView->stimPlanColors->resultName();
QString resultUnitFromColors = activeView->stimPlanColors->unit();
QString resultNameFromColors = activeView.stimPlanColors->resultName();
QString resultUnitFromColors = activeView.stimPlanColors->unit();
std::vector<double> prCellResults = stimPlanFracTemplate->fractureGridResults(resultNameFromColors,
resultUnitFromColors,
@ -433,9 +450,9 @@ cvf::ref<cvf::DrawableGeo> RivWellFracturePartMgr::createStimPlanMeshDrawable(Ri
}
cvf::Mat4d fractureXf = m_rimFracture->transformMatrix();
std::vector<cvf::Vec3f> stimPlanMeshVerticesDisplayCoords = transfromToFractureDisplayCoords(stimPlanMeshVertices,
std::vector<cvf::Vec3f> stimPlanMeshVerticesDisplayCoords = transformToFractureDisplayCoords(stimPlanMeshVertices,
fractureXf,
displayCoordTransform);
*displayCoordTransform);
cvf::Vec3fArray* stimPlanMeshVertexList;
stimPlanMeshVertexList = new cvf::Vec3fArray;
@ -455,81 +472,9 @@ cvf::ref<cvf::DrawableGeo> RivWellFracturePartMgr::createStimPlanMeshDrawable(Ri
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivWellFracturePartMgr::getPolygonBB(float &polygonXmin, float &polygonXmax, float &polygonYmin, float &polygonYmax)
{
std::vector<cvf::Vec3f> polygon;
if (m_rimFracture->fractureTemplate())
{
polygon = m_rimFracture->fractureTemplate()->fractureBorderPolygon(m_rimFracture->fractureUnit());
}
if (polygon.size() > 1)
{
polygonXmin = polygon[0].x();
polygonXmax = polygon[0].x();
polygonYmin = polygon[0].y();
polygonYmax = polygon[0].y();
}
for (cvf::Vec3f v : polygon)
{
if (v.x() < polygonXmin) polygonXmin = v.x();
if (v.x() > polygonXmax) polygonXmax = v.x();
if (v.y() < polygonYmin) polygonYmin = v.y();
if (v.y() > polygonYmax) polygonYmax = v.y();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::DrawableGeo> RivWellFracturePartMgr::createPolygonDrawable(const caf::DisplayCoordTransform* displayCoordTransform)
{
std::vector<cvf::uint> lineIndices;
std::vector<cvf::Vec3f> vertices;
if(m_rimFracture->fractureTemplate())
{
std::vector<cvf::Vec3f> polygon = m_rimFracture->fractureTemplate()->fractureBorderPolygon(m_rimFracture->fractureUnit());
cvf::Mat4d m = m_rimFracture->transformMatrix();
std::vector<cvf::Vec3f> polygonDisplayCoords = transfromToFractureDisplayCoords(polygon, m, displayCoordTransform);
for (size_t i = 0; i < polygonDisplayCoords.size(); ++i)
{
vertices.push_back(cvf::Vec3f(polygonDisplayCoords[i]));
if (i < polygonDisplayCoords.size() - 1)
{
lineIndices.push_back(static_cast<cvf::uint>(i));
lineIndices.push_back(static_cast<cvf::uint>(i + 1));
}
}
}
if (vertices.size() == 0) return nullptr;
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> polygonGeo = new cvf::DrawableGeo;
polygonGeo->setVertexArray(vx.p());
polygonGeo->addPrimitiveSet(prim.p());
return polygonGeo;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<cvf::Vec3f> RivWellFracturePartMgr::transfromToFractureDisplayCoords(const std::vector<cvf::Vec3f>& coordinatesVector,
std::vector<cvf::Vec3f> RivWellFracturePartMgr::transformToFractureDisplayCoords(const std::vector<cvf::Vec3f>& coordinatesVector,
cvf::Mat4d m,
const caf::DisplayCoordTransform* displayCoordTransform)
const caf::DisplayCoordTransform& displayCoordTransform)
{
std::vector<cvf::Vec3f> polygonInDisplayCoords;
polygonInDisplayCoords.reserve(coordinatesVector.size());
@ -538,7 +483,7 @@ std::vector<cvf::Vec3f> RivWellFracturePartMgr::transfromToFractureDisplayCoords
{
cvf::Vec3d vd(v);
vd.transformPoint(m);
cvf::Vec3d displayCoordsDouble = displayCoordTransform->transformToDisplayCoord(vd);
cvf::Vec3d displayCoordsDouble = displayCoordTransform.transformToDisplayCoord(vd);
polygonInDisplayCoords.push_back(cvf::Vec3f(displayCoordsDouble));
}
@ -565,87 +510,61 @@ std::vector<double> RivWellFracturePartMgr::mirrorDataAtSingleDepth(std::vector<
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivWellFracturePartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* model,
const RimEclipseView* eclView)
void RivWellFracturePartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* model, const RimEclipseView& eclView)
{
clearGeometryCache();
if (!m_rimFracture->isChecked()) return;
cvf::ref<cvf::Part> surfacePart;
cvf::ref<cvf::Part> stimPlanMeshPart;
cvf::ref<cvf::Part> containmentMaskPart;
RimStimPlanFractureTemplate* stimPlanFracTemplate = dynamic_cast<RimStimPlanFractureTemplate*>(m_rimFracture->fractureTemplate());
auto displayCoordTransform = eclView->displayCoordTransform();
if (m_surfacePart.isNull())
if (m_rimFracture->fractureTemplate())
{
if (m_rimFracture->fractureTemplate())
// StimPlan
if (stimPlanFracTemplate)
{
if (stimPlanFracTemplate)
{
generateSurfacePart(displayCoordTransform.p());
generateFractureOutlinePolygonPart(displayCoordTransform.p());
surfacePart = createStimPlanSurfacePart(eclView);
applyResultTextureColor(eclView);
if (stimPlanFracTemplate->showStimPlanMesh())
{
generateStimPlanMeshPart(displayCoordTransform.p(), eclView);
}
}
else // Ellipse
if (stimPlanFracTemplate->showStimPlanMesh())
{
generateSurfacePart(displayCoordTransform.p());
applyFractureUniformColor(eclView);
stimPlanMeshPart = createStimPlanMeshPart(eclView);
}
}
// Ellipse
else
{
surfacePart = createEllipseSurfacePart(eclView);
}
if (m_rimFracture->fractureTemplate()->fractureContainment()->isEnabled())
{
generateContainmentMaskPart(eclView);
}
else
{
m_containmentMaskPart = nullptr;
}
if (m_rimFracture->fractureTemplate()->fractureContainment()->isEnabled())
{
containmentMaskPart = createContainmentMaskPart(eclView);
}
}
if (m_surfacePart.notNull())
if (surfacePart.notNull())
{
model->addPart(m_surfacePart.p());
model->addPart(surfacePart.p());
}
if (m_stimPlanMeshPart.notNull()
&& stimPlanFracTemplate->showStimPlanMesh())
if (stimPlanMeshPart.notNull())
{
model->addPart(m_stimPlanMeshPart.p());
model->addPart(stimPlanMeshPart.p());
}
if (stimPlanFracTemplate
&& m_rimFracture->showPolygonFractureOutline()
&& m_polygonPart.notNull())
if (containmentMaskPart.notNull())
{
model->addPart(m_polygonPart.p());
}
if (m_containmentMaskPart.notNull())
{
model->addPart(m_containmentMaskPart.p());
model->addPart(containmentMaskPart.p());
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivWellFracturePartMgr::clearGeometryCache()
{
m_surfacePart = nullptr;
m_polygonPart = nullptr;
m_stimPlanMeshPart = nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::DrawableGeo> RivWellFracturePartMgr::buildDrawableGeoFromTriangles(const std::vector<cvf::uint>& triangleIndices,
const std::vector<cvf::Vec3f>& nodeCoords)
cvf::ref<cvf::DrawableGeo> RivWellFracturePartMgr::buildDrawableGeoFromTriangles(const std::vector<cvf::uint>& triangleIndices, const std::vector<cvf::Vec3f>& nodeCoords)
{
CVF_ASSERT(triangleIndices.size() > 0);
CVF_ASSERT(nodeCoords.size() > 0);

View File

@ -52,38 +52,24 @@ public:
RivWellFracturePartMgr(RimFracture* well);
~RivWellFracturePartMgr();
void appendGeometryPartsToModel(cvf::ModelBasicList* model,
const RimEclipseView* eclView);
void clearGeometryCache();
void appendGeometryPartsToModel(cvf::ModelBasicList* model, const RimEclipseView& eclView);
static std::vector<double> mirrorDataAtSingleDepth(std::vector<double> depthData);
private:
void generateSurfacePart(const caf::DisplayCoordTransform* displayCoordTransform);
cvf::ref<cvf::Part> createEllipseSurfacePart(const RimEclipseView& activeView);
cvf::ref<cvf::Part> createStimPlanSurfacePart(const RimEclipseView& activeView);
void generateContainmentMaskPart(const RimEclipseView* activeView);
void applyFractureUniformColor(const RimEclipseView* activeView);
cvf::ref<cvf::Part> createContainmentMaskPart(const RimEclipseView& activeView);
void applyResultTextureColor(const RimEclipseView* activeView);
cvf::ref<cvf::Part> createStimPlanMeshPart(const RimEclipseView& activeView);
cvf::ref<cvf::DrawableGeo> createStimPlanMeshDrawable(RimStimPlanFractureTemplate* stimPlanFracTemplate, const RimEclipseView& activeView) const;
void generateFractureOutlinePolygonPart(const caf::DisplayCoordTransform* displayCoordTransform);
void generateStimPlanMeshPart(const caf::DisplayCoordTransform* displayCoordTransform,
const RimEclipseView* activeView);
cvf::ref<cvf::DrawableGeo> createPolygonDrawable(const caf::DisplayCoordTransform* displayCoordTransform);
cvf::ref<cvf::DrawableGeo> createStimPlanMeshDrawable(RimStimPlanFractureTemplate* stimPlanFracTemplate,
const caf::DisplayCoordTransform* displayCoordTransform,
const RimEclipseView* activeView);
void getPolygonBB(float &polygonXmin,
float &polygonXmax,
float &polygonYmin,
float &polygonYmax);
std::vector<cvf::Vec3f> transfromToFractureDisplayCoords(const std::vector<cvf::Vec3f>& polygon,
static std::vector<cvf::Vec3f> transformToFractureDisplayCoords(const std::vector<cvf::Vec3f>& polygon,
cvf::Mat4d m,
const caf::DisplayCoordTransform* displayCoordTransform);
bool stimPlanCellTouchesPolygon(const std::vector<cvf::Vec3f>& polygon,
const caf::DisplayCoordTransform& displayCoordTransform);
static bool stimPlanCellTouchesPolygon(const std::vector<cvf::Vec3f>& polygon,
double xMin,
double xMax,
double yMin,
@ -93,14 +79,8 @@ private:
float polygonYmin,
float polygonYmax);
static cvf::ref<cvf::DrawableGeo> buildDrawableGeoFromTriangles(const std::vector<cvf::uint>& triangleIndices,
const std::vector<cvf::Vec3f>& nodeCoords);
static cvf::ref<cvf::DrawableGeo> buildDrawableGeoFromTriangles(const std::vector<cvf::uint>& triangleIndices, const std::vector<cvf::Vec3f>& nodeCoords);
private:
caf::PdmPointer<RimFracture> m_rimFracture;
cvf::ref<cvf::Part> m_surfacePart;
cvf::ref<cvf::Part> m_containmentMaskPart;
cvf::ref<cvf::Part> m_polygonPart;
cvf::ref<cvf::Part> m_stimPlanMeshPart;
};

View File

@ -102,7 +102,7 @@ RivWellPathPartMgr::~RivWellPathPartMgr()
///
//--------------------------------------------------------------------------------------------------
#ifdef USE_PROTOTYPE_FEATURE_FRACTURES
void RivWellPathPartMgr::appendStaticFracturePartsToModel(cvf::ModelBasicList* model, const RimEclipseView* eclView)
void RivWellPathPartMgr::appendStaticFracturePartsToModel(cvf::ModelBasicList* model, const RimEclipseView& eclView)
{
if (!m_rimWellPath || !m_rimWellPath->showWellPath() || !m_rimWellPath->fractureCollection()->isChecked()) return;

View File

@ -61,7 +61,7 @@ public:
#ifdef USE_PROTOTYPE_FEATURE_FRACTURES
void appendStaticFracturePartsToModel(cvf::ModelBasicList* model,
const RimEclipseView* eclView);
const RimEclipseView& eclView);
#endif // USE_PROTOTYPE_FEATURE_FRACTURES
void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model,

View File

@ -88,17 +88,6 @@ void RimEllipseFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* cha
if (proj)
{
//Regenerate geometry
std::vector<RimFracture*> fractures;
proj->descendantsIncludingThisOfType(fractures);
for (RimFracture* fracture : fractures)
{
if (fracture->fractureTemplate() == this)
{
fracture->clearDisplayGeometryCache();
}
}
proj->createDisplayModelAndRedrawAllViews();
setupFractureGridCells();
}

View File

@ -120,8 +120,6 @@ RimFracture::RimFracture(void)
CAF_PDM_InitField(&wellDiameter, "WellDiameter", 0.216, "Well Diameter at Fracture", "", "", "");
CAF_PDM_InitField(&dip, "Dip", 0.0, "Dip", "", "", "");
CAF_PDM_InitField(&tilt, "Tilt", 0.0, "Tilt", "", "", "");
CAF_PDM_InitField(&showPolygonFractureOutline, "ShowPolygonFractureOutline", false, "Show Polygon Outline", "", "", "");
showPolygonFractureOutline.uiCapability()->setUiHidden(true);
CAF_PDM_InitField(&m_fractureUnit, "FractureUnit", caf::AppEnum<RiaEclipseUnitTools::UnitSystem>(RiaEclipseUnitTools::UNITS_METRIC), "Fracture Unit System", "", "", "");
m_fractureUnit.uiCapability()->setUiReadOnly(true);
@ -182,13 +180,9 @@ void RimFracture::fieldChangedByUi(const caf::PdmFieldHandle* changedField, cons
changedField == &m_fractureTemplate ||
changedField == &stimPlanTimeIndexToPlot ||
changedField == this->objectToggleField() ||
changedField == &showPolygonFractureOutline ||
changedField == &dip ||
changedField == &tilt)
{
clearDisplayGeometryCache();
RimView* rimView = nullptr;
this->firstAncestorOrThisOfType(rimView);
if (rimView)
@ -319,14 +313,6 @@ cvf::Mat4d RimFracture::transformMatrix() const
return m;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimFracture::clearDisplayGeometryCache()
{
m_fracturePartMgr->clearGeometryCache();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -530,8 +516,6 @@ void RimFracture::defineEditorAttribute(const caf::PdmFieldHandle* field, QStrin
void RimFracture::setAnchorPosition(const cvf::Vec3d& pos)
{
m_anchorPosition = pos;
clearDisplayGeometryCache();
}
//--------------------------------------------------------------------------------------------------

View File

@ -64,7 +64,6 @@ public:
caf::PdmField<double> tilt;
caf::PdmField<int> stimPlanTimeIndexToPlot;
caf::PdmField<bool> showPolygonFractureOutline;
double wellRadius(RiaEclipseUnitTools::UnitSystem unitSystem) const;
@ -84,8 +83,6 @@ public:
RivWellFracturePartMgr* fracturePartManager();
void clearDisplayGeometryCache();
void triangleGeometry(std::vector<cvf::uint>* triangleIndices, std::vector<cvf::Vec3f>* vxCoords );
std::vector<size_t> getPotentiallyFracturedCells(const RigMainGrid* mainGrid);

View File

@ -123,7 +123,6 @@ void RimFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* changedFie
if (changedField == &azimuthAngle && (abs(oldValue.toDouble() - fracture->azimuth()) < 1e-5))
{
fracture->azimuth = azimuthAngle;
fracture->clearDisplayGeometryCache();
}
if (changedField == &orientationType)
@ -133,8 +132,6 @@ void RimFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* changedFie
fracture->azimuth = azimuthAngle;
}
else fracture->updateAzimuthBasedOnWellAzimuthAngle();
fracture->clearDisplayGeometryCache();
}
}
}

View File

@ -197,7 +197,6 @@ void RimSimWellFracture::defineUiOrdering(QString uiConfigName, caf::PdmUiOrderi
RimFracture::defineUiOrdering(uiConfigName, uiOrdering);
uiOrdering.add(nameField());
uiOrdering.add(&showPolygonFractureOutline);
caf::PdmUiGroup* locationGroup = uiOrdering.addNewGroup("Location / Orientation");
locationGroup->add(&m_location);

View File

@ -113,8 +113,7 @@ void RimStimPlanFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* ch
{
if (fracture->fractureTemplate() == this)
{
fracture->stimPlanTimeIndexToPlot = m_activeTimeStepIndex;
fracture->clearDisplayGeometryCache();
fracture->stimPlanTimeIndexToPlot = m_activeTimeStepIndex;
}
}
proj->createDisplayModelAndRedrawAllViews();
@ -138,19 +137,8 @@ void RimStimPlanFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* ch
if (proj)
{
//Regenerate geometry
std::vector<RimFracture*> fractures;
proj->descendantsIncludingThisOfType(fractures);
for (RimFracture* fracture : fractures)
{
if (fracture->fractureTemplate() == this)
{
fracture->clearDisplayGeometryCache();
}
}
proj->createDisplayModelAndRedrawAllViews();
}
proj->createDisplayModelAndRedrawAllViews();
}
}

View File

@ -163,7 +163,6 @@ void RimWellPathFracture::defineUiOrdering(QString uiConfigName, caf::PdmUiOrder
RimFracture::defineUiOrdering(uiConfigName, uiOrdering);
uiOrdering.add(nameField());
uiOrdering.add(&showPolygonFractureOutline);
caf::PdmUiGroup* locationGroup = uiOrdering.addNewGroup("Location / Orientation");
locationGroup->add(&m_measuredDepth);

View File

@ -265,16 +265,6 @@ void RimEclipseView::updateScaleTransform()
this->scaleTransform()->setLocalTransform(scale);
m_simWellsPartManager->setScaleTransform(this->scaleTransform());
#ifdef USE_PROTOTYPE_FEATURE_FRACTURES
// Regenerate fracture geometry
std::vector<RimFracture*> fractures;
this->descendantsIncludingThisOfType(fractures);
for (RimFracture* fracture : fractures)
{
fracture->clearDisplayGeometryCache();
}
#endif // USE_PROTOTYPE_FEATURE_FRACTURES
if (m_viewer) m_viewer->updateCachedValuesInScene();
}
@ -476,7 +466,7 @@ void RimEclipseView::createDisplayModel()
addWellPathsToModel(m_wellPathPipeVizModel.p(), currentActiveCellInfo()->geometryBoundingBox());
#ifdef USE_PROTOTYPE_FEATURE_FRACTURES
wellPathCollection()->appendStaticFracturePartsToModel(m_wellPathPipeVizModel.p(), this);
wellPathCollection()->appendStaticFracturePartsToModel(m_wellPathPipeVizModel.p(), *this);
#endif // USE_PROTOTYPE_FEATURE_FRACTURES
m_wellPathPipeVizModel->updateBoundingBoxesRecursive();
m_viewer->addStaticModelOnce(m_wellPathPipeVizModel.p());
@ -732,7 +722,7 @@ void RimEclipseView::updateCurrentTimeStep()
}
}
f->fracturePartManager()->appendGeometryPartsToModel(simWellFracturesModelBasicList.p(), this);
f->fracturePartManager()->appendGeometryPartsToModel(simWellFracturesModelBasicList.p(), *this);
}
simWellFracturesModelBasicList->updateBoundingBoxesRecursive();

View File

@ -27,7 +27,6 @@
#include "RimProject.h"
#include "RimStimPlanFractureTemplate.h"
#include "cafPdmUiDoubleSliderEditor.h"
#include "cafPdmUiItem.h"
#include "cafPdmUiTreeOrdering.h"
#include "cafSelectionManagerTools.h"
@ -54,8 +53,6 @@ RimStimPlanColors::RimStimPlanColors()
CAF_PDM_InitObject("StimPlan Colors", ":/FractureSymbol16x16.png", "", "");
CAF_PDM_InitField(&m_resultNameAndUnit, "ResultName", QString(""), "StimPlan Result Variable", "", "", "");
CAF_PDM_InitField(&m_opacityLevel, "OpacityLevel", 1.0f, "Transparency", "", "", "");
m_opacityLevel.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName());
CAF_PDM_InitField(&m_defaultColor, "DefaultColor", cvf::Color3f(cvf::Color3::BROWN), "Default Color", "", "", "");
@ -223,14 +220,6 @@ QString RimStimPlanColors::unit() const
return RimStimPlanColors::toUnit(m_resultNameAndUnit());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
float RimStimPlanColors::opacityLevel() const
{
return m_opacityLevel();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -352,24 +341,6 @@ void RimStimPlanColors::defineUiOrdering(QString uiConfigName, caf::PdmUiOrderin
uiOrdering.skipRemainingFields(true);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimStimPlanColors::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute)
{
if (field == &m_opacityLevel)
{
caf::PdmUiDoubleSliderEditorAttribute* myAttr = dynamic_cast<caf::PdmUiDoubleSliderEditorAttribute*>(attribute);
if (myAttr)
{
myAttr->m_minimum = 0.0;
myAttr->m_maximum = 1.0;
myAttr->m_decimals = 2;
myAttr->m_sliderTickCount = 100;
}
}
}
//--------------------------------------------------------------------------------------------------
/// Internal methods

View File

@ -52,7 +52,6 @@ public:
QString resultName() const;
void setDefaultResultNameForStimPlan();
QString unit() const;
float opacityLevel() const;
cvf::Color3f defaultColor() const;
void loadDataAndUpdate();
@ -65,7 +64,6 @@ protected:
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "") override;
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override;
private:
RimFractureTemplateCollection* fractureTemplateCollection() const;
@ -74,7 +72,6 @@ private:
static QString toUnit(const QString& resultNameAndUnit);
private:
caf::PdmField<float> m_opacityLevel;
caf::PdmField<cvf::Color3f> m_defaultColor;
caf::PdmField<QString> m_resultNameAndUnit;
caf::PdmChildArrayField<RimLegendConfig*> m_legendConfigurations;

View File

@ -437,7 +437,7 @@ void RimWellPathCollection::appendStaticGeometryPartsToModel(cvf::ModelBasicList
//--------------------------------------------------------------------------------------------------
#ifdef USE_PROTOTYPE_FEATURE_FRACTURES
void RimWellPathCollection::appendStaticFracturePartsToModel(cvf::ModelBasicList* model,
const RimEclipseView* eclView)
const RimEclipseView& eclView)
{
if (!this->isActive()) return;
if (this->wellPathVisibility() == RimWellPathCollection::FORCE_ALL_OFF) return;

View File

@ -113,7 +113,7 @@ public:
#ifdef USE_PROTOTYPE_FEATURE_FRACTURES
void appendStaticFracturePartsToModel(cvf::ModelBasicList* model,
const RimEclipseView* eclView);
const RimEclipseView& eclView);
#endif // USE_PROTOTYPE_FEATURE_FRACTURES
void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model,