3D Well Log Curve: Give Plane Part Mgr more responsibility

This commit is contained in:
Rebecca Cox 2018-03-21 15:32:03 +01:00
parent 1369b11e6e
commit 85cd8b0e1d
8 changed files with 133 additions and 135 deletions

View File

@ -116,8 +116,11 @@ cvf::ref<cvf::DrawableGeo> Riv3dWellLogCurveGeometryGenerator::createGrid(const
}
std::vector<cvf::Vec3d> pointNormals;
std::vector<cvf::Vec3d> closestPoints;
calculatePairsOfClosestPointsAlongWellPath(&closestPoints, gridPoints);
pointNormals = calculatePointNormals(drawPlane, gridPoints);
pointNormals = calculateLineSegmentNormals(drawPlane, closestPoints, LINE_SEGMENTS);
if (pointNormals.size() != gridPoints.size()) return nullptr;
std::vector<cvf::Vec3f> vertices;
@ -142,7 +145,7 @@ cvf::ref<cvf::DrawableGeo> Riv3dWellLogCurveGeometryGenerator::createGrid(const
}
// 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 = calculateLineSegmentNormals(drawPlane, wellPathGeometry()->m_wellPathPoints, POLYLINE);
wellPathSegmentNormals.erase(wellPathSegmentNormals.begin(), wellPathSegmentNormals.end() - wellPathPoints.size());
// Line along and close to well
@ -161,6 +164,7 @@ cvf::ref<cvf::DrawableGeo> Riv3dWellLogCurveGeometryGenerator::createGrid(const
{
vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(
wellPathPoints[i] + wellPathSegmentNormals[i] * (offsetFromWellPathCenter + gridWidth()))));
indices.push_back(counter);
indices.push_back(++counter);
}
@ -231,7 +235,10 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const Rim
resultValues.erase(resultValues.begin(), resultValues.end() - interpolatedWellPathPoints.size());
std::vector<cvf::Vec3d> pointNormals = calculatePointNormals(rim3dWellLogCurve->drawPlane(), interpolatedWellPathPoints);
std::vector<cvf::Vec3d> closestPoints;
calculatePairsOfClosestPointsAlongWellPath(&closestPoints, interpolatedWellPathPoints);
std::vector<cvf::Vec3d> pointNormals = calculateLineSegmentNormals(rim3dWellLogCurve->drawPlane(), closestPoints, LINE_SEGMENTS);
if (interpolatedWellPathPoints.size() != pointNormals.size()) return;
double maxResult = -HUGE_VAL;
@ -279,26 +286,38 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const Rim
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<cvf::Vec3d> Riv3dWellLogCurveGeometryGenerator::calculatePointNormals(Rim3dWellLogCurve::DrawPlane drawPlane,
const std::vector<cvf::Vec3d>& points) const
std::vector<cvf::Vec3d> Riv3dWellLogCurveGeometryGenerator::calculateLineSegmentNormals(Rim3dWellLogCurve::DrawPlane drawPlane,
const std::vector<cvf::Vec3d>& vertices,
VertexOrganization organization) const
{
std::vector<cvf::Vec3d> pointNormals;
if (!wellPathGeometry()) return pointNormals;
if (points.empty()) return pointNormals;
if (vertices.empty()) return pointNormals;
pointNormals.reserve(points.size());
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)
size_t intervalSize;
if (organization == LINE_SEGMENTS)
{
cvf::Vec3d p1 = cvf::Vec3d::UNDEFINED;
cvf::Vec3d p2 = cvf::Vec3d::UNDEFINED;
wellPathGeometry()->twoClosestPoints(point, &p1, &p2);
if (p1.isUndefined() || p2.isUndefined()) continue;
pointNormals.reserve(vertices.size() / 2);
intervalSize = 2;
}
else //organization == POLYLINE
{
pointNormals.reserve(vertices.size());
intervalSize = 1;
}
cvf::Vec3d normal;
for (size_t i = 0; i < vertices.size() - 1; i += intervalSize)
{
cvf::Vec3d p1 = vertices[i];
cvf::Vec3d p2 = vertices[i+1];
cvf::Vec3d vecAlongPath = (p2 - p1).getNormalized();
@ -318,7 +337,6 @@ std::vector<cvf::Vec3d> Riv3dWellLogCurveGeometryGenerator::calculatePointNormal
cvf::Vec3d Ey = (up ^ Ex).getNormalized();
cvf::Vec3d Ez = (Ex ^ Ey).getNormalized();
cvf::Vec3d normal;
switch (drawPlane)
{
@ -341,75 +359,12 @@ std::vector<cvf::Vec3d> Riv3dWellLogCurveGeometryGenerator::calculatePointNormal
pointNormals.push_back(normal);
}
return pointNormals;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<cvf::Vec3d>
Riv3dWellLogCurveGeometryGenerator::calculateWellPathSegmentNormals(Rim3dWellLogCurve::DrawPlane drawPlane) const
{
std::vector<cvf::Vec3d> wellSegmentNormals;
if (!wellPathGeometry()) return wellSegmentNormals;
std::vector<cvf::Vec3d> wellPathPoints = wellPathGeometry()->m_wellPathPoints;
const cvf::Vec3d globalDirection = (wellPathPoints.back() - wellPathPoints.front()).getNormalized();
const cvf::Vec3d up(0, 0, 1);
cvf::Vec3d normal;
for (size_t i = 0; i < wellPathPoints.size() - 1; i++)
if (organization == POLYLINE)
{
cvf::Vec3d p1 = wellPathPoints[i];
cvf::Vec3d p2 = wellPathPoints[i + 1];
if (p1.isUndefined() || p2.isUndefined()) continue;
cvf::Vec3d vecAlongPath = (p2 - p1).getNormalized();
double dotProduct = up * vecAlongPath;
cvf::Vec3d Ex;
if (cvf::Math::abs(dotProduct) > 0.7071)
{
Ex = globalDirection;
}
else
{
Ex = vecAlongPath;
}
cvf::Vec3d Ey = (up ^ Ex).getNormalized();
cvf::Vec3d Ez = (Ex ^ Ey).getNormalized();
switch (drawPlane)
{
case Rim3dWellLogCurve::HORIZONTAL_LEFT:
normal = -Ey;
break;
case Rim3dWellLogCurve::HORIZONTAL_RIGHT:
normal = Ey;
break;
case Rim3dWellLogCurve::VERTICAL_ABOVE:
normal = Ez;
break;
case Rim3dWellLogCurve::VERTICAL_BELOW:
normal = -Ez;
break;
default:
break;
}
wellSegmentNormals.push_back(normal);
pointNormals.push_back(normal);
}
wellSegmentNormals.push_back(normal);
return wellSegmentNormals;
return pointNormals;
}
//--------------------------------------------------------------------------------------------------
@ -417,6 +372,8 @@ std::vector<cvf::Vec3d>
//--------------------------------------------------------------------------------------------------
double Riv3dWellLogCurveGeometryGenerator::wellPathCenterToPlotStartOffset() const
{
if (!m_gridView) return 0;
double cellSize = m_gridView->ownerCase()->characteristicCellSize();
return m_wellPath->wellPathRadius(cellSize) * 2;
@ -427,7 +384,11 @@ double Riv3dWellLogCurveGeometryGenerator::wellPathCenterToPlotStartOffset() con
//--------------------------------------------------------------------------------------------------
double Riv3dWellLogCurveGeometryGenerator::gridWidth() const
{
return 400;
if (!m_gridView) return 0;
double cellSize = m_gridView->ownerCase()->characteristicCellSize();
return m_wellPath->wellPathRadius(cellSize) * 3;
}
//--------------------------------------------------------------------------------------------------
@ -437,3 +398,22 @@ const RigWellPath* Riv3dWellLogCurveGeometryGenerator::wellPathGeometry() const
{
return m_wellPath->wellPathGeometry();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Riv3dWellLogCurveGeometryGenerator::calculatePairsOfClosestPointsAlongWellPath(std::vector<cvf::Vec3d>* closestWellPathPoints, std::vector<cvf::Vec3d>& points) const
{
CVF_ASSERT(closestWellPathPoints != nullptr);
for (const cvf::Vec3d point : points)
{
cvf::Vec3d p1 = cvf::Vec3d::UNDEFINED;
cvf::Vec3d p2 = cvf::Vec3d::UNDEFINED;
wellPathGeometry()->twoClosestPoints(point, &p1, &p2);
if (p1.isUndefined() || p2.isUndefined()) continue;
closestWellPathPoints->push_back(p1);
closestWellPathPoints->push_back(p2);
}
}

View File

@ -47,10 +47,11 @@ class Riv3dWellLogCurveGeometryGenerator : public cvf::Object
{
public:
Riv3dWellLogCurveGeometryGenerator(RimWellPath* wellPath, RimGridView* gridView)
: m_wellPath(wellPath), m_gridView(gridView) {};
: m_wellPath(wellPath)
, m_gridView(gridView){};
cvf::ref<cvf::DrawableGeo> createCurveLine(const caf::DisplayCoordTransform* displayCoordTransform,
const cvf::BoundingBox& wellPathClipBoundingBox,
const cvf::BoundingBox& wellPathClipBoundingBox,
const Rim3dWellLogCurve* rim3dWellLogCurve) const;
cvf::ref<cvf::DrawableGeo> createGrid(const caf::DisplayCoordTransform* displayCoordTransform,
@ -58,6 +59,13 @@ public:
const Rim3dWellLogCurve::DrawPlane drawPlane,
double gridIntervalSize) const;
private:
enum VertexOrganization
{
LINE_SEGMENTS,
POLYLINE
};
private:
void createCurveVerticesAndIndices(const Rim3dWellLogCurve* rim3dWellLogCurve,
const caf::DisplayCoordTransform* displayCoordTransform,
@ -65,16 +73,18 @@ private:
std::vector<cvf::Vec3f>* vertices,
std::vector<cvf::uint>* indices) const;
std::vector<cvf::Vec3d> calculatePointNormals(Rim3dWellLogCurve::DrawPlane drawPlane,
const std::vector<cvf::Vec3d>& points) const;
std::vector<cvf::Vec3d> calculateWellPathSegmentNormals(Rim3dWellLogCurve::DrawPlane drawPlane) const;
std::vector<cvf::Vec3d> calculateLineSegmentNormals(Rim3dWellLogCurve::DrawPlane drawPlane,
const std::vector<cvf::Vec3d>& vertices,
VertexOrganization organization) const;
double wellPathCenterToPlotStartOffset() const;
double gridWidth() const;
const RigWellPath* wellPathGeometry() const;
void calculatePairsOfClosestPointsAlongWellPath(std::vector<cvf::Vec3d>* closestWellPathPoints,
std::vector<cvf::Vec3d>& points) const;
private:
caf::PdmPointer<RimWellPath> m_wellPath;
caf::PdmPointer<RimGridView> m_gridView;

View File

@ -18,6 +18,7 @@
#include "Riv3dWellLogPlanePartMgr.h"
#include "Rim3dWellLogCurveCollection.h"
#include "RimGridView.h"
#include "RimWellPath.h"
@ -41,6 +42,39 @@ Riv3dWellLogPlanePartMgr::Riv3dWellLogPlanePartMgr(RimWellPath* wellPath, RimGri
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Riv3dWellLogPlanePartMgr::appendPlaneToModel(cvf::ModelBasicList* model,
const caf::DisplayCoordTransform* displayCoordTransform,
const cvf::BoundingBox& wellPathClipBoundingBox)
{
if (m_wellPath.isNull()) return;
if (!m_wellPath->rim3dWellLogCurveCollection()) return;
if (!m_wellPath->rim3dWellLogCurveCollection()->showPlot()) return;
if (m_wellPath->rim3dWellLogCurveCollection()->vectorOf3dWellLogCurves().empty()) return;
append3dWellLogCurvesToModel(model, displayCoordTransform, wellPathClipBoundingBox);
if (m_wellPath->rim3dWellLogCurveCollection()->showGrid())
{
std::map<Rim3dWellLogCurve::DrawPlane, bool> drawPlanes;
for (Rim3dWellLogCurve* rim3dWellLogCurve : m_wellPath->rim3dWellLogCurveCollection()->vectorOf3dWellLogCurves())
{
drawPlanes[rim3dWellLogCurve->drawPlane()];
}
for (const std::pair<Rim3dWellLogCurve::DrawPlane, bool>& drawPlane : drawPlanes)
{
appendGridToModel(model, displayCoordTransform, wellPathClipBoundingBox, drawPlane.first, 400);
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -48,16 +82,16 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList*
const caf::DisplayCoordTransform* displayCoordTransform,
const cvf::BoundingBox& wellPathClipBoundingBox)
{
std::vector<Rim3dWellLogCurve*> rim3dWellLogCurves = m_wellPath->vectorOf3dWellLogCurves();
if (rim3dWellLogCurves.empty()) return;
if (m_wellPath.isNull()) return;
if (m_wellPath->rim3dWellLogCurveCollection()->vectorOf3dWellLogCurves().empty()) return;
if (m_3dWellLogCurveGeometryGenerator.isNull())
{
m_3dWellLogCurveGeometryGenerator = new Riv3dWellLogCurveGeometryGenerator(m_wellPath.p(), m_gridView);
}
for (Rim3dWellLogCurve* rim3dWellLogCurve : rim3dWellLogCurves)
for (Rim3dWellLogCurve* rim3dWellLogCurve : m_wellPath->rim3dWellLogCurveCollection()->vectorOf3dWellLogCurves())
{
if (!rim3dWellLogCurve->toggleState()) continue;
@ -99,11 +133,14 @@ cvf::ref<cvf::Part> Riv3dWellLogPlanePartMgr::createPart(cvf::Drawable* drawable
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* model,
const caf::DisplayCoordTransform* displayCoordTransform,
const cvf::BoundingBox& wellPathClipBoundingBox,
double gridIntervalSize)
void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* model,
const caf::DisplayCoordTransform* displayCoordTransform,
const cvf::BoundingBox& wellPathClipBoundingBox,
const Rim3dWellLogCurve::DrawPlane& drawPlane,
double gridIntervalSize)
{
if (m_wellPath.isNull()) return;
if (m_3dWellLogCurveGeometryGenerator.isNull())
{
m_3dWellLogCurveGeometryGenerator = new Riv3dWellLogCurveGeometryGenerator(m_wellPath.p(), m_gridView);
@ -113,19 +150,7 @@ void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList*
{
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());
if (part.notNull())
{
model->addPart(part.p());
}
}
{
cvf::ref<cvf::Drawable> gridHorizontalDrawable = m_3dWellLogCurveGeometryGenerator->createGrid(
displayCoordTransform, wellPathClipBoundingBox, Rim3dWellLogCurve::HORIZONTAL_RIGHT, gridIntervalSize);
displayCoordTransform, wellPathClipBoundingBox, drawPlane, gridIntervalSize);
cvf::ref<cvf::Effect> effect = meshEffectGen.generateCachedEffect();
cvf::ref<cvf::Part> part = createPart(gridHorizontalDrawable.p(), effect.p());

View File

@ -50,16 +50,19 @@ class Riv3dWellLogPlanePartMgr : public cvf::Object
public:
Riv3dWellLogPlanePartMgr(RimWellPath* wellPath, RimGridView* gridView);
void appendPlaneToModel(cvf::ModelBasicList* model,
const caf::DisplayCoordTransform* displayCoordTransform,
const cvf::BoundingBox& wellPathClipBoundingBox);
private:
void append3dWellLogCurvesToModel(cvf::ModelBasicList* model,
const caf::DisplayCoordTransform* displayCoordTransform,
const cvf::BoundingBox& wellPathClipBoundingBox);
void appendGridToModel(cvf::ModelBasicList* model,
const caf::DisplayCoordTransform* displayCoordTransform,
const cvf::BoundingBox& wellPathClipBoundingBox,
double gridIntervalSize);
private:
void appendGridToModel(cvf::ModelBasicList* model,
const caf::DisplayCoordTransform* displayCoordTransform,
const cvf::BoundingBox& wellPathClipBoundingBox,
const Rim3dWellLogCurve::DrawPlane& drawPlane,
double gridIntervalSize);
cvf::ref<cvf::Part> createPart(cvf::Drawable* drawable, cvf::Effect* effect);
private:

View File

@ -540,22 +540,11 @@ void RivWellPathPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList*
appendPerforationsToModel(model, timeStepIndex, displayCoordTransform, characteristicCellSize, false);
appendVirtualTransmissibilitiesToModel(model, timeStepIndex, displayCoordTransform, characteristicCellSize);
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,
wellPathClipBoundingBox);
if (m_rimWellPath->rim3dWellLogCurveCollection()->showGrid())
{
m_3dWellLogCurvePartMgr->appendGridToModel(model, displayCoordTransform, wellPathClipBoundingBox, 800);
}
m_3dWellLogPlanePartMgr = new Riv3dWellLogPlanePartMgr(m_rimWellPath, gridView);
m_3dWellLogPlanePartMgr->appendPlaneToModel(model, displayCoordTransform, wellPathClipBoundingBox);
}
//--------------------------------------------------------------------------------------------------

View File

@ -124,6 +124,6 @@ private:
cvf::ref<cvf::DrawableGeo> m_centerLineDrawable;
cvf::ref<cvf::Part> m_wellLabelPart;
cvf::ref<Riv3dWellLogPlanePartMgr> m_3dWellLogCurvePartMgr;
cvf::ref<Riv3dWellLogPlanePartMgr> m_3dWellLogPlanePartMgr;
cvf::ref<RivWellConnectionFactorPartMgr> m_wellConnectionFactorPartMgr;
};

View File

@ -809,14 +809,6 @@ void RimWellPath::add3dWellLogCurve(Rim3dWellLogCurve* rim3dWellLogCurve)
m_3dWellLogCurves->add3dWellLogCurve(rim3dWellLogCurve);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<Rim3dWellLogCurve*> RimWellPath::vectorOf3dWellLogCurves() const
{
return m_3dWellLogCurves->vectorOf3dWellLogCurves();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -80,7 +80,6 @@ public:
const RigWellPathFormations* formationsGeometry() const;
void add3dWellLogCurve(Rim3dWellLogCurve* rim3dWellLogCurve);
std::vector<Rim3dWellLogCurve*> vectorOf3dWellLogCurves() const;
Rim3dWellLogCurveCollection* rim3dWellLogCurveCollection() const;
virtual caf::PdmFieldHandle* userDescriptionField() override;