From 2e3ac5b02b4a4456a94584ed1d208c3e65e04d50 Mon Sep 17 00:00:00 2001 From: Jon Jenssen Date: Mon, 1 Aug 2022 15:42:26 +0200 Subject: [PATCH] Fix intersection depth filter limit calculations --- ...udedCurveIntersectionGeometryGenerator.cpp | 6 ++--- .../RivExtrudedCurveIntersectionPartMgr.cpp | 2 +- .../RimExtrudedCurveIntersection.cpp | 24 +++++++++---------- .../RimExtrudedCurveIntersection.h | 4 ++-- 4 files changed, 17 insertions(+), 19 deletions(-) diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionGeometryGenerator.cpp b/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionGeometryGenerator.cpp index cfc11611b9..f6fe15b6ae 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionGeometryGenerator.cpp +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionGeometryGenerator.cpp @@ -291,11 +291,9 @@ void RivExtrudedCurveIntersectionGeometryGenerator::calculateArrays() calculateLineSegementTransforms(); calculateTransformedPolyline(); - const double gridRadius = gridBBox.radius(); - // set up our horizontal cut planes - const double topDepth = -1.0 * m_intersection->upperFilterDepth( gridRadius ); - const double bottomDepth = -1.0 * m_intersection->lowerFilterDepth( gridRadius ); + const double topDepth = m_intersection->upperFilterDepth( gridBBox.max().z() ); + const double bottomDepth = m_intersection->lowerFilterDepth( gridBBox.min().z() ); std::array corners; gridBBox.cornerVertices( corners.data() ); diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.cpp b/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.cpp index cd65d860c6..e5ef915e91 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.cpp +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.cpp @@ -237,7 +237,7 @@ void RivExtrudedCurveIntersectionPartMgr::generatePartGeometry() if ( m_intersectionGenerator.isNull() ) return; if ( m_rimIntersection->depthFilterType() == RimIntersectionFilterEnum::INTERSECT_FILTER_BETWEEN && - ( m_rimIntersection->lowerFilterDepth( 1.0 ) <= m_rimIntersection->upperFilterDepth( 1.0 ) ) ) + ( m_rimIntersection->lowerFilterDepth( 1.0 ) >= m_rimIntersection->upperFilterDepth( 1.0 ) ) ) return; bool useBufferObjects = true; diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.cpp b/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.cpp index 25760249b8..81e86a44b1 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.cpp @@ -251,10 +251,10 @@ RimExtrudedCurveIntersection::RimExtrudedCurveIntersection() m_surfaceIntersections = new RimSurfaceIntersectionCollection; m_surfaceIntersections->objectChanged.connect( this, &RimExtrudedCurveIntersection::onSurfaceIntersectionsChanged ); - CAF_PDM_InitField( &m_depthUpperThreshold, "UpperThreshold", 2000.0, "Upper Threshold" ); + CAF_PDM_InitField( &m_depthUpperThreshold, "UpperThreshold", 0.0, "Upper Threshold" ); m_depthUpperThreshold.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); - CAF_PDM_InitField( &m_depthLowerThreshold, "LowerThreshold", 3000.0, "Lower Threshold" ); + CAF_PDM_InitField( &m_depthLowerThreshold, "LowerThreshold", 300000.0, "Lower Threshold" ); m_depthLowerThreshold.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); CAF_PDM_InitFieldNoDefault( &m_depthFilterType, "DepthFilter", "Depth Filter" ); @@ -313,7 +313,7 @@ void RimExtrudedCurveIntersection::setName( const QString& newName ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -double RimExtrudedCurveIntersection::upperFilterDepth( double sceneRadius ) const +double RimExtrudedCurveIntersection::upperFilterDepth( double upperGridLimit ) const { if ( m_depthThresholdOverridden ) { @@ -321,12 +321,12 @@ double RimExtrudedCurveIntersection::upperFilterDepth( double sceneRadius ) cons { case RimIntersectionFilterEnum::INTERSECT_FILTER_BELOW: case RimIntersectionFilterEnum::INTERSECT_FILTER_BETWEEN: - return m_collectionUpperThreshold; + return -m_collectionUpperThreshold; case RimIntersectionFilterEnum::INTERSECT_FILTER_ABOVE: case RimIntersectionFilterEnum::INTERSECT_FILTER_NONE: default: - return -sceneRadius; + return upperGridLimit; } } @@ -334,12 +334,12 @@ double RimExtrudedCurveIntersection::upperFilterDepth( double sceneRadius ) cons { case RimIntersectionFilterEnum::INTERSECT_FILTER_BELOW: case RimIntersectionFilterEnum::INTERSECT_FILTER_BETWEEN: - return m_depthUpperThreshold; + return -m_depthUpperThreshold; case RimIntersectionFilterEnum::INTERSECT_FILTER_ABOVE: case RimIntersectionFilterEnum::INTERSECT_FILTER_NONE: default: - return -sceneRadius; + return upperGridLimit; } } @@ -358,7 +358,7 @@ RimIntersectionFilterEnum RimExtrudedCurveIntersection::depthFilterType() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -double RimExtrudedCurveIntersection::lowerFilterDepth( double sceneRadius ) const +double RimExtrudedCurveIntersection::lowerFilterDepth( double lowerGridLimit ) const { if ( m_depthThresholdOverridden ) { @@ -366,12 +366,12 @@ double RimExtrudedCurveIntersection::lowerFilterDepth( double sceneRadius ) cons { case RimIntersectionFilterEnum::INTERSECT_FILTER_ABOVE: case RimIntersectionFilterEnum::INTERSECT_FILTER_BETWEEN: - return m_collectionLowerThreshold; + return -m_collectionLowerThreshold; case RimIntersectionFilterEnum::INTERSECT_FILTER_BELOW: case RimIntersectionFilterEnum::INTERSECT_FILTER_NONE: default: - return sceneRadius; + return lowerGridLimit; } } @@ -379,12 +379,12 @@ double RimExtrudedCurveIntersection::lowerFilterDepth( double sceneRadius ) cons { case RimIntersectionFilterEnum::INTERSECT_FILTER_ABOVE: case RimIntersectionFilterEnum::INTERSECT_FILTER_BETWEEN: - return m_depthLowerThreshold; + return -m_depthLowerThreshold; case RimIntersectionFilterEnum::INTERSECT_FILTER_BELOW: case RimIntersectionFilterEnum::INTERSECT_FILTER_NONE: default: - return sceneRadius; + return lowerGridLimit; } } diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.h b/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.h index d1a0a78393..be726af8db 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.h +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimExtrudedCurveIntersection.h @@ -78,8 +78,8 @@ public: QString name() const override; void setName( const QString& newName ); - double upperFilterDepth( double sceneRadius ) const; - double lowerFilterDepth( double sceneRadius ) const; + double upperFilterDepth( double upperGridLimit ) const; + double lowerFilterDepth( double lowerGridLimit ) const; RimIntersectionFilterEnum depthFilterType() const; void setDepthOverride( bool collectionOverride );