diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp index 961b8bb55f..055a9708c2 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.cpp @@ -74,7 +74,7 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const std::vector 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); @@ -104,14 +104,15 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const cvf::uint counter = 0; - double offsetFromWellPathCenter = wellPathRadius()*1.2; - double gridWidth = 100; + double offsetFromWellPathCenter = wellPathCenterToPlotStartOffset(); // Normal lines for (size_t i = 0; i < pointNormals.size(); i++) { - vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(gridPoints[i] + pointNormals[i] * offsetFromWellPathCenter))); - vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(gridPoints[i] + pointNormals[i] * (offsetFromWellPathCenter+gridWidth)))); + vertices.push_back(cvf::Vec3f( + displayCoordTransform->transformToDisplayCoord(gridPoints[i] + pointNormals[i] * offsetFromWellPathCenter))); + vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord( + gridPoints[i] + pointNormals[i] * (offsetFromWellPathCenter + gridWidth())))); indices.push_back(counter++); indices.push_back(counter++); @@ -122,7 +123,8 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const // Line along and close to well for (size_t i = 0; i < wellPathPoints.size(); i++) { - vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(wellPathPoints[i] + wellPathSegmentNormals[i] * offsetFromWellPathCenter))); + vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord( + wellPathPoints[i] + wellPathSegmentNormals[i] * offsetFromWellPathCenter))); indices.push_back(counter); indices.push_back(++counter); } @@ -132,7 +134,8 @@ cvf::ref Riv3dWellLogCurveGeometryGenerator::createGrid(const // Line along and far away from well for (size_t i = 0; i < wellPathPoints.size(); i++) { - vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(wellPathPoints[i] + wellPathSegmentNormals[i] * (offsetFromWellPathCenter + gridWidth)))); + vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord( + wellPathPoints[i] + wellPathSegmentNormals[i] * (offsetFromWellPathCenter + gridWidth())))); indices.push_back(counter); indices.push_back(++counter); } @@ -197,26 +200,20 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const Rim vertices->resize(interpolatedWellPathPoints.size()); - double range = maxResult - minResult; - double offset = wellPathRadius()*1.2; - double factor = 2 * offset / range; - - if (minResult < 0) - { - offset += cvf::Math::abs(minResult * factor); - } + double plotRangeToResultRangeFactor = gridWidth() / (maxResult - minResult); + double offsetFromWellPathCenter = wellPathCenterToPlotStartOffset(); for (size_t i = 0; i < pointNormals.size(); i++) { - cvf::Vec3d result(0, 0, 0); + double scaledResult = 0; if (RigCurveDataTools::isValidValue(resultValues[i], false)) { - result = resultValues[i] * factor * pointNormals[i]; + scaledResult = offsetFromWellPathCenter + (resultValues[i] - minResult) * plotRangeToResultRangeFactor; } (*vertices)[i] = cvf::Vec3f( - displayCoordTransform->transformToDisplayCoord(interpolatedWellPathPoints[i] + pointNormals[i] * offset + result)); + displayCoordTransform->transformToDisplayCoord(interpolatedWellPathPoints[i] + scaledResult * pointNormals[i])); } std::vector> valuesIntervals = @@ -239,7 +236,7 @@ std::vector Riv3dWellLogCurveGeometryGenerator::calculatePointNormal const std::vector& points) const { std::vector pointNormals; - + if (!wellPathGeometry()) return pointNormals; pointNormals.reserve(points.size()); @@ -275,20 +272,20 @@ std::vector Riv3dWellLogCurveGeometryGenerator::calculatePointNormal 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; + 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; } pointNormals.push_back(normal); @@ -298,9 +295,10 @@ std::vector Riv3dWellLogCurveGeometryGenerator::calculatePointNormal } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -std::vector Riv3dWellLogCurveGeometryGenerator::calculateWellPathSegmentNormals(Rim3dWellLogCurve::DrawPlane drawPlane) const +std::vector + Riv3dWellLogCurveGeometryGenerator::calculateWellPathSegmentNormals(Rim3dWellLogCurve::DrawPlane drawPlane) const { std::vector wellSegmentNormals; @@ -312,12 +310,12 @@ std::vector Riv3dWellLogCurveGeometryGenerator::calculateWellPathSeg const cvf::Vec3d up(0, 0, 1); cvf::Vec3d normal; - - for (size_t i = 0; i < wellPathPoints.size()-1; i++) + + for (size_t i = 0; i < wellPathPoints.size() - 1; i++) { cvf::Vec3d p1 = wellPathPoints[i]; cvf::Vec3d p2 = wellPathPoints[i + 1]; - + if (p1.isUndefined() || p2.isUndefined()) continue; cvf::Vec3d vecAlongPath = (p2 - p1).getNormalized(); @@ -338,23 +336,22 @@ std::vector Riv3dWellLogCurveGeometryGenerator::calculateWellPathSeg 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; + 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); @@ -366,17 +363,25 @@ std::vector Riv3dWellLogCurveGeometryGenerator::calculateWellPathSeg } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -double Riv3dWellLogCurveGeometryGenerator::wellPathRadius() const +double Riv3dWellLogCurveGeometryGenerator::wellPathCenterToPlotStartOffset() const { double cellSize = m_gridView->ownerCase()->characteristicCellSize(); - return m_wellPath->wellPathRadius(cellSize); + return m_wellPath->wellPathRadius(cellSize) * 1.2; } //-------------------------------------------------------------------------------------------------- -/// +/// +//-------------------------------------------------------------------------------------------------- +double Riv3dWellLogCurveGeometryGenerator::gridWidth() const +{ + return 100; +} + +//-------------------------------------------------------------------------------------------------- +/// //-------------------------------------------------------------------------------------------------- const RigWellPath* Riv3dWellLogCurveGeometryGenerator::wellPathGeometry() const { diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h index 2376f78645..17ec52a37f 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeomertyGenerator.h @@ -62,7 +62,8 @@ private: std::vector calculateWellPathSegmentNormals(Rim3dWellLogCurve::DrawPlane drawPlane) const; - double wellPathRadius() const; + double wellPathCenterToPlotStartOffset() const; + double gridWidth() const; const RigWellPath* wellPathGeometry() const; diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp index a763f5fba4..78516d3cd4 100644 --- a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -49,7 +49,10 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurvesToModel(cvf::ModelBasicList* if (rim3dWellLogCurves.empty()) return; if (m_wellPath.isNull()) return; - m_3dWellLogCurveGeometryGenerator = new Riv3dWellLogCurveGeometryGenerator(m_wellPath.p(), m_gridView); + if (m_3dWellLogCurveGeometryGenerator.isNull()) + { + m_3dWellLogCurveGeometryGenerator = new Riv3dWellLogCurveGeometryGenerator(m_wellPath.p(), m_gridView); + } for (Rim3dWellLogCurve* rim3dWellLogCurve : rim3dWellLogCurves) { @@ -94,7 +97,10 @@ cvf::ref Riv3dWellLogPlanePartMgr::createPart(cvf::Drawable* drawable //-------------------------------------------------------------------------------------------------- void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList* model, const caf::DisplayCoordTransform* displayCoordTransform, double gridIntervalSize) { - if (m_3dWellLogCurveGeometryGenerator.isNull()) return; + if (m_3dWellLogCurveGeometryGenerator.isNull()) + { + m_3dWellLogCurveGeometryGenerator = new Riv3dWellLogCurveGeometryGenerator(m_wellPath.p(), m_gridView); + } caf::MeshEffectGenerator meshEffectGen(cvf::Color3f(0.4f, 0.4f, 0.4f));