This commit is contained in:
Magne Sjaastad 2018-06-25 08:24:47 +02:00
parent 1575a6564a
commit c79b120031

View File

@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@ -65,9 +65,8 @@
#include <cmath>
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RivWellFracturePartMgr::RivWellFracturePartMgr(RimFracture* fracture)
: m_rimFracture(fracture)
@ -75,15 +74,12 @@ RivWellFracturePartMgr::RivWellFracturePartMgr(RimFracture* fracture)
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RivWellFracturePartMgr::~RivWellFracturePartMgr()
{
}
RivWellFracturePartMgr::~RivWellFracturePartMgr() {}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RivWellFracturePartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* model, const RimEclipseView& eclView)
{
@ -93,8 +89,9 @@ void RivWellFracturePartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* mod
double characteristicCellSize = eclView.ownerCase()->characteristicCellSize();
cvf::Collection<cvf::Part> parts;
RimStimPlanFractureTemplate* stimPlanFracTemplate = dynamic_cast<RimStimPlanFractureTemplate*>(m_rimFracture->fractureTemplate());
cvf::Collection<cvf::Part> parts;
RimStimPlanFractureTemplate* stimPlanFracTemplate =
dynamic_cast<RimStimPlanFractureTemplate*>(m_rimFracture->fractureTemplate());
if (stimPlanFracTemplate)
{
@ -115,7 +112,7 @@ void RivWellFracturePartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* mod
if (part.notNull()) parts.push_back(part.p());
}
}
else
else
{
auto part = createEllipseSurfacePart(eclView);
if (part.notNull()) parts.push_back(part.p());
@ -138,7 +135,6 @@ void RivWellFracturePartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* mod
}
}
// Make sure the distance is slightly smaller than the pipe radius to make the pipe is visible through the fracture
distanceToCenterLine *= 0.1;
@ -149,7 +145,8 @@ void RivWellFracturePartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* mod
auto fractureMatrix = m_rimFracture->transformMatrix();
if (m_rimFracture->fractureTemplate() && m_rimFracture->fractureTemplate()->orientationType() == RimFractureTemplate::ALONG_WELL_PATH)
if (m_rimFracture->fractureTemplate() &&
m_rimFracture->fractureTemplate()->orientationType() == RimFractureTemplate::ALONG_WELL_PATH)
{
cvf::Vec3d partTranslation = distanceToCenterLine * cvf::Vec3d(fractureMatrix.col(2));
@ -183,7 +180,8 @@ void RivWellFracturePartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* mod
cvf::Vec3d partTranslation = scaleFactor * cvf::Vec3d(fractureMatrix.col(2));
RivWellFracturePartMgr::addPartAtPositiveAndNegativeTranslation(model, maskOfFractureAreasOutsideGrid.p(), partTranslation);
RivWellFracturePartMgr::addPartAtPositiveAndNegativeTranslation(
model, maskOfFractureAreasOutsideGrid.p(), partTranslation);
}
}
@ -196,7 +194,8 @@ void RivWellFracturePartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* mod
if (containmentMask.notNull())
{
double scaleFactor = 0.03;
if (m_rimFracture->fractureTemplate() && m_rimFracture->fractureTemplate()->orientationType() == RimFractureTemplate::ALONG_WELL_PATH)
if (m_rimFracture->fractureTemplate() &&
m_rimFracture->fractureTemplate()->orientationType() == RimFractureTemplate::ALONG_WELL_PATH)
{
scaleFactor = 2 * distanceToCenterLine;
}
@ -212,7 +211,7 @@ void RivWellFracturePartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* mod
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
const QString RivWellFracturePartMgr::resultInfoText(const RimEclipseView& activeView, cvf::Vec3d domainIntersectionPoint) const
{
@ -220,18 +219,18 @@ const QString RivWellFracturePartMgr::resultInfoText(const RimEclipseView& activ
if (m_rimFracture.isNull()) return text;
RimEllipseFractureTemplate* ellipseFractureTemplate = dynamic_cast<RimEllipseFractureTemplate*>(m_rimFracture->fractureTemplate());
RimStimPlanFractureTemplate* stimPlanTemplate = dynamic_cast<RimStimPlanFractureTemplate*>(m_rimFracture->fractureTemplate());
auto* ellipseFractureTemplate = dynamic_cast<RimEllipseFractureTemplate*>(m_rimFracture->fractureTemplate());
auto* stimPlanTemplate = dynamic_cast<RimStimPlanFractureTemplate*>(m_rimFracture->fractureTemplate());
if (ellipseFractureTemplate)
{
text.append("Result value: CONDUCTIVITY ");
text.append(QString::number(ellipseFractureTemplate->conductivity()) + "\n");
}
else if (stimPlanTemplate)
{
const RigFractureCell* cell = getFractureCellAtDomainCoord(domainIntersectionPoint);
RimStimPlanColors* stimPlanColors = activeView.fractureColors();
const RigFractureCell* cell = getFractureCellAtDomainCoord(domainIntersectionPoint);
RimStimPlanColors* stimPlanColors = activeView.fractureColors();
QString resultNameFromColors = activeView.fractureColors()->uiResultName();
QString resultUnitFromColors = activeView.fractureColors()->unit();
@ -241,8 +240,8 @@ const QString RivWellFracturePartMgr::resultInfoText(const RimEclipseView& activ
QString resultValueText = QString("%1").arg(resultValue);
QString iText = cell ? QString::number(cell->getI()) : "-";
QString jText = cell ? QString::number(cell->getJ()) : "-";
QString iText = cell ? QString::number(cell->getI()) : "-";
QString jText = cell ? QString::number(cell->getJ()) : "-";
// Conductivity
text.append("Result value: ");
@ -260,29 +259,29 @@ const QString RivWellFracturePartMgr::resultInfoText(const RimEclipseView& activ
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
const RigFractureCell* RivWellFracturePartMgr::getFractureCellAtDomainCoord(cvf::Vec3d domainCoord) const
{
if (!m_rimFracture) return nullptr;
cvf::Mat4d toFractureXf = m_rimFracture->transformMatrix().getInverted();
cvf::Mat4d toFractureXf = m_rimFracture->transformMatrix().getInverted();
cvf::Vec3d fractureCoord = domainCoord.getTransformedPoint(toFractureXf);
const RimStimPlanFractureTemplate* stimPlanTempl = dynamic_cast<RimStimPlanFractureTemplate*>(m_rimFracture->fractureTemplate());
auto* stimPlanTempl = dynamic_cast<RimStimPlanFractureTemplate*>(m_rimFracture->fractureTemplate());
if (!stimPlanTempl) return nullptr;
const RigFractureGrid* grid = stimPlanTempl->fractureGrid();
size_t cellI = cvf::UNDEFINED_SIZE_T;
size_t cellJ = cvf::UNDEFINED_SIZE_T;
const std::vector<RigFractureCell>& cells = grid->fractureCells();
const RigFractureGrid* grid = stimPlanTempl->fractureGrid();
size_t cellI = cvf::UNDEFINED_SIZE_T;
size_t cellJ = cvf::UNDEFINED_SIZE_T;
const std::vector<RigFractureCell>& cells = grid->fractureCells();
for (size_t i = 0; i < grid->iCellCount(); i++)
{
const RigFractureCell& cell = cells[i * grid->jCellCount()];
const RigFractureCell& cell = cells[i * grid->jCellCount()];
std::vector<cvf::Vec3d> polygon = cell.getPolygon();
double xmin = polygon[0].x();
double xmax = polygon[2].x();
double xmin = polygon[0].x();
double xmax = polygon[2].x();
if (fractureCoord.x() >= xmin && fractureCoord.x() <= xmax)
{
cellI = cell.getI();
@ -292,10 +291,10 @@ const RigFractureCell* RivWellFracturePartMgr::getFractureCellAtDomainCoord(cvf:
for (size_t j = 0; j < grid->jCellCount(); j++)
{
const RigFractureCell& cell = cells[j];
const RigFractureCell& cell = cells[j];
std::vector<cvf::Vec3d> polygon = cell.getPolygon();
double ymin = polygon[2].y();
double ymax = polygon[0].y();
double ymin = polygon[2].y();
double ymax = polygon[0].y();
if (fractureCoord.y() >= ymin && fractureCoord.y() <= ymax)
{
cellJ = cell.getJ();
@ -311,7 +310,7 @@ const RigFractureCell* RivWellFracturePartMgr::getFractureCellAtDomainCoord(cvf:
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::Part> RivWellFracturePartMgr::createEllipseSurfacePart(const RimEclipseView& activeView)
{
@ -321,12 +320,13 @@ cvf::ref<cvf::Part> RivWellFracturePartMgr::createEllipseSurfacePart(const RimEc
if (m_rimFracture)
{
std::vector<cvf::Vec3f> nodeCoords;
std::vector<cvf::uint> triangleIndices;
std::vector<cvf::uint> triangleIndices;
m_rimFracture->fractureTemplate()->fractureTriangleGeometry(&nodeCoords, &triangleIndices);
cvf::Mat4d fractureXf = m_rimFracture->transformMatrix();
std::vector<cvf::Vec3f> nodeDisplayCoords = transformToFractureDisplayCoords(nodeCoords, fractureXf, *displayCoordTransform);
cvf::Mat4d fractureXf = m_rimFracture->transformMatrix();
std::vector<cvf::Vec3f> nodeDisplayCoords =
transformToFractureDisplayCoords(nodeCoords, fractureXf, *displayCoordTransform);
if (triangleIndices.empty() || nodeDisplayCoords.empty())
{
@ -335,38 +335,39 @@ cvf::ref<cvf::Part> RivWellFracturePartMgr::createEllipseSurfacePart(const RimEc
cvf::ref<cvf::DrawableGeo> geo = buildDrawableGeoFromTriangles(triangleIndices, nodeDisplayCoords);
CVF_ASSERT(geo.notNull());
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.fractureColors()->defaultColor());
RimRegularLegendConfig* legendConfig = nullptr;
if (activeView.fractureColors() && activeView.fractureColors()->isChecked())
{
legendConfig = activeView.fractureColors()->activeLegend();
}
if (legendConfig && legendConfig->scalarMapper())
{
RimRegularLegendConfig* legendConfig = nullptr;
if (activeView.fractureColors() && activeView.fractureColors()->isChecked())
{
legendConfig = activeView.fractureColors()->activeLegend();
}
if (legendConfig && legendConfig->scalarMapper())
{
cvf::Color3ub resultColor = cvf::Color3ub(RiaColorTables::undefinedCellColor());
if (activeView.fractureColors()->uiResultName() == RiaDefines::conductivityResultName())
{
RimEllipseFractureTemplate* ellipseFractureTemplate = dynamic_cast<RimEllipseFractureTemplate*>(m_rimFracture->fractureTemplate());
RimEllipseFractureTemplate* ellipseFractureTemplate =
dynamic_cast<RimEllipseFractureTemplate*>(m_rimFracture->fractureTemplate());
if (ellipseFractureTemplate)
{
double conductivity = ellipseFractureTemplate->conductivity();
resultColor = legendConfig->scalarMapper()->mapToColor(conductivity);
resultColor = legendConfig->scalarMapper()->mapToColor(conductivity);
}
}
fractureColor.set(cvf::Color3f::fromByteColor(resultColor.r(), resultColor.g(), resultColor.b()));
}
fractureColor.set(cvf::Color3f::fromByteColor(resultColor.r(), resultColor.g(), resultColor.b()));
}
caf::SurfaceEffectGenerator surfaceGen(fractureColor, caf::PO_1);
cvf::ref<cvf::Effect> eff = surfaceGen.generateCachedEffect();
cvf::ref<cvf::Effect> eff = surfaceGen.generateCachedEffect();
surfacePart->setEffect(eff.p());
return surfacePart;
@ -375,23 +376,23 @@ cvf::ref<cvf::Part> RivWellFracturePartMgr::createEllipseSurfacePart(const RimEc
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::Part> RivWellFracturePartMgr::createStimPlanColorInterpolatedSurfacePart(const RimEclipseView& activeView)
{
CVF_ASSERT(m_rimFracture);
RimStimPlanFractureTemplate* stimPlanFracTemplate = dynamic_cast<RimStimPlanFractureTemplate*>(m_rimFracture->fractureTemplate());
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
// 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;
std::vector<cvf::uint> triangleIndices;
stimPlanFracTemplate->fractureTriangleGeometry(&nodeCoords, &triangleIndices);
@ -400,7 +401,7 @@ cvf::ref<cvf::Part> RivWellFracturePartMgr::createStimPlanColorInterpolatedSurfa
return nullptr;
}
cvf::Mat4d fractureXf = m_rimFracture->transformMatrix();
cvf::Mat4d fractureXf = m_rimFracture->transformMatrix();
std::vector<cvf::Vec3f> nodeDisplayCoords = transformToFractureDisplayCoords(nodeCoords, fractureXf, *displayCoordTransform);
RimRegularLegendConfig* legendConfig = nullptr;
@ -416,8 +417,11 @@ cvf::ref<cvf::Part> RivWellFracturePartMgr::createStimPlanColorInterpolatedSurfa
// Since some time steps don't have result vales, we initialize the array to well known values before populating it
std::vector<double> perNodeResultValues(nodeDisplayCoords.size(), HUGE_VAL);
{
size_t idx = 0;
const std::vector<std::vector<double> > dataToPlot = stimPlanFracTemplate->resultValues(activeView.fractureColors()->uiResultName(), activeView.fractureColors()->unit(), stimPlanFracTemplate->activeTimeStepIndex());
size_t idx = 0;
const std::vector<std::vector<double>> dataToPlot =
stimPlanFracTemplate->resultValues(activeView.fractureColors()->uiResultName(),
activeView.fractureColors()->unit(),
stimPlanFracTemplate->activeTimeStepIndex());
for (const std::vector<double>& dataAtY : dataToPlot)
{
for (double val : dataAtY)
@ -455,8 +459,8 @@ cvf::ref<cvf::Part> RivWellFracturePartMgr::createStimPlanColorInterpolatedSurfa
return nullptr;
}
cvf::ref<cvf::DrawableGeo> geo = buildDrawableGeoFromTriangles(triIndicesToInclude, nodeDisplayCoords);
const cvf::ScalarMapper* scalarMapper = legendConfig->scalarMapper();
cvf::ref<cvf::DrawableGeo> geo = buildDrawableGeoFromTriangles(triIndicesToInclude, nodeDisplayCoords);
const cvf::ScalarMapper* scalarMapper = legendConfig->scalarMapper();
CVF_ASSERT(scalarMapper);
cvf::ref<cvf::Vec2fArray> textureCoords = new cvf::Vec2fArray(nodeDisplayCoords.size());
@ -466,16 +470,17 @@ cvf::ref<cvf::Part> RivWellFracturePartMgr::createStimPlanColorInterpolatedSurfa
const double val = perNodeResultValues[i];
if (val < HUGE_VAL && val == val)
{
textureCoords->set(i, scalarMapper->mapToTextureCoord(val));
textureCoords->set(i, scalarMapper->mapToTextureCoord(val));
}
}
geo->setTextureCoordArray(textureCoords.p());
cvf::ref<cvf::Part> surfacePart = createScalarMapperPart(geo.p(), scalarMapper, m_rimFracture, activeView.isLightingDisabled());
cvf::ref<cvf::Part> surfacePart =
createScalarMapperPart(geo.p(), scalarMapper, m_rimFracture, activeView.isLightingDisabled());
return surfacePart;
}
else
else
{
// No result is mapped, show the entire StimPlan surface with default color
@ -485,11 +490,12 @@ cvf::ref<cvf::Part> RivWellFracturePartMgr::createStimPlanColorInterpolatedSurfa
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::Part> RivWellFracturePartMgr::createSingleColorSurfacePart(const std::vector<cvf::uint>& triangleIndices, const std::vector<cvf::Vec3f>& nodeCoords, const cvf::Color3f& color)
cvf::ref<cvf::Part> RivWellFracturePartMgr::createSingleColorSurfacePart(const std::vector<cvf::uint>& triangleIndices,
const std::vector<cvf::Vec3f>& nodeCoords,
const cvf::Color3f& color)
{
cvf::ref<cvf::DrawableGeo> geo = buildDrawableGeoFromTriangles(triangleIndices, nodeCoords);
@ -498,21 +504,22 @@ cvf::ref<cvf::Part> RivWellFracturePartMgr::createSingleColorSurfacePart(const s
surfacePart->setPriority(RivPartPriority::PartType::BaseLevel);
surfacePart->setSourceInfo(new RivObjectSourceInfo(m_rimFracture));
cvf::Color4f fractureColor = cvf::Color4f(color);
cvf::Color4f fractureColor = cvf::Color4f(color);
caf::SurfaceEffectGenerator surfaceGen(fractureColor, caf::PO_1);
cvf::ref<cvf::Effect> eff = surfaceGen.generateCachedEffect();
cvf::ref<cvf::Effect> eff = surfaceGen.generateCachedEffect();
surfacePart->setEffect(eff.p());
return surfacePart;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::Part> RivWellFracturePartMgr::createStimPlanElementColorSurfacePart(const RimEclipseView& activeView)
{
CVF_ASSERT(m_rimFracture);
RimStimPlanFractureTemplate* stimPlanFracTemplate = dynamic_cast<RimStimPlanFractureTemplate*>(m_rimFracture->fractureTemplate());
RimStimPlanFractureTemplate* stimPlanFracTemplate =
dynamic_cast<RimStimPlanFractureTemplate*>(m_rimFracture->fractureTemplate());
CVF_ASSERT(stimPlanFracTemplate);
if (!stimPlanFracTemplate->fractureGrid()) return nullptr;
@ -520,16 +527,15 @@ cvf::ref<cvf::Part> RivWellFracturePartMgr::createStimPlanElementColorSurfacePar
auto displayCoordTransform = activeView.displayCoordTransform();
if (displayCoordTransform.isNull()) return nullptr;
std::vector<cvf::Vec3f> stimPlanMeshVertices;
std::vector<cvf::Vec3f> stimPlanMeshVertices;
cvf::ref<cvf::Vec2fArray> textureCoords = new cvf::Vec2fArray;
const cvf::ScalarMapper* scalarMapper = nullptr;
const cvf::ScalarMapper* scalarMapper = nullptr;
{
std::vector<RigFractureCell> stimPlanCells = stimPlanFracTemplate->fractureGrid()->fractureCells();
RimRegularLegendConfig* legendConfig = nullptr;
if (activeView.fractureColors() &&
activeView.fractureColors()->isChecked() &&
if (activeView.fractureColors() && activeView.fractureColors()->isChecked() &&
activeView.fractureColors()->activeLegend())
{
legendConfig = activeView.fractureColors()->activeLegend();
@ -539,9 +545,8 @@ cvf::ref<cvf::Part> RivWellFracturePartMgr::createStimPlanElementColorSurfacePar
QString resultNameFromColors = activeView.fractureColors()->uiResultName();
QString resultUnitFromColors = activeView.fractureColors()->unit();
std::vector<double> prCellResults = stimPlanFracTemplate->fractureGridResults(resultNameFromColors,
resultUnitFromColors,
stimPlanFracTemplate->activeTimeStepIndex());
std::vector<double> prCellResults = stimPlanFracTemplate->fractureGridResults(
resultNameFromColors, resultUnitFromColors, stimPlanFracTemplate->activeTimeStepIndex());
textureCoords->reserve(prCellResults.size() * 4);
@ -549,12 +554,12 @@ cvf::ref<cvf::Part> RivWellFracturePartMgr::createStimPlanElementColorSurfacePar
{
if (prCellResults[cIdx] > 1e-7)
{
const RigFractureCell& stimPlanCell = stimPlanCells[cIdx];
const RigFractureCell& stimPlanCell = stimPlanCells[cIdx];
std::vector<cvf::Vec3d> stimPlanCellPolygon = stimPlanCell.getPolygon();
for (const cvf::Vec3d& cellCorner : stimPlanCellPolygon)
{
stimPlanMeshVertices.push_back(static_cast<cvf::Vec3f>(cellCorner));
textureCoords->add(scalarMapper->mapToTextureCoord(prCellResults[cIdx]));
textureCoords->add(scalarMapper->mapToTextureCoord(prCellResults[cIdx]));
}
}
}
@ -578,7 +583,7 @@ cvf::ref<cvf::Part> RivWellFracturePartMgr::createStimPlanElementColorSurfacePar
return nullptr;
}
cvf::Mat4d fractureXf = m_rimFracture->transformMatrix();
cvf::Mat4d fractureXf = m_rimFracture->transformMatrix();
std::vector<cvf::Vec3f> nodeDisplayCoords =
transformToFractureDisplayCoords(stimPlanMeshVertices, fractureXf, *displayCoordTransform);
@ -607,11 +612,12 @@ cvf::ref<cvf::Part> RivWellFracturePartMgr::createStimPlanElementColorSurfacePar
cvf::ref<cvf::DrawableGeo> geo = buildDrawableGeoFromTriangles(triIndicesToInclude, nodeDisplayCoords);
geo->setTextureCoordArray(textureCoords.p());
cvf::ref<cvf::Part> surfacePart = createScalarMapperPart(geo.p(), scalarMapper, m_rimFracture, activeView.isLightingDisabled());
cvf::ref<cvf::Part> surfacePart =
createScalarMapperPart(geo.p(), scalarMapper, m_rimFracture, activeView.isLightingDisabled());
return surfacePart;
}
else
else
{
// No result is mapped, show the entire StimPlan surface with default color
@ -620,16 +626,16 @@ cvf::ref<cvf::Part> RivWellFracturePartMgr::createStimPlanElementColorSurfacePar
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::Part> RivWellFracturePartMgr::createContainmentMaskPart(const RimEclipseView& activeView)
{
std::vector<cvf::Vec3d> borderPolygonLocalCS = fractureBorderPolygon();
cvf::Mat4d frMx = m_rimFracture->transformMatrix();
std::vector<cvf::Vec3d> borderPolygonLocalCS = fractureBorderPolygon();
cvf::Mat4d frMx = m_rimFracture->transformMatrix();
cvf::BoundingBox frBBox;
cvf::BoundingBox frBBox;
std::vector<cvf::Vec3d> borderPolygonLocalCsd;
for (const auto& pv: borderPolygonLocalCS)
for (const auto& pv : borderPolygonLocalCS)
{
cvf::Vec3d pvd(pv);
borderPolygonLocalCsd.push_back(pvd);
@ -652,12 +658,12 @@ cvf::ref<cvf::Part> RivWellFracturePartMgr::createContainmentMaskPart(const RimE
{
if (!m_rimFracture->isEclipseCellWithinContainment(activeView.mainGrid(), containedFractureCells, resCellIdx))
{
// Calculate Eclipse cell intersection with fracture plane
// Calculate Eclipse cell intersection with fracture plane
std::array<cvf::Vec3d,8> corners;
activeView.mainGrid()->cellCornerVertices(resCellIdx, corners.data());
std::array<cvf::Vec3d, 8> corners;
activeView.mainGrid()->cellCornerVertices(resCellIdx, corners.data());
std::vector<std::vector<cvf::Vec3d> > eclCellPolygons;
std::vector<std::vector<cvf::Vec3d>> eclCellPolygons;
bool hasIntersection = RigHexIntersectionTools::planeHexIntersectionPolygons(corners, frMx, eclCellPolygons);
if (!hasIntersection || eclCellPolygons.empty()) continue;
@ -665,9 +671,9 @@ cvf::ref<cvf::Part> RivWellFracturePartMgr::createContainmentMaskPart(const RimE
// Transform eclCell - plane intersection onto fracture
cvf::Mat4d invertedTransformMatrix = frMx.getInverted();
for ( std::vector<cvf::Vec3d>& eclCellPolygon : eclCellPolygons )
for (std::vector<cvf::Vec3d>& eclCellPolygon : eclCellPolygons)
{
for ( cvf::Vec3d& v : eclCellPolygon )
for (cvf::Vec3d& v : eclCellPolygon)
{
v.transformPoint(invertedTransformMatrix);
}
@ -678,11 +684,11 @@ cvf::ref<cvf::Part> RivWellFracturePartMgr::createContainmentMaskPart(const RimE
{
// Clip Eclipse cell polygon with fracture border
std::vector< std::vector<cvf::Vec3d> > clippedPolygons = RigCellGeometryTools::intersectPolygons(eclCellPolygon,
borderPolygonLocalCsd);
std::vector<std::vector<cvf::Vec3d>> clippedPolygons =
RigCellGeometryTools::intersectPolygons(eclCellPolygon, borderPolygonLocalCsd);
for (auto& clippedPolygon : clippedPolygons)
{
for (auto& v: clippedPolygon)
for (auto& v : clippedPolygon)
{
v.transformPoint(frMx);
}
@ -697,22 +703,23 @@ cvf::ref<cvf::Part> RivWellFracturePartMgr::createContainmentMaskPart(const RimE
cvf::Vec3dArray cvfNodes(clippedPolygon);
tess.setGlobalNodeArray(cvfNodes);
std::vector<size_t> polyIndexes;
for (size_t idx = 0; idx < clippedPolygon.size(); ++idx) polyIndexes.push_back(idx);
for (size_t idx = 0; idx < clippedPolygon.size(); ++idx)
polyIndexes.push_back(idx);
tess.setPolygonIndices(polyIndexes);
std::vector<size_t> triangleIndices;
tess.calculateTriangles(&triangleIndices);
for (size_t idx: triangleIndices)
for (size_t idx : triangleIndices)
{
maskTriangles.push_back( cvf::Vec3f( displCoordTrans->transformToDisplayCoord(clippedPolygon[idx]) ) );
maskTriangles.push_back(cvf::Vec3f(displCoordTrans->transformToDisplayCoord(clippedPolygon[idx])));
}
}
}
}
}
if ( maskTriangles.size() >= 3 )
if (maskTriangles.size() >= 3)
{
cvf::ref<cvf::DrawableGeo> maskTriangleGeo = new cvf::DrawableGeo;
maskTriangleGeo->setVertexArray(new cvf::Vec3fArray(maskTriangles));
@ -729,7 +736,7 @@ cvf::ref<cvf::Part> RivWellFracturePartMgr::createContainmentMaskPart(const RimE
cvf::Color4f maskColor = cvf::Color4f(cvf::Color3f(cvf::Color3::GRAY));
caf::SurfaceEffectGenerator surfaceGen(maskColor, caf::PO_NONE);
cvf::ref<cvf::Effect> eff = surfaceGen.generateCachedEffect();
cvf::ref<cvf::Effect> eff = surfaceGen.generateCachedEffect();
containmentMaskPart->setEffect(eff.p());
return containmentMaskPart;
@ -753,7 +760,7 @@ cvf::ref<cvf::Part> RivWellFracturePartMgr::createMaskOfFractureOutsideGrid(cons
{
std::vector<cvf::Vec3d> borderOfFractureCellPolygonLocalCsd;
cvf::BoundingBox frBBox;
for (const auto& pv : visibleFracturePolygon)
{
cvf::Vec3d pvd(pv);
@ -810,7 +817,7 @@ cvf::ref<cvf::Part> RivWellFracturePartMgr::createMaskOfFractureOutsideGrid(cons
if (!allPointsInsideGrid)
{
std::vector<std::vector<cvf::Vec3d> > allEclCellPolygons;
std::vector<std::vector<cvf::Vec3d>> allEclCellPolygons;
for (size_t resCellIdx : cellCandidates)
{
// Calculate Eclipse cell intersection with fracture plane
@ -898,18 +905,17 @@ cvf::ref<cvf::Part> RivWellFracturePartMgr::createMaskOfFractureOutsideGrid(cons
cvf::Color4f maskColor = cvf::Color4f(cvf::Color3f(cvf::Color3::GRAY));
caf::SurfaceEffectGenerator surfaceGen(maskColor, caf::PO_NONE);
cvf::ref<cvf::Effect> eff = surfaceGen.generateCachedEffect();
cvf::ref<cvf::Effect> eff = surfaceGen.generateCachedEffect();
containmentMaskPart->setEffect(eff.p());
return containmentMaskPart;
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RivWellFracturePartMgr::appendFracturePerforationLengthParts(const RimEclipseView& activeView, cvf::ModelBasicList* model)
{
@ -953,13 +959,14 @@ void RivWellFracturePartMgr::appendFracturePerforationLengthParts(const RimEclip
if (!displayCoords.empty())
{
cvf::ref<RivObjectSourceInfo> objectSourceInfo = new RivObjectSourceInfo(m_rimFracture);
double perforationRadius = wellPathRadius * 1.2;
cvf::Collection<cvf::Part> parts;
cvf::ref<RivObjectSourceInfo> objectSourceInfo = new RivObjectSourceInfo(m_rimFracture);
double perforationRadius = wellPathRadius * 1.2;
cvf::Collection<cvf::Part> parts;
RivPipeGeometryGenerator geoGenerator;
geoGenerator.cylinderWithCenterLineParts(&parts, displayCoords, RiaColorTables::perforationLengthColor(), perforationRadius);
geoGenerator.cylinderWithCenterLineParts(
&parts, displayCoords, RiaColorTables::perforationLengthColor(), perforationRadius);
for (auto part : parts)
{
part->setSourceInfo(objectSourceInfo.p());
@ -969,13 +976,14 @@ void RivWellFracturePartMgr::appendFracturePerforationLengthParts(const RimEclip
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::Part> RivWellFracturePartMgr::createStimPlanMeshPart(const RimEclipseView& activeView)
{
if (!m_rimFracture->fractureTemplate()) return nullptr;
RimStimPlanFractureTemplate* stimPlanFracTemplate = dynamic_cast<RimStimPlanFractureTemplate*>(m_rimFracture->fractureTemplate());
RimStimPlanFractureTemplate* stimPlanFracTemplate =
dynamic_cast<RimStimPlanFractureTemplate*>(m_rimFracture->fractureTemplate());
if (!stimPlanFracTemplate) return nullptr;
cvf::ref<cvf::DrawableGeo> stimPlanMeshGeo = createStimPlanMeshDrawable(stimPlanFracTemplate, activeView);
@ -1000,9 +1008,10 @@ cvf::ref<cvf::Part> RivWellFracturePartMgr::createStimPlanMeshPart(const RimEcli
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::DrawableGeo> RivWellFracturePartMgr::createStimPlanMeshDrawable(RimStimPlanFractureTemplate* stimPlanFracTemplate, const RimEclipseView& activeView)
cvf::ref<cvf::DrawableGeo> RivWellFracturePartMgr::createStimPlanMeshDrawable(RimStimPlanFractureTemplate* stimPlanFracTemplate,
const RimEclipseView& activeView)
{
if (!stimPlanFracTemplate->fractureGrid()) return nullptr;
@ -1010,21 +1019,20 @@ cvf::ref<cvf::DrawableGeo> RivWellFracturePartMgr::createStimPlanMeshDrawable(Ri
if (displayCoordTransform.isNull()) return nullptr;
std::vector<RigFractureCell> stimPlanCells = stimPlanFracTemplate->fractureGrid()->fractureCells();
std::vector<cvf::Vec3f> stimPlanMeshVertices;
std::vector<cvf::Vec3f> stimPlanMeshVertices;
QString resultNameFromColors = activeView.fractureColors()->uiResultName();
QString resultUnitFromColors = activeView.fractureColors()->unit();
std::vector<double> prCellResults = stimPlanFracTemplate->fractureGridResults(resultNameFromColors,
resultUnitFromColors,
stimPlanFracTemplate->activeTimeStepIndex());
std::vector<double> prCellResults = stimPlanFracTemplate->fractureGridResults(
resultNameFromColors, resultUnitFromColors, stimPlanFracTemplate->activeTimeStepIndex());
m_visibleFracturePolygons.clear();
for ( size_t cIdx = 0; cIdx < stimPlanCells.size() ; ++cIdx)
for (size_t cIdx = 0; cIdx < stimPlanCells.size(); ++cIdx)
{
if (prCellResults[cIdx] > 1e-7)
{
const RigFractureCell& stimPlanCell = stimPlanCells[cIdx];
const RigFractureCell& stimPlanCell = stimPlanCells[cIdx];
std::vector<cvf::Vec3d> stimPlanCellPolygon = stimPlanCell.getPolygon();
for (const cvf::Vec3d& cellCorner : stimPlanCellPolygon)
{
@ -1039,10 +1047,9 @@ cvf::ref<cvf::DrawableGeo> RivWellFracturePartMgr::createStimPlanMeshDrawable(Ri
return nullptr;
}
cvf::Mat4d fractureXf = m_rimFracture->transformMatrix();
std::vector<cvf::Vec3f> stimPlanMeshVerticesDisplayCoords = transformToFractureDisplayCoords(stimPlanMeshVertices,
fractureXf,
*displayCoordTransform);
cvf::Mat4d fractureXf = m_rimFracture->transformMatrix();
std::vector<cvf::Vec3f> stimPlanMeshVerticesDisplayCoords =
transformToFractureDisplayCoords(stimPlanMeshVertices, fractureXf, *displayCoordTransform);
cvf::Vec3fArray* stimPlanMeshVertexList;
stimPlanMeshVertexList = new cvf::Vec3fArray;
@ -1060,7 +1067,7 @@ cvf::ref<cvf::DrawableGeo> RivWellFracturePartMgr::createStimPlanMeshDrawable(Ri
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::Part> RivWellFracturePartMgr::createScalarMapperPart(cvf::DrawableGeo* drawableGeo,
const cvf::ScalarMapper* scalarMapper,
@ -1082,7 +1089,7 @@ cvf::ref<cvf::Part> RivWellFracturePartMgr::createScalarMapperPart(cvf::Drawable
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
std::vector<cvf::Vec3d> RivWellFracturePartMgr::fractureBorderPolygon()
{
@ -1090,11 +1097,12 @@ std::vector<cvf::Vec3d> RivWellFracturePartMgr::fractureBorderPolygon()
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
std::vector<cvf::Vec3f> RivWellFracturePartMgr::transformToFractureDisplayCoords(const std::vector<cvf::Vec3f>& coordinatesVector,
cvf::Mat4d m,
const caf::DisplayCoordTransform& displayCoordTransform)
std::vector<cvf::Vec3f>
RivWellFracturePartMgr::transformToFractureDisplayCoords(const std::vector<cvf::Vec3f>& coordinatesVector,
cvf::Mat4d m,
const caf::DisplayCoordTransform& displayCoordTransform)
{
std::vector<cvf::Vec3f> polygonInDisplayCoords;
polygonInDisplayCoords.reserve(coordinatesVector.size());
@ -1111,16 +1119,17 @@ std::vector<cvf::Vec3f> RivWellFracturePartMgr::transformToFractureDisplayCoords
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
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);
cvf::ref<cvf::DrawableGeo> geo = new cvf::DrawableGeo;
cvf::ref<cvf::UIntArray> indices = new cvf::UIntArray(triangleIndices);
cvf::ref<cvf::UIntArray> indices = new cvf::UIntArray(triangleIndices);
cvf::ref<cvf::Vec3fArray> vertices = new cvf::Vec3fArray(nodeCoords);
geo->setVertexArray(vertices.p());
@ -1131,7 +1140,7 @@ cvf::ref<cvf::DrawableGeo> RivWellFracturePartMgr::buildDrawableGeoFromTriangles
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::Transform> RivWellFracturePartMgr::createLocalTransformFromTranslation(const cvf::Vec3d& translation)
{
@ -1144,9 +1153,11 @@ cvf::ref<cvf::Transform> RivWellFracturePartMgr::createLocalTransformFromTransla
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RivWellFracturePartMgr::addPartAtPositiveAndNegativeTranslation(cvf::ModelBasicList* model, cvf::Part* part, const cvf::Vec3d& translation)
void RivWellFracturePartMgr::addPartAtPositiveAndNegativeTranslation(cvf::ModelBasicList* model,
cvf::Part* part,
const cvf::Vec3d& translation)
{
{
cvf::ref<cvf::Transform> partTransform = RivWellFracturePartMgr::createLocalTransformFromTranslation(translation);
@ -1166,4 +1177,3 @@ void RivWellFracturePartMgr::addPartAtPositiveAndNegativeTranslation(cvf::ModelB
model->addPart(copy.p());
}
}