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
commit 203677e837
5 changed files with 116 additions and 42 deletions

View File

@ -21,6 +21,7 @@
#include "RimCase.h"
#include "RimGridView.h"
#include "RimWellPath.h"
#include "RimWellPathCollection.h"
#include "RigCurveDataTools.h"
#include "RigWellPath.h"
@ -28,6 +29,8 @@
#include "cafDisplayCoordTransform.h"
#include "cvfPrimitiveSetIndexedUInt.h"
#include "cvfBoundingBox.h"
#include <cmath>
//--------------------------------------------------------------------------------------------------
@ -35,12 +38,13 @@
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::DrawableGeo>
Riv3dWellLogCurveGeometryGenerator::createCurveLine(const caf::DisplayCoordTransform* displayCoordTransform,
const cvf::BoundingBox& wellPathClipBoundingBox,
const Rim3dWellLogCurve* rim3dWellLogCurve) const
{
std::vector<cvf::Vec3f> vertices;
std::vector<cvf::uint> indices;
createCurveVerticesAndIndices(rim3dWellLogCurve, displayCoordTransform, &vertices, &indices);
createCurveVerticesAndIndices(rim3dWellLogCurve, displayCoordTransform, wellPathClipBoundingBox, &vertices, &indices);
if (vertices.empty() || indices.empty())
{
@ -65,34 +69,54 @@ cvf::ref<cvf::DrawableGeo>
///
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::DrawableGeo> Riv3dWellLogCurveGeometryGenerator::createGrid(const caf::DisplayCoordTransform* displayCoordTransform,
const cvf::BoundingBox& wellPathClipBoundingBox,
const Rim3dWellLogCurve::DrawPlane drawPlane,
double gridIntervalSize) const
{
CVF_ASSERT(gridIntervalSize > 0);
if (!wellPathGeometry()) return nullptr;
if (!wellPathClipBoundingBox.isValid()) return nullptr;
RimWellPathCollection* wellPathCollection = nullptr;
m_wellPath->firstAncestorOrThisOfTypeAsserted(wellPathCollection);
std::vector<cvf::Vec3d> wellPathPoints = wellPathGeometry()->m_wellPathPoints;
if (wellPathPoints.empty()) return nullptr;
const cvf::Vec3d globalDirection = (wellPathPoints.back() - wellPathPoints.front()).getNormalized();
const cvf::Vec3d up(0, 0, 1);
size_t originalWellPathSize = wellPathPoints.size();
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;
double firstMd = wellPathGeometry()->m_measuredDepths.front();
double lastMd = wellPathGeometry()->m_measuredDepths.back();
if (wellPathGeometry()->m_measuredDepths.empty()) return nullptr;
double md = firstMd;
while (md <= lastMd)
size_t newStartIndex = originalWellPathSize - wellPathPoints.size();
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);
gridPoints.push_back(point);
md += gridIntervalSize;
md -= gridIntervalSize;
}
std::vector<cvf::Vec3d> pointNormals;
pointNormals = calculatePointNormals(drawPlane, gridPoints);
if (pointNormals.size() != gridPoints.size()) return nullptr;
@ -103,7 +127,6 @@ cvf::ref<cvf::DrawableGeo> Riv3dWellLogCurveGeometryGenerator::createGrid(const
indices.reserve(gridPoints.size() * 2);
cvf::uint counter = 0;
double offsetFromWellPathCenter = wellPathCenterToPlotStartOffset();
// Normal lines
@ -118,7 +141,9 @@ cvf::ref<cvf::DrawableGeo> Riv3dWellLogCurveGeometryGenerator::createGrid(const
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);
wellPathSegmentNormals.erase(wellPathSegmentNormals.begin(), wellPathSegmentNormals.end() - wellPathPoints.size());
// Line along and close to well
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,
const caf::DisplayCoordTransform* displayCoordTransform,
const cvf::BoundingBox& wellPathClipBoundingBox,
std::vector<cvf::Vec3f>* vertices,
std::vector<cvf::uint>* indices) const
{
if (!wellPathGeometry()) return;
if (wellPathGeometry()->m_wellPathPoints.empty()) return;
if (!wellPathClipBoundingBox.isValid()) return;
std::vector<double> resultValues;
std::vector<double> mds;
@ -173,17 +201,36 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const Rim
if (resultValues.empty()) return;
CVF_ASSERT(resultValues.size() == mds.size());
cvf::Vec3d globalDirection =
(wellPathGeometry()->m_wellPathPoints.back() - wellPathGeometry()->m_wellPathPoints.front()).getNormalized();
RimWellPathCollection* wellPathCollection = nullptr;
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;
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);
if (interpolatedWellPathPoints.size() != pointNormals.size()) return;
@ -201,7 +248,7 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const Rim
vertices->resize(interpolatedWellPathPoints.size());
double plotRangeToResultRangeFactor = gridWidth() / (maxResult - minResult);
double offsetFromWellPathCenter = wellPathCenterToPlotStartOffset();
double offsetFromWellPathCenter = wellPathCenterToPlotStartOffset();
for (size_t i = 0; i < pointNormals.size(); i++)
{
@ -238,9 +285,12 @@ std::vector<cvf::Vec3d> Riv3dWellLogCurveGeometryGenerator::calculatePointNormal
std::vector<cvf::Vec3d> pointNormals;
if (!wellPathGeometry()) return pointNormals;
if (points.empty()) return pointNormals;
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);
for (const cvf::Vec3d point : points)
@ -369,7 +419,7 @@ double Riv3dWellLogCurveGeometryGenerator::wellPathCenterToPlotStartOffset() con
{
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
{
return 100;
return 400;
}
//--------------------------------------------------------------------------------------------------

View File

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

View File

@ -26,6 +26,7 @@
#include "cafDisplayCoordTransform.h"
#include "cafEffectGenerator.h"
#include "cvfBoundingBox.h"
#include "cvfColor3.h"
#include "cvfDrawableGeo.h"
#include "cvfModelBasicList.h"
@ -35,7 +36,8 @@
///
//--------------------------------------------------------------------------------------------------
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,
const caf::DisplayCoordTransform* displayCoordTransform,
std::vector<Rim3dWellLogCurve*> rim3dWellLogCurves)
const cvf::BoundingBox& wellPathClipBoundingBox)
{
std::vector<Rim3dWellLogCurve*> rim3dWellLogCurves = m_wellPath->vectorOf3dWellLogCurves();
if (rim3dWellLogCurves.empty()) return;
if (m_wellPath.isNull()) return;
@ -57,8 +60,9 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList*
for (Rim3dWellLogCurve* rim3dWellLogCurve : rim3dWellLogCurves)
{
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())
{
@ -66,7 +70,7 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList*
}
caf::MeshEffectGenerator meshEffectGen(cvf::Color3f(0.9f, 0.0f, 0.0f));
cvf::ref<cvf::Effect> effect = meshEffectGen.generateCachedEffect();
cvf::ref<cvf::Effect> effect = meshEffectGen.generateCachedEffect();
cvf::ref<cvf::Part> part = new cvf::Part;
part->setDrawable(curveDrawable.p());
@ -93,9 +97,12 @@ 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())
{
@ -105,10 +112,11 @@ void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* model, con
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::Part> part = createPart(gridHorizontalDrawable.p(), effect.p());
cvf::ref<cvf::Part> part = createPart(gridHorizontalDrawable.p(), effect.p());
if (part.notNull())
{
@ -116,10 +124,11 @@ 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::Part> part = createPart(gridHorizontalDrawable.p(), effect.p());
cvf::ref<cvf::Part> part = createPart(gridHorizontalDrawable.p(), effect.p());
if (part.notNull())
{

View File

@ -29,15 +29,16 @@
namespace cvf
{
class ModelBasicList;
class Drawable;
class Effect;
class Part;
}
class ModelBasicList;
class Drawable;
class Effect;
class Part;
class BoundingBox;
} // namespace cvf
namespace caf
{
class DisplayCoordTransform;
class DisplayCoordTransform;
}
class RimGridView;
@ -49,15 +50,18 @@ class Riv3dWellLogPlanePartMgr : public cvf::Object
public:
Riv3dWellLogPlanePartMgr(RimWellPath* wellPath, RimGridView* gridView);
void append3dWellLogCurvesToModel(cvf::ModelBasicList* model,
void append3dWellLogCurvesToModel(cvf::ModelBasicList* model,
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,
double gridIntervalSize);
const cvf::BoundingBox& wellPathClipBoundingBox,
double gridIntervalSize);
private:
cvf::ref<cvf::Part> createPart(cvf::Drawable* drawable, cvf::Effect* effect);
private:
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()->showPlot()) return;
if (m_rimWellPath->vectorOf3dWellLogCurves().empty()) return;
RimGridView* gridView = dynamic_cast<RimGridView*>(m_rimView.p());
if (!gridView) return;
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())
{
m_3dWellLogCurvePartMgr->appendGridToModel(model, displayCoordTransform, 200);
m_3dWellLogCurvePartMgr->appendGridToModel(model, displayCoordTransform, wellPathClipBoundingBox, 800);
}
}