diff --git a/ApplicationLibCode/ModelVisualization/RivWellPathPartMgr.cpp b/ApplicationLibCode/ModelVisualization/RivWellPathPartMgr.cpp index f501c2899f..ab705ee977 100644 --- a/ApplicationLibCode/ModelVisualization/RivWellPathPartMgr.cpp +++ b/ApplicationLibCode/ModelVisualization/RivWellPathPartMgr.cpp @@ -928,6 +928,10 @@ void RivWellPathPartMgr::buildWellPathParts( const caf::DisplayCoordTransform* d { auto geoDef = modeledWellPath->geometryDefinition(); + // A lateral gets its well path geometry from the parent well, and can have no active well targets + auto wellTargets = geoDef->activeWellTargets(); + if ( wellTargets.empty() ) return; + auto sphereColor = geoDef->sphereColor(); double sphereRadiusFactor = geoDef->sphereRadiusFactor(); @@ -935,8 +939,6 @@ void RivWellPathPartMgr::buildWellPathParts( const caf::DisplayCoordTransform* d cvf::ref vecRes = new cvf::Vec3fArray; cvf::ref colors = new cvf::Color3fArray; - auto wellTargets = geoDef->activeWellTargets(); - size_t pointCount = wellTargets.size(); vertices->reserve( pointCount ); vecRes->reserve( pointCount ); diff --git a/ApplicationLibCode/UnitTests/CMakeLists.txt b/ApplicationLibCode/UnitTests/CMakeLists.txt index 23f334b3c8..4fbd643d14 100644 --- a/ApplicationLibCode/UnitTests/CMakeLists.txt +++ b/ApplicationLibCode/UnitTests/CMakeLists.txt @@ -75,6 +75,7 @@ set(SOURCE_UNITTEST_FILES ${CMAKE_CURRENT_LIST_DIR}/RifPerforationIntervalReader-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellPathCompletions-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellPathValve-Test.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimWellPathGeometryDef-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RimDataFilterCollection-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCaseCollection-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RifActiveCellsReader-Test.cpp diff --git a/ApplicationLibCode/UnitTests/RimWellPathGeometryDef-Test.cpp b/ApplicationLibCode/UnitTests/RimWellPathGeometryDef-Test.cpp new file mode 100644 index 0000000000..959eb42458 --- /dev/null +++ b/ApplicationLibCode/UnitTests/RimWellPathGeometryDef-Test.cpp @@ -0,0 +1,50 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2026 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "gtest/gtest.h" + +#include "RimModeledWellPath.h" +#include "RimWellPathGeometryDef.h" +#include "Well/RigWellPath.h" + +//-------------------------------------------------------------------------------------------------- +/// A lateral gets its well path geometry from the parent well. The geometry is then long enough to be +/// visualized, even if the lateral has no active well targets. Visualization code must not assume that +/// a well path with geometry has at least one active well target. +//-------------------------------------------------------------------------------------------------- +TEST( RimWellPathGeometryDefTest, GeometryFromParentWellWithoutActiveTargets ) +{ + RimModeledWellPath wellPath; + + RimWellPathGeometryDef* geoDef = wellPath.geometryDefinition(); + ASSERT_TRUE( geoDef != nullptr ); + + // Mimic a lateral tied in to a parent well, see RimModeledWellPath::updateTieInLocationFromParentWell() + geoDef->setIsAttachedToParentWell( true ); + geoDef->setFixedWellPathPoints( { cvf::Vec3d( 0.0, 0.0, 0.0 ), cvf::Vec3d( 0.0, 0.0, -100.0 ) } ); + geoDef->setFixedMeasuredDepths( { 0.0, 100.0 } ); + + EXPECT_TRUE( geoDef->activeWellTargets().empty() ); + EXPECT_TRUE( geoDef->showSpheres() ); + + wellPath.createWellPathGeometry(); + + RigWellPath* wellPathGeometry = wellPath.wellPathGeometry(); + ASSERT_TRUE( wellPathGeometry != nullptr ); + EXPECT_GE( wellPathGeometry->wellPathPoints().size(), size_t( 2 ) ); +}