Merge several 2D Intersection View fixes (MD and Perf intervals) into dev

This commit is contained in:
Jacob Støren
2018-03-21 14:21:44 +01:00
5 changed files with 116 additions and 42 deletions

View File

@@ -21,6 +21,7 @@
#include "RimCase.h" #include "RimCase.h"
#include "RimGridView.h" #include "RimGridView.h"
#include "RimWellPath.h" #include "RimWellPath.h"
#include "RimWellPathCollection.h"
#include "RigCurveDataTools.h" #include "RigCurveDataTools.h"
#include "RigWellPath.h" #include "RigWellPath.h"
@@ -28,6 +29,8 @@
#include "cafDisplayCoordTransform.h" #include "cafDisplayCoordTransform.h"
#include "cvfPrimitiveSetIndexedUInt.h" #include "cvfPrimitiveSetIndexedUInt.h"
#include "cvfBoundingBox.h"
#include <cmath> #include <cmath>
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -35,12 +38,13 @@
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
cvf::ref<cvf::DrawableGeo> cvf::ref<cvf::DrawableGeo>
Riv3dWellLogCurveGeometryGenerator::createCurveLine(const caf::DisplayCoordTransform* displayCoordTransform, Riv3dWellLogCurveGeometryGenerator::createCurveLine(const caf::DisplayCoordTransform* displayCoordTransform,
const cvf::BoundingBox& wellPathClipBoundingBox,
const Rim3dWellLogCurve* rim3dWellLogCurve) const const Rim3dWellLogCurve* rim3dWellLogCurve) const
{ {
std::vector<cvf::Vec3f> vertices; std::vector<cvf::Vec3f> vertices;
std::vector<cvf::uint> indices; std::vector<cvf::uint> indices;
createCurveVerticesAndIndices(rim3dWellLogCurve, displayCoordTransform, &vertices, &indices); createCurveVerticesAndIndices(rim3dWellLogCurve, displayCoordTransform, wellPathClipBoundingBox, &vertices, &indices);
if (vertices.empty() || indices.empty()) if (vertices.empty() || indices.empty())
{ {
@@ -65,34 +69,54 @@ cvf::ref<cvf::DrawableGeo>
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
cvf::ref<cvf::DrawableGeo> Riv3dWellLogCurveGeometryGenerator::createGrid(const caf::DisplayCoordTransform* displayCoordTransform, cvf::ref<cvf::DrawableGeo> Riv3dWellLogCurveGeometryGenerator::createGrid(const caf::DisplayCoordTransform* displayCoordTransform,
const cvf::BoundingBox& wellPathClipBoundingBox,
const Rim3dWellLogCurve::DrawPlane drawPlane, const Rim3dWellLogCurve::DrawPlane drawPlane,
double gridIntervalSize) const double gridIntervalSize) const
{ {
CVF_ASSERT(gridIntervalSize > 0); CVF_ASSERT(gridIntervalSize > 0);
if (!wellPathGeometry()) return nullptr; if (!wellPathGeometry()) return nullptr;
if (!wellPathClipBoundingBox.isValid()) return nullptr;
RimWellPathCollection* wellPathCollection = nullptr;
m_wellPath->firstAncestorOrThisOfTypeAsserted(wellPathCollection);
std::vector<cvf::Vec3d> wellPathPoints = wellPathGeometry()->m_wellPathPoints; std::vector<cvf::Vec3d> wellPathPoints = wellPathGeometry()->m_wellPathPoints;
if (wellPathPoints.empty()) return nullptr; if (wellPathPoints.empty()) return nullptr;
const cvf::Vec3d globalDirection = (wellPathPoints.back() - wellPathPoints.front()).getNormalized(); size_t originalWellPathSize = wellPathPoints.size();
const cvf::Vec3d up(0, 0, 1);
if (wellPathCollection->wellPathClip)
{
double horizontalLengthAlongWellToClipPoint;
double maxZClipHeight = wellPathClipBoundingBox.max().z() + wellPathCollection->wellPathClipZDistance;
size_t indexToFirstVisibleSegment;
wellPathPoints =
RigWellPath::clipPolylineStartAboveZ(wellPathPoints,
maxZClipHeight,
&horizontalLengthAlongWellToClipPoint,
&indexToFirstVisibleSegment);
}
if (wellPathPoints.empty()) return nullptr;
std::vector<cvf::Vec3d> pointNormals;
std::vector<cvf::Vec3d> gridPoints; std::vector<cvf::Vec3d> gridPoints;
double firstMd = wellPathGeometry()->m_measuredDepths.front();
double lastMd = wellPathGeometry()->m_measuredDepths.back();
if (wellPathGeometry()->m_measuredDepths.empty()) return nullptr; if (wellPathGeometry()->m_measuredDepths.empty()) return nullptr;
double md = firstMd; size_t newStartIndex = originalWellPathSize - wellPathPoints.size();
while (md <= lastMd) double firstMd = wellPathGeometry()->m_measuredDepths.at(newStartIndex);
double lastMd = wellPathGeometry()->m_measuredDepths.back();
double md = lastMd;
while (md >= firstMd)
{ {
cvf::Vec3d point = wellPathGeometry()->interpolatedPointAlongWellPath(md); cvf::Vec3d point = wellPathGeometry()->interpolatedPointAlongWellPath(md);
gridPoints.push_back(point); gridPoints.push_back(point);
md += gridIntervalSize; md -= gridIntervalSize;
} }
std::vector<cvf::Vec3d> pointNormals;
pointNormals = calculatePointNormals(drawPlane, gridPoints); pointNormals = calculatePointNormals(drawPlane, gridPoints);
if (pointNormals.size() != gridPoints.size()) return nullptr; if (pointNormals.size() != gridPoints.size()) return nullptr;
@@ -103,7 +127,6 @@ cvf::ref<cvf::DrawableGeo> Riv3dWellLogCurveGeometryGenerator::createGrid(const
indices.reserve(gridPoints.size() * 2); indices.reserve(gridPoints.size() * 2);
cvf::uint counter = 0; cvf::uint counter = 0;
double offsetFromWellPathCenter = wellPathCenterToPlotStartOffset(); double offsetFromWellPathCenter = wellPathCenterToPlotStartOffset();
// Normal lines // Normal lines
@@ -118,7 +141,9 @@ cvf::ref<cvf::DrawableGeo> Riv3dWellLogCurveGeometryGenerator::createGrid(const
indices.push_back(counter++); indices.push_back(counter++);
} }
// calculateWellPathSegmentNormals returns normals for the whole well path. Erase the part which is clipped off
std::vector<cvf::Vec3d> wellPathSegmentNormals = calculateWellPathSegmentNormals(drawPlane); std::vector<cvf::Vec3d> wellPathSegmentNormals = calculateWellPathSegmentNormals(drawPlane);
wellPathSegmentNormals.erase(wellPathSegmentNormals.begin(), wellPathSegmentNormals.end() - wellPathPoints.size());
// Line along and close to well // Line along and close to well
for (size_t i = 0; i < wellPathPoints.size(); i++) for (size_t i = 0; i < wellPathPoints.size(); i++)
@@ -161,10 +186,13 @@ cvf::ref<cvf::DrawableGeo> Riv3dWellLogCurveGeometryGenerator::createGrid(const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const Rim3dWellLogCurve* rim3dWellLogCurve, void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const Rim3dWellLogCurve* rim3dWellLogCurve,
const caf::DisplayCoordTransform* displayCoordTransform, const caf::DisplayCoordTransform* displayCoordTransform,
const cvf::BoundingBox& wellPathClipBoundingBox,
std::vector<cvf::Vec3f>* vertices, std::vector<cvf::Vec3f>* vertices,
std::vector<cvf::uint>* indices) const std::vector<cvf::uint>* indices) const
{ {
if (!wellPathGeometry()) return; if (!wellPathGeometry()) return;
if (wellPathGeometry()->m_wellPathPoints.empty()) return;
if (!wellPathClipBoundingBox.isValid()) return;
std::vector<double> resultValues; std::vector<double> resultValues;
std::vector<double> mds; std::vector<double> mds;
@@ -173,17 +201,36 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const Rim
if (resultValues.empty()) return; if (resultValues.empty()) return;
CVF_ASSERT(resultValues.size() == mds.size()); CVF_ASSERT(resultValues.size() == mds.size());
cvf::Vec3d globalDirection = RimWellPathCollection* wellPathCollection = nullptr;
(wellPathGeometry()->m_wellPathPoints.back() - wellPathGeometry()->m_wellPathPoints.front()).getNormalized(); m_wellPath->firstAncestorOrThisOfTypeAsserted(wellPathCollection);
double maxZClipHeight = wellPathGeometry()->m_wellPathPoints.front().z();
if (wellPathCollection->wellPathClip)
{
maxZClipHeight = wellPathClipBoundingBox.max().z() + wellPathCollection->wellPathClipZDistance;
}
std::vector<cvf::Vec3d> interpolatedWellPathPoints; std::vector<cvf::Vec3d> interpolatedWellPathPoints;
interpolatedWellPathPoints.reserve(mds.size());
for (double md : mds) for (auto rit = mds.rbegin(); rit != mds.rend(); rit++)
{ {
interpolatedWellPathPoints.push_back(wellPathGeometry()->interpolatedPointAlongWellPath(md)); cvf::Vec3d point = wellPathGeometry()->interpolatedPointAlongWellPath(*rit);
if (point.z() > maxZClipHeight) break;
interpolatedWellPathPoints.push_back(point);
} }
if (interpolatedWellPathPoints.size() % 2 != 0)
{
interpolatedWellPathPoints.pop_back();
}
std::reverse(interpolatedWellPathPoints.begin(), interpolatedWellPathPoints.end());
if (interpolatedWellPathPoints.empty()) return;
resultValues.erase(resultValues.begin(), resultValues.end() - interpolatedWellPathPoints.size());
std::vector<cvf::Vec3d> pointNormals = calculatePointNormals(rim3dWellLogCurve->drawPlane(), interpolatedWellPathPoints); std::vector<cvf::Vec3d> pointNormals = calculatePointNormals(rim3dWellLogCurve->drawPlane(), interpolatedWellPathPoints);
if (interpolatedWellPathPoints.size() != pointNormals.size()) return; if (interpolatedWellPathPoints.size() != pointNormals.size()) return;
@@ -238,9 +285,12 @@ std::vector<cvf::Vec3d> Riv3dWellLogCurveGeometryGenerator::calculatePointNormal
std::vector<cvf::Vec3d> pointNormals; std::vector<cvf::Vec3d> pointNormals;
if (!wellPathGeometry()) return pointNormals; if (!wellPathGeometry()) return pointNormals;
if (points.empty()) return pointNormals;
pointNormals.reserve(points.size()); pointNormals.reserve(points.size());
const cvf::Vec3d globalDirection = (points.back() - points.front()).getNormalized(); const cvf::Vec3d globalDirection =
(wellPathGeometry()->m_wellPathPoints.back() - wellPathGeometry()->m_wellPathPoints.front()).getNormalized();
const cvf::Vec3d up(0, 0, 1); const cvf::Vec3d up(0, 0, 1);
for (const cvf::Vec3d point : points) for (const cvf::Vec3d point : points)
@@ -369,7 +419,7 @@ double Riv3dWellLogCurveGeometryGenerator::wellPathCenterToPlotStartOffset() con
{ {
double cellSize = m_gridView->ownerCase()->characteristicCellSize(); double cellSize = m_gridView->ownerCase()->characteristicCellSize();
return m_wellPath->wellPathRadius(cellSize) * 1.2; return m_wellPath->wellPathRadius(cellSize) * 2;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -377,7 +427,7 @@ double Riv3dWellLogCurveGeometryGenerator::wellPathCenterToPlotStartOffset() con
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
double Riv3dWellLogCurveGeometryGenerator::gridWidth() const double Riv3dWellLogCurveGeometryGenerator::gridWidth() const
{ {
return 100; return 400;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@@ -34,6 +34,11 @@ namespace caf
class DisplayCoordTransform; class DisplayCoordTransform;
} }
namespace cvf
{
class BoundingBox;
}
class RigWellPath; class RigWellPath;
class RimGridView; class RimGridView;
class RimWellPath; class RimWellPath;
@@ -45,15 +50,18 @@ public:
: m_wellPath(wellPath), m_gridView(gridView) {}; : m_wellPath(wellPath), m_gridView(gridView) {};
cvf::ref<cvf::DrawableGeo> createCurveLine(const caf::DisplayCoordTransform* displayCoordTransform, cvf::ref<cvf::DrawableGeo> createCurveLine(const caf::DisplayCoordTransform* displayCoordTransform,
const cvf::BoundingBox& wellPathClipBoundingBox,
const Rim3dWellLogCurve* rim3dWellLogCurve) const; const Rim3dWellLogCurve* rim3dWellLogCurve) const;
cvf::ref<cvf::DrawableGeo> createGrid(const caf::DisplayCoordTransform* displayCoordTransform, cvf::ref<cvf::DrawableGeo> createGrid(const caf::DisplayCoordTransform* displayCoordTransform,
const cvf::BoundingBox& wellPathClipBoundingBox,
const Rim3dWellLogCurve::DrawPlane drawPlane, const Rim3dWellLogCurve::DrawPlane drawPlane,
double gridIntervalSize) const; double gridIntervalSize) const;
private: private:
void createCurveVerticesAndIndices(const Rim3dWellLogCurve* rim3dWellLogCurve, void createCurveVerticesAndIndices(const Rim3dWellLogCurve* rim3dWellLogCurve,
const caf::DisplayCoordTransform* displayCoordTransform, const caf::DisplayCoordTransform* displayCoordTransform,
const cvf::BoundingBox& wellPathClipBoundingBox,
std::vector<cvf::Vec3f>* vertices, std::vector<cvf::Vec3f>* vertices,
std::vector<cvf::uint>* indices) const; std::vector<cvf::uint>* indices) const;

View File

@@ -26,6 +26,7 @@
#include "cafDisplayCoordTransform.h" #include "cafDisplayCoordTransform.h"
#include "cafEffectGenerator.h" #include "cafEffectGenerator.h"
#include "cvfBoundingBox.h"
#include "cvfColor3.h" #include "cvfColor3.h"
#include "cvfDrawableGeo.h" #include "cvfDrawableGeo.h"
#include "cvfModelBasicList.h" #include "cvfModelBasicList.h"
@@ -35,7 +36,8 @@
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
Riv3dWellLogPlanePartMgr::Riv3dWellLogPlanePartMgr(RimWellPath* wellPath, RimGridView* gridView) Riv3dWellLogPlanePartMgr::Riv3dWellLogPlanePartMgr(RimWellPath* wellPath, RimGridView* gridView)
:m_wellPath(wellPath), m_gridView(gridView) : m_wellPath(wellPath)
, m_gridView(gridView)
{ {
} }
@@ -44,8 +46,9 @@ Riv3dWellLogPlanePartMgr::Riv3dWellLogPlanePartMgr(RimWellPath* wellPath, RimGri
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList* model, void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList* model,
const caf::DisplayCoordTransform* displayCoordTransform, const caf::DisplayCoordTransform* displayCoordTransform,
std::vector<Rim3dWellLogCurve*> rim3dWellLogCurves) const cvf::BoundingBox& wellPathClipBoundingBox)
{ {
std::vector<Rim3dWellLogCurve*> rim3dWellLogCurves = m_wellPath->vectorOf3dWellLogCurves();
if (rim3dWellLogCurves.empty()) return; if (rim3dWellLogCurves.empty()) return;
if (m_wellPath.isNull()) return; if (m_wellPath.isNull()) return;
@@ -58,7 +61,8 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList*
{ {
if (!rim3dWellLogCurve->toggleState()) continue; if (!rim3dWellLogCurve->toggleState()) continue;
cvf::ref<cvf::Drawable> curveDrawable = m_3dWellLogCurveGeometryGenerator->createCurveLine(displayCoordTransform, rim3dWellLogCurve); cvf::ref<cvf::Drawable> curveDrawable =
m_3dWellLogCurveGeometryGenerator->createCurveLine(displayCoordTransform, wellPathClipBoundingBox, rim3dWellLogCurve);
if (curveDrawable.isNull() || !curveDrawable->boundingBox().isValid()) if (curveDrawable.isNull() || !curveDrawable->boundingBox().isValid())
{ {
@@ -95,7 +99,10 @@ cvf::ref<cvf::Part> Riv3dWellLogPlanePartMgr::createPart(cvf::Drawable* drawable
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* model, const caf::DisplayCoordTransform* displayCoordTransform, double gridIntervalSize) void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* model,
const caf::DisplayCoordTransform* displayCoordTransform,
const cvf::BoundingBox& wellPathClipBoundingBox,
double gridIntervalSize)
{ {
if (m_3dWellLogCurveGeometryGenerator.isNull()) if (m_3dWellLogCurveGeometryGenerator.isNull())
{ {
@@ -105,7 +112,8 @@ void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* model, con
caf::MeshEffectGenerator meshEffectGen(cvf::Color3f(0.4f, 0.4f, 0.4f)); caf::MeshEffectGenerator meshEffectGen(cvf::Color3f(0.4f, 0.4f, 0.4f));
{ {
cvf::ref<cvf::Drawable> gridHorizontalDrawable = m_3dWellLogCurveGeometryGenerator->createGrid(displayCoordTransform, Rim3dWellLogCurve::HORIZONTAL_LEFT, gridIntervalSize); cvf::ref<cvf::Drawable> gridHorizontalDrawable = m_3dWellLogCurveGeometryGenerator->createGrid(
displayCoordTransform, wellPathClipBoundingBox, Rim3dWellLogCurve::HORIZONTAL_LEFT, gridIntervalSize);
cvf::ref<cvf::Effect> effect = meshEffectGen.generateCachedEffect(); cvf::ref<cvf::Effect> effect = meshEffectGen.generateCachedEffect();
cvf::ref<cvf::Part> part = createPart(gridHorizontalDrawable.p(), effect.p()); cvf::ref<cvf::Part> part = createPart(gridHorizontalDrawable.p(), effect.p());
@@ -116,7 +124,8 @@ void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* model, con
} }
} }
{ {
cvf::ref<cvf::Drawable> gridHorizontalDrawable = m_3dWellLogCurveGeometryGenerator->createGrid(displayCoordTransform, Rim3dWellLogCurve::HORIZONTAL_RIGHT, gridIntervalSize); cvf::ref<cvf::Drawable> gridHorizontalDrawable = m_3dWellLogCurveGeometryGenerator->createGrid(
displayCoordTransform, wellPathClipBoundingBox, Rim3dWellLogCurve::HORIZONTAL_RIGHT, gridIntervalSize);
cvf::ref<cvf::Effect> effect = meshEffectGen.generateCachedEffect(); cvf::ref<cvf::Effect> effect = meshEffectGen.generateCachedEffect();
cvf::ref<cvf::Part> part = createPart(gridHorizontalDrawable.p(), effect.p()); cvf::ref<cvf::Part> part = createPart(gridHorizontalDrawable.p(), effect.p());

View File

@@ -33,7 +33,8 @@ namespace cvf
class Drawable; class Drawable;
class Effect; class Effect;
class Part; class Part;
} class BoundingBox;
} // namespace cvf
namespace caf namespace caf
{ {
@@ -51,13 +52,16 @@ public:
void append3dWellLogCurvesToModel(cvf::ModelBasicList* model, void append3dWellLogCurvesToModel(cvf::ModelBasicList* model,
const caf::DisplayCoordTransform* displayCoordTransform, const caf::DisplayCoordTransform* displayCoordTransform,
std::vector<Rim3dWellLogCurve*> rim3dWellLogCurves); const cvf::BoundingBox& wellPathClipBoundingBox);
void appendGridToModel(cvf::ModelBasicList* model, void appendGridToModel(cvf::ModelBasicList* model,
const caf::DisplayCoordTransform* displayCoordTransform, const caf::DisplayCoordTransform* displayCoordTransform,
const cvf::BoundingBox& wellPathClipBoundingBox,
double gridIntervalSize); double gridIntervalSize);
private: private:
cvf::ref<cvf::Part> createPart(cvf::Drawable* drawable, cvf::Effect* effect); cvf::ref<cvf::Part> createPart(cvf::Drawable* drawable, cvf::Effect* effect);
private: private:
cvf::ref<Riv3dWellLogCurveGeometryGenerator> m_3dWellLogCurveGeometryGenerator; cvf::ref<Riv3dWellLogCurveGeometryGenerator> m_3dWellLogCurveGeometryGenerator;

View File

@@ -542,16 +542,19 @@ void RivWellPathPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList*
if (!m_rimWellPath->rim3dWellLogCurveCollection()) return; if (!m_rimWellPath->rim3dWellLogCurveCollection()) return;
if (!m_rimWellPath->rim3dWellLogCurveCollection()->showPlot()) return; if (!m_rimWellPath->rim3dWellLogCurveCollection()->showPlot()) return;
if (m_rimWellPath->vectorOf3dWellLogCurves().empty()) return;
RimGridView* gridView = dynamic_cast<RimGridView*>(m_rimView.p()); RimGridView* gridView = dynamic_cast<RimGridView*>(m_rimView.p());
if (!gridView) return; if (!gridView) return;
m_3dWellLogCurvePartMgr = new Riv3dWellLogPlanePartMgr(m_rimWellPath, gridView); m_3dWellLogCurvePartMgr = new Riv3dWellLogPlanePartMgr(m_rimWellPath, gridView);
m_3dWellLogCurvePartMgr->append3dWellLogCurvesToModel(model, displayCoordTransform, m_rimWellPath->vectorOf3dWellLogCurves()); m_3dWellLogCurvePartMgr->append3dWellLogCurvesToModel(model,
displayCoordTransform,
wellPathClipBoundingBox);
if (m_rimWellPath->rim3dWellLogCurveCollection()->showGrid()) if (m_rimWellPath->rim3dWellLogCurveCollection()->showGrid())
{ {
m_3dWellLogCurvePartMgr->appendGridToModel(model, displayCoordTransform, 200); m_3dWellLogCurvePartMgr->appendGridToModel(model, displayCoordTransform, wellPathClipBoundingBox, 800);
} }
} }