2017-01-04 01:10:02 -06:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// 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>
|
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2017-01-19 00:28:04 -06:00
|
|
|
#include "RivWellFracturePartMgr.h"
|
2017-01-04 01:10:02 -06:00
|
|
|
|
2017-02-20 02:31:24 -06:00
|
|
|
#include "RiaApplication.h"
|
|
|
|
|
2017-05-26 09:27:48 -05:00
|
|
|
#include "RigFractureGrid.h"
|
|
|
|
|
2017-01-06 03:26:57 -06:00
|
|
|
#include "RimEclipseView.h"
|
2017-01-04 01:10:02 -06:00
|
|
|
#include "RimEclipseWell.h"
|
|
|
|
#include "RimFracture.h"
|
2017-02-28 07:28:14 -06:00
|
|
|
#include "RimFractureTemplate.h"
|
2017-02-20 02:31:24 -06:00
|
|
|
#include "RimLegendConfig.h"
|
2017-05-30 04:52:19 -05:00
|
|
|
#include "RigFractureCell.h"
|
2017-02-20 02:31:24 -06:00
|
|
|
#include "RimStimPlanColors.h"
|
|
|
|
#include "RimStimPlanFractureTemplate.h"
|
2017-01-04 01:10:02 -06:00
|
|
|
|
2017-03-27 07:19:21 -05:00
|
|
|
#include "RivFaultGeometryGenerator.h"
|
2017-02-20 04:10:03 -06:00
|
|
|
#include "RivPartPriority.h"
|
2017-02-23 04:53:26 -06:00
|
|
|
#include "RivObjectSourceInfo.h"
|
2017-02-20 04:10:03 -06:00
|
|
|
|
2017-02-20 02:31:24 -06:00
|
|
|
#include "cafDisplayCoordTransform.h"
|
2017-01-04 01:10:02 -06:00
|
|
|
#include "cafEffectGenerator.h"
|
|
|
|
|
|
|
|
#include "cvfDrawableGeo.h"
|
|
|
|
#include "cvfModelBasicList.h"
|
|
|
|
#include "cvfPart.h"
|
|
|
|
#include "cvfPrimitiveSet.h"
|
|
|
|
#include "cvfPrimitiveSetIndexedUInt.h"
|
2017-02-14 03:29:25 -06:00
|
|
|
#include "cvfScalarMapperContinuousLinear.h"
|
2017-02-28 07:28:14 -06:00
|
|
|
#include "cvfRenderStateDepth.h"
|
2017-01-04 01:10:02 -06:00
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-01-19 00:28:04 -06:00
|
|
|
RivWellFracturePartMgr::RivWellFracturePartMgr(RimFracture* fracture)
|
|
|
|
: m_rimFracture(fracture)
|
2017-01-04 01:10:02 -06:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-01-19 00:28:04 -06:00
|
|
|
RivWellFracturePartMgr::~RivWellFracturePartMgr()
|
2017-01-04 01:10:02 -06:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-01-19 00:28:04 -06:00
|
|
|
void RivWellFracturePartMgr::updatePartGeometry(caf::DisplayCoordTransform* displayCoordTransform)
|
2017-01-04 01:10:02 -06:00
|
|
|
{
|
2017-01-19 00:28:04 -06:00
|
|
|
if (m_part.notNull()) return;
|
|
|
|
if (!displayCoordTransform) return;
|
2017-01-04 01:10:02 -06:00
|
|
|
|
2017-01-19 00:28:04 -06:00
|
|
|
if (m_rimFracture)
|
2017-01-04 01:10:02 -06:00
|
|
|
{
|
2017-06-12 05:45:09 -05:00
|
|
|
std::vector<cvf::Vec3f> nodeCoords;
|
|
|
|
std::vector<cvf::uint> triangleIndices;
|
|
|
|
m_rimFracture->triangleGeometry(&triangleIndices, &nodeCoords);
|
2017-01-06 03:26:57 -06:00
|
|
|
|
2017-01-19 00:28:04 -06:00
|
|
|
std::vector<cvf::Vec3f> displayCoords;
|
|
|
|
|
2017-02-03 03:14:02 -06:00
|
|
|
for (size_t i = 0; i < nodeCoords.size(); i++)
|
2017-01-19 00:28:04 -06:00
|
|
|
{
|
|
|
|
cvf::Vec3d nodeCoordsDouble = static_cast<cvf::Vec3d>(nodeCoords[i]);
|
|
|
|
cvf::Vec3d displayCoordsDouble = displayCoordTransform->transformToDisplayCoord(nodeCoordsDouble);
|
|
|
|
displayCoords.push_back(static_cast<cvf::Vec3f>(displayCoordsDouble));
|
|
|
|
}
|
2017-01-06 03:26:57 -06:00
|
|
|
|
2017-06-07 07:46:54 -05:00
|
|
|
if (triangleIndices.size() == 0 || displayCoords.size() == 0)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2017-01-06 03:26:57 -06:00
|
|
|
|
2017-06-07 07:46:54 -05:00
|
|
|
cvf::ref<cvf::DrawableGeo> geo = createGeo(triangleIndices, displayCoords);
|
|
|
|
CVF_ASSERT(geo.notNull());
|
|
|
|
|
2017-01-19 00:28:04 -06:00
|
|
|
m_part = new cvf::Part;
|
|
|
|
m_part->setDrawable(geo.p());
|
|
|
|
|
2017-02-23 03:15:56 -06:00
|
|
|
cvf::Color4f fractureColor = cvf::Color4f(cvf::Color3f(cvf::Color3::BROWN));
|
2017-01-19 00:28:04 -06:00
|
|
|
|
2017-02-23 03:15:56 -06:00
|
|
|
RimEclipseView* activeView = dynamic_cast<RimEclipseView*>(RiaApplication::instance()->activeReservoirView());
|
|
|
|
if (activeView)
|
|
|
|
{
|
2017-02-23 04:25:21 -06:00
|
|
|
fractureColor = cvf::Color4f(activeView->stimPlanColors->defaultColor());
|
2017-02-23 03:15:56 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
caf::SurfaceEffectGenerator surfaceGen(fractureColor, caf::PO_1);
|
|
|
|
cvf::ref<cvf::Effect> eff = surfaceGen.generateCachedEffect();
|
2017-01-19 00:28:04 -06:00
|
|
|
m_part->setEffect(eff.p());
|
2017-02-23 04:53:26 -06:00
|
|
|
|
|
|
|
m_part->setSourceInfo(new RivObjectSourceInfo(m_rimFracture));
|
2017-01-06 03:26:57 -06:00
|
|
|
}
|
2017-01-04 01:10:02 -06:00
|
|
|
}
|
|
|
|
|
2017-02-14 03:29:25 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RivWellFracturePartMgr::updatePartGeometryTexture(caf::DisplayCoordTransform* displayCoordTransform)
|
|
|
|
{
|
|
|
|
if (m_part.notNull()) return;
|
|
|
|
if (!displayCoordTransform) return;
|
|
|
|
|
|
|
|
if (m_rimFracture)
|
|
|
|
{
|
2017-02-20 02:31:24 -06:00
|
|
|
RimLegendConfig* legendConfig = nullptr;
|
|
|
|
RimEclipseView* activeView = dynamic_cast<RimEclipseView*>(RiaApplication::instance()->activeReservoirView());
|
2017-02-28 12:17:36 -06:00
|
|
|
if (activeView && activeView->stimPlanColors())
|
2017-02-20 02:31:24 -06:00
|
|
|
{
|
2017-02-28 12:17:36 -06:00
|
|
|
if (activeView->stimPlanColors()->isChecked())
|
2017-02-22 08:32:19 -06:00
|
|
|
{
|
2017-02-28 12:17:36 -06:00
|
|
|
legendConfig = activeView->stimPlanColors()->activeLegend();
|
2017-02-22 08:32:19 -06:00
|
|
|
}
|
2017-02-20 02:31:24 -06:00
|
|
|
}
|
|
|
|
|
2017-06-09 10:21:59 -05:00
|
|
|
RimFractureTemplate* fracTemplate = m_rimFracture->fractureTemplate();
|
2017-06-07 07:46:54 -05:00
|
|
|
RimStimPlanFractureTemplate* stimPlanFracTemplate = dynamic_cast<RimStimPlanFractureTemplate*>(fracTemplate);
|
|
|
|
if (!stimPlanFracTemplate)
|
2017-02-15 08:49:53 -06:00
|
|
|
{
|
2017-06-07 07:46:54 -05:00
|
|
|
return;
|
2017-02-15 08:49:53 -06:00
|
|
|
}
|
|
|
|
|
2017-06-12 05:45:09 -05:00
|
|
|
std::vector<cvf::Vec3f> nodeCoords;
|
|
|
|
std::vector<cvf::uint> triangleIndices;
|
2017-06-07 07:46:54 -05:00
|
|
|
|
2017-06-12 05:45:09 -05:00
|
|
|
m_rimFracture->triangleGeometry(&triangleIndices, &nodeCoords);
|
|
|
|
|
2017-02-14 03:29:25 -06:00
|
|
|
std::vector<cvf::Vec3f> displayCoords;
|
|
|
|
|
|
|
|
for (size_t i = 0; i < nodeCoords.size(); i++)
|
|
|
|
{
|
|
|
|
cvf::Vec3d nodeCoordsDouble = static_cast<cvf::Vec3d>(nodeCoords[i]);
|
|
|
|
cvf::Vec3d displayCoordsDouble = displayCoordTransform->transformToDisplayCoord(nodeCoordsDouble);
|
|
|
|
displayCoords.push_back(static_cast<cvf::Vec3f>(displayCoordsDouble));
|
|
|
|
}
|
|
|
|
|
2017-06-07 07:46:54 -05:00
|
|
|
if (triangleIndices.size() == 0 || displayCoords.size() == 0)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-02-14 03:29:25 -06:00
|
|
|
cvf::ref<cvf::DrawableGeo> geo = createGeo(triangleIndices, displayCoords);
|
2017-06-07 07:46:54 -05:00
|
|
|
CVF_ASSERT(geo.notNull());
|
2017-02-14 03:29:25 -06:00
|
|
|
|
|
|
|
m_part = new cvf::Part;
|
|
|
|
m_part->setDrawable(geo.p());
|
|
|
|
|
2017-02-28 07:28:14 -06:00
|
|
|
generateFractureOutlinePolygonPart(displayCoordTransform);
|
2017-03-16 06:02:07 -05:00
|
|
|
generateStimPlanMeshPart(displayCoordTransform);
|
2017-02-28 07:28:14 -06:00
|
|
|
|
2017-02-22 08:32:19 -06:00
|
|
|
float opacityLevel = activeView->stimPlanColors->opacityLevel();
|
2017-02-20 02:31:24 -06:00
|
|
|
if (legendConfig)
|
|
|
|
{
|
|
|
|
cvf::ScalarMapper* scalarMapper = legendConfig->scalarMapper();
|
2017-02-15 08:14:16 -06:00
|
|
|
|
2017-02-20 02:31:24 -06:00
|
|
|
cvf::ref<cvf::Vec2fArray> textureCoords = new cvf::Vec2fArray;
|
|
|
|
textureCoords->resize(nodeCoords.size());
|
2017-02-15 08:49:53 -06:00
|
|
|
|
2017-06-07 07:46:54 -05:00
|
|
|
int timeStepIndex = m_rimFracture->stimPlanTimeIndexToPlot;
|
|
|
|
std::vector<std::vector<double> > dataToPlot = stimPlanFracTemplate->getDataAtTimeIndex(activeView->stimPlanColors->resultName(), activeView->stimPlanColors->unit(), timeStepIndex);
|
|
|
|
|
2017-02-20 02:31:24 -06:00
|
|
|
int i = 0;
|
|
|
|
for (std::vector<double> depthData : dataToPlot)
|
2017-02-15 08:14:16 -06:00
|
|
|
{
|
2017-02-20 02:31:24 -06:00
|
|
|
std::vector<double> mirroredValuesAtDepth = mirrorDataAtSingleDepth(depthData);
|
|
|
|
for (double gridXdata : mirroredValuesAtDepth)
|
|
|
|
{
|
|
|
|
cvf::Vec2f texCoord = scalarMapper->mapToTextureCoord(gridXdata);
|
2017-02-20 04:03:18 -06:00
|
|
|
|
|
|
|
if (gridXdata > 1e-7)
|
|
|
|
{
|
|
|
|
texCoord[1] = 0; // Set the Y texture coordinate to the opaque line in the texture
|
|
|
|
}
|
2017-02-20 02:31:24 -06:00
|
|
|
textureCoords->set(i, texCoord);
|
2017-02-20 04:03:18 -06:00
|
|
|
|
|
|
|
|
2017-02-20 02:31:24 -06:00
|
|
|
i++;
|
|
|
|
}
|
2017-02-15 08:14:16 -06:00
|
|
|
}
|
|
|
|
|
2017-02-20 02:31:24 -06:00
|
|
|
geo->setTextureCoordArray(textureCoords.p());
|
2017-02-14 03:29:25 -06:00
|
|
|
|
2017-02-28 11:41:58 -06:00
|
|
|
caf::ScalarMapperEffectGenerator effGen(scalarMapper, caf::PO_1);
|
2017-02-20 06:24:22 -06:00
|
|
|
|
2017-02-27 15:21:37 -06:00
|
|
|
effGen.setOpacityLevel(0.5);
|
|
|
|
effGen.discardTransparentFragments(true);
|
2017-02-20 04:03:18 -06:00
|
|
|
|
|
|
|
if (activeView && activeView->isLightingDisabled())
|
|
|
|
{
|
|
|
|
effGen.disableLighting(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
cvf::ref<cvf::Effect> eff = effGen.generateCachedEffect();
|
2017-02-14 03:29:25 -06:00
|
|
|
|
2017-02-20 02:31:24 -06:00
|
|
|
m_part->setEffect(eff.p());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-02-27 15:21:37 -06:00
|
|
|
cvf::Color4f fractureColor = cvf::Color4f(activeView->stimPlanColors->defaultColor(), 1.0);
|
2017-02-22 08:32:19 -06:00
|
|
|
|
|
|
|
caf::SurfaceEffectGenerator surfaceGen(fractureColor, caf::PO_1);
|
2017-02-20 02:31:24 -06:00
|
|
|
cvf::ref<cvf::Effect> eff = surfaceGen.generateCachedEffect();
|
|
|
|
m_part->setEffect(eff.p());
|
|
|
|
}
|
2017-02-22 08:32:19 -06:00
|
|
|
|
|
|
|
m_part->setPriority(RivPartPriority::PartType::Transparent);
|
2017-02-23 04:53:26 -06:00
|
|
|
m_part->setSourceInfo(new RivObjectSourceInfo(m_rimFracture));
|
2017-02-14 03:29:25 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-28 07:28:14 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RivWellFracturePartMgr::generateFractureOutlinePolygonPart(caf::DisplayCoordTransform* displayCoordTransform)
|
|
|
|
{
|
2017-06-07 07:46:54 -05:00
|
|
|
m_polygonPart = nullptr;
|
|
|
|
|
2017-02-28 07:28:14 -06:00
|
|
|
cvf::ref<cvf::DrawableGeo> polygonGeo = createPolygonDrawable(displayCoordTransform);
|
|
|
|
|
2017-06-07 07:46:54 -05:00
|
|
|
if (polygonGeo.notNull())
|
|
|
|
{
|
|
|
|
m_polygonPart = new cvf::Part;
|
|
|
|
m_polygonPart->setDrawable(polygonGeo.p());
|
2017-02-28 07:28:14 -06:00
|
|
|
|
2017-06-07 07:46:54 -05:00
|
|
|
m_polygonPart->updateBoundingBox();
|
|
|
|
m_polygonPart->setPriority(RivPartPriority::PartType::TransparentMeshLines);
|
2017-02-28 07:28:14 -06:00
|
|
|
|
2017-06-07 07:46:54 -05:00
|
|
|
caf::MeshEffectGenerator lineEffGen(cvf::Color3::MAGENTA);
|
|
|
|
lineEffGen.setLineWidth(3.0f);
|
|
|
|
cvf::ref<cvf::Effect> eff = lineEffGen.generateCachedEffect();
|
2017-02-28 07:28:14 -06:00
|
|
|
|
2017-06-07 07:46:54 -05:00
|
|
|
m_polygonPart->setEffect(eff.p());
|
|
|
|
}
|
2017-02-28 07:28:14 -06:00
|
|
|
}
|
|
|
|
|
2017-03-16 06:02:07 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RivWellFracturePartMgr::generateStimPlanMeshPart(caf::DisplayCoordTransform* displayCoordTransform)
|
|
|
|
{
|
2017-06-07 07:46:54 -05:00
|
|
|
m_stimPlanMeshPart = nullptr;
|
2017-03-16 06:02:07 -05:00
|
|
|
|
2017-06-09 10:21:59 -05:00
|
|
|
if (!m_rimFracture->fractureTemplate()) return;
|
2017-03-16 06:02:07 -05:00
|
|
|
|
2017-06-09 10:21:59 -05:00
|
|
|
RimStimPlanFractureTemplate* stimPlanFracTemplate = dynamic_cast<RimStimPlanFractureTemplate*>(m_rimFracture->fractureTemplate());
|
2017-03-16 06:02:07 -05:00
|
|
|
if (!stimPlanFracTemplate) return;
|
|
|
|
|
|
|
|
cvf::ref<cvf::DrawableGeo> stimPlanMeshGeo = createStimPlanMeshDrawable(stimPlanFracTemplate, displayCoordTransform);
|
2017-06-07 07:46:54 -05:00
|
|
|
if (stimPlanMeshGeo.notNull())
|
|
|
|
{
|
|
|
|
m_stimPlanMeshPart = new cvf::Part;
|
|
|
|
m_stimPlanMeshPart->setDrawable(stimPlanMeshGeo.p());
|
2017-03-16 06:02:07 -05:00
|
|
|
|
2017-06-07 07:46:54 -05:00
|
|
|
m_stimPlanMeshPart->updateBoundingBox();
|
|
|
|
m_stimPlanMeshPart->setPriority(RivPartPriority::PartType::TransparentMeshLines);
|
2017-03-16 06:02:07 -05:00
|
|
|
|
2017-06-07 07:46:54 -05:00
|
|
|
caf::MeshEffectGenerator lineEffGen(cvf::Color3::BLACK);
|
|
|
|
lineEffGen.setLineWidth(1.0f);
|
|
|
|
cvf::ref<cvf::Effect> eff = lineEffGen.generateCachedEffect();
|
2017-03-16 06:02:07 -05:00
|
|
|
|
2017-06-07 07:46:54 -05:00
|
|
|
m_stimPlanMeshPart->setEffect(eff.p());
|
|
|
|
}
|
2017-03-16 06:02:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
cvf::ref<cvf::DrawableGeo> RivWellFracturePartMgr::createStimPlanMeshDrawable(RimStimPlanFractureTemplate* stimPlanFracTemplate, caf::DisplayCoordTransform* displayCoordTransform)
|
|
|
|
{
|
2017-04-07 05:41:06 -05:00
|
|
|
//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...
|
2017-04-07 03:17:17 -05:00
|
|
|
stimPlanFracTemplate->setupStimPlanCells();
|
|
|
|
|
2017-05-30 07:57:21 -05:00
|
|
|
std::vector<RigFractureCell> stimPlanCells = stimPlanFracTemplate->fractureGrid()->fractureCells();
|
2017-03-16 06:02:07 -05:00
|
|
|
std::vector<cvf::Vec3f> stimPlanMeshVertices;
|
2017-03-20 04:38:58 -05:00
|
|
|
|
2017-05-30 04:52:19 -05:00
|
|
|
for (RigFractureCell stimPlanCell : stimPlanCells)
|
2017-03-16 06:02:07 -05:00
|
|
|
{
|
2017-04-06 02:34:38 -05:00
|
|
|
if (stimPlanCell.getDisplayValue() > 1e-7)
|
2017-03-16 06:02:07 -05:00
|
|
|
{
|
2017-04-06 02:34:38 -05:00
|
|
|
std::vector<cvf::Vec3d> stimPlanCellPolygon = stimPlanCell.getPolygon();
|
2017-03-27 07:19:21 -05:00
|
|
|
for (cvf::Vec3d cellCorner : stimPlanCellPolygon)
|
2017-03-16 06:02:07 -05:00
|
|
|
{
|
2017-03-20 04:38:58 -05:00
|
|
|
stimPlanMeshVertices.push_back(static_cast<cvf::Vec3f>(cellCorner));
|
2017-03-16 06:02:07 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-07 07:46:54 -05:00
|
|
|
if (stimPlanMeshVertices.size() == 0)
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2017-03-16 06:02:07 -05:00
|
|
|
cvf::Mat4f m = m_rimFracture->transformMatrix();
|
|
|
|
std::vector<cvf::Vec3f> stimPlanMeshVerticesDisplayCoords = transfromToFractureDisplayCoords(stimPlanMeshVertices, m, displayCoordTransform);
|
|
|
|
|
|
|
|
cvf::Vec3fArray* stimPlanMeshVertexList;
|
|
|
|
stimPlanMeshVertexList = new cvf::Vec3fArray;
|
|
|
|
stimPlanMeshVertexList->assign(stimPlanMeshVerticesDisplayCoords);
|
|
|
|
|
|
|
|
cvf::ref<cvf::DrawableGeo> stimPlanMeshGeo = new cvf::DrawableGeo;
|
|
|
|
stimPlanMeshGeo->setVertexArray(stimPlanMeshVertexList);
|
|
|
|
cvf::ref<cvf::UIntArray> indices = RivFaultGeometryGenerator::lineIndicesFromQuadVertexArray(stimPlanMeshVertexList);
|
|
|
|
cvf::ref<cvf::PrimitiveSetIndexedUInt> prim = new cvf::PrimitiveSetIndexedUInt(cvf::PT_LINES);
|
|
|
|
prim->setIndices(indices.p());
|
|
|
|
|
|
|
|
stimPlanMeshGeo->addPrimitiveSet(prim.p());
|
|
|
|
|
|
|
|
return stimPlanMeshGeo;
|
|
|
|
}
|
|
|
|
|
2017-03-16 08:53:44 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RivWellFracturePartMgr::getPolygonBB(float &polygonXmin, float &polygonXmax, float &polygonYmin, float &polygonYmax)
|
|
|
|
{
|
2017-06-09 10:21:59 -05:00
|
|
|
std::vector<cvf::Vec3f> polygon = m_rimFracture->fractureTemplate()->fractureBorderPolygon(m_rimFracture->fractureUnit());
|
2017-03-16 08:53:44 -05:00
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-28 07:28:14 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
cvf::ref<cvf::DrawableGeo> RivWellFracturePartMgr::createPolygonDrawable(caf::DisplayCoordTransform* displayCoordTransform)
|
|
|
|
{
|
|
|
|
std::vector<cvf::uint> lineIndices;
|
|
|
|
std::vector<cvf::Vec3f> vertices;
|
|
|
|
|
|
|
|
{
|
2017-06-09 10:21:59 -05:00
|
|
|
std::vector<cvf::Vec3f> polygon = m_rimFracture->fractureTemplate()->fractureBorderPolygon(m_rimFracture->fractureUnit());
|
2017-06-07 07:46:54 -05:00
|
|
|
|
|
|
|
cvf::Mat4f m = m_rimFracture->transformMatrix();
|
|
|
|
std::vector<cvf::Vec3f> polygonDisplayCoords = transfromToFractureDisplayCoords(polygon, m, displayCoordTransform);
|
|
|
|
|
|
|
|
for (size_t i = 0; i < polygonDisplayCoords.size(); ++i)
|
2017-02-28 07:28:14 -06:00
|
|
|
{
|
2017-06-07 07:46:54 -05:00
|
|
|
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));
|
|
|
|
}
|
2017-02-28 07:28:14 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-07 07:46:54 -05:00
|
|
|
if (vertices.size() == 0) return nullptr;
|
2017-02-28 07:28:14 -06:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2017-03-16 06:02:07 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::vector<cvf::Vec3f> RivWellFracturePartMgr::transfromToFractureDisplayCoords(std::vector<cvf::Vec3f> coordinatesVector, cvf::Mat4f m, caf::DisplayCoordTransform* displayCoordTransform)
|
|
|
|
{
|
|
|
|
std::vector<cvf::Vec3f> polygonInDisplayCoords;
|
|
|
|
for (cvf::Vec3f v : coordinatesVector)
|
|
|
|
{
|
|
|
|
v.transformPoint(m);
|
|
|
|
cvf::Vec3d nodeCoordsDouble = static_cast<cvf::Vec3d>(v);
|
|
|
|
cvf::Vec3d displayCoordsDouble = displayCoordTransform->transformToDisplayCoord(nodeCoordsDouble);
|
|
|
|
polygonInDisplayCoords.push_back(static_cast<cvf::Vec3f>(displayCoordsDouble));
|
|
|
|
}
|
2017-06-07 07:46:54 -05:00
|
|
|
|
2017-03-16 06:02:07 -05:00
|
|
|
return polygonInDisplayCoords;
|
|
|
|
}
|
|
|
|
|
2017-02-15 08:14:16 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::vector<double> RivWellFracturePartMgr::mirrorDataAtSingleDepth(std::vector<double> depthData)
|
|
|
|
{
|
|
|
|
std::vector<double> mirroredValuesAtGivenDepth;
|
|
|
|
mirroredValuesAtGivenDepth.push_back(depthData[0]);
|
2017-06-09 08:55:47 -05:00
|
|
|
for (size_t i = 1; i < (depthData.size()); i++) //starting at 1 since we don't want center value twice
|
2017-02-15 08:14:16 -06:00
|
|
|
{
|
|
|
|
double valueAtGivenX = depthData[i];
|
|
|
|
mirroredValuesAtGivenDepth.insert(mirroredValuesAtGivenDepth.begin(), valueAtGivenX);
|
|
|
|
mirroredValuesAtGivenDepth.push_back(valueAtGivenX);
|
|
|
|
}
|
|
|
|
|
|
|
|
return mirroredValuesAtGivenDepth;
|
|
|
|
}
|
|
|
|
|
2017-01-04 01:10:02 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-01-19 00:28:04 -06:00
|
|
|
void RivWellFracturePartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* model, caf::DisplayCoordTransform* displayCoordTransform)
|
2017-01-04 01:10:02 -06:00
|
|
|
{
|
2017-02-16 02:15:23 -06:00
|
|
|
clearGeometryCache();
|
|
|
|
|
2017-02-22 06:29:20 -06:00
|
|
|
if (!m_rimFracture->isChecked()) return;
|
|
|
|
|
2017-01-19 00:28:04 -06:00
|
|
|
if (m_part.isNull())
|
2017-01-04 01:10:02 -06:00
|
|
|
{
|
2017-06-09 10:21:59 -05:00
|
|
|
if (m_rimFracture->fractureTemplate())
|
2017-02-15 08:14:16 -06:00
|
|
|
{
|
2017-06-09 10:21:59 -05:00
|
|
|
if (dynamic_cast<RimStimPlanFractureTemplate*>(m_rimFracture->fractureTemplate()))
|
2017-02-15 08:14:16 -06:00
|
|
|
{
|
|
|
|
updatePartGeometryTexture(displayCoordTransform);
|
2017-03-16 06:02:07 -05:00
|
|
|
|
2017-06-09 10:21:59 -05:00
|
|
|
RimStimPlanFractureTemplate* stimPlanFracTemplate = dynamic_cast<RimStimPlanFractureTemplate*>(m_rimFracture->fractureTemplate());
|
2017-06-07 07:46:54 -05:00
|
|
|
if (stimPlanFracTemplate->showStimPlanMesh() && m_stimPlanMeshPart.notNull())
|
2017-03-16 06:02:07 -05:00
|
|
|
{
|
2017-06-07 07:46:54 -05:00
|
|
|
model->addPart(m_stimPlanMeshPart.p());
|
2017-03-16 06:02:07 -05:00
|
|
|
}
|
2017-02-15 08:14:16 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
updatePartGeometry(displayCoordTransform);
|
|
|
|
}
|
|
|
|
}
|
2017-01-19 00:28:04 -06:00
|
|
|
}
|
2017-01-04 01:10:02 -06:00
|
|
|
|
2017-01-19 00:28:04 -06:00
|
|
|
if (m_part.notNull())
|
|
|
|
{
|
|
|
|
model->addPart(m_part.p());
|
2017-01-04 01:10:02 -06:00
|
|
|
}
|
2017-06-07 04:17:56 -05:00
|
|
|
|
2017-06-09 10:21:59 -05:00
|
|
|
if (dynamic_cast<RimStimPlanFractureTemplate*>(m_rimFracture->fractureTemplate())
|
2017-06-07 04:17:56 -05:00
|
|
|
&& m_rimFracture->showPolygonFractureOutline()
|
|
|
|
&& m_polygonPart.notNull())
|
2017-02-28 07:28:14 -06:00
|
|
|
{
|
|
|
|
model->addPart(m_polygonPart.p());
|
|
|
|
}
|
2017-01-04 01:10:02 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-01-19 00:28:04 -06:00
|
|
|
void RivWellFracturePartMgr::clearGeometryCache()
|
|
|
|
{
|
|
|
|
m_part = nullptr;
|
2017-06-07 07:46:54 -05:00
|
|
|
m_polygonPart = nullptr;
|
|
|
|
m_stimPlanMeshPart = nullptr;
|
2017-01-19 00:28:04 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-02-14 03:29:25 -06:00
|
|
|
cvf::ref<cvf::DrawableGeo> RivWellFracturePartMgr::createGeo(const std::vector<cvf::uint>& triangleIndices, const std::vector<cvf::Vec3f>& nodeCoords)
|
2017-01-04 01:10:02 -06:00
|
|
|
{
|
2017-06-07 07:46:54 -05:00
|
|
|
CVF_ASSERT(triangleIndices.size() > 0);
|
|
|
|
CVF_ASSERT(nodeCoords.size() > 0);
|
|
|
|
|
2017-01-04 01:10:02 -06:00
|
|
|
cvf::ref<cvf::DrawableGeo> geo = new cvf::DrawableGeo;
|
|
|
|
|
2017-02-14 03:29:25 -06:00
|
|
|
cvf::ref<cvf::UIntArray> indices = new cvf::UIntArray(triangleIndices);
|
2017-01-04 01:10:02 -06:00
|
|
|
cvf::ref<cvf::Vec3fArray> vertices = new cvf::Vec3fArray(nodeCoords);
|
|
|
|
|
|
|
|
geo->setVertexArray(vertices.p());
|
|
|
|
geo->addPrimitiveSet(new cvf::PrimitiveSetIndexedUInt(cvf::PT_TRIANGLES, indices.p()));
|
2017-01-11 01:02:23 -06:00
|
|
|
geo->computeNormals();
|
2017-01-04 01:10:02 -06:00
|
|
|
|
|
|
|
return geo;
|
|
|
|
}
|
|
|
|
|
2017-03-16 06:02:07 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-03-22 01:46:38 -05:00
|
|
|
bool RivWellFracturePartMgr::stimPlanCellTouchesPolygon(const std::vector<cvf::Vec3f>& polygon, double xMin, double xMax, double yMin, double yMax, float polygonXmin, float polygonXmax, float polygonYmin, float polygonYmax)
|
2017-03-16 06:02:07 -05:00
|
|
|
{
|
2017-03-16 08:53:44 -05:00
|
|
|
|
|
|
|
if (static_cast<float>(xMin) > polygonXmin && static_cast<float>(xMax) < polygonXmax)
|
|
|
|
{
|
|
|
|
if (static_cast<float>(yMin) > polygonYmin && static_cast<float>(yMax) < polygonYmax)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-22 01:46:38 -05:00
|
|
|
//std::vector<cvf::Vec3f> polygon = m_rimFracture->attachedFractureDefinition()->fracturePolygon(m_rimFracture->fractureUnit);
|
2017-03-16 06:02:07 -05:00
|
|
|
|
|
|
|
for (cvf::Vec3f v : polygon)
|
|
|
|
{
|
|
|
|
if (v.x() > xMin && v.x() < xMax)
|
|
|
|
{
|
|
|
|
if (v.y() > yMin && v.y() < yMax)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|