From 622e49fe69b9341b6cc161da84c1e31387340a60 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 4 Dec 2015 12:05:06 +0100 Subject: [PATCH] (#404) Compute well segment index from triangle index --- .../RivPipeGeometryGenerator.cpp | 23 ++++++++++++++- .../RivPipeGeometryGenerator.h | 13 +++++---- .../ModelVisualization/RivWellPathPartMgr.cpp | 28 +++++++++++++++++-- .../ModelVisualization/RivWellPathPartMgr.h | 3 +- 4 files changed, 58 insertions(+), 9 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivPipeGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/RivPipeGeometryGenerator.cpp index 19bff35595..71b1404ddc 100644 --- a/ApplicationCode/ModelVisualization/RivPipeGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/RivPipeGeometryGenerator.cpp @@ -1,6 +1,8 @@ ///////////////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS +// Copyright (C) Statoil ASA +// Copyright (C) Ceetron Solutions AS +// Copyright (C) 2011-2012 Ceetron AS // // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -35,6 +37,7 @@ RivPipeGeometryGenerator::RivPipeGeometryGenerator() m_crossSectionNodeCount = 8; m_minimumBendAngle = 80.0; m_bendScalingFactor = 0.00001; + m_firstSegmentIndex = 0; } //-------------------------------------------------------------------------------------------------- @@ -582,3 +585,21 @@ void RivPipeGeometryGenerator::clearComputedData() m_filteredPipeSegmentToResult.clear(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RivPipeGeometryGenerator::segmentIndexFromTriangleIndex(size_t triangleIndex) const +{ + size_t filteredIndex = triangleIndex / (m_crossSectionNodeCount * 2); + + return filteredIndex + m_firstSegmentIndex; +} + +//-------------------------------------------------------------------------------------------------- +/// Well pipes are clipped, set index to first segment in visible well path +//-------------------------------------------------------------------------------------------------- +void RivPipeGeometryGenerator::setFirstSegmentIndex(size_t segmentIndex) +{ + m_firstSegmentIndex = segmentIndex; +} + diff --git a/ApplicationCode/ModelVisualization/RivPipeGeometryGenerator.h b/ApplicationCode/ModelVisualization/RivPipeGeometryGenerator.h index 40a392ada8..657d5a15b2 100644 --- a/ApplicationCode/ModelVisualization/RivPipeGeometryGenerator.h +++ b/ApplicationCode/ModelVisualization/RivPipeGeometryGenerator.h @@ -1,6 +1,8 @@ ///////////////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS +// Copyright (C) Statoil ASA +// Copyright (C) Ceetron Solutions AS +// Copyright (C) 2011-2012 Ceetron AS // // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -18,8 +20,6 @@ #pragma once -//class RivPipeQuadToSegmentMapper; - class RivPipeGeometryGenerator : public cvf::Object { public: @@ -31,6 +31,7 @@ public: // Pipe bends with a opening angle below given angle is modified with extra bend coordinates void setMinimumBendAngle(double degrees); + // Scaling factor used to control how far from original pipe position the extra bend coordinates are located // This will affect how sharp or smooth bend will appear void setBendScalingFactor(double scaleFactor); @@ -46,6 +47,9 @@ public: void pipeSurfaceTextureCoords(cvf::Vec2fArray* textureCoords, const std::vector& segmentResults, const cvf::ScalarMapper* mapper) const; void centerlineTextureCoords(cvf::Vec2fArray* textureCoords, const std::vector& segmentResults, const cvf::ScalarMapper* mapper) const; + void setFirstSegmentIndex(size_t segmentIndex); + size_t segmentIndexFromTriangleIndex(size_t triangleIndex) const; + private: void clearComputedData(); void updateFilteredPipeCenterCoords(); @@ -72,8 +76,7 @@ private: // Map from generated cylinder segments to pipe result indices std::vector m_filteredPipeSegmentToResult; - // TODO: implement - //RivPipeQuadToSegmentMapper* m_quadToSegmentMapper; + size_t m_firstSegmentIndex; double m_radius; double m_minimumBendAngle; diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp index e9332d80b6..f390936e24 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp @@ -114,13 +114,29 @@ void RivWellPathPartMgr::buildWellPathParts(cvf::Vec3d displayModelOffset, doubl cvf::ref cvfCoords = new cvf::Vec3dArray; if (wellPathCollection->wellPathClip) { - std::vector clippedPoints; + size_t firstVisibleSegmentIndex = cvf::UNDEFINED_SIZE_T; for (size_t idx = 0; idx < wellPathGeometry->m_wellPathPoints.size(); idx++) { cvf::Vec3d point = wellPathGeometry->m_wellPathPoints[idx]; if (point.z() < (wellPathClipBoundingBox.max().z() + wellPathCollection->wellPathClipZDistance)) - clippedPoints.push_back(point); + { + firstVisibleSegmentIndex = idx; + break; + } } + + std::vector clippedPoints; + + if (firstVisibleSegmentIndex != cvf::UNDEFINED_SIZE_T) + { + for (size_t idx = firstVisibleSegmentIndex; idx < wellPathGeometry->m_wellPathPoints.size(); idx++) + { + clippedPoints.push_back(wellPathGeometry->m_wellPathPoints[idx]); + } + + pbd.m_pipeGeomGenerator->setFirstSegmentIndex(firstVisibleSegmentIndex); + } + if (clippedPoints.size() < 2) return; textPosition = clippedPoints[0]; @@ -274,3 +290,11 @@ void RivWellPathPartMgr::clearAllBranchData() m_pipeBranchData.m_centerLinePart = NULL; m_pipeBranchData.m_centerLineDrawable = NULL; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RivWellPathPartMgr::segmentIndexFromTriangleIndex(size_t triangleIndex) +{ + return m_pipeBranchData.m_pipeGeomGenerator->segmentIndexFromTriangleIndex(triangleIndex); +} diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h index 16828f9123..18e8e1c646 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h @@ -50,6 +50,8 @@ public: void appendStaticGeometryPartsToModel(cvf::ModelBasicList* model, cvf::Vec3d displayModelOffset, double characteristicCellSize, cvf::BoundingBox wellPathClipBoundingBox); + size_t segmentIndexFromTriangleIndex(size_t triangleIndex); + private: caf::PdmPointer m_rimWellPath; @@ -58,7 +60,6 @@ private: void buildWellPathParts(cvf::Vec3d displayModelOffset, double characteristicCellSize, cvf::BoundingBox wellPathClipBoundingBox); void clearAllBranchData(); - struct RivPipeBranchData { cvf::ref m_pipeGeomGenerator;