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-04-19 06:35:11 -05:00
|
|
|
#include "RiaApplication.h"
|
2018-03-22 07:26:33 -05:00
|
|
|
|
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-09-21 04:36:32 -05:00
|
|
|
#include "RiuViewer.h"
|
2018-03-09 06:15:01 -06:00
|
|
|
|
2018-05-02 05:10:05 -05:00
|
|
|
#include "Riv3dWellLogCurveGeometryGenerator.h"
|
|
|
|
#include "Riv3dWellLogDrawSurfaceGenerator.h"
|
2018-09-21 04:36:32 -05:00
|
|
|
#include "RivMeshLinesSourceInfo.h"
|
2018-04-20 09:08:17 -05:00
|
|
|
#include "RivObjectSourceInfo.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"
|
2018-04-19 06:35:11 -05:00
|
|
|
#include "cvfOpenGLResourceManager.h"
|
2018-03-09 06:15:01 -06:00
|
|
|
#include "cvfPart.h"
|
2018-04-19 06:35:11 -05:00
|
|
|
#include "cvfShaderProgram.h"
|
2018-03-09 06:15:01 -06:00
|
|
|
|
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());
|
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,
|
2018-09-03 07:52:00 -05:00
|
|
|
const cvf::BoundingBox& wellPathClipBoundingBox,
|
|
|
|
bool isStaticResult)
|
2018-03-21 09:32:03 -05:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
|
2018-09-03 07:52:00 -05:00
|
|
|
if (isStaticResult)
|
|
|
|
{
|
|
|
|
std::set<Rim3dWellLogCurve::DrawPlane> drawPlanes;
|
|
|
|
for (Rim3dWellLogCurve* rim3dWellLogCurve : m_wellPath->rim3dWellLogCurveCollection()->vectorOf3dWellLogCurves())
|
|
|
|
{
|
|
|
|
if (rim3dWellLogCurve->showInView(m_gridView))
|
|
|
|
{
|
|
|
|
drawPlanes.insert(rim3dWellLogCurve->drawPlane());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (Rim3dWellLogCurve::DrawPlane drawPlane : drawPlanes)
|
|
|
|
{
|
|
|
|
m_3dWellLogDrawSurfaceGeometryGenerators[drawPlane] = new Riv3dWellLogDrawSurfaceGenerator(m_wellPath.p());
|
|
|
|
appendDrawSurfaceToModel(model, displayCoordTransform, wellPathClipBoundingBox, drawPlane, planeWidth());
|
|
|
|
}
|
|
|
|
}
|
2018-04-17 01:30:06 -05:00
|
|
|
for (Rim3dWellLogCurve* rim3dWellLogCurve : m_wellPath->rim3dWellLogCurveCollection()->vectorOf3dWellLogCurves())
|
2018-03-21 09:32:03 -05:00
|
|
|
{
|
2018-09-04 05:57:55 -05:00
|
|
|
if (rim3dWellLogCurve->showInView(m_gridView) && rim3dWellLogCurve->isShowingTimeDependentResult() != isStaticResult)
|
2018-05-02 03:21:27 -05:00
|
|
|
{
|
|
|
|
append3dWellLogCurveToModel(model,
|
|
|
|
displayCoordTransform,
|
|
|
|
wellPathClipBoundingBox,
|
|
|
|
rim3dWellLogCurve,
|
2018-09-03 07:52:00 -05:00
|
|
|
m_3dWellLogDrawSurfaceGeometryGenerators[rim3dWellLogCurve->drawPlane()]->vertices());
|
2018-05-02 03:21:27 -05:00
|
|
|
}
|
2018-03-21 09:32:03 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-09 06:15:01 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-04-30 02:22:59 -05:00
|
|
|
void Riv3dWellLogPlanePartMgr::append3dWellLogCurveToModel(cvf::ModelBasicList* model,
|
|
|
|
const caf::DisplayCoordTransform* displayCoordTransform,
|
|
|
|
const cvf::BoundingBox& wellPathClipBoundingBox,
|
2018-05-02 03:21:27 -05:00
|
|
|
Rim3dWellLogCurve* rim3dWellLogCurve,
|
2018-05-18 03:50:13 -05:00
|
|
|
const std::vector<cvf::Vec3d>& drawSurfaceVertices)
|
2018-03-09 06:15:01 -06:00
|
|
|
{
|
2018-04-30 02:22:59 -05:00
|
|
|
CVF_ASSERT(rim3dWellLogCurve);
|
2018-03-22 07:26:33 -05:00
|
|
|
|
2018-04-30 02:22:59 -05:00
|
|
|
cvf::ref<Riv3dWellLogCurveGeometryGenerator> generator = rim3dWellLogCurve->geometryGenerator();
|
|
|
|
if (generator.isNull())
|
2018-03-09 08:42:23 -06:00
|
|
|
{
|
2018-04-30 02:22:59 -05:00
|
|
|
generator = new Riv3dWellLogCurveGeometryGenerator(m_wellPath.p());
|
|
|
|
rim3dWellLogCurve->setGeometryGenerator(generator.p());
|
|
|
|
}
|
2018-03-22 02:54:48 -05:00
|
|
|
|
2018-04-30 02:22:59 -05:00
|
|
|
generator->createCurveDrawables(displayCoordTransform,
|
2018-09-21 04:36:32 -05:00
|
|
|
wellPathClipBoundingBox,
|
|
|
|
rim3dWellLogCurve,
|
|
|
|
wellPathCenterToPlotStartOffset(rim3dWellLogCurve->drawPlane()),
|
|
|
|
planeWidth(),
|
|
|
|
drawSurfaceVertices,
|
|
|
|
m_gridView->currentTimeStep());
|
|
|
|
|
2018-04-30 02:22:59 -05:00
|
|
|
cvf::ref<cvf::DrawableGeo> curveDrawable = generator->curveDrawable();
|
2018-05-04 06:20:49 -05:00
|
|
|
if (curveDrawable.notNull() && curveDrawable->boundingBox().isValid())
|
2018-04-30 02:22:59 -05:00
|
|
|
{
|
2018-05-04 06:20:49 -05:00
|
|
|
caf::MeshEffectGenerator meshEffectGen(rim3dWellLogCurve->color());
|
2018-05-09 08:55:54 -05:00
|
|
|
meshEffectGen.setLineWidth(3.0f);
|
2018-05-04 06:20:49 -05:00
|
|
|
cvf::ref<cvf::Effect> effect = meshEffectGen.generateCachedEffect();
|
|
|
|
|
2018-09-21 04:36:32 -05:00
|
|
|
cvf::ref<cvf::Part> part = new cvf::Part;
|
|
|
|
part->setDrawable(curveDrawable.p());
|
|
|
|
part->setEffect(effect.p());
|
|
|
|
|
|
|
|
part->setSourceInfo(new RivMeshLinesSourceInfo(rim3dWellLogCurve));
|
|
|
|
|
|
|
|
model->addPart(part.p());
|
2018-04-30 02:22:59 -05:00
|
|
|
}
|
2018-03-20 05:29:46 -05:00
|
|
|
}
|
2018-03-09 08:42:23 -06:00
|
|
|
|
2018-04-18 01:38:15 -05: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-09-03 07:52:00 -05:00
|
|
|
double Riv3dWellLogPlanePartMgr::wellPathCenterToPlotStartOffset(Rim3dWellLogCurve::DrawPlane drawPlane) const
|
2018-03-22 03:54:58 -05:00
|
|
|
{
|
2018-09-21 04:36:32 -05:00
|
|
|
if (drawPlane == Rim3dWellLogCurve::HORIZONTAL_CENTER || drawPlane == Rim3dWellLogCurve::VERTICAL_CENTER)
|
2018-03-22 06:54:31 -05:00
|
|
|
{
|
2018-09-21 04:36:32 -05:00
|
|
|
return -0.5 * planeWidth();
|
2018-03-22 06:54:31 -05:00
|
|
|
}
|
2018-04-18 01:38:15 -05:00
|
|
|
else
|
|
|
|
{
|
2018-09-21 04:36:32 -05:00
|
|
|
double cellSize = m_gridView->ownerCase()->characteristicCellSize();
|
2018-04-18 01:38:15 -05:00
|
|
|
double wellPathOffset = std::min(m_wellPath->wellPathRadius(cellSize), 0.1 * planeWidth());
|
|
|
|
return m_wellPath->wellPathRadius(cellSize) + wellPathOffset;
|
|
|
|
}
|
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;
|
|
|
|
|
2018-09-21 04:36:32 -05:00
|
|
|
double cellSize = m_gridView->ownerCase()->characteristicCellSize();
|
|
|
|
const Rim3dWellLogCurveCollection* curveCollection = m_wellPath->rim3dWellLogCurveCollection();
|
2018-04-17 02:40:30 -05:00
|
|
|
return cellSize * curveCollection->planeWidthScaling();
|
2018-03-22 03:54:58 -05:00
|
|
|
}
|
|
|
|
|
2018-03-22 02:54:48 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-09-21 04:36:32 -05:00
|
|
|
void Riv3dWellLogPlanePartMgr::appendDrawSurfaceToModel(cvf::ModelBasicList* model,
|
|
|
|
const caf::DisplayCoordTransform* displayCoordTransform,
|
|
|
|
const cvf::BoundingBox& wellPathClipBoundingBox,
|
|
|
|
Rim3dWellLogCurve::DrawPlane drawPlane,
|
|
|
|
double samplingInterval)
|
2018-03-20 05:29:46 -05:00
|
|
|
{
|
2018-09-21 04:36:32 -05:00
|
|
|
Rim3dWellLogCurveCollection* curveCollection = m_wellPath->rim3dWellLogCurveCollection();
|
|
|
|
cvf::ref<RivObjectSourceInfo> sourceInfo = new RivObjectSourceInfo(curveCollection);
|
2018-05-04 06:20:49 -05:00
|
|
|
|
2018-09-03 07:52:00 -05:00
|
|
|
bool showCoordinateSystemMesh = curveCollection->isShowingGrid();
|
|
|
|
bool showBackground = curveCollection->isShowingBackground();
|
2018-03-22 06:54:31 -05:00
|
|
|
|
2018-09-21 04:36:32 -05:00
|
|
|
cvf::Color3f borderColor(0.4f, 0.4f, 0.4f);
|
2018-04-16 03:35:56 -05:00
|
|
|
caf::SurfaceEffectGenerator backgroundEffectGen(cvf::Color4f(1.0, 1.0, 1.0, 1.0), caf::PO_2);
|
2018-05-02 05:10:05 -05:00
|
|
|
caf::MeshEffectGenerator borderEffectGen(borderColor);
|
2018-04-19 06:35:11 -05:00
|
|
|
caf::VectorEffectGenerator curveNormalsEffectGen;
|
2018-04-16 03:35:56 -05:00
|
|
|
backgroundEffectGen.enableLighting(false);
|
2018-09-21 04:36:32 -05:00
|
|
|
|
2018-04-23 03:35:19 -05:00
|
|
|
if (!showBackground)
|
|
|
|
{
|
|
|
|
// Make the background invisible but still present for picking.
|
|
|
|
backgroundEffectGen.enableColorMask(false);
|
|
|
|
backgroundEffectGen.enableDepthTest(false);
|
|
|
|
backgroundEffectGen.enableDepthWrite(false);
|
|
|
|
}
|
2018-04-16 03:35:56 -05:00
|
|
|
|
2018-09-21 04:36:32 -05:00
|
|
|
bool drawSurfaceCreated =
|
|
|
|
m_3dWellLogDrawSurfaceGeometryGenerators[drawPlane]->createDrawSurface(displayCoordTransform,
|
|
|
|
wellPathClipBoundingBox,
|
|
|
|
Rim3dWellLogCurve::drawPlaneAngle(drawPlane),
|
|
|
|
wellPathCenterToPlotStartOffset(drawPlane),
|
|
|
|
planeWidth(),
|
|
|
|
samplingInterval);
|
2018-05-02 05:10:05 -05:00
|
|
|
if (!drawSurfaceCreated) return;
|
2018-04-16 03:35:56 -05:00
|
|
|
|
2018-09-21 04:36:32 -05:00
|
|
|
cvf::ref<cvf::Effect> backgroundEffect = backgroundEffectGen.generateCachedEffect();
|
|
|
|
cvf::ref<cvf::Effect> borderEffect = borderEffectGen.generateCachedEffect();
|
2018-04-16 03:42:01 -05:00
|
|
|
cvf::ref<cvf::Effect> curveNormalsEffect = curveNormalsEffectGen.generateCachedEffect();
|
2018-09-21 04:36:32 -05:00
|
|
|
|
2018-09-03 07:52:00 -05:00
|
|
|
cvf::ref<cvf::DrawableGeo> background = m_3dWellLogDrawSurfaceGeometryGenerators[drawPlane]->background();
|
2018-09-21 04:36:32 -05:00
|
|
|
|
2018-04-23 03:35:19 -05:00
|
|
|
if (background.notNull())
|
2018-03-22 03:54:58 -05:00
|
|
|
{
|
2018-04-16 03:35:56 -05:00
|
|
|
cvf::ref<cvf::Part> part = createPart(background.p(), backgroundEffect.p());
|
|
|
|
if (part.notNull())
|
|
|
|
{
|
|
|
|
model->addPart(part.p());
|
2018-04-20 09:08:17 -05:00
|
|
|
part->setSourceInfo(sourceInfo.p());
|
2018-04-16 03:35:56 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-02 05:10:05 -05:00
|
|
|
if (showCoordinateSystemMesh)
|
2018-04-23 03:35:19 -05:00
|
|
|
{
|
2018-09-03 07:52:00 -05:00
|
|
|
cvf::ref<cvf::DrawableGeo> border = m_3dWellLogDrawSurfaceGeometryGenerators[drawPlane]->border();
|
2018-04-17 01:30:06 -05:00
|
|
|
if (border.notNull())
|
2018-04-16 03:35:56 -05:00
|
|
|
{
|
2018-04-17 01:30:06 -05:00
|
|
|
cvf::ref<cvf::Part> part = createPart(border.p(), borderEffect.p());
|
|
|
|
if (part.notNull())
|
|
|
|
{
|
|
|
|
model->addPart(part.p());
|
|
|
|
}
|
2018-04-16 03:35:56 -05:00
|
|
|
}
|
|
|
|
|
2018-09-03 07:52:00 -05:00
|
|
|
cvf::ref<cvf::DrawableVectors> normals = m_3dWellLogDrawSurfaceGeometryGenerators[drawPlane]->curveNormalVectors();
|
2018-04-17 01:30:06 -05:00
|
|
|
if (normals.notNull())
|
2018-04-12 10:44:50 -05:00
|
|
|
{
|
2018-05-02 05:10:05 -05:00
|
|
|
normals->setSingleColor(borderColor);
|
2018-04-19 06:35:11 -05:00
|
|
|
if (RiaApplication::instance()->useShaders())
|
|
|
|
{
|
|
|
|
normals->setUniformNames("u_transformationMatrix", "u_color");
|
|
|
|
}
|
|
|
|
|
2018-04-17 01:30:06 -05:00
|
|
|
cvf::ref<cvf::Part> part = createPart(normals.p(), curveNormalsEffect.p());
|
|
|
|
if (part.notNull())
|
|
|
|
{
|
|
|
|
model->addPart(part.p());
|
2018-04-20 09:08:17 -05:00
|
|
|
part->setSourceInfo(sourceInfo.p());
|
2018-04-17 01:30:06 -05:00
|
|
|
}
|
2018-04-12 10:44:50 -05:00
|
|
|
}
|
2018-03-09 08:42:23 -06:00
|
|
|
}
|
2018-03-09 06:15:01 -06:00
|
|
|
}
|