diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp index 8bd67f605e..ca31bd4d8e 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -47,33 +47,11 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList* m_3dWellLogCurveGeometryGenerator = new Riv3dWellLogCurveGeometryGenerator; - std::vector wellPathPoints = m_wellPathGeometry->m_wellPathPoints; - - std::vector vertices; - vertices.resize(wellPathPoints.size()); - - cvf::Mat4d transMat; - transMat.setTranslation(cvf::Vec3d(0, 0, 10)); - - for (size_t i = 0; i < wellPathPoints.size(); i++) - { - wellPathPoints[i].transformPoint(transMat); - vertices[i] = cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(wellPathPoints[i])); - } - - std::vector indices; - indices.resize((vertices.size() - 1) * 2); - - cvf::uint counter = 0; - for (size_t i = 0; i < indices.size(); i++) - { - indices[i] = counter; - if (i % 2 == 0) counter++; - } - + std::vector indices = createPolylineIndices(m_wellPathGeometry->m_wellPathPoints.size()); for (Rim3dWellLogCurve* rim3dWellLogCurve : rim3dWellLogCurves) { + std::vector vertices = createCurveVertices(rim3dWellLogCurve, displayCoordTransform); cvf::ref drawable = m_3dWellLogCurveGeometryGenerator->createDrawable(vertices, indices); caf::SurfaceEffectGenerator surfaceGen(cvf::Color4f(255, 0, 0, 0.5), caf::PO_1); @@ -89,3 +67,74 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList* } } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector Riv3dWellLogPlanePartMgr::createCurveVertices(const Rim3dWellLogCurve* rim3dWellLogCurve, + const caf::DisplayCoordTransform* displayCoordTransform) +{ + std::vector wellPathPoints = m_wellPathGeometry->m_wellPathPoints; + + std::vector vertices; + vertices.resize(wellPathPoints.size()); + + std::vector curveNormals; + curveNormals.reserve(wellPathPoints.size()); + + for (size_t i = 0; i < wellPathPoints.size() - 1; i++) + { + cvf::Vec3d wellPathSegment = wellPathPoints[i + 1] - wellPathPoints[i]; + + cvf::Vec3d normVec; + if (rim3dWellLogCurve->drawPlane() == Rim3dWellLogCurve::HORIZONTAL_LEFT) + { + normVec = -wellPathSegment.perpendicularVector(); + } + else + { + normVec = wellPathSegment.perpendicularVector(); + } + curveNormals.push_back((wellPathSegment ^ normVec).getNormalized()*30); + } + + cvf::Vec3d wellPathSegment = wellPathPoints[wellPathPoints.size()-1] - wellPathPoints[wellPathPoints.size() - 2]; + cvf::Vec3d normVec = wellPathSegment.perpendicularVector(); + curveNormals.push_back((wellPathSegment ^ normVec).getNormalized() * 30); + + for (size_t i = 0; i < curveNormals.size(); i++) + { + cvf::Mat4d transMat; + transMat.setTranslation(curveNormals[i]); + + vertices[i] = cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(wellPathPoints[i].getTransformedPoint(transMat))); + } + +// cvf::Mat4d transMat; +// transMat.setTranslation(cvf::Vec3d(0, 0, 10)); +// +// for (size_t i = 0; i < wellPathPoints.size(); i++) +// { +// vertices[i] = cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(wellPathPoints[i].getTransformedPoint(transMat))); +// } + + return vertices; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector Riv3dWellLogPlanePartMgr::createPolylineIndices(size_t vertexCount) +{ + std::vector indices; + indices.resize((vertexCount - 1) * 2); + + cvf::uint counter = 0; + for (size_t i = 0; i < indices.size(); i++) + { + indices[i] = counter; + if (i % 2 == 0) counter++; + } + + return indices; +} diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h index b3db1054bb..aff90e8f36 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h @@ -20,9 +20,14 @@ #include "cvfBase.h" #include "cvfObject.h" +#include "cvfVector3.h" #include "Rim3dWellLogCurve.h" +#include "cafPdmPointer.h" + +#include + namespace cvf { class ModelBasicList; @@ -45,6 +50,10 @@ public: void append3dWellLogCurvesToModel(cvf::ModelBasicList* model, const caf::DisplayCoordTransform* displayCoordTransform, std::vector rim3dWellLogCurves); +private: + std::vector createCurveVertices(const Rim3dWellLogCurve* rim3dWellLogCurve, + const caf::DisplayCoordTransform* displayCoordTransform); + std::vector createPolylineIndices(size_t vertexCount); private: cvf::ref m_3dWellLogCurveGeometryGenerator; diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp index 1b964f0fbf..403416b007 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp @@ -140,6 +140,14 @@ void Rim3dWellLogCurve::setPropertiesFromView(Rim3dView* view) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim3dWellLogCurve::DrawPlane Rim3dWellLogCurve::drawPlane() const +{ + return m_drawPlane(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h index 8e6e66b005..60d1779533 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h @@ -66,6 +66,8 @@ public: void setPropertiesFromView(Rim3dView* view); + DrawPlane drawPlane() const; + private: virtual caf::PdmFieldHandle* objectToggleField() override; virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;