2018-03-09 06:15:01 -06:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2018- 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.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "Riv3dWellLogPlanePartMgr.h"
|
|
|
|
|
2018-03-22 07:26:33 -05:00
|
|
|
#include "RiaColorTables.h"
|
|
|
|
|
2018-03-22 05:45:11 -05:00
|
|
|
#include "Rim3dView.h"
|
2018-03-21 09:32:03 -05:00
|
|
|
#include "Rim3dWellLogCurveCollection.h"
|
2018-03-22 05:45:11 -05:00
|
|
|
#include "RimCase.h"
|
2018-03-20 07:51:51 -05:00
|
|
|
#include "RimGridView.h"
|
|
|
|
#include "RimWellPath.h"
|
2018-03-09 06:15:01 -06:00
|
|
|
|
|
|
|
#include "Riv3dWellLogCurveGeomertyGenerator.h"
|
2018-03-22 08:35:54 -05:00
|
|
|
#include "Riv3dWellLogGridGeomertyGenerator.h"
|
2018-03-09 06:15:01 -06:00
|
|
|
|
|
|
|
#include "cafDisplayCoordTransform.h"
|
|
|
|
#include "cafEffectGenerator.h"
|
|
|
|
|
2018-03-21 03:48:51 -05:00
|
|
|
#include "cvfBoundingBox.h"
|
2018-03-12 10:18:40 -05:00
|
|
|
#include "cvfColor3.h"
|
|
|
|
#include "cvfDrawableGeo.h"
|
2018-03-09 06:15:01 -06:00
|
|
|
#include "cvfModelBasicList.h"
|
|
|
|
#include "cvfPart.h"
|
|
|
|
|
2018-04-12 10:44:50 -05:00
|
|
|
#include <utility>
|
|
|
|
|
2018-03-09 06:15:01 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-03-20 07:51:51 -05:00
|
|
|
Riv3dWellLogPlanePartMgr::Riv3dWellLogPlanePartMgr(RimWellPath* wellPath, RimGridView* gridView)
|
2018-03-21 03:48:51 -05:00
|
|
|
: m_wellPath(wellPath)
|
|
|
|
, m_gridView(gridView)
|
2018-03-09 06:15:01 -06:00
|
|
|
{
|
2018-03-22 05:45:11 -05:00
|
|
|
CVF_ASSERT(m_wellPath.notNull());
|
|
|
|
m_3dWellLogCurveGeometryGenerator = new Riv3dWellLogCurveGeometryGenerator(m_wellPath.p());
|
2018-03-22 08:35:54 -05:00
|
|
|
m_3dWellLogGridGeometryGenerator = new Riv3dWellLogGridGeometryGenerator(m_wellPath.p());
|
2018-03-09 06:15:01 -06:00
|
|
|
}
|
|
|
|
|
2018-03-21 09:32:03 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void Riv3dWellLogPlanePartMgr::appendPlaneToModel(cvf::ModelBasicList* model,
|
|
|
|
const caf::DisplayCoordTransform* displayCoordTransform,
|
|
|
|
const cvf::BoundingBox& wellPathClipBoundingBox)
|
|
|
|
{
|
|
|
|
if (m_wellPath.isNull()) return;
|
2018-03-22 02:54:48 -05:00
|
|
|
|
2018-03-21 09:32:03 -05:00
|
|
|
if (!m_wellPath->rim3dWellLogCurveCollection()) return;
|
2018-03-22 02:54:48 -05:00
|
|
|
|
2018-03-22 05:45:11 -05:00
|
|
|
if (!m_wellPath->rim3dWellLogCurveCollection()->isShowingPlot()) return;
|
2018-03-21 09:32:03 -05:00
|
|
|
|
|
|
|
if (m_wellPath->rim3dWellLogCurveCollection()->vectorOf3dWellLogCurves().empty()) return;
|
|
|
|
|
|
|
|
append3dWellLogCurvesToModel(model, displayCoordTransform, wellPathClipBoundingBox);
|
|
|
|
|
2018-03-22 05:45:11 -05:00
|
|
|
if (m_wellPath->rim3dWellLogCurveCollection()->isShowingGrid())
|
2018-03-21 09:32:03 -05:00
|
|
|
{
|
2018-03-22 05:45:11 -05:00
|
|
|
std::set<Rim3dWellLogCurve::DrawPlane> drawPlanes;
|
2018-03-21 09:32:03 -05:00
|
|
|
|
|
|
|
for (Rim3dWellLogCurve* rim3dWellLogCurve : m_wellPath->rim3dWellLogCurveCollection()->vectorOf3dWellLogCurves())
|
|
|
|
{
|
2018-03-22 05:45:11 -05:00
|
|
|
drawPlanes.insert(rim3dWellLogCurve->drawPlane());
|
2018-03-21 09:32:03 -05:00
|
|
|
}
|
|
|
|
|
2018-03-22 05:45:11 -05:00
|
|
|
for (const Rim3dWellLogCurve::DrawPlane& drawPlane : drawPlanes)
|
2018-03-21 09:32:03 -05:00
|
|
|
{
|
2018-03-22 05:45:11 -05:00
|
|
|
appendGridToModel(model, displayCoordTransform, wellPathClipBoundingBox, drawPlane, planeWidth());
|
2018-03-21 09:32:03 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-09 06:15:01 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList* model,
|
|
|
|
const caf::DisplayCoordTransform* displayCoordTransform,
|
2018-03-21 07:15:48 -05:00
|
|
|
const cvf::BoundingBox& wellPathClipBoundingBox)
|
2018-03-09 06:15:01 -06:00
|
|
|
{
|
2018-03-20 07:51:51 -05:00
|
|
|
if (m_wellPath.isNull()) return;
|
2018-03-22 03:54:58 -05:00
|
|
|
if (!m_wellPath->rim3dWellLogCurveCollection()) return;
|
2018-03-21 09:32:03 -05:00
|
|
|
if (m_wellPath->rim3dWellLogCurveCollection()->vectorOf3dWellLogCurves().empty()) return;
|
2018-03-22 06:54:31 -05:00
|
|
|
|
|
|
|
const Rim3dWellLogCurveCollection* curveCollection = m_wellPath->rim3dWellLogCurveCollection();
|
|
|
|
Rim3dWellLogCurveCollection::PlanePosition planePosition = curveCollection->planePosition();
|
|
|
|
|
2018-03-22 07:26:33 -05:00
|
|
|
size_t colorIndex = 0;
|
|
|
|
|
2018-03-21 09:32:03 -05:00
|
|
|
for (Rim3dWellLogCurve* rim3dWellLogCurve : m_wellPath->rim3dWellLogCurveCollection()->vectorOf3dWellLogCurves())
|
2018-03-09 08:42:23 -06:00
|
|
|
{
|
2018-03-22 07:26:33 -05:00
|
|
|
colorIndex++;
|
2018-03-22 05:45:11 -05:00
|
|
|
if (!rim3dWellLogCurve->isShowingCurve()) continue;
|
2018-03-21 03:48:51 -05:00
|
|
|
|
2018-03-22 02:54:48 -05:00
|
|
|
std::vector<double> resultValues;
|
|
|
|
std::vector<double> resultMds;
|
|
|
|
rim3dWellLogCurve->curveValuesAndMds(&resultValues, &resultMds);
|
|
|
|
|
2018-03-22 06:54:31 -05:00
|
|
|
cvf::ref<cvf::Drawable> curveDrawable =
|
|
|
|
m_3dWellLogCurveGeometryGenerator->createCurveLine(displayCoordTransform,
|
|
|
|
wellPathClipBoundingBox,
|
|
|
|
resultValues,
|
|
|
|
resultMds,
|
|
|
|
planeAngle(rim3dWellLogCurve->drawPlane()),
|
|
|
|
wellPathCenterToPlotStartOffset(planePosition),
|
|
|
|
planeWidth());
|
2018-03-09 08:42:23 -06:00
|
|
|
|
2018-03-15 07:04:39 -05:00
|
|
|
if (curveDrawable.isNull() || !curveDrawable->boundingBox().isValid())
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2018-03-22 07:26:33 -05:00
|
|
|
caf::MeshEffectGenerator meshEffectGen(curveColor(colorIndex));
|
|
|
|
meshEffectGen.setLineWidth(2.0f);
|
2018-03-21 03:48:51 -05:00
|
|
|
cvf::ref<cvf::Effect> effect = meshEffectGen.generateCachedEffect();
|
2018-03-09 08:42:23 -06:00
|
|
|
|
|
|
|
cvf::ref<cvf::Part> part = new cvf::Part;
|
2018-03-12 10:18:40 -05:00
|
|
|
part->setDrawable(curveDrawable.p());
|
2018-03-09 08:42:23 -06:00
|
|
|
part->setEffect(effect.p());
|
|
|
|
|
|
|
|
if (part.notNull())
|
|
|
|
{
|
|
|
|
model->addPart(part.p());
|
|
|
|
}
|
|
|
|
}
|
2018-03-20 05:29:46 -05:00
|
|
|
}
|
2018-03-09 08:42:23 -06:00
|
|
|
|
2018-03-20 05:29:46 -05:00
|
|
|
cvf::ref<cvf::Part> Riv3dWellLogPlanePartMgr::createPart(cvf::Drawable* drawable, cvf::Effect* effect)
|
|
|
|
{
|
|
|
|
cvf::ref<cvf::Part> part = new cvf::Part;
|
2018-03-09 06:15:01 -06:00
|
|
|
|
2018-03-20 05:29:46 -05:00
|
|
|
if (drawable && drawable->boundingBox().isValid())
|
2018-03-14 08:22:14 -05:00
|
|
|
{
|
2018-03-20 05:29:46 -05:00
|
|
|
part->setDrawable(drawable);
|
|
|
|
part->setEffect(effect);
|
2018-03-14 08:22:14 -05:00
|
|
|
}
|
2018-03-15 07:04:39 -05:00
|
|
|
|
2018-03-20 05:29:46 -05:00
|
|
|
return part;
|
|
|
|
}
|
2018-03-09 06:15:01 -06:00
|
|
|
|
2018-03-20 05:29:46 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-03-21 03:48:51 -05:00
|
|
|
///
|
2018-03-20 05:29:46 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-03-22 05:45:11 -05:00
|
|
|
double Riv3dWellLogPlanePartMgr::planeAngle(const Rim3dWellLogCurve::DrawPlane& drawPlane)
|
2018-03-22 02:54:48 -05:00
|
|
|
{
|
|
|
|
switch (drawPlane)
|
|
|
|
{
|
|
|
|
case Rim3dWellLogCurve::HORIZONTAL_LEFT:
|
2018-04-13 06:34:41 -05:00
|
|
|
return cvf::PI_D / 2.0;
|
2018-03-22 02:54:48 -05:00
|
|
|
case Rim3dWellLogCurve::HORIZONTAL_RIGHT:
|
2018-04-13 06:34:41 -05:00
|
|
|
return -cvf::PI_D / 2.0;
|
2018-03-22 02:54:48 -05:00
|
|
|
case Rim3dWellLogCurve::VERTICAL_ABOVE:
|
2018-04-13 06:34:41 -05:00
|
|
|
return 0.0;
|
2018-03-22 02:54:48 -05:00
|
|
|
case Rim3dWellLogCurve::VERTICAL_BELOW:
|
2018-04-13 06:34:41 -05:00
|
|
|
return cvf::PI_D;
|
2018-03-22 02:54:48 -05:00
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-22 03:54:58 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-03-22 06:54:31 -05:00
|
|
|
///
|
2018-03-22 03:54:58 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-03-22 06:54:31 -05:00
|
|
|
double Riv3dWellLogPlanePartMgr::wellPathCenterToPlotStartOffset(Rim3dWellLogCurveCollection::PlanePosition planePosition) const
|
2018-03-22 03:54:58 -05:00
|
|
|
{
|
|
|
|
if (!m_gridView) return 0;
|
|
|
|
|
|
|
|
double cellSize = m_gridView->ownerCase()->characteristicCellSize();
|
|
|
|
|
2018-03-22 06:54:31 -05:00
|
|
|
if (planePosition == Rim3dWellLogCurveCollection::ALONG_WELLPATH)
|
|
|
|
{
|
|
|
|
return m_wellPath->wellPathRadius(cellSize) * 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-04-05 07:17:39 -05:00
|
|
|
return -0.5*planeWidth();
|
2018-03-22 06:54:31 -05:00
|
|
|
}
|
2018-03-22 03:54:58 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-03-22 06:54:31 -05:00
|
|
|
///
|
2018-03-22 03:54:58 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
double Riv3dWellLogPlanePartMgr::planeWidth() const
|
|
|
|
{
|
|
|
|
if (!m_gridView) return 0;
|
|
|
|
|
|
|
|
double cellSize = m_gridView->ownerCase()->characteristicCellSize();
|
|
|
|
|
2018-04-05 07:17:39 -05:00
|
|
|
return cellSize * 1.0;
|
2018-03-22 03:54:58 -05:00
|
|
|
}
|
|
|
|
|
2018-03-22 07:26:33 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
cvf::Color3f Riv3dWellLogPlanePartMgr::curveColor(size_t index)
|
|
|
|
{
|
|
|
|
return RiaColorTables::wellLogPlotPaletteColors().cycledColor3f(index);
|
|
|
|
}
|
|
|
|
|
2018-03-22 02:54:48 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* model,
|
|
|
|
const caf::DisplayCoordTransform* displayCoordTransform,
|
|
|
|
const cvf::BoundingBox& wellPathClipBoundingBox,
|
|
|
|
const Rim3dWellLogCurve::DrawPlane& drawPlane,
|
|
|
|
double gridIntervalSize)
|
2018-03-20 05:29:46 -05:00
|
|
|
{
|
2018-03-22 06:54:31 -05:00
|
|
|
const Rim3dWellLogCurveCollection* curveCollection = m_wellPath->rim3dWellLogCurveCollection();
|
|
|
|
Rim3dWellLogCurveCollection::PlanePosition planePosition = curveCollection->planePosition();
|
|
|
|
|
2018-04-12 10:44:50 -05:00
|
|
|
caf::SurfaceEffectGenerator surfaceEffectGen(cvf::Color4f(1.0, 1.0, 1.0, 0.5), caf::PO_1);
|
|
|
|
caf::MeshEffectGenerator gridBorderEffectGen(cvf::Color3f(0.4f, 0.4f, 0.4f));
|
|
|
|
caf::MeshEffectGenerator normalsEffectGen(cvf::Color3f(0.4f, 0.4f, 0.4f));
|
|
|
|
normalsEffectGen.setLineStipple(true);
|
2018-03-20 05:29:46 -05:00
|
|
|
|
2018-04-12 10:44:50 -05:00
|
|
|
std::map < Riv3dWellLogGridGeometryGenerator::DrawableId, cvf::ref<cvf::DrawableGeo> > gridDrawables =
|
2018-03-22 08:35:54 -05:00
|
|
|
m_3dWellLogGridGeometryGenerator->createGrid(displayCoordTransform,
|
|
|
|
wellPathClipBoundingBox,
|
|
|
|
planeAngle(drawPlane),
|
|
|
|
wellPathCenterToPlotStartOffset(planePosition),
|
|
|
|
planeWidth(),
|
|
|
|
gridIntervalSize);
|
2018-03-20 05:29:46 -05:00
|
|
|
|
2018-04-12 10:44:50 -05:00
|
|
|
std::map < Riv3dWellLogGridGeometryGenerator::DrawableId, cvf::ref<cvf::Effect> > effects;
|
|
|
|
effects[Riv3dWellLogGridGeometryGenerator::GridBackground] = surfaceEffectGen.generateCachedEffect();
|
|
|
|
effects[Riv3dWellLogGridGeometryGenerator::GridBorder] = gridBorderEffectGen.generateCachedEffect();
|
|
|
|
effects[Riv3dWellLogGridGeometryGenerator::NormalLines] = normalsEffectGen.generateCachedEffect();
|
|
|
|
cvf::ref<cvf::Effect> normalsEffect = normalsEffectGen.generateCachedEffect();
|
2018-03-20 05:29:46 -05:00
|
|
|
|
2018-04-12 10:44:50 -05:00
|
|
|
for(std::pair< Riv3dWellLogGridGeometryGenerator::DrawableId, cvf::ref<cvf::DrawableGeo> > item : gridDrawables)
|
2018-03-22 03:54:58 -05:00
|
|
|
{
|
2018-04-12 10:44:50 -05:00
|
|
|
Riv3dWellLogGridGeometryGenerator::DrawableId drawableId = item.first;
|
|
|
|
cvf::ref<cvf::DrawableGeo> drawable = item.second;
|
|
|
|
CVF_ASSERT(drawable.notNull());
|
|
|
|
cvf::ref<cvf::Part> part = createPart(drawable.p(), effects[drawableId].p());
|
|
|
|
if (part.notNull())
|
|
|
|
{
|
|
|
|
model->addPart(part.p());
|
|
|
|
}
|
2018-03-09 08:42:23 -06:00
|
|
|
}
|
2018-03-09 06:15:01 -06:00
|
|
|
}
|