-
Notifications
You must be signed in to change notification settings - Fork 104
#14797 Add support for detection of N local maximum locations in a contour map #14798
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
fdb4d86
#14797 Add RigContourMapPeakFinder to find local maxima in contour maps
magnesj 5137366
#14797 Polygons: Add sphere display options and view update helpers
magnesj 9c09a21
#14797 Contour map: Compute peaks and show them as markers
magnesj 93b73b5
#14797 Add command to compute contour map peaks
magnesj 25de6c8
#14797 Hide cells-to-include option for line polygon filters
magnesj 1e005b4
Address review feedback: add range validation and input-size assertion
magnesj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
ApplicationLibCode/Commands/RicComputeContourMapPeaksFeature.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| ///////////////////////////////////////////////////////////////////////////////// | ||
| // | ||
| // 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 <http://www.gnu.org/licenses/gpl.html> | ||
| // for more details. | ||
| // | ||
| ///////////////////////////////////////////////////////////////////////////////// | ||
|
|
||
| #include "RicComputeContourMapPeaksFeature.h" | ||
|
|
||
| #include "RicExportContourMapToTextFeature.h" | ||
|
|
||
| #include "ContourMap/RimContourMapPeaksCollection.h" | ||
| #include "ContourMap/RimContourMapProjection.h" | ||
| #include "ContourMap/RimEclipseContourMapView.h" | ||
| #include "RimGeoMechContourMapView.h" | ||
|
|
||
| #include <QAction> | ||
|
|
||
| CAF_CMD_SOURCE_INIT( RicComputeContourMapPeaksFeature, "RicComputeContourMapPeaksFeature" ); | ||
|
|
||
| //-------------------------------------------------------------------------------------------------- | ||
| /// Enabled for all contour map view types (Eclipse, GeoMech and ensemble statistics). | ||
| //-------------------------------------------------------------------------------------------------- | ||
| bool RicComputeContourMapPeaksFeature::isCommandEnabled() const | ||
| { | ||
| auto [existingEclipseContourMap, existingGeoMechContourMap] = RicExportContourMapToTextFeature::findContourMapView(); | ||
|
|
||
| return existingEclipseContourMap || existingGeoMechContourMap; | ||
| } | ||
|
|
||
| //-------------------------------------------------------------------------------------------------- | ||
| /// Computes peaks using the peaks collection's current (default, unless previously edited) peakCount and | ||
| /// minDistance field values. Use the "Contour Map Peaks" object's own property panel to customize and | ||
| /// recompute. | ||
| //-------------------------------------------------------------------------------------------------- | ||
| void RicComputeContourMapPeaksFeature::onActionTriggered( bool isChecked ) | ||
| { | ||
| auto [existingEclipseContourMap, existingGeoMechContourMap] = RicExportContourMapToTextFeature::findContourMapView(); | ||
|
|
||
| RimContourMapProjection* contourMapProjection = nullptr; | ||
| if ( existingEclipseContourMap ) contourMapProjection = existingEclipseContourMap->contourMapProjection(); | ||
| if ( existingGeoMechContourMap ) contourMapProjection = existingGeoMechContourMap->contourMapProjection(); | ||
| if ( !contourMapProjection ) return; | ||
|
|
||
| auto* peaksCollection = contourMapProjection->peaksCollection(); | ||
| if ( !peaksCollection ) return; | ||
|
|
||
| peaksCollection->computePeaks(); | ||
| } | ||
|
|
||
| //-------------------------------------------------------------------------------------------------- | ||
| /// | ||
| //-------------------------------------------------------------------------------------------------- | ||
| void RicComputeContourMapPeaksFeature::setupActionLook( QAction* actionToSetup ) | ||
| { | ||
| actionToSetup->setIcon( QIcon( ":/WellTargetPoint16x16.png" ) ); | ||
| actionToSetup->setText( "Compute Contour Map Peaks" ); | ||
| } |
38 changes: 38 additions & 0 deletions
38
ApplicationLibCode/Commands/RicComputeContourMapPeaksFeature.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| ///////////////////////////////////////////////////////////////////////////////// | ||
| // | ||
| // 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 <http://www.gnu.org/licenses/gpl.html> | ||
| // for more details. | ||
| // | ||
| ///////////////////////////////////////////////////////////////////////////////// | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "cafCmdFeature.h" | ||
|
|
||
| //================================================================================================== | ||
| /// Compute the N most significant peaks (local maxima) in the current contour map, and create a marker | ||
| /// (single-point polygon) for each in the project tree. | ||
| /// | ||
| /// Available for Eclipse and GeoMech contour maps, including ensemble statistics contour maps | ||
| /// (RimStatisticsContourMapView derives from RimEclipseContourMapView). | ||
| //================================================================================================== | ||
| class RicComputeContourMapPeaksFeature : public caf::CmdFeature | ||
| { | ||
| CAF_CMD_HEADER_INIT; | ||
|
|
||
| protected: | ||
| bool isCommandEnabled() const override; | ||
| void onActionTriggered( bool isChecked ) override; | ||
| void setupActionLook( QAction* actionToSetup ) override; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
145 changes: 145 additions & 0 deletions
145
ApplicationLibCode/ProjectDataModel/ContourMap/RimContourMapPeak.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,145 @@ | ||
| ///////////////////////////////////////////////////////////////////////////////// | ||
| // | ||
| // 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 <http://www.gnu.org/licenses/gpl.html> | ||
| // for more details. | ||
| // | ||
| ///////////////////////////////////////////////////////////////////////////////// | ||
|
|
||
| #include "RimContourMapPeak.h" | ||
|
|
||
| #include "Polygons/RimPolygon.h" | ||
| #include "Polygons/RimPolygonCollection.h" | ||
|
|
||
| CAF_PDM_SOURCE_INIT( RimContourMapPeak, "RimContourMapPeak" ); | ||
|
|
||
| //-------------------------------------------------------------------------------------------------- | ||
| /// | ||
| //-------------------------------------------------------------------------------------------------- | ||
| RimContourMapPeak::RimContourMapPeak() | ||
| { | ||
| CAF_PDM_InitObject( "Peak", ":/WellTargetPoint16x16.png" ); | ||
|
|
||
| CAF_PDM_InitField( &m_rank, "Rank", 0, "Rank" ); | ||
| m_rank.uiCapability()->setUiReadOnly( true ); | ||
|
|
||
| CAF_PDM_InitField( &m_value, "Value", 0.0, "Value" ); | ||
| m_value.uiCapability()->setUiReadOnly( true ); | ||
|
|
||
| CAF_PDM_InitField( &m_prominence, "Prominence", 0.0, "Prominence" ); | ||
| m_prominence.uiCapability()->setUiReadOnly( true ); | ||
|
|
||
| CAF_PDM_InitField( &m_position, "Position", cvf::Vec3d::ZERO, "Position" ); | ||
| m_position.uiCapability()->setUiReadOnly( true ); | ||
|
|
||
| CAF_PDM_InitFieldNoDefault( &m_markerPolygon, "MarkerPolygon", "Marker Polygon" ); | ||
| m_markerPolygon.uiCapability()->setUiHidden( true ); | ||
| } | ||
|
|
||
| //-------------------------------------------------------------------------------------------------- | ||
| /// Delete the marker polygon along with this object, so no orphaned polygons are left behind in the | ||
| /// project-wide polygon collection when a peak is removed (e.g. via the generic delete-item command). | ||
| //-------------------------------------------------------------------------------------------------- | ||
| RimContourMapPeak::~RimContourMapPeak() | ||
| { | ||
| deleteMarkerPolygon(); | ||
| } | ||
|
|
||
| //-------------------------------------------------------------------------------------------------- | ||
| /// Only the marker polygon and its direct parent field are accessed, no project-wide lookups, so this is | ||
| /// safe during project teardown. If the polygon collection is destroyed first, the pointer field is | ||
| /// already null. The polygon is removed from whichever container owns it, also if the user moved it into | ||
| /// a sub-folder. The project tree and views are refreshed later from the event loop, as this is also | ||
| /// called when a whole contour map view is deleted. | ||
| //-------------------------------------------------------------------------------------------------- | ||
| void RimContourMapPeak::deleteMarkerPolygon() | ||
| { | ||
| RimPolygon* polygon = m_markerPolygon(); | ||
| if ( !polygon ) return; | ||
|
|
||
| m_markerPolygon = nullptr; | ||
|
|
||
| if ( auto* parentField = polygon->parentField() ) parentField->removeChild( polygon ); | ||
| delete polygon; | ||
|
|
||
| RimPolygonCollection::scheduleUpdateViewsAfterPolygonsChanged(); | ||
| } | ||
|
|
||
| //-------------------------------------------------------------------------------------------------- | ||
| /// | ||
| //-------------------------------------------------------------------------------------------------- | ||
| void RimContourMapPeak::setValues( int rank, double value, double prominence, const cvf::Vec3d& domainPosition ) | ||
| { | ||
| m_rank = rank; | ||
| m_value = value; | ||
| m_prominence = prominence; | ||
| m_position = domainPosition; | ||
|
|
||
| setName( QString( "Peak %1 (%2)" ).arg( rank ).arg( value, 0, 'g', 6 ) ); | ||
| } | ||
|
|
||
| //-------------------------------------------------------------------------------------------------- | ||
| /// | ||
| //-------------------------------------------------------------------------------------------------- | ||
| void RimContourMapPeak::setMarkerPolygon( RimPolygon* markerPolygon ) | ||
| { | ||
| m_markerPolygon = markerPolygon; | ||
| } | ||
|
|
||
| //-------------------------------------------------------------------------------------------------- | ||
| /// | ||
| //-------------------------------------------------------------------------------------------------- | ||
| void RimContourMapPeak::releaseMarkerPolygon() | ||
| { | ||
| m_markerPolygon = nullptr; | ||
| } | ||
|
|
||
| //-------------------------------------------------------------------------------------------------- | ||
| /// | ||
| //-------------------------------------------------------------------------------------------------- | ||
| int RimContourMapPeak::rank() const | ||
| { | ||
| return m_rank(); | ||
| } | ||
|
|
||
| //-------------------------------------------------------------------------------------------------- | ||
| /// | ||
| //-------------------------------------------------------------------------------------------------- | ||
| double RimContourMapPeak::value() const | ||
| { | ||
| return m_value(); | ||
| } | ||
|
|
||
| //-------------------------------------------------------------------------------------------------- | ||
| /// | ||
| //-------------------------------------------------------------------------------------------------- | ||
| double RimContourMapPeak::prominence() const | ||
| { | ||
| return m_prominence(); | ||
| } | ||
|
|
||
| //-------------------------------------------------------------------------------------------------- | ||
| /// | ||
| //-------------------------------------------------------------------------------------------------- | ||
| cvf::Vec3d RimContourMapPeak::position() const | ||
| { | ||
| return m_position(); | ||
| } | ||
|
|
||
| //-------------------------------------------------------------------------------------------------- | ||
| /// | ||
| //-------------------------------------------------------------------------------------------------- | ||
| RimPolygon* RimContourMapPeak::markerPolygon() const | ||
| { | ||
| return m_markerPolygon(); | ||
| } |
68 changes: 68 additions & 0 deletions
68
ApplicationLibCode/ProjectDataModel/ContourMap/RimContourMapPeak.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| ///////////////////////////////////////////////////////////////////////////////// | ||
| // | ||
| // 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 <http://www.gnu.org/licenses/gpl.html> | ||
| // for more details. | ||
| // | ||
| ///////////////////////////////////////////////////////////////////////////////// | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "RimNamedObject.h" | ||
|
|
||
| #include "cafPdmField.h" | ||
| #include "cafPdmPtrField.h" | ||
|
|
||
| #include "cvfVector3.h" | ||
|
|
||
| class RimPolygon; | ||
|
|
||
| //================================================================================================== | ||
| /// A single computed "peak" (local maximum) in a contour map, as produced by RigContourMapPeakFinder. | ||
| /// | ||
| /// Stores the result value, prominence and rank for inspection/sorting in the project tree, and | ||
| /// references a small marker RimPolygon (owned by the global polygon collection, so it can be | ||
| /// mirrored and rendered by the existing polygon-in-view machinery) used to visualize the peak's | ||
| /// position in 3d views. The marker polygon is deleted together with this object, unless it has been | ||
| /// detached with releaseMarkerPolygon(). | ||
| //================================================================================================== | ||
| class RimContourMapPeak : public RimNamedObject | ||
| { | ||
| CAF_PDM_HEADER_INIT; | ||
|
|
||
| public: | ||
| RimContourMapPeak(); | ||
| ~RimContourMapPeak() override; | ||
|
|
||
| void setValues( int rank, double value, double prominence, const cvf::Vec3d& domainPosition ); | ||
| void setMarkerPolygon( RimPolygon* markerPolygon ); | ||
|
|
||
| // Stop referencing the marker polygon without deleting it | ||
| void releaseMarkerPolygon(); | ||
|
|
||
| int rank() const; | ||
| double value() const; | ||
| double prominence() const; | ||
| cvf::Vec3d position() const; | ||
| RimPolygon* markerPolygon() const; | ||
|
|
||
| private: | ||
| void deleteMarkerPolygon(); | ||
|
|
||
| private: | ||
| caf::PdmField<int> m_rank; | ||
| caf::PdmField<double> m_value; | ||
| caf::PdmField<double> m_prominence; | ||
| caf::PdmField<cvf::Vec3d> m_position; | ||
| caf::PdmPtrField<RimPolygon*> m_markerPolygon; | ||
| }; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.