mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3807 Initial implementation of GeoMech contour maps.
This commit is contained in:
parent
aed0de8a2b
commit
1f754f2b63
@ -17,9 +17,9 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicContourMapPickEventHandler.h"
|
||||
#include "RimEclipseContourMapProjection.h"
|
||||
#include "RimContourMapProjection.h"
|
||||
#include "RimGeoMechContourMapView.h"
|
||||
#include "RimEclipseContourMapView.h"
|
||||
#include "RimEclipseCellColors.h"
|
||||
#include "Rim3dView.h"
|
||||
|
||||
#include "RiuMainWindow.h"
|
||||
@ -53,12 +53,12 @@ bool RicContourMapPickEventHandler::handlePickEvent(const Ric3DPickEvent& eventO
|
||||
const RivObjectSourceInfo* sourceInfo = dynamic_cast<const RivObjectSourceInfo*>(firstPickedPart->sourceInfo());
|
||||
if (sourceInfo)
|
||||
{
|
||||
RimEclipseContourMapProjection* contourMap = dynamic_cast<RimEclipseContourMapProjection*>(sourceInfo->object());
|
||||
RimContourMapProjection* contourMap = dynamic_cast<RimContourMapProjection*>(sourceInfo->object());
|
||||
if (contourMap)
|
||||
{
|
||||
RiuMainWindow::instance()->selectAsCurrentItem(contourMap);
|
||||
|
||||
RimEclipseContourMapView* view = nullptr;
|
||||
RimGridView* view = nullptr;
|
||||
contourMap->firstAncestorOrThisOfTypeAsserted(view);
|
||||
|
||||
cvf::Vec2d pickedPoint;
|
||||
@ -74,7 +74,17 @@ bool RicContourMapPickEventHandler::handlePickEvent(const Ric3DPickEvent& eventO
|
||||
RiuMainWindow::instance()->setResultInfo(curveText);
|
||||
|
||||
contourMap->setPickPoint(pickedPoint);
|
||||
view->updatePickPointAndRedraw();
|
||||
|
||||
RimGeoMechContourMapView* geoMechContourView = dynamic_cast<RimGeoMechContourMapView*>(view);
|
||||
RimEclipseContourMapView* eclipseContourView = dynamic_cast<RimEclipseContourMapView*>(view);
|
||||
if (geoMechContourView)
|
||||
{
|
||||
geoMechContourView->updatePickPointAndRedraw();
|
||||
}
|
||||
else
|
||||
{
|
||||
eclipseContourView->updatePickPointAndRedraw();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
contourMap->setPickPoint(cvf::Vec2d::UNDEFINED);
|
||||
|
@ -21,10 +21,16 @@
|
||||
#include "Rim3dView.h"
|
||||
#include "RimCellEdgeColors.h"
|
||||
#include "RimEclipseContourMapView.h"
|
||||
#include "RimContourMapViewCollection.h"
|
||||
#include "RimEclipseContourMapViewCollection.h"
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimEclipseCellColors.h"
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimGeoMechContourMapView.h"
|
||||
#include "RimGeoMechContourMapViewCollection.h"
|
||||
#include "RimGeoMechCase.h"
|
||||
#include "RimGeoMechCellColors.h"
|
||||
#include "RimGeoMechView.h"
|
||||
|
||||
#include "RimFaultInViewCollection.h"
|
||||
#include "RimSimWellInViewCollection.h"
|
||||
|
||||
@ -46,10 +52,11 @@ CAF_CMD_SOURCE_INIT(RicNewContourMapViewFeature, "RicNewContourMapViewFeature");
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicNewContourMapViewFeature::isCommandEnabled()
|
||||
{
|
||||
bool selectedView = caf::SelectionManager::instance()->selectedItemOfType<RimEclipseView>() != nullptr;
|
||||
bool selectedCase = caf::SelectionManager::instance()->selectedItemOfType<RimEclipseCase>() != nullptr;
|
||||
bool selectedMapCollection = caf::SelectionManager::instance()->selectedItemOfType<RimContourMapViewCollection>();
|
||||
return selectedView || selectedCase || selectedMapCollection;
|
||||
bool selectedView = caf::SelectionManager::instance()->selectedItemOfType<RimGridView>() != nullptr;
|
||||
bool selectedCase = caf::SelectionManager::instance()->selectedItemOfType<RimCase>() != nullptr;
|
||||
bool selectedEclipseContourMapCollection = caf::SelectionManager::instance()->selectedItemOfType<RimEclipseContourMapViewCollection>();
|
||||
bool selectedGeoMechContourMapCollection = caf::SelectionManager::instance()->selectedItemOfType<RimGeoMechContourMapViewCollection>();
|
||||
return selectedView || selectedCase || selectedEclipseContourMapCollection || selectedGeoMechContourMapCollection;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -57,40 +64,71 @@ bool RicNewContourMapViewFeature::isCommandEnabled()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewContourMapViewFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
RimEclipseView* reservoirView = caf::SelectionManager::instance()->selectedItemOfType<RimEclipseView>();
|
||||
RimEclipseContourMapView* existingContourMap = caf::SelectionManager::instance()->selectedItemOfType<RimEclipseContourMapView>();
|
||||
RimEclipseCase* eclipseCase = caf::SelectionManager::instance()->selectedItemAncestorOfType<RimEclipseCase>();
|
||||
RimEclipseContourMapView* contourMap = nullptr;
|
||||
RimEclipseView* reservoirView = caf::SelectionManager::instance()->selectedItemOfType<RimEclipseView>();
|
||||
RimEclipseContourMapView* existingEclipseContourMap =
|
||||
caf::SelectionManager::instance()->selectedItemOfType<RimEclipseContourMapView>();
|
||||
RimEclipseCase* eclipseCase = caf::SelectionManager::instance()->selectedItemAncestorOfType<RimEclipseCase>();
|
||||
RimEclipseContourMapView* eclipseContourMap = nullptr;
|
||||
|
||||
RimGeoMechView* geoMechView = caf::SelectionManager::instance()->selectedItemOfType<RimGeoMechView>();
|
||||
RimGeoMechContourMapView* existingGeoMechContourMap =
|
||||
caf::SelectionManager::instance()->selectedItemOfType<RimGeoMechContourMapView>();
|
||||
RimGeoMechCase* geoMechCase = caf::SelectionManager::instance()->selectedItemAncestorOfType<RimGeoMechCase>();
|
||||
RimGeoMechContourMapView* geoMechContourMap = nullptr;
|
||||
|
||||
// Find case to insert into
|
||||
if (existingContourMap)
|
||||
if (existingEclipseContourMap)
|
||||
{
|
||||
contourMap = create2dContourMapFromExistingContourMap(eclipseCase, existingContourMap);
|
||||
eclipseContourMap = createEclipseContourMapFromExistingContourMap(eclipseCase, existingEclipseContourMap);
|
||||
}
|
||||
else if (reservoirView)
|
||||
{
|
||||
contourMap = create2dContourMapFrom3dView(eclipseCase, reservoirView);
|
||||
eclipseContourMap = createEclipseContourMapFrom3dView(eclipseCase, reservoirView);
|
||||
}
|
||||
else if (eclipseCase)
|
||||
{
|
||||
contourMap = create2dContourMap(eclipseCase);
|
||||
eclipseContourMap = createEclipseContourMap(eclipseCase);
|
||||
}
|
||||
else if (existingGeoMechContourMap)
|
||||
{
|
||||
geoMechContourMap = createGeoMechContourMapFromExistingContourMap(geoMechCase, existingGeoMechContourMap);
|
||||
}
|
||||
else if (geoMechView)
|
||||
{
|
||||
geoMechContourMap = createGeoMechContourMapFrom3dView(geoMechCase, geoMechView);
|
||||
}
|
||||
else if (geoMechCase)
|
||||
{
|
||||
geoMechContourMap = createGeoMechContourMap(geoMechCase);
|
||||
}
|
||||
|
||||
if (contourMap)
|
||||
if (eclipseContourMap)
|
||||
{
|
||||
// Must be run before buildViewItems, as wells are created in this function
|
||||
contourMap->loadDataAndUpdate();
|
||||
eclipseContourMap->loadDataAndUpdate();
|
||||
|
||||
if (eclipseCase)
|
||||
{
|
||||
eclipseCase->updateConnectedEditors();
|
||||
}
|
||||
caf::SelectionManager::instance()->setSelectedItem(contourMap);
|
||||
caf::SelectionManager::instance()->setSelectedItem(eclipseContourMap);
|
||||
|
||||
contourMap->createDisplayModelAndRedraw();
|
||||
contourMap->zoomAll();
|
||||
eclipseContourMap->createDisplayModelAndRedraw();
|
||||
eclipseContourMap->zoomAll();
|
||||
|
||||
Riu3DMainWindowTools::setExpanded(contourMap);
|
||||
Riu3DMainWindowTools::setExpanded(eclipseContourMap);
|
||||
}
|
||||
else if (geoMechContourMap)
|
||||
{
|
||||
geoMechContourMap->loadDataAndUpdate();
|
||||
if (geoMechCase)
|
||||
{
|
||||
geoMechCase->updateConnectedEditors();
|
||||
caf::SelectionManager::instance()->setSelectedItem(geoMechContourMap);
|
||||
geoMechContourMap->createDisplayModelAndRedraw();
|
||||
geoMechContourMap->zoomAll();
|
||||
Riu3DMainWindowTools::setExpanded(geoMechContourMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,13 +137,17 @@ void RicNewContourMapViewFeature::onActionTriggered(bool isChecked)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewContourMapViewFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
RimEclipseContourMapView* contourMap = caf::SelectionManager::instance()->selectedItemOfType<RimEclipseContourMapView>();
|
||||
RimEclipseView* eclipseView = caf::SelectionManager::instance()->selectedItemOfType<RimEclipseView>();
|
||||
if (contourMap)
|
||||
bool contourMapSelected = caf::SelectionManager::instance()->selectedItemOfType<RimEclipseContourMapView>() != nullptr ||
|
||||
caf::SelectionManager::instance()->selectedItemOfType<RimGeoMechContourMapView>() != nullptr;
|
||||
|
||||
bool viewSelected = caf::SelectionManager::instance()->selectedItemOfType<RimEclipseView>() != nullptr ||
|
||||
caf::SelectionManager::instance()->selectedItemOfType<RimGeoMechView>() != nullptr;
|
||||
|
||||
if (contourMapSelected)
|
||||
{
|
||||
actionToSetup->setText("Duplicate Contour Map");
|
||||
}
|
||||
else if (eclipseView)
|
||||
else if (viewSelected)
|
||||
{
|
||||
actionToSetup->setText("New Contour Map From 3d View");
|
||||
}
|
||||
@ -119,7 +161,7 @@ void RicNewContourMapViewFeature::setupActionLook(QAction* actionToSetup)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimEclipseContourMapView* RicNewContourMapViewFeature::create2dContourMapFromExistingContourMap(RimEclipseCase* eclipseCase,
|
||||
RimEclipseContourMapView* RicNewContourMapViewFeature::createEclipseContourMapFromExistingContourMap(RimEclipseCase* eclipseCase,
|
||||
RimEclipseContourMapView* existingContourMap)
|
||||
{
|
||||
RimEclipseContourMapView* contourMap = dynamic_cast<RimEclipseContourMapView*>(
|
||||
@ -145,7 +187,7 @@ RimEclipseContourMapView* RicNewContourMapViewFeature::create2dContourMapFromExi
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimEclipseContourMapView* RicNewContourMapViewFeature::create2dContourMapFrom3dView(RimEclipseCase* eclipseCase,
|
||||
RimEclipseContourMapView* RicNewContourMapViewFeature::createEclipseContourMapFrom3dView(RimEclipseCase* eclipseCase,
|
||||
const RimEclipseView* sourceView)
|
||||
{
|
||||
RimEclipseContourMapView* contourMap = dynamic_cast<RimEclipseContourMapView*>(sourceView->xmlCapability()->copyAndCastByXmlSerialization(
|
||||
@ -180,7 +222,7 @@ RimEclipseContourMapView* RicNewContourMapViewFeature::create2dContourMapFrom3dV
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimEclipseContourMapView* RicNewContourMapViewFeature::create2dContourMap(RimEclipseCase* eclipseCase)
|
||||
RimEclipseContourMapView* RicNewContourMapViewFeature::createEclipseContourMap(RimEclipseCase* eclipseCase)
|
||||
{
|
||||
RimEclipseContourMapView* contourMap = new RimEclipseContourMapView();
|
||||
contourMap->setEclipseCase(eclipseCase);
|
||||
@ -207,3 +249,79 @@ RimEclipseContourMapView* RicNewContourMapViewFeature::create2dContourMap(RimEcl
|
||||
|
||||
return contourMap;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimGeoMechContourMapView*
|
||||
RicNewContourMapViewFeature::createGeoMechContourMapFromExistingContourMap(RimGeoMechCase* geoMechCase,
|
||||
RimGeoMechContourMapView* existingContourMap)
|
||||
{
|
||||
RimGeoMechContourMapView* contourMap = dynamic_cast<RimGeoMechContourMapView*>(
|
||||
existingContourMap->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance()));
|
||||
CVF_ASSERT(contourMap);
|
||||
|
||||
contourMap->setGeoMechCase(geoMechCase);
|
||||
contourMap->setBackgroundColor(cvf::Color3f(1.0f, 1.0f, 0.98f)); // Ignore original view background
|
||||
|
||||
caf::PdmDocument::updateUiIconStateRecursively(contourMap);
|
||||
|
||||
size_t i = geoMechCase->contourMapCollection()->views().size();
|
||||
contourMap->setName(QString("Contour Map %1").arg(i + 1));
|
||||
geoMechCase->contourMapCollection()->push_back(contourMap);
|
||||
|
||||
// Resolve references after contour map has been inserted into Rim structures
|
||||
contourMap->resolveReferencesRecursively();
|
||||
contourMap->initAfterReadRecursively();
|
||||
|
||||
return contourMap;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimGeoMechContourMapView* RicNewContourMapViewFeature::createGeoMechContourMapFrom3dView(RimGeoMechCase* geoMechCase,
|
||||
const RimGeoMechView* sourceView)
|
||||
{
|
||||
RimGeoMechContourMapView* contourMap = dynamic_cast<RimGeoMechContourMapView*>(
|
||||
sourceView->xmlCapability()->copyAndCastByXmlSerialization(RimGeoMechContourMapView::classKeywordStatic(),
|
||||
sourceView->classKeyword(),
|
||||
caf::PdmDefaultObjectFactory::instance()));
|
||||
CVF_ASSERT(contourMap);
|
||||
|
||||
contourMap->setGeoMechCase(geoMechCase);
|
||||
contourMap->setBackgroundColor(cvf::Color3f(1.0f, 1.0f, 0.98f)); // Ignore original view background
|
||||
contourMap->setDefaultCustomName();
|
||||
|
||||
caf::PdmDocument::updateUiIconStateRecursively(contourMap);
|
||||
|
||||
geoMechCase->contourMapCollection()->push_back(contourMap);
|
||||
|
||||
// Resolve references after contour map has been inserted into Rim structures
|
||||
std::vector<caf::PdmFieldHandle*> fieldsWithFailingResolve;
|
||||
contourMap->resolveReferencesRecursively(&fieldsWithFailingResolve);
|
||||
contourMap->initAfterReadRecursively();
|
||||
|
||||
return contourMap;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimGeoMechContourMapView* RicNewContourMapViewFeature::createGeoMechContourMap(RimGeoMechCase* geoMechCase)
|
||||
{
|
||||
RimGeoMechContourMapView* contourMap = new RimGeoMechContourMapView();
|
||||
contourMap->setGeoMechCase(geoMechCase);
|
||||
|
||||
caf::PdmDocument::updateUiIconStateRecursively(contourMap);
|
||||
|
||||
size_t i = geoMechCase->contourMapCollection()->views().size();
|
||||
contourMap->setName(QString("Contour Map %1").arg(i + 1));
|
||||
geoMechCase->contourMapCollection()->push_back(contourMap);
|
||||
|
||||
contourMap->hasUserRequestedAnimation = true;
|
||||
contourMap->setBackgroundColor(cvf::Color3f(1.0f, 1.0f, 0.98f));
|
||||
contourMap->initAfterReadRecursively();
|
||||
|
||||
return contourMap;
|
||||
}
|
||||
|
@ -22,8 +22,11 @@
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
class RimEclipseCase;
|
||||
class RimGeoMechCase;
|
||||
class RimEclipseContourMapView;
|
||||
class RimGeoMechContourMapView;
|
||||
class RimEclipseView;
|
||||
class RimGeoMechView;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@ -38,8 +41,12 @@ protected:
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
|
||||
static RimEclipseContourMapView* create2dContourMapFromExistingContourMap(RimEclipseCase* eclipseCase, RimEclipseContourMapView* existingContourMap);
|
||||
static RimEclipseContourMapView* create2dContourMapFrom3dView(RimEclipseCase* eclipseCase, const RimEclipseView* reservoirView);
|
||||
static RimEclipseContourMapView* create2dContourMap(RimEclipseCase* eclipseCase);
|
||||
static RimEclipseContourMapView* createEclipseContourMapFromExistingContourMap(RimEclipseCase* eclipseCase, RimEclipseContourMapView* existingContourMap);
|
||||
static RimEclipseContourMapView* createEclipseContourMapFrom3dView(RimEclipseCase* eclipseCase, const RimEclipseView* sourceView);
|
||||
static RimEclipseContourMapView* createEclipseContourMap(RimEclipseCase* eclipseCase);
|
||||
|
||||
|
||||
static RimGeoMechContourMapView* createGeoMechContourMapFromExistingContourMap(RimGeoMechCase* geoMechCase, RimGeoMechContourMapView* existingContourMap);
|
||||
static RimGeoMechContourMapView* createGeoMechContourMapFrom3dView(RimGeoMechCase* geoMechCase, const RimGeoMechView* sourceView);
|
||||
static RimGeoMechContourMapView* createGeoMechContourMap(RimGeoMechCase* geoMechCase);
|
||||
};
|
||||
|
@ -342,10 +342,28 @@ cvf::BoundingBox RigFemPart::boundingBox() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigFemPart::findIntersectingCells(const cvf::BoundingBox& inputBB, std::vector<size_t>* elementIndices) const
|
||||
{
|
||||
ensureIntersectionSearchTreeIsBuilt();
|
||||
findIntersectingCellsWithExistingSearchTree(inputBB, elementIndices);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigFemPart::findIntersectingCellsWithExistingSearchTree(const cvf::BoundingBox& inputBB,
|
||||
std::vector<size_t>* elementIndices) const
|
||||
{
|
||||
CVF_ASSERT(m_elementSearchTree.notNull());
|
||||
m_elementSearchTree->findIntersections(inputBB, elementIndices);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigFemPart::ensureIntersectionSearchTreeIsBuilt() const
|
||||
{
|
||||
// build tree
|
||||
if (m_elementSearchTree.isNull())
|
||||
{
|
||||
// build tree
|
||||
|
||||
size_t elmCount = elementCount();
|
||||
|
||||
std::vector<cvf::BoundingBox> cellBoundingBoxes;
|
||||
@ -353,7 +371,7 @@ void RigFemPart::findIntersectingCells(const cvf::BoundingBox& inputBB, std::vec
|
||||
|
||||
for (size_t elmIdx = 0; elmIdx < elmCount; ++elmIdx)
|
||||
{
|
||||
const int* cellIndices = connectivities(elmIdx);
|
||||
const int* cellIndices = connectivities(elmIdx);
|
||||
cvf::BoundingBox& cellBB = cellBoundingBoxes[elmIdx];
|
||||
cellBB.add(m_nodes.coordinates[cellIndices[0]]);
|
||||
cellBB.add(m_nodes.coordinates[cellIndices[1]]);
|
||||
@ -368,8 +386,6 @@ void RigFemPart::findIntersectingCells(const cvf::BoundingBox& inputBB, std::vec
|
||||
m_elementSearchTree = new cvf::BoundingBoxTree;
|
||||
m_elementSearchTree->buildTreeFromBoundingBoxes(cellBoundingBoxes, nullptr);
|
||||
}
|
||||
|
||||
m_elementSearchTree->findIntersections(inputBB, elementIndices);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -82,6 +82,9 @@ public:
|
||||
float characteristicElementSize() const;
|
||||
const std::vector<int>& possibleGridCornerElements() const { return m_possibleGridCornerElements; }
|
||||
void findIntersectingCells(const cvf::BoundingBox& inputBB, std::vector<size_t>* elementIndices) const;
|
||||
void findIntersectingCellsWithExistingSearchTree(const cvf::BoundingBox& inputBB, std::vector<size_t>* elementIndices) const;
|
||||
|
||||
void ensureIntersectionSearchTreeIsBuilt() const;
|
||||
|
||||
cvf::Vec3f faceNormal(int elmentIndex, int faceIndex) const;
|
||||
|
||||
|
@ -1499,6 +1499,8 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateCompactionValues
|
||||
RigFemScalarResultFrames* compactionFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr);
|
||||
|
||||
const RigFemPart* part = m_femParts->part(partIndex);
|
||||
part->ensureIntersectionSearchTreeIsBuilt();
|
||||
|
||||
for (int t = 0; t < u3Frames->frameCount(); t++)
|
||||
{
|
||||
std::vector<float>& compactionFrame = compactionFrames->frameData(t);
|
||||
|
@ -52,7 +52,7 @@ void RivFemElmVisibilityCalculator::computeAllVisible(cvf::UByteArray* elmVisibi
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivFemElmVisibilityCalculator::computeRangeVisibility(cvf::UByteArray* elmVisibilities, RigFemPart* femPart,
|
||||
void RivFemElmVisibilityCalculator::computeRangeVisibility(cvf::UByteArray* elmVisibilities, const RigFemPart* femPart,
|
||||
const cvf::CellRangeFilter& rangeFilter)
|
||||
{
|
||||
elmVisibilities->resize(femPart->elementCount());
|
||||
|
@ -37,7 +37,7 @@ class RivFemElmVisibilityCalculator
|
||||
{
|
||||
public:
|
||||
static void computeAllVisible(cvf::UByteArray* elmVisibilities, const RigFemPart* femPart );
|
||||
static void computeRangeVisibility(cvf::UByteArray* elmVisibilities, RigFemPart* femPart,
|
||||
static void computeRangeVisibility(cvf::UByteArray* elmVisibilities, const RigFemPart* femPart,
|
||||
const cvf::CellRangeFilter& rangeFilter);
|
||||
|
||||
static void computePropertyVisibility(cvf::UByteArray* cellVisibility,
|
||||
|
@ -8,8 +8,8 @@
|
||||
#include "RivScalarMapperUtils.h"
|
||||
#include "RivPartPriority.h"
|
||||
|
||||
#include "RimEclipseContourMapView.h"
|
||||
#include "RimEclipseContourMapProjection.h"
|
||||
#include "RimGridView.h"
|
||||
#include "RimContourMapProjection.h"
|
||||
|
||||
#include "cafEffectGenerator.h"
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivContourMapProjectionPartMgr::RivContourMapProjectionPartMgr(RimEclipseContourMapProjection* contourMapProjection, RimEclipseContourMapView* contourMap)
|
||||
RivContourMapProjectionPartMgr::RivContourMapProjectionPartMgr(RimContourMapProjection* contourMapProjection, RimGridView* contourMap)
|
||||
{
|
||||
m_contourMapProjection = contourMapProjection;
|
||||
m_parentContourMap = contourMap;
|
||||
|
@ -40,7 +40,7 @@ namespace cvf
|
||||
class RivContourMapProjectionPartMgr : public cvf::Object
|
||||
{
|
||||
public:
|
||||
RivContourMapProjectionPartMgr(RimEclipseContourMapProjection* contourMapProjection, RimEclipseContourMapView* contourMap);
|
||||
RivContourMapProjectionPartMgr(RimContourMapProjection* contourMapProjection, RimGridView* contourMap);
|
||||
|
||||
void createProjectionGeometry();
|
||||
void appendProjectionToModel(cvf::ModelBasicList* model,
|
||||
@ -59,10 +59,10 @@ private:
|
||||
std::vector<cvf::ref<cvf::Drawable>> createContourLabels(const cvf::Camera* camera, const caf::DisplayCoordTransform* displayCoordTransform, std::vector<std::vector<cvf::BoundingBox>>* labelBBoxes) const;
|
||||
cvf::ref<cvf::DrawableGeo> createPickPointVisDrawable(const caf::DisplayCoordTransform* displayCoordTransform) const;
|
||||
private:
|
||||
caf::PdmPointer<RimEclipseContourMapProjection> m_contourMapProjection;
|
||||
caf::PdmPointer<RimEclipseContourMapView> m_parentContourMap;
|
||||
caf::PdmPointer<RimContourMapProjection> m_contourMapProjection;
|
||||
caf::PdmPointer<RimGridView> m_parentContourMap;
|
||||
|
||||
std::vector<RimEclipseContourMapProjection::ContourPolygons> m_contourLinePolygons;
|
||||
std::vector<RimContourMapProjection::ContourPolygons> m_contourLinePolygons;
|
||||
std::vector<cvf::Vec4d> m_contourMapTriangles;
|
||||
std::vector<std::vector<cvf::BoundingBox>> m_labelBoundingBoxes;
|
||||
cvf::ref<cvf::Effect> m_labelEffect;
|
||||
|
@ -120,7 +120,10 @@ ${CMAKE_CURRENT_LIST_DIR}/RimWellLogCurveCommonDataSource.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimContourMapProjection.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimEclipseContourMapProjection.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimEclipseContourMapView.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimContourMapViewCollection.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimEclipseContourMapViewCollection.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimGeoMechContourMapProjection.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimGeoMechContourMapView.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimGeoMechContourMapViewCollection.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimViewNameConfig.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimScaleLegendConfig.h
|
||||
)
|
||||
@ -247,7 +250,10 @@ ${CMAKE_CURRENT_LIST_DIR}/RimWellLogCurveCommonDataSource.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimContourMapProjection.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimEclipseContourMapProjection.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimEclipseContourMapView.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimContourMapViewCollection.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimEclipseContourMapViewCollection.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimGeoMechContourMapProjection.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimGeoMechContourMapView.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimGeoMechContourMapViewCollection.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimViewNameConfig.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimScaleLegendConfig.cpp
|
||||
)
|
||||
|
@ -37,7 +37,9 @@
|
||||
#include "RigMainGrid.h"
|
||||
#include "RigStatisticsDataCache.h"
|
||||
|
||||
#include "RimGeoMechContourMapView.h"
|
||||
#include "RimEclipseContourMapView.h"
|
||||
#include "RimGeoMechContourMapProjection.h"
|
||||
#include "RimEclipseContourMapProjection.h"
|
||||
#include "Rim2dIntersectionView.h"
|
||||
#include "Rim2dIntersectionViewCollection.h"
|
||||
@ -176,9 +178,11 @@ Rim3dOverlayInfoConfig::HistogramData Rim3dOverlayInfoConfig::histogramData()
|
||||
{
|
||||
auto eclipseView = dynamic_cast<RimEclipseView*>(m_viewDef.p());
|
||||
auto geoMechView = dynamic_cast<RimGeoMechView*>(m_viewDef.p());
|
||||
auto contourMap = dynamic_cast<RimEclipseContourMapView*>(eclipseView);
|
||||
auto eclipseContourMap = dynamic_cast<RimEclipseContourMapView*>(eclipseView);
|
||||
auto geoMechContourMap = dynamic_cast<RimGeoMechContourMapView*>(geoMechView);
|
||||
|
||||
if (contourMap) return histogramData(contourMap);
|
||||
if (eclipseContourMap) return histogramData(eclipseContourMap);
|
||||
else if (geoMechContourMap) return histogramData(geoMechContourMap);
|
||||
else if (eclipseView) return histogramData(eclipseView);
|
||||
else if (geoMechView) return histogramData(geoMechView);
|
||||
return HistogramData();
|
||||
@ -297,6 +301,28 @@ Rim3dOverlayInfoConfig::HistogramData Rim3dOverlayInfoConfig::histogramData(RimE
|
||||
return histData;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
Rim3dOverlayInfoConfig::HistogramData Rim3dOverlayInfoConfig::histogramData(RimGeoMechContourMapView* contourMap)
|
||||
{
|
||||
HistogramData histData;
|
||||
|
||||
if (contourMap)
|
||||
{
|
||||
bool isResultsInfoRelevant = contourMap->contourMapProjection()->numberOfValidCells() > 0u;
|
||||
|
||||
if (isResultsInfoRelevant)
|
||||
{
|
||||
histData.min = contourMap->contourMapProjection()->minValue();
|
||||
histData.max = contourMap->contourMapProjection()->maxValue();
|
||||
histData.mean = contourMap->contourMapProjection()->meanValue();
|
||||
histData.sum = contourMap->contourMapProjection()->sumAllValues();
|
||||
}
|
||||
}
|
||||
return histData;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@ -553,19 +579,39 @@ QString Rim3dOverlayInfoConfig::caseInfoText(RimGeoMechView* geoMechView)
|
||||
|
||||
if (geoMechView)
|
||||
{
|
||||
RimGeoMechCase* geoMechCase = geoMechView->geoMechCase();
|
||||
RigGeoMechCaseData* caseData = geoMechCase ? geoMechCase->geoMechData() : nullptr;
|
||||
RimGeoMechCase* geoMechCase = geoMechView->geoMechCase();
|
||||
RigGeoMechCaseData* caseData = geoMechCase ? geoMechCase->geoMechData() : nullptr;
|
||||
RigFemPartCollection* femParts = caseData ? caseData->femParts() : nullptr;
|
||||
|
||||
if (femParts)
|
||||
{
|
||||
QString caseName = geoMechCase->caseUserDescription();
|
||||
QString cellCount = QString("%1").arg(femParts->totalElementCount());
|
||||
QString zScale = QString::number(geoMechView->scaleZ());
|
||||
RimGeoMechContourMapView* contourMap = dynamic_cast<RimGeoMechContourMapView*>(geoMechView);
|
||||
|
||||
infoText = QString(
|
||||
"<p><b>-- %1 --</b><p>"
|
||||
"<b>Cell count:</b> %2 <b>Z-Scale:</b> %3<br>").arg(caseName, cellCount, zScale);
|
||||
if (contourMap && contourMap->contourMapProjection())
|
||||
{
|
||||
QString totCellCount = QString::number(contourMap->contourMapProjection()->numberOfCells());
|
||||
cvf::uint validCellCount = contourMap->contourMapProjection()->numberOfValidCells();
|
||||
QString activeCellCountText = QString::number(validCellCount);
|
||||
QString iSize = QString::number(contourMap->contourMapProjection()->numberOfElementsIJ().x());
|
||||
QString jSize = QString::number(contourMap->contourMapProjection()->numberOfElementsIJ().y());
|
||||
QString aggregationType = contourMap->contourMapProjection()->resultAggregationText();
|
||||
|
||||
infoText += QString("<p><b>-- Contour Map: %1 --</b><p> "
|
||||
"<b>Sample Count. Total:</b> %2 <b>Valid Results:</b> %3 <br>"
|
||||
"<b>Projection Type:</b> %4<br>")
|
||||
.arg(caseName, totCellCount, activeCellCountText, aggregationType);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
QString cellCount = QString("%1").arg(femParts->totalElementCount());
|
||||
QString zScale = QString::number(geoMechView->scaleZ());
|
||||
|
||||
infoText = QString(
|
||||
"<p><b>-- %1 --</b><p>"
|
||||
"<b>Cell count:</b> %2 <b>Z-Scale:</b> %3<br>").arg(caseName, cellCount, zScale);
|
||||
}
|
||||
}
|
||||
}
|
||||
return infoText;
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <cmath>
|
||||
#include <memory>
|
||||
|
||||
class RimGeoMechContourMapView;
|
||||
class RimEclipseContourMapView;
|
||||
class RimEclipseView;
|
||||
class RimGeoMechView;
|
||||
@ -114,6 +115,7 @@ private:
|
||||
QString timeStepText(RimEclipseView* eclipseView);
|
||||
QString timeStepText(RimGeoMechView* geoMechView);
|
||||
HistogramData histogramData(RimEclipseContourMapView* contourMap);
|
||||
HistogramData histogramData(RimGeoMechContourMapView* contourMap);
|
||||
HistogramData histogramData(RimEclipseView* eclipseView);
|
||||
HistogramData histogramData(RimGeoMechView* geoMechView);
|
||||
QString caseInfoText(RimEclipseView* eclipseView);
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include "RimCaseCollection.h"
|
||||
#include "RimCellRangeFilter.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimContourMapViewCollection.h"
|
||||
#include "RimEclipseContourMapViewCollection.h"
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimEclipseCaseCollection.h"
|
||||
#include "RimEclipseCellColors.h"
|
||||
@ -53,6 +53,7 @@
|
||||
#include "RimFormationNames.h"
|
||||
#include "RimFormationNamesCollection.h"
|
||||
#include "RimGeoMechCase.h"
|
||||
#include "RimGeoMechContourMapViewCollection.h"
|
||||
#include "RimGeoMechPropertyFilter.h"
|
||||
#include "RimGeoMechPropertyFilterCollection.h"
|
||||
#include "RimGeoMechView.h"
|
||||
@ -153,6 +154,8 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
|
||||
menuBuilder << "Separator";
|
||||
|
||||
menuBuilder << "RicNewViewFeature";
|
||||
menuBuilder << "RicNewContourMapViewFeature";
|
||||
|
||||
menuBuilder << "Separator";
|
||||
menuBuilder << "RicCopyReferencesToClipboardFeature";
|
||||
}
|
||||
@ -166,7 +169,11 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
|
||||
menuBuilder << "RicCopyReferencesToClipboardFeature";
|
||||
menuBuilder << "RicSaveEclipseInputVisibleCellsFeature";
|
||||
}
|
||||
else if (dynamic_cast<RimContourMapViewCollection*>(uiItem))
|
||||
else if (dynamic_cast<RimEclipseContourMapViewCollection*>(uiItem))
|
||||
{
|
||||
menuBuilder << "RicNewContourMapViewFeature";
|
||||
}
|
||||
else if (dynamic_cast<RimGeoMechContourMapViewCollection*>(uiItem))
|
||||
{
|
||||
menuBuilder << "RicNewContourMapViewFeature";
|
||||
}
|
||||
@ -206,6 +213,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
|
||||
menuBuilder << "RicPasteGeoMechViewsFeature";
|
||||
menuBuilder << "Separator";
|
||||
menuBuilder << "RicNewViewFeature";
|
||||
menuBuilder << "RicNewContourMapViewFeature";
|
||||
menuBuilder << "Separator";
|
||||
menuBuilder << "RicImportElementPropertyFeature";
|
||||
menuBuilder << "Separator";
|
||||
|
@ -112,6 +112,7 @@ void RimContourMapProjection::generateResultsIfNecessary(int timeStep)
|
||||
if (resultsNeedsUpdating(timeStep))
|
||||
{
|
||||
generateResults(timeStep);
|
||||
generateVertexResults();
|
||||
}
|
||||
}
|
||||
|
||||
@ -240,9 +241,7 @@ double RimContourMapProjection::maxValue() const
|
||||
{
|
||||
double maxV = -std::numeric_limits<double>::infinity();
|
||||
|
||||
int nVertices = numberOfCells();
|
||||
|
||||
for (int index = 0; index < nVertices; ++index)
|
||||
for (size_t index = 0; index < m_aggregatedResults.size(); ++index)
|
||||
{
|
||||
if (m_aggregatedResults[index] != std::numeric_limits<double>::infinity())
|
||||
{
|
||||
@ -259,9 +258,7 @@ double RimContourMapProjection::minValue() const
|
||||
{
|
||||
double minV = std::numeric_limits<double>::infinity();
|
||||
|
||||
int nVertices = numberOfCells();
|
||||
|
||||
for (int index = 0; index < nVertices; ++index)
|
||||
for (size_t index = 0; index < m_aggregatedResults.size(); ++index)
|
||||
{
|
||||
if (m_aggregatedResults[index] != std::numeric_limits<double>::infinity())
|
||||
{
|
||||
@ -286,9 +283,7 @@ double RimContourMapProjection::sumAllValues() const
|
||||
{
|
||||
double sum = 0.0;
|
||||
|
||||
int nVertices = numberOfCells();
|
||||
|
||||
for (int index = 0; index < nVertices; ++index)
|
||||
for (size_t index = 0; index < m_aggregatedResults.size(); ++index)
|
||||
{
|
||||
if (m_aggregatedResults[index] != std::numeric_limits<double>::infinity())
|
||||
{
|
||||
@ -423,6 +418,132 @@ cvf::Vec3d RimContourMapProjection::origin3d() const
|
||||
return m_expandedBoundingBox.min();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RimContourMapProjection::calculateValueInMapCell(uint i, uint j) const
|
||||
{
|
||||
const std::vector<std::pair<size_t, double>>& matchingCells = cellsAtIJ(i, j);
|
||||
if (!matchingCells.empty())
|
||||
{
|
||||
switch (m_resultAggregation())
|
||||
{
|
||||
case RESULTS_TOP_VALUE:
|
||||
{
|
||||
size_t cellIdx = matchingCells.front().first;
|
||||
double cellValue = gridCellValue(cellIdx);
|
||||
return cellValue;
|
||||
}
|
||||
case RESULTS_MEAN_VALUE:
|
||||
{
|
||||
RiaWeightedMeanCalculator<double> calculator;
|
||||
for (auto cellIdxAndWeight : matchingCells)
|
||||
{
|
||||
size_t cellIdx = cellIdxAndWeight.first;
|
||||
double cellValue = gridCellValue(cellIdx);
|
||||
if (cellValue != std::numeric_limits<double>::infinity())
|
||||
{
|
||||
calculator.addValueAndWeight(cellValue, cellIdxAndWeight.second);
|
||||
}
|
||||
}
|
||||
if (calculator.validAggregatedWeight())
|
||||
{
|
||||
return calculator.weightedMean();
|
||||
}
|
||||
return std::numeric_limits<double>::infinity();
|
||||
}
|
||||
case RESULTS_GEOM_VALUE:
|
||||
{
|
||||
RiaWeightedGeometricMeanCalculator calculator;
|
||||
for (auto cellIdxAndWeight : matchingCells)
|
||||
{
|
||||
size_t cellIdx = cellIdxAndWeight.first;
|
||||
double cellValue = gridCellValue(cellIdx);
|
||||
if (cellValue < 1.0e-8)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
if (cellValue != std::numeric_limits<double>::infinity())
|
||||
{
|
||||
calculator.addValueAndWeight(cellValue, cellIdxAndWeight.second);
|
||||
}
|
||||
}
|
||||
if (calculator.validAggregatedWeight())
|
||||
{
|
||||
return calculator.weightedMean();
|
||||
}
|
||||
return std::numeric_limits<double>::infinity();
|
||||
}
|
||||
case RESULTS_HARM_VALUE:
|
||||
{
|
||||
RiaWeightedHarmonicMeanCalculator calculator;
|
||||
for (auto cellIdxAndWeight : matchingCells)
|
||||
{
|
||||
size_t cellIdx = cellIdxAndWeight.first;
|
||||
double cellValue = gridCellValue(cellIdx);
|
||||
if (std::fabs(cellValue) < 1.0e-8)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
if (cellValue != std::numeric_limits<double>::infinity())
|
||||
{
|
||||
calculator.addValueAndWeight(cellValue, cellIdxAndWeight.second);
|
||||
}
|
||||
}
|
||||
if (calculator.validAggregatedWeight())
|
||||
{
|
||||
return calculator.weightedMean();
|
||||
}
|
||||
return std::numeric_limits<double>::infinity();
|
||||
}
|
||||
case RESULTS_MAX_VALUE:
|
||||
{
|
||||
double maxValue = -std::numeric_limits<double>::infinity();
|
||||
for (auto cellIdxAndWeight : matchingCells)
|
||||
{
|
||||
size_t cellIdx = cellIdxAndWeight.first;
|
||||
double cellValue = gridCellValue(cellIdx);
|
||||
if (cellValue != std::numeric_limits<double>::infinity())
|
||||
{
|
||||
maxValue = std::max(maxValue, cellValue);
|
||||
}
|
||||
}
|
||||
return maxValue;
|
||||
}
|
||||
case RESULTS_MIN_VALUE:
|
||||
{
|
||||
double minValue = std::numeric_limits<double>::infinity();
|
||||
for (auto cellIdxAndWeight : matchingCells)
|
||||
{
|
||||
size_t cellIdx = cellIdxAndWeight.first;
|
||||
double cellValue = gridCellValue(cellIdx);
|
||||
minValue = std::min(minValue, cellValue);
|
||||
}
|
||||
return minValue;
|
||||
}
|
||||
case RESULTS_VOLUME_SUM:
|
||||
case RESULTS_SUM:
|
||||
{
|
||||
double sum = 0.0;
|
||||
for (auto cellIdxAndWeight : matchingCells)
|
||||
{
|
||||
size_t cellIdx = cellIdxAndWeight.first;
|
||||
double cellValue = gridCellValue(cellIdx);
|
||||
if (cellValue != std::numeric_limits<double>::infinity())
|
||||
{
|
||||
sum += cellValue * cellIdxAndWeight.second;
|
||||
}
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
default:
|
||||
CVF_TIGHT_ASSERT(false);
|
||||
}
|
||||
}
|
||||
return std::numeric_limits<double>::infinity();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -432,7 +553,19 @@ bool RimContourMapProjection::gridMappingNeedsUpdating() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return gridMappingImplNeedsUpdating();
|
||||
|
||||
if (m_cellGridIdxVisibility.isNull())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
cvf::ref<cvf::UByteArray> currentVisibility = getCellVisibility();
|
||||
|
||||
CVF_ASSERT(currentVisibility->size() == m_cellGridIdxVisibility->size());
|
||||
for (size_t i = 0; i < currentVisibility->size(); ++i)
|
||||
{
|
||||
if ((*currentVisibility)[i] != (*m_cellGridIdxVisibility)[i]) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -454,7 +587,7 @@ bool RimContourMapProjection::resultsNeedsUpdating(int timeStep) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return resultsImplNeedsUpdating();
|
||||
return resultVariableChanged();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -486,7 +619,72 @@ void RimContourMapProjection::clearResults()
|
||||
m_aggregatedVertexResults.clear();
|
||||
m_currentResultTimestep = -1;
|
||||
|
||||
clearImplSpecificResultData();
|
||||
clearResultVariable();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::UByteArray> RimContourMapProjection::getCellVisibility() const
|
||||
{
|
||||
return baseView()->currentTotalCellVisibility();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimContourMapProjection::generateGridMapping()
|
||||
{
|
||||
clearResults();
|
||||
|
||||
m_cellGridIdxVisibility = getCellVisibility();
|
||||
|
||||
int nCells = numberOfCells();
|
||||
m_projected3dGridIndices.resize(nCells);
|
||||
|
||||
std::vector<double> weightingResultValues = retrieveParameterWeights();
|
||||
|
||||
if (isStraightSummationResult())
|
||||
{
|
||||
#pragma omp parallel for
|
||||
for (int index = 0; index < nCells; ++index)
|
||||
{
|
||||
cvf::Vec2ui ij = ijFromCellIndex(index);
|
||||
|
||||
cvf::Vec2d globalPos = cellCenterPosition(ij.x(), ij.y()) + origin2d();
|
||||
m_projected3dGridIndices[index] = cellRayIntersectionAndResults(globalPos, weightingResultValues);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#pragma omp parallel for
|
||||
for (int index = 0; index < nCells; ++index)
|
||||
{
|
||||
cvf::Vec2ui ij = ijFromCellIndex(index);
|
||||
|
||||
cvf::Vec2d globalPos = cellCenterPosition(ij.x(), ij.y()) + origin2d();
|
||||
m_projected3dGridIndices[index] = cellOverlapVolumesAndResults(globalPos, weightingResultValues);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimContourMapProjection::generateVertexResults()
|
||||
{
|
||||
size_t nCells = numberOfCells();
|
||||
if (nCells != m_aggregatedResults.size())
|
||||
return;
|
||||
|
||||
size_t nVertices = numberOfVertices();
|
||||
m_aggregatedVertexResults = std::vector<double>(nVertices, std::numeric_limits<double>::infinity());
|
||||
#pragma omp parallel for
|
||||
for (int index = 0; index < static_cast<int>(nVertices); ++index)
|
||||
{
|
||||
cvf::Vec2ui ij = ijFromVertexIndex(index);
|
||||
m_aggregatedVertexResults[index] = calculateValueAtVertex(ij.x(), ij.y());
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -541,7 +739,8 @@ void RimContourMapProjection::generateTrianglesWithVertexValues()
|
||||
for (size_t n = 0; n < 3; ++n)
|
||||
{
|
||||
uint vn = (*faceList)[i + n];
|
||||
double value = m_aggregatedVertexResults[vn];
|
||||
double value = vn < m_aggregatedVertexResults.size() ? m_aggregatedVertexResults[vn]
|
||||
: std::numeric_limits<double>::infinity();
|
||||
triangle[n] = vertices[vn];
|
||||
triangleWithValues[n] = cvf::Vec4d(vertices[vn], value);
|
||||
}
|
||||
@ -829,6 +1028,121 @@ void RimContourMapProjection::smoothContourPolygons(ContourPolygons* conto
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<std::pair<size_t, double>>
|
||||
RimContourMapProjection::cellOverlapVolumesAndResults(const cvf::Vec2d& globalPos2d,
|
||||
const std::vector<double>& weightingResultValues) const
|
||||
{
|
||||
cvf::Vec3d top2dElementCentroid(globalPos2d, m_expandedBoundingBox.max().z());
|
||||
cvf::Vec3d bottom2dElementCentroid(globalPos2d, m_expandedBoundingBox.min().z());
|
||||
cvf::Vec3d planarDiagonalVector(0.5 * m_sampleSpacing, 0.5 * m_sampleSpacing, 0.0);
|
||||
cvf::Vec3d topNECorner = top2dElementCentroid + planarDiagonalVector;
|
||||
cvf::Vec3d bottomSWCorner = bottom2dElementCentroid - planarDiagonalVector;
|
||||
|
||||
cvf::BoundingBox bbox2dElement(bottomSWCorner, topNECorner);
|
||||
|
||||
std::vector<std::pair<size_t, double>> matchingVisibleCellsAndWeight;
|
||||
|
||||
// Bounding box has been expanded, so 2d element may be outside actual 3d grid
|
||||
if (!bbox2dElement.intersects(m_gridBoundingBox))
|
||||
{
|
||||
return matchingVisibleCellsAndWeight;
|
||||
}
|
||||
|
||||
std::vector<size_t> allCellIndices = findIntersectingCells(bbox2dElement);
|
||||
|
||||
typedef std::map<size_t, std::vector<std::pair<size_t, double>>> KLayerCellWeightMap;
|
||||
KLayerCellWeightMap matchingVisibleCellsWeightPerKLayer;
|
||||
|
||||
for (size_t globalCellIdx : allCellIndices)
|
||||
{
|
||||
if ((*m_cellGridIdxVisibility)[globalCellIdx])
|
||||
{
|
||||
size_t cellKLayer = 0u;
|
||||
double overlapVolume = calculateOverlapVolume(globalCellIdx, bbox2dElement, &cellKLayer);
|
||||
|
||||
if (overlapVolume > 0.0)
|
||||
{
|
||||
double weight = overlapVolume * getParameterWeightForCell(globalCellIdx, weightingResultValues);
|
||||
|
||||
if (weight > 0.0)
|
||||
{
|
||||
matchingVisibleCellsWeightPerKLayer[cellKLayer].push_back(std::make_pair(globalCellIdx, weight));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto kLayerCellWeight : matchingVisibleCellsWeightPerKLayer)
|
||||
{
|
||||
for (auto cellWeight : kLayerCellWeight.second)
|
||||
{
|
||||
matchingVisibleCellsAndWeight.push_back(std::make_pair(cellWeight.first, cellWeight.second));
|
||||
}
|
||||
}
|
||||
|
||||
return matchingVisibleCellsAndWeight;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<std::pair<size_t, double>>
|
||||
RimContourMapProjection::cellRayIntersectionAndResults(const cvf::Vec2d& globalPos2d,
|
||||
const std::vector<double>& weightingResultValues) const
|
||||
{
|
||||
std::vector<std::pair<size_t, double>> matchingVisibleCellsAndWeight;
|
||||
|
||||
cvf::Vec3d highestPoint(globalPos2d, m_expandedBoundingBox.max().z());
|
||||
cvf::Vec3d lowestPoint(globalPos2d, m_expandedBoundingBox.min().z());
|
||||
|
||||
// Bounding box has been expanded, so ray may be outside actual grid
|
||||
if (!m_gridBoundingBox.contains(highestPoint))
|
||||
{
|
||||
return matchingVisibleCellsAndWeight;
|
||||
}
|
||||
|
||||
cvf::BoundingBox rayBBox;
|
||||
rayBBox.add(highestPoint);
|
||||
rayBBox.add(lowestPoint);
|
||||
|
||||
std::vector<size_t> allCellIndices = findIntersectingCells(rayBBox);
|
||||
|
||||
std::map<size_t, std::vector<std::pair<size_t, double>>> matchingVisibleCellsAndWeightPerKLayer;
|
||||
|
||||
for (size_t globalCellIdx : allCellIndices)
|
||||
{
|
||||
if ((*m_cellGridIdxVisibility)[globalCellIdx])
|
||||
{
|
||||
size_t cellKLayer = 0u;
|
||||
double lengthInCell = calculateRayLengthInCell(globalCellIdx, highestPoint, lowestPoint, &cellKLayer);
|
||||
if (lengthInCell > 0.0)
|
||||
{
|
||||
matchingVisibleCellsAndWeightPerKLayer[cellKLayer].push_back(std::make_pair(globalCellIdx, lengthInCell));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto kLayerCellWeight : matchingVisibleCellsAndWeightPerKLayer)
|
||||
{
|
||||
// Make sure the sum of all weights in the same K-layer is 1.
|
||||
double weightSumThisKLayer = 0.0;
|
||||
for (auto cellWeight : kLayerCellWeight.second)
|
||||
{
|
||||
weightSumThisKLayer += cellWeight.second;
|
||||
}
|
||||
|
||||
for (auto cellWeight : kLayerCellWeight.second)
|
||||
{
|
||||
matchingVisibleCellsAndWeight.push_back(std::make_pair(cellWeight.first, cellWeight.second / weightSumThisKLayer));
|
||||
}
|
||||
}
|
||||
|
||||
return matchingVisibleCellsAndWeight;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
#include "cvfArray.h"
|
||||
#include "cvfBoundingBox.h"
|
||||
#include "cvfGeometryBuilderFaceList.h"
|
||||
#include "cvfString.h"
|
||||
@ -116,13 +117,19 @@ public:
|
||||
|
||||
protected:
|
||||
// Protected virtual methods to be overridden by Eclipse and Geo-mechanical contour map implementations
|
||||
virtual void updateGridInformation() = 0;
|
||||
virtual void generateGridMapping() = 0;
|
||||
virtual void generateResults(int timeStep) = 0;
|
||||
virtual bool gridMappingImplNeedsUpdating() const = 0;
|
||||
virtual bool resultsImplNeedsUpdating() const = 0;
|
||||
virtual void clearImplSpecificResultData() = 0;
|
||||
virtual RimGridView* baseView() const = 0;
|
||||
virtual void updateGridInformation() = 0;
|
||||
virtual std::vector<double> retrieveParameterWeights() = 0;
|
||||
virtual void generateResults(int timeStep) = 0;
|
||||
virtual bool resultVariableChanged() const = 0;
|
||||
virtual void clearResultVariable() = 0;
|
||||
virtual RimGridView* baseView() const = 0;
|
||||
virtual std::vector<size_t> findIntersectingCells(const cvf::BoundingBox& bbox) const = 0;
|
||||
virtual double calculateOverlapVolume(size_t globalCellIdx, const cvf::BoundingBox& bbox, size_t* cellKLayerOut) const = 0;
|
||||
virtual double calculateRayLengthInCell(size_t globalCellIdx, const cvf::Vec3d& highestPoint, const cvf::Vec3d& lowestPoint, size_t* cellKLayerOut) const = 0;
|
||||
virtual double getParameterWeightForCell(size_t globalCellIdx, const std::vector<double>& parameterWeights) const = 0;
|
||||
virtual double gridCellValue(size_t globalCellIdx) const = 0;
|
||||
|
||||
virtual double calculateValueInMapCell(uint i, uint j) const;
|
||||
|
||||
protected:
|
||||
// Keep track of whether cached data needs updating
|
||||
@ -132,11 +139,19 @@ protected:
|
||||
void clearGridMapping();
|
||||
void clearResults();
|
||||
|
||||
virtual cvf::ref<cvf::UByteArray> getCellVisibility() const;
|
||||
void generateGridMapping();
|
||||
void generateVertexResults();
|
||||
void generateTrianglesWithVertexValues();
|
||||
std::vector<cvf::Vec3d> generateVertices() const;
|
||||
void generateContourPolygons();
|
||||
void smoothContourPolygons(ContourPolygons* contourPolygons, const ContourPolygons* clipBy, bool favourExpansion);
|
||||
|
||||
|
||||
std::vector<CellIndexAndResult> cellOverlapVolumesAndResults(const cvf::Vec2d& globalPos2d,
|
||||
const std::vector<double>& weightingResultValues) const;
|
||||
std::vector<CellIndexAndResult> cellRayIntersectionAndResults(const cvf::Vec2d& globalPos2d,
|
||||
const std::vector<double>& weightingResultValues) const;
|
||||
|
||||
bool isMeanResult() const;
|
||||
bool isSummationResult() const;
|
||||
bool isStraightSummationResult() const;
|
||||
@ -182,6 +197,7 @@ protected:
|
||||
caf::PdmField<bool> m_showContourLabels;
|
||||
caf::PdmField<bool> m_smoothContourLines;
|
||||
|
||||
cvf::ref<cvf::UByteArray> m_cellGridIdxVisibility;
|
||||
std::vector<double> m_aggregatedResults;
|
||||
std::vector<double> m_aggregatedVertexResults;
|
||||
std::vector<std::vector<std::pair<size_t, double>>> m_projected3dGridIndices;
|
||||
|
@ -36,7 +36,7 @@
|
||||
#include "RigVirtualPerforationTransmissibilities.h"
|
||||
|
||||
#include "RimEclipseContourMapView.h"
|
||||
#include "RimContourMapViewCollection.h"
|
||||
#include "RimEclipseContourMapViewCollection.h"
|
||||
#include "Rim2dIntersectionView.h"
|
||||
#include "Rim2dIntersectionViewCollection.h"
|
||||
#include "RimCaseCollection.h"
|
||||
@ -102,7 +102,7 @@ RimEclipseCase::RimEclipseCase()
|
||||
m_filesContainingFaultsSemColSeparated.uiCapability()->setUiHidden(true);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_contourMapCollection, "ContourMaps", "2d Contour Maps", "", "", "");
|
||||
m_contourMapCollection = new RimContourMapViewCollection;
|
||||
m_contourMapCollection = new RimEclipseContourMapViewCollection;
|
||||
m_contourMapCollection.uiCapability()->setUiTreeHidden(true);
|
||||
|
||||
// Obsolete fields
|
||||
@ -517,10 +517,12 @@ void RimEclipseCase::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering
|
||||
{
|
||||
uiTreeOrdering.add(&m_2dIntersectionViewCollection);
|
||||
}
|
||||
|
||||
if (!m_contourMapCollection->views().empty())
|
||||
{
|
||||
uiTreeOrdering.add(&m_contourMapCollection);
|
||||
}
|
||||
|
||||
uiTreeOrdering.skipRemainingChildren(true);
|
||||
}
|
||||
|
||||
@ -572,7 +574,7 @@ RimCaseCollection* RimEclipseCase::parentCaseCollection()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimContourMapViewCollection* RimEclipseCase::contourMapCollection()
|
||||
RimEclipseContourMapViewCollection* RimEclipseCase::contourMapCollection()
|
||||
{
|
||||
return m_contourMapCollection;
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ class RimCaseCollection;
|
||||
class RimIdenticalGridCaseGroup;
|
||||
class RimReservoirCellResultsStorage;
|
||||
class RimEclipseContourMapView;
|
||||
class RimContourMapViewCollection;
|
||||
class RimEclipseContourMapViewCollection;
|
||||
class RimEclipseView;
|
||||
class RigVirtualPerforationTransmissibilities;
|
||||
|
||||
@ -95,7 +95,7 @@ public:
|
||||
|
||||
|
||||
RimCaseCollection* parentCaseCollection();
|
||||
RimContourMapViewCollection* contourMapCollection();
|
||||
RimEclipseContourMapViewCollection* contourMapCollection();
|
||||
|
||||
QStringList timeStepStrings() const override;
|
||||
QString timeStepName(int frameIdx) const override;
|
||||
@ -140,7 +140,7 @@ private:
|
||||
caf::PdmField<QString> m_filesContainingFaultsSemColSeparated;
|
||||
caf::PdmField<bool> m_releaseResultMemory;
|
||||
|
||||
caf::PdmChildField<RimContourMapViewCollection*> m_contourMapCollection;
|
||||
caf::PdmChildField<RimEclipseContourMapViewCollection*> m_contourMapCollection;
|
||||
|
||||
cvf::ref<RigEclipseCaseData> m_rigEclipseCase;
|
||||
QString m_timeStepFormatString;
|
||||
|
@ -176,96 +176,6 @@ void RimEclipseContourMapProjection::updatedWeightingResult()
|
||||
proj->scheduleCreateDisplayModelAndRedrawAllViews();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEclipseContourMapProjection::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
||||
{
|
||||
RimContourMapProjection::defineUiOrdering(uiConfigName, uiOrdering);
|
||||
|
||||
caf::PdmUiGroup* weightingGroup = uiOrdering.addNewGroup("Mean Weighting Options");
|
||||
weightingGroup->add(&m_weightByParameter);
|
||||
weightingGroup->setCollapsedByDefault(true);
|
||||
|
||||
m_weightByParameter.uiCapability()->setUiReadOnly(!isMeanResult());
|
||||
if (!isMeanResult())
|
||||
{
|
||||
m_weightByParameter = false;
|
||||
}
|
||||
|
||||
if (m_weightByParameter())
|
||||
{
|
||||
m_weightingResult->uiOrdering(uiConfigName, *weightingGroup);
|
||||
}
|
||||
|
||||
uiOrdering.skipRemainingFields(true);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEclipseContourMapProjection::initAfterRead()
|
||||
{
|
||||
RimContourMapProjection::initAfterRead();
|
||||
if (eclipseCase())
|
||||
{
|
||||
m_weightingResult->setEclipseCase(eclipseCase());
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEclipseContourMapProjection::generateGridMapping()
|
||||
{
|
||||
clearResults();
|
||||
|
||||
m_cellGridIdxVisibility = view()->currentTotalCellVisibility();
|
||||
|
||||
int nCells = numberOfCells();
|
||||
m_projected3dGridIndices.resize(nCells);
|
||||
|
||||
const std::vector<double>* weightingResultValues = nullptr;
|
||||
if (m_weightByParameter())
|
||||
{
|
||||
size_t gridScalarResultIdx = m_weightingResult->scalarResultIndex();
|
||||
if (gridScalarResultIdx != cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
m_weightingResult->loadResult();
|
||||
int timeStep = 0;
|
||||
if (m_weightingResult->hasDynamicResult())
|
||||
{
|
||||
timeStep = view()->currentTimeStep();
|
||||
}
|
||||
weightingResultValues =
|
||||
&(m_weightingResult->currentGridCellResults()->cellScalarResults(gridScalarResultIdx)[timeStep]);
|
||||
}
|
||||
}
|
||||
|
||||
if (isStraightSummationResult())
|
||||
{
|
||||
#pragma omp parallel for
|
||||
for (int index = 0; index < nCells; ++index)
|
||||
{
|
||||
cvf::Vec2ui ij = ijFromCellIndex(index);
|
||||
|
||||
cvf::Vec2d globalPos = cellCenterPosition(ij.x(), ij.y()) + origin2d();
|
||||
m_projected3dGridIndices[index] = visibleCellsAndLengthInCellFrom2dPoint(globalPos, weightingResultValues);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#pragma omp parallel for
|
||||
for (int index = 0; index < nCells; ++index)
|
||||
{
|
||||
cvf::Vec2ui ij = ijFromCellIndex(index);
|
||||
|
||||
cvf::Vec2d globalPos = cellCenterPosition(ij.x(), ij.y()) + origin2d();
|
||||
m_projected3dGridIndices[index] = visibleCellsAndOverlapVolumeFrom2dPoint(globalPos, weightingResultValues);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -276,12 +186,10 @@ void RimEclipseContourMapProjection::generateResults(int timeStep)
|
||||
m_weightingResult->loadResult();
|
||||
|
||||
size_t nCells = numberOfCells();
|
||||
size_t nVertices = numberOfVertices();
|
||||
|
||||
m_aggregatedResults = std::vector<double>(nCells, std::numeric_limits<double>::infinity());
|
||||
m_aggregatedVertexResults = std::vector<double>(nVertices, std::numeric_limits<double>::infinity());
|
||||
RimEclipseCellColors* cellColors = view()->cellResult();
|
||||
|
||||
RimEclipseCellColors* cellColors = view()->cellResult();
|
||||
RimEclipseResultCase* eclipseCase = this->eclipseCase();
|
||||
{
|
||||
if (!cellColors->isTernarySaturationSelected())
|
||||
@ -319,14 +227,7 @@ void RimEclipseContourMapProjection::generateResults(int timeStep)
|
||||
for (int index = 0; index < static_cast<int>(nCells); ++index)
|
||||
{
|
||||
cvf::Vec2ui ij = ijFromCellIndex(index);
|
||||
m_aggregatedResults[index] = calculateValueInCell(ij.x(), ij.y());
|
||||
}
|
||||
|
||||
#pragma omp parallel for
|
||||
for (int index = 0; index < static_cast<int>(nVertices); ++index)
|
||||
{
|
||||
cvf::Vec2ui ij = ijFromVertexIndex(index);
|
||||
m_aggregatedVertexResults[index] = calculateValueAtVertex(ij.x(), ij.y());
|
||||
m_aggregatedResults[index] = calculateValueInMapCell(ij.x(), ij.y());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -336,25 +237,7 @@ void RimEclipseContourMapProjection::generateResults(int timeStep)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimEclipseContourMapProjection::gridMappingImplNeedsUpdating() const
|
||||
{
|
||||
if (m_cellGridIdxVisibility.isNull())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
cvf::ref<cvf::UByteArray> currentVisibility = view()->currentTotalCellVisibility();
|
||||
CVF_ASSERT(currentVisibility->size() == m_cellGridIdxVisibility->size());
|
||||
for (size_t i = 0; i < currentVisibility->size(); ++i)
|
||||
{
|
||||
if ((*currentVisibility)[i] != (*m_cellGridIdxVisibility)[i]) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimEclipseContourMapProjection::resultsImplNeedsUpdating() const
|
||||
bool RimEclipseContourMapProjection::resultVariableChanged() const
|
||||
{
|
||||
if (!m_currentResultName.isEmpty())
|
||||
{
|
||||
@ -370,7 +253,7 @@ bool RimEclipseContourMapProjection::resultsImplNeedsUpdating() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEclipseContourMapProjection::clearImplSpecificResultData()
|
||||
void RimEclipseContourMapProjection::clearResultVariable()
|
||||
{
|
||||
m_currentResultName = "";
|
||||
}
|
||||
@ -378,130 +261,41 @@ void RimEclipseContourMapProjection::clearImplSpecificResultData()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RimEclipseContourMapProjection::calculateValueInCell(uint i, uint j) const
|
||||
double RimEclipseContourMapProjection::calculateValueInMapCell(uint i, uint j) const
|
||||
{
|
||||
if (!isColumnResult())
|
||||
if (isColumnResult())
|
||||
{
|
||||
const std::vector<std::pair<size_t, double>>& matchingCells = cellsAtIJ(i, j);
|
||||
if (!matchingCells.empty())
|
||||
{
|
||||
switch (m_resultAggregation())
|
||||
{
|
||||
case RESULTS_OIL_COLUMN:
|
||||
case RESULTS_GAS_COLUMN:
|
||||
case RESULTS_HC_COLUMN:
|
||||
{
|
||||
double sum = 0.0;
|
||||
for (auto cellIdxAndWeight : matchingCells)
|
||||
{
|
||||
size_t cellIdx = cellIdxAndWeight.first;
|
||||
double cellValue = calculateColumnResult(m_resultAggregation(), cellIdx);
|
||||
sum += cellValue * cellIdxAndWeight.second;
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
default:
|
||||
CVF_TIGHT_ASSERT(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!view()->cellResult()->isFlowDiagOrInjectionFlooding() &&
|
||||
view()->cellResult()->scalarResultIndex() == cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
return 0.0; // Special case of NONE-result. Show 0 all over to ensure we see something.
|
||||
}
|
||||
}
|
||||
const std::vector<std::pair<size_t, double>>& matchingCells = cellsAtIJ(i, j);
|
||||
if (!matchingCells.empty())
|
||||
{
|
||||
switch (m_resultAggregation())
|
||||
{
|
||||
case RESULTS_TOP_VALUE:
|
||||
{
|
||||
size_t cellIdx = matchingCells.front().first;
|
||||
double cellValue = m_resultAccessor->cellScalarGlobIdx(cellIdx);
|
||||
return cellValue;
|
||||
}
|
||||
case RESULTS_MEAN_VALUE:
|
||||
{
|
||||
RiaWeightedMeanCalculator<double> calculator;
|
||||
for (auto cellIdxAndWeight : matchingCells)
|
||||
{
|
||||
size_t cellIdx = cellIdxAndWeight.first;
|
||||
double cellValue = m_resultAccessor->cellScalarGlobIdx(cellIdx);
|
||||
calculator.addValueAndWeight(cellValue, cellIdxAndWeight.second);
|
||||
}
|
||||
if (calculator.validAggregatedWeight())
|
||||
{
|
||||
return calculator.weightedMean();
|
||||
}
|
||||
return std::numeric_limits<double>::infinity();
|
||||
}
|
||||
case RESULTS_GEOM_VALUE:
|
||||
{
|
||||
RiaWeightedGeometricMeanCalculator calculator;
|
||||
for (auto cellIdxAndWeight : matchingCells)
|
||||
{
|
||||
size_t cellIdx = cellIdxAndWeight.first;
|
||||
double cellValue = m_resultAccessor->cellScalarGlobIdx(cellIdx);
|
||||
if (cellValue < 1.0e-8)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
calculator.addValueAndWeight(cellValue, cellIdxAndWeight.second);
|
||||
}
|
||||
if (calculator.validAggregatedWeight())
|
||||
{
|
||||
return calculator.weightedMean();
|
||||
}
|
||||
return std::numeric_limits<double>::infinity();
|
||||
}
|
||||
case RESULTS_HARM_VALUE:
|
||||
{
|
||||
RiaWeightedHarmonicMeanCalculator calculator;
|
||||
for (auto cellIdxAndWeight : matchingCells)
|
||||
{
|
||||
size_t cellIdx = cellIdxAndWeight.first;
|
||||
double cellValue = m_resultAccessor->cellScalarGlobIdx(cellIdx);
|
||||
if (std::fabs(cellValue) < 1.0e-8)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
calculator.addValueAndWeight(cellValue, cellIdxAndWeight.second);
|
||||
}
|
||||
if (calculator.validAggregatedWeight())
|
||||
{
|
||||
return calculator.weightedMean();
|
||||
}
|
||||
return std::numeric_limits<double>::infinity();
|
||||
}
|
||||
case RESULTS_MAX_VALUE:
|
||||
{
|
||||
double maxValue = -std::numeric_limits<double>::infinity();
|
||||
for (auto cellIdxAndWeight : matchingCells)
|
||||
{
|
||||
size_t cellIdx = cellIdxAndWeight.first;
|
||||
double cellValue = m_resultAccessor->cellScalarGlobIdx(cellIdx);
|
||||
maxValue = std::max(maxValue, cellValue);
|
||||
}
|
||||
return maxValue;
|
||||
}
|
||||
case RESULTS_MIN_VALUE:
|
||||
{
|
||||
double minValue = std::numeric_limits<double>::infinity();
|
||||
for (auto cellIdxAndWeight : matchingCells)
|
||||
{
|
||||
size_t cellIdx = cellIdxAndWeight.first;
|
||||
double cellValue = m_resultAccessor->cellScalarGlobIdx(cellIdx);
|
||||
minValue = std::min(minValue, cellValue);
|
||||
}
|
||||
return minValue;
|
||||
}
|
||||
case RESULTS_VOLUME_SUM:
|
||||
case RESULTS_SUM:
|
||||
{
|
||||
double sum = 0.0;
|
||||
for (auto cellIdxAndWeight : matchingCells)
|
||||
{
|
||||
size_t cellIdx = cellIdxAndWeight.first;
|
||||
double cellValue = m_resultAccessor->cellScalarGlobIdx(cellIdx);
|
||||
sum += cellValue * cellIdxAndWeight.second;
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
case RESULTS_OIL_COLUMN:
|
||||
case RESULTS_GAS_COLUMN:
|
||||
case RESULTS_HC_COLUMN:
|
||||
{
|
||||
double sum = 0.0;
|
||||
for (auto cellIdxAndWeight : matchingCells)
|
||||
{
|
||||
size_t cellIdx = cellIdxAndWeight.first;
|
||||
double cellValue = calculateColumnResult(m_resultAggregation(), cellIdx);
|
||||
sum += cellValue * cellIdxAndWeight.second;
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
default:
|
||||
CVF_TIGHT_ASSERT(false);
|
||||
}
|
||||
return RimContourMapProjection::calculateValueInMapCell(i, j);
|
||||
}
|
||||
return std::numeric_limits<double>::infinity();
|
||||
}
|
||||
@ -562,162 +356,6 @@ double RimEclipseContourMapProjection::calculateColumnResult(ResultAggregation r
|
||||
return resultValue * poro * ntg * dz;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<std::pair<size_t, double>>
|
||||
RimEclipseContourMapProjection::visibleCellsAndOverlapVolumeFrom2dPoint(const cvf::Vec2d& globalPos2d,
|
||||
const std::vector<double>* weightingResultValues) const
|
||||
{
|
||||
cvf::Vec3d top2dElementCentroid(globalPos2d, m_expandedBoundingBox.max().z());
|
||||
cvf::Vec3d bottom2dElementCentroid(globalPos2d, m_expandedBoundingBox.min().z());
|
||||
cvf::Vec3d planarDiagonalVector(0.5 * m_sampleSpacing, 0.5 * m_sampleSpacing, 0.0);
|
||||
cvf::Vec3d topNECorner = top2dElementCentroid + planarDiagonalVector;
|
||||
cvf::Vec3d bottomSWCorner = bottom2dElementCentroid - planarDiagonalVector;
|
||||
|
||||
cvf::BoundingBox bbox2dElement(bottomSWCorner, topNECorner);
|
||||
|
||||
std::vector<std::pair<size_t, double>> matchingVisibleCellsAndWeight;
|
||||
|
||||
// Bounding box has been expanded, so 2d element may be outside actual 3d grid
|
||||
if (!bbox2dElement.intersects(m_gridBoundingBox))
|
||||
{
|
||||
return matchingVisibleCellsAndWeight;
|
||||
}
|
||||
|
||||
std::vector<size_t> allCellIndices;
|
||||
m_mainGrid->findIntersectingCells(bbox2dElement, &allCellIndices);
|
||||
|
||||
typedef std::map<size_t, std::vector<std::pair<size_t, double>>> KLayerCellWeightMap;
|
||||
KLayerCellWeightMap matchingVisibleCellsWeightPerKLayer;
|
||||
|
||||
std::array<cvf::Vec3d, 8> hexCorners;
|
||||
for (size_t globalCellIdx : allCellIndices)
|
||||
{
|
||||
if ((*m_cellGridIdxVisibility)[globalCellIdx])
|
||||
{
|
||||
RigCell cell = m_mainGrid->globalCellArray()[globalCellIdx];
|
||||
|
||||
size_t mainGridCellIdx = cell.mainGridCellIndex();
|
||||
size_t i, j, k;
|
||||
m_mainGrid->ijkFromCellIndex(mainGridCellIdx, &i, &j, &k);
|
||||
|
||||
size_t localCellIdx = cell.gridLocalCellIndex();
|
||||
RigGridBase* localGrid = cell.hostGrid();
|
||||
|
||||
localGrid->cellCornerVertices(localCellIdx, hexCorners.data());
|
||||
|
||||
cvf::BoundingBox overlapBBox;
|
||||
std::array<cvf::Vec3d, 8> overlapCorners =
|
||||
RigCellGeometryTools::estimateHexOverlapWithBoundingBox(hexCorners, bbox2dElement, &overlapBBox);
|
||||
|
||||
double overlapVolume = RigCellGeometryTools::calculateCellVolume(overlapCorners);
|
||||
|
||||
if (overlapVolume > 0.0)
|
||||
{
|
||||
double weight = overlapVolume;
|
||||
if (weightingResultValues)
|
||||
{
|
||||
const RigActiveCellInfo* activeCellInfo =
|
||||
eclipseCase()->eclipseCaseData()->activeCellInfo(RiaDefines::MATRIX_MODEL);
|
||||
size_t cellResultIdx = activeCellInfo->cellResultIndex(globalCellIdx);
|
||||
double result = std::max((*weightingResultValues)[cellResultIdx], 0.0);
|
||||
if (result < 1.0e-6)
|
||||
{
|
||||
result = 0.0;
|
||||
}
|
||||
weight *= result;
|
||||
}
|
||||
if (weight > 0.0)
|
||||
{
|
||||
matchingVisibleCellsWeightPerKLayer[k].push_back(std::make_pair(globalCellIdx, weight));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto kLayerCellWeight : matchingVisibleCellsWeightPerKLayer)
|
||||
{
|
||||
for (auto cellWeight : kLayerCellWeight.second)
|
||||
{
|
||||
matchingVisibleCellsAndWeight.push_back(std::make_pair(cellWeight.first, cellWeight.second));
|
||||
}
|
||||
}
|
||||
|
||||
return matchingVisibleCellsAndWeight;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<std::pair<size_t, double>> RimEclipseContourMapProjection::visibleCellsAndLengthInCellFrom2dPoint(
|
||||
const cvf::Vec2d& globalPos2d,
|
||||
const std::vector<double>* weightingResultValues /*= nullptr*/) const
|
||||
{
|
||||
std::vector<std::pair<size_t, double>> matchingVisibleCellsAndWeight;
|
||||
|
||||
cvf::Vec3d highestPoint(globalPos2d, m_expandedBoundingBox.max().z());
|
||||
cvf::Vec3d lowestPoint(globalPos2d, m_expandedBoundingBox.min().z());
|
||||
|
||||
// Bounding box has been expanded, so ray may be outside actual grid
|
||||
if (!m_gridBoundingBox.contains(highestPoint))
|
||||
{
|
||||
return matchingVisibleCellsAndWeight;
|
||||
}
|
||||
|
||||
cvf::BoundingBox rayBBox;
|
||||
rayBBox.add(highestPoint);
|
||||
rayBBox.add(lowestPoint);
|
||||
|
||||
std::vector<size_t> allCellIndices;
|
||||
m_mainGrid->findIntersectingCells(rayBBox, &allCellIndices);
|
||||
|
||||
std::map<size_t, std::vector<std::pair<size_t, double>>> matchingVisibleCellsAndWeightPerKLayer;
|
||||
|
||||
cvf::Vec3d hexCorners[8];
|
||||
for (size_t globalCellIdx : allCellIndices)
|
||||
{
|
||||
if ((*m_cellGridIdxVisibility)[globalCellIdx])
|
||||
{
|
||||
RigCell cell = m_mainGrid->globalCellArray()[globalCellIdx];
|
||||
|
||||
size_t mainGridCellIdx = cell.mainGridCellIndex();
|
||||
size_t i, j, k;
|
||||
m_mainGrid->ijkFromCellIndex(mainGridCellIdx, &i, &j, &k);
|
||||
|
||||
size_t localCellIdx = cell.gridLocalCellIndex();
|
||||
RigGridBase* localGrid = cell.hostGrid();
|
||||
|
||||
localGrid->cellCornerVertices(localCellIdx, hexCorners);
|
||||
std::vector<HexIntersectionInfo> intersections;
|
||||
|
||||
if (RigHexIntersectionTools::lineHexCellIntersection(highestPoint, lowestPoint, hexCorners, 0, &intersections))
|
||||
{
|
||||
double lengthInCell =
|
||||
(intersections.back().m_intersectionPoint - intersections.front().m_intersectionPoint).length();
|
||||
matchingVisibleCellsAndWeightPerKLayer[k].push_back(std::make_pair(globalCellIdx, lengthInCell));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto kLayerCellWeight : matchingVisibleCellsAndWeightPerKLayer)
|
||||
{
|
||||
// Make sure the sum of all weights in the same K-layer is 1.
|
||||
double weightSumThisKLayer = 0.0;
|
||||
for (auto cellWeight : kLayerCellWeight.second)
|
||||
{
|
||||
weightSumThisKLayer += cellWeight.second;
|
||||
}
|
||||
|
||||
for (auto cellWeight : kLayerCellWeight.second)
|
||||
{
|
||||
matchingVisibleCellsAndWeight.push_back(std::make_pair(cellWeight.first, cellWeight.second / weightSumThisKLayer));
|
||||
}
|
||||
}
|
||||
|
||||
return matchingVisibleCellsAndWeight;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -740,6 +378,29 @@ void RimEclipseContourMapProjection::updateGridInformation()
|
||||
m_expandedBoundingBox = cvf::BoundingBox(minPoint, maxPoint);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<double> RimEclipseContourMapProjection::retrieveParameterWeights()
|
||||
{
|
||||
std::vector<double> weights;
|
||||
if (m_weightByParameter())
|
||||
{
|
||||
size_t gridScalarResultIdx = m_weightingResult->scalarResultIndex();
|
||||
if (gridScalarResultIdx != cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
m_weightingResult->loadResult();
|
||||
int timeStep = 0;
|
||||
if (m_weightingResult->hasDynamicResult())
|
||||
{
|
||||
timeStep = view()->currentTimeStep();
|
||||
}
|
||||
weights = m_weightingResult->currentGridCellResults()->cellScalarResults(gridScalarResultIdx)[timeStep];
|
||||
}
|
||||
}
|
||||
return weights;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -758,6 +419,105 @@ RimGridView* RimEclipseContourMapProjection::baseView() const
|
||||
return view();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<size_t> RimEclipseContourMapProjection::findIntersectingCells(const cvf::BoundingBox& bbox) const
|
||||
{
|
||||
std::vector<size_t> allCellIndices;
|
||||
m_mainGrid->findIntersectingCells(bbox, &allCellIndices);
|
||||
return allCellIndices;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RimEclipseContourMapProjection::calculateOverlapVolume(size_t globalCellIdx, const cvf::BoundingBox& bbox, size_t* cellKLayerOut) const
|
||||
{
|
||||
CVF_ASSERT(cellKLayerOut != nullptr);
|
||||
|
||||
std::array<cvf::Vec3d, 8> hexCorners;
|
||||
|
||||
RigCell cell = m_mainGrid->globalCellArray()[globalCellIdx];
|
||||
|
||||
size_t mainGridCellIdx = cell.mainGridCellIndex();
|
||||
size_t i, j, k;
|
||||
m_mainGrid->ijkFromCellIndex(mainGridCellIdx, &i, &j, &k);
|
||||
|
||||
size_t localCellIdx = cell.gridLocalCellIndex();
|
||||
RigGridBase* localGrid = cell.hostGrid();
|
||||
|
||||
localGrid->cellCornerVertices(localCellIdx, hexCorners.data());
|
||||
|
||||
cvf::BoundingBox overlapBBox;
|
||||
std::array<cvf::Vec3d, 8> overlapCorners =
|
||||
RigCellGeometryTools::estimateHexOverlapWithBoundingBox(hexCorners, bbox, &overlapBBox);
|
||||
|
||||
double overlapVolume = RigCellGeometryTools::calculateCellVolume(overlapCorners);
|
||||
|
||||
*cellKLayerOut = k;
|
||||
|
||||
return overlapVolume;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RimEclipseContourMapProjection::calculateRayLengthInCell(size_t globalCellIdx,
|
||||
const cvf::Vec3d& highestPoint,
|
||||
const cvf::Vec3d& lowestPoint,
|
||||
size_t* cellKLayerOut) const
|
||||
{
|
||||
CVF_ASSERT(cellKLayerOut);
|
||||
|
||||
std::array<cvf::Vec3d, 8> hexCorners;
|
||||
|
||||
RigCell cell = m_mainGrid->globalCellArray()[globalCellIdx];
|
||||
|
||||
size_t mainGridCellIdx = cell.mainGridCellIndex();
|
||||
size_t i, j, k;
|
||||
m_mainGrid->ijkFromCellIndex(mainGridCellIdx, &i, &j, &k);
|
||||
|
||||
size_t localCellIdx = cell.gridLocalCellIndex();
|
||||
RigGridBase* localGrid = cell.hostGrid();
|
||||
|
||||
localGrid->cellCornerVertices(localCellIdx, hexCorners.data());
|
||||
std::vector<HexIntersectionInfo> intersections;
|
||||
|
||||
if (RigHexIntersectionTools::lineHexCellIntersection(highestPoint, lowestPoint, hexCorners.data(), 0, &intersections))
|
||||
{
|
||||
double lengthInCell = (intersections.back().m_intersectionPoint - intersections.front().m_intersectionPoint).length();
|
||||
*cellKLayerOut = k;
|
||||
return lengthInCell;
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RimEclipseContourMapProjection::getParameterWeightForCell(size_t globalCellIdx, const std::vector<double>& cellWeights) const
|
||||
{
|
||||
if (cellWeights.empty()) return 1.0;
|
||||
|
||||
const RigActiveCellInfo* activeCellInfo = eclipseCase()->eclipseCaseData()->activeCellInfo(RiaDefines::MATRIX_MODEL);
|
||||
size_t cellResultIdx = activeCellInfo->cellResultIndex(globalCellIdx);
|
||||
double result = std::max(cellWeights[cellResultIdx], 0.0);
|
||||
if (result < 1.0e-6)
|
||||
{
|
||||
result = 0.0;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RimEclipseContourMapProjection::gridCellValue(size_t globalCellIdx) const
|
||||
{
|
||||
return m_resultAccessor->cellScalarGlobIdx(globalCellIdx);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -781,3 +541,40 @@ void RimEclipseContourMapProjection::fieldChangedByUi(const caf::PdmFieldHandle*
|
||||
clearGridMapping();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEclipseContourMapProjection::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
||||
{
|
||||
RimContourMapProjection::defineUiOrdering(uiConfigName, uiOrdering);
|
||||
|
||||
caf::PdmUiGroup* weightingGroup = uiOrdering.addNewGroup("Mean Weighting Options");
|
||||
weightingGroup->add(&m_weightByParameter);
|
||||
weightingGroup->setCollapsedByDefault(true);
|
||||
|
||||
m_weightByParameter.uiCapability()->setUiReadOnly(!isMeanResult());
|
||||
if (!isMeanResult())
|
||||
{
|
||||
m_weightByParameter = false;
|
||||
}
|
||||
|
||||
if (m_weightByParameter())
|
||||
{
|
||||
m_weightingResult->uiOrdering(uiConfigName, *weightingGroup);
|
||||
}
|
||||
|
||||
uiOrdering.skipRemainingFields(true);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEclipseContourMapProjection::initAfterRead()
|
||||
{
|
||||
RimContourMapProjection::initAfterRead();
|
||||
if (eclipseCase())
|
||||
{
|
||||
m_weightingResult->setEclipseCase(eclipseCase());
|
||||
}
|
||||
}
|
||||
|
@ -62,18 +62,20 @@ protected:
|
||||
typedef RimContourMapProjection::CellIndexAndResult CellIndexAndResult;
|
||||
|
||||
void updateGridInformation() override;
|
||||
void generateGridMapping() override;
|
||||
std::vector<double> retrieveParameterWeights() override;
|
||||
void generateResults(int timeStep) override;
|
||||
bool gridMappingImplNeedsUpdating() const override;
|
||||
bool resultsImplNeedsUpdating() const override;
|
||||
void clearImplSpecificResultData() override;
|
||||
bool resultVariableChanged() const override;
|
||||
void clearResultVariable() override;
|
||||
RimGridView* baseView() const override;
|
||||
std::vector<size_t> findIntersectingCells(const cvf::BoundingBox& bbox) const override;
|
||||
double calculateOverlapVolume(size_t globalCellIdx, const cvf::BoundingBox& bbox, size_t* cellKLayerOut) const override;
|
||||
double calculateRayLengthInCell(size_t globalCellIdx, const cvf::Vec3d& highestPoint, const cvf::Vec3d& lowestPoint, size_t* cellKLayerOut) const override;
|
||||
double getParameterWeightForCell(size_t globalCellIdx, const std::vector<double>& parameterWeights) const override;
|
||||
double gridCellValue(size_t globalCellIdx) const override;
|
||||
|
||||
// Eclipse implementation specific data generation methods
|
||||
double calculateValueInCell(uint i, uint j) const;
|
||||
double calculateValueInMapCell(uint i, uint j) const;
|
||||
double calculateColumnResult(ResultAggregation resultAggregation, size_t cellGlobalIdx) const;
|
||||
std::vector<CellIndexAndResult> visibleCellsAndOverlapVolumeFrom2dPoint(const cvf::Vec2d& globalPos2d, const std::vector<double>* weightingResultValues = nullptr) const;
|
||||
std::vector<CellIndexAndResult> visibleCellsAndLengthInCellFrom2dPoint(const cvf::Vec2d& globalPos2d, const std::vector<double>* weightingResultValues = nullptr) const;
|
||||
|
||||
RimEclipseResultCase* eclipseCase() const;
|
||||
RimEclipseContourMapView* view() const;
|
||||
@ -89,11 +91,8 @@ protected:
|
||||
caf::PdmField<bool> m_weightByParameter;
|
||||
caf::PdmChildField<RimEclipseResultDefinition*> m_weightingResult;
|
||||
|
||||
cvf::ref<cvf::UByteArray> m_cellGridIdxVisibility;
|
||||
|
||||
cvf::ref<RigResultAccessor> m_resultAccessor;
|
||||
|
||||
caf::PdmPointer<RimEclipseResultCase> m_eclipseCase;
|
||||
cvf::ref<RigMainGrid> m_mainGrid;
|
||||
QString m_currentResultName;
|
||||
};
|
||||
|
@ -133,6 +133,27 @@ void RimEclipseContourMapView::setDefaultCustomName()
|
||||
nameConfig()->hideSampleSpacingField(false);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEclipseContourMapView::updatePickPointAndRedraw()
|
||||
{
|
||||
appendPickPointVisToModel();
|
||||
if (m_viewer)
|
||||
{
|
||||
m_viewer->update();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEclipseContourMapView::updateCurrentTimeStepAndRedraw()
|
||||
{
|
||||
m_contourMapProjection->clearGeometry();
|
||||
RimEclipseView::updateCurrentTimeStepAndRedraw();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -210,15 +231,6 @@ void RimEclipseContourMapView::updateCurrentTimeStep()
|
||||
updateGeometry();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEclipseContourMapView::updateCurrentTimeStepAndRedraw()
|
||||
{
|
||||
m_contourMapProjection->clearGeometry();
|
||||
RimEclipseView::updateCurrentTimeStepAndRedraw();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -392,18 +404,6 @@ void RimEclipseContourMapView::updateViewFollowingRangeFilterUpdates()
|
||||
scheduleCreateDisplayModelAndRedraw();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEclipseContourMapView::updatePickPointAndRedraw()
|
||||
{
|
||||
appendPickPointVisToModel();
|
||||
if (m_viewer)
|
||||
{
|
||||
m_viewer->update();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimNameConfig.h"
|
||||
|
||||
class RimEclipseContourMapProjection;
|
||||
class RimViewNameConfig;
|
||||
class RimScaleLegendConfig;
|
||||
class RivContourMapProjectionPartMgr;
|
||||
|
@ -1,14 +1,14 @@
|
||||
#include "RimContourMapViewCollection.h"
|
||||
#include "RimEclipseContourMapViewCollection.h"
|
||||
|
||||
#include "RimEclipseContourMapView.h"
|
||||
#include "RimCase.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimContourMapViewCollection, "Eclipse2dViewCollection");
|
||||
CAF_PDM_SOURCE_INIT(RimEclipseContourMapViewCollection, "Eclipse2dViewCollection");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimContourMapViewCollection::RimContourMapViewCollection()
|
||||
RimEclipseContourMapViewCollection::RimEclipseContourMapViewCollection()
|
||||
{
|
||||
CAF_PDM_InitObject("Contour Maps", ":/2DMaps16x16.png", "", "");
|
||||
|
||||
@ -19,7 +19,7 @@ RimContourMapViewCollection::RimContourMapViewCollection()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimContourMapViewCollection::~RimContourMapViewCollection()
|
||||
RimEclipseContourMapViewCollection::~RimEclipseContourMapViewCollection()
|
||||
{
|
||||
|
||||
}
|
||||
@ -27,7 +27,7 @@ RimContourMapViewCollection::~RimContourMapViewCollection()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimEclipseContourMapView*> RimContourMapViewCollection::views()
|
||||
std::vector<RimEclipseContourMapView*> RimEclipseContourMapViewCollection::views()
|
||||
{
|
||||
return m_contourMapViews.childObjects();
|
||||
}
|
||||
@ -35,7 +35,7 @@ std::vector<RimEclipseContourMapView*> RimContourMapViewCollection::views()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimContourMapViewCollection::push_back(RimEclipseContourMapView* contourMap)
|
||||
void RimEclipseContourMapViewCollection::push_back(RimEclipseContourMapView* contourMap)
|
||||
{
|
||||
m_contourMapViews.push_back(contourMap);
|
||||
}
|
@ -24,12 +24,12 @@
|
||||
|
||||
class RimEclipseContourMapView;
|
||||
|
||||
class RimContourMapViewCollection : public caf::PdmObject
|
||||
class RimEclipseContourMapViewCollection : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
public:
|
||||
RimContourMapViewCollection();
|
||||
~RimContourMapViewCollection() override;
|
||||
RimEclipseContourMapViewCollection();
|
||||
~RimEclipseContourMapViewCollection() override;
|
||||
|
||||
std::vector<RimEclipseContourMapView*> views();
|
||||
void push_back(RimEclipseContourMapView* contourMap);
|
@ -33,6 +33,8 @@
|
||||
#include "Rim2dIntersectionViewCollection.h"
|
||||
#include "RimFormationNames.h"
|
||||
#include "RimGeoMechCellColors.h"
|
||||
#include "RimGeoMechContourMapView.h"
|
||||
#include "RimGeoMechContourMapViewCollection.h"
|
||||
#include "RimGeoMechPropertyFilter.h"
|
||||
#include "RimGeoMechPropertyFilterCollection.h"
|
||||
#include "RimGeoMechResultDefinition.h"
|
||||
@ -79,6 +81,10 @@ RimGeoMechCase::RimGeoMechCase(void)
|
||||
|
||||
CAF_PDM_InitField(&m_reloadElementPropertyFileCommand, "reloadElementPropertyFileCommand", false, "", "", "", "");
|
||||
caf::PdmUiPushButtonEditor::configureEditorForField(&m_reloadElementPropertyFileCommand);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_contourMapCollection, "ContourMaps", "2d Contour Maps", "", "", "");
|
||||
m_contourMapCollection = new RimGeoMechContourMapViewCollection;
|
||||
m_contourMapCollection.uiCapability()->setUiTreeHidden(true);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -158,6 +164,14 @@ void RimGeoMechCase::reloadDataAndUpdate()
|
||||
v->loadDataAndUpdate();
|
||||
v->setCurrentTimeStep(v->currentTimeStep());
|
||||
}
|
||||
|
||||
for (RimGeoMechContourMapView* contourMap : m_contourMapCollection->views())
|
||||
{
|
||||
CVF_ASSERT(contourMap);
|
||||
contourMap->loadDataAndUpdate();
|
||||
contourMap->updateGridBoxData();
|
||||
contourMap->updateAnnotationItems();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -274,6 +288,12 @@ std::vector<Rim3dView*> RimGeoMechCase::allSpecialViews() const
|
||||
{
|
||||
views.push_back(geoMechViews[vIdx]);
|
||||
}
|
||||
|
||||
for (RimGeoMechContourMapView* view : m_contourMapCollection->views())
|
||||
{
|
||||
views.push_back(view);
|
||||
}
|
||||
|
||||
return views;
|
||||
}
|
||||
|
||||
@ -292,9 +312,22 @@ void RimGeoMechCase::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering
|
||||
uiTreeOrdering.add(&m_2dIntersectionViewCollection);
|
||||
}
|
||||
|
||||
if (!m_contourMapCollection->views().empty())
|
||||
{
|
||||
uiTreeOrdering.add(&m_contourMapCollection);
|
||||
}
|
||||
|
||||
uiTreeOrdering.skipRemainingChildren(true);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimGeoMechContourMapViewCollection* RimGeoMechCase::contourMapCollection()
|
||||
{
|
||||
return m_contourMapCollection;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -319,6 +352,10 @@ void RimGeoMechCase::initAfterRead()
|
||||
riv->setGeoMechCase(this);
|
||||
}
|
||||
|
||||
for (RimGeoMechContourMapView* contourMap : m_contourMapCollection->views())
|
||||
{
|
||||
contourMap->setGeoMechCase(this);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -34,6 +34,8 @@
|
||||
class RimGeoMechView;
|
||||
class RigGeoMechCaseData;
|
||||
class RifGeoMechReaderInterface;
|
||||
class RimGeoMechContourMapView;
|
||||
class RimGeoMechContourMapViewCollection;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@ -60,6 +62,8 @@ public:
|
||||
RigGeoMechCaseData* geoMechData();
|
||||
const RigGeoMechCaseData* geoMechData() const;
|
||||
|
||||
RimGeoMechContourMapViewCollection* contourMapCollection();
|
||||
|
||||
void reloadDataAndUpdate();
|
||||
|
||||
RimGeoMechView* createAndAddReservoirView();
|
||||
@ -115,5 +119,8 @@ private:
|
||||
caf::PdmField<std::vector<int> > m_elementPropertyFileNameIndexUiSelection;
|
||||
caf::PdmField<bool> m_closeElementPropertyFileCommand;
|
||||
caf::PdmField<bool> m_reloadElementPropertyFileCommand;
|
||||
|
||||
caf::PdmChildField<RimGeoMechContourMapViewCollection*> m_contourMapCollection;
|
||||
|
||||
bool m_applyTimeFilter;
|
||||
};
|
||||
|
@ -0,0 +1,456 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- 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 "RimGeoMechContourMapProjection.h"
|
||||
|
||||
#include "RiaWeightedGeometricMeanCalculator.h"
|
||||
#include "RiaWeightedHarmonicMeanCalculator.h"
|
||||
#include "RiaWeightedMeanCalculator.h"
|
||||
|
||||
#include "RigCellGeometryTools.h"
|
||||
#include "RigGeoMechCaseData.h"
|
||||
#include "RigFemPart.h"
|
||||
#include "RigFemPartGrid.h"
|
||||
#include "RigFemPartCollection.h"
|
||||
#include "RigFemPartResultsCollection.h"
|
||||
#include "RigHexIntersectionTools.h"
|
||||
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimGeoMechContourMapView.h"
|
||||
#include "RimGeoMechCellColors.h"
|
||||
#include "RimGeoMechPropertyFilterCollection.h"
|
||||
|
||||
#include "RivFemElmVisibilityCalculator.h"
|
||||
|
||||
#include "cvfArray.h"
|
||||
#include "cvfCellRange.h"
|
||||
#include "cvfGeometryTools.h"
|
||||
#include "cvfGeometryUtils.h"
|
||||
#include "cvfScalarMapper.h"
|
||||
#include "cvfStructGridGeometryGenerator.h"
|
||||
#include "cvfVector3.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <omp.h>
|
||||
#include <QDebug>
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimGeoMechContourMapProjection, "RimGeoMechContourMapProjection");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimGeoMechContourMapProjection::RimGeoMechContourMapProjection()
|
||||
{
|
||||
CAF_PDM_InitObject("RimContourMapProjection", ":/2DMapProjection16x16.png", "", "");
|
||||
|
||||
setName("Map Projection");
|
||||
nameField()->uiCapability()->setUiReadOnly(true);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimGeoMechContourMapProjection::~RimGeoMechContourMapProjection() {}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimGeoMechContourMapProjection::resultDescriptionText() const
|
||||
{
|
||||
QString resultText = QString("%1, %2").arg(resultAggregationText()).arg(view()->cellResult()->resultFieldUiName());
|
||||
return resultText;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimRegularLegendConfig* RimGeoMechContourMapProjection::legendConfig() const
|
||||
{
|
||||
return view()->cellResult()->legendConfig();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGeoMechContourMapProjection::updateLegend()
|
||||
{
|
||||
RimGeoMechCellColors* cellColors = view()->cellResult();
|
||||
|
||||
if (use3dGridLegendRange())
|
||||
{
|
||||
view()->updateLegendTextAndRanges(cellColors->legendConfig(), view()->currentTimeStep());
|
||||
}
|
||||
else
|
||||
{
|
||||
CVF_ASSERT(use2dMapLegendRange());
|
||||
|
||||
double minVal = minValue();
|
||||
double maxVal = maxValue();
|
||||
legendConfig()->setAutomaticRanges(minVal, maxVal, minVal, maxVal);
|
||||
}
|
||||
|
||||
QString projectionLegendText = QString("Map Projection\n%1").arg(m_resultAggregation().uiText());
|
||||
projectionLegendText += QString("\nResult: %1").arg(cellColors->resultFieldUiName());
|
||||
|
||||
legendConfig()->setTitle(projectionLegendText);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::UByteArray> RimGeoMechContourMapProjection::getCellVisibility() const
|
||||
{
|
||||
cvf::ref<cvf::UByteArray> cellGridIdxVisibility = new cvf::UByteArray(m_femPart->elementCount());
|
||||
RivFemElmVisibilityCalculator::computeAllVisible(cellGridIdxVisibility.p(), m_femPart.p());
|
||||
|
||||
cvf::CellRangeFilter cellRangeFilter;
|
||||
view()->rangeFilterCollection()->compoundCellRangeFilter(&cellRangeFilter, 0);
|
||||
RivFemElmVisibilityCalculator::computeRangeVisibility(cellGridIdxVisibility.p(), m_femPart.p(), cellRangeFilter);
|
||||
RivFemElmVisibilityCalculator::computePropertyVisibility(cellGridIdxVisibility.p(), m_femPart.p(), view()->currentTimeStep(), cellGridIdxVisibility.p(), view()->geoMechPropertyFilterCollection());
|
||||
|
||||
ensureOnlyValidPorBarVisible(cellGridIdxVisibility.p(), view()->currentTimeStep());
|
||||
return cellGridIdxVisibility;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGeoMechContourMapProjection::ensureOnlyValidPorBarVisible(cvf::UByteArray* visibility, int timeStep) const
|
||||
{
|
||||
RigFemResultAddress porBarAddr(RigFemResultPosEnum::RIG_ELEMENT_NODAL, "POR-Bar", view()->cellResult()->resultComponentName().toStdString());
|
||||
RigGeoMechCaseData* caseData = geoMechCase()->geoMechData();
|
||||
RigFemPartResultsCollection* resultCollection = caseData->femPartResults();
|
||||
|
||||
const std::vector<float>& resultValues = resultCollection->resultValues(porBarAddr, 0, timeStep);
|
||||
for (size_t i = 0; i < visibility->size(); ++i)
|
||||
{
|
||||
int resValueIdx = m_femPart->elementNodeResultIdx(i, 0);
|
||||
double scalarValue = resultValues[resValueIdx];
|
||||
(*visibility)[i] &= scalarValue != std::numeric_limits<double>::infinity();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGeoMechContourMapProjection::updateGridInformation()
|
||||
{
|
||||
RimGeoMechCase* geoMechCase = this->geoMechCase();
|
||||
m_femPart = geoMechCase->geoMechData()->femParts()->part(0);
|
||||
m_femPartGrid = m_femPart->getOrCreateStructGrid();
|
||||
m_sampleSpacing = m_relativeSampleSpacing * geoMechCase->characteristicCellSize();
|
||||
m_gridBoundingBox = geoMechCase->activeCellsBoundingBox();
|
||||
m_femPart->ensureIntersectionSearchTreeIsBuilt();
|
||||
|
||||
cvf::Vec3d minExpandedPoint = m_gridBoundingBox.min() - cvf::Vec3d(gridEdgeOffset(), gridEdgeOffset(), 0.0);
|
||||
cvf::Vec3d maxExpandedPoint = m_gridBoundingBox.max() + cvf::Vec3d(gridEdgeOffset(), gridEdgeOffset(), 0.0);
|
||||
m_expandedBoundingBox = cvf::BoundingBox(minExpandedPoint, maxExpandedPoint);
|
||||
|
||||
m_mapSize = calculateMapSize();
|
||||
|
||||
// Re-jig max point to be an exact multiple of cell size
|
||||
cvf::Vec3d minPoint = m_expandedBoundingBox.min();
|
||||
cvf::Vec3d maxPoint = m_expandedBoundingBox.max();
|
||||
maxPoint.x() = minPoint.x() + m_mapSize.x() * m_sampleSpacing;
|
||||
maxPoint.y() = minPoint.y() + m_mapSize.y() * m_sampleSpacing;
|
||||
m_expandedBoundingBox = cvf::BoundingBox(minPoint, maxPoint);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<double> RimGeoMechContourMapProjection::retrieveParameterWeights()
|
||||
{
|
||||
return std::vector<double>();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGeoMechContourMapProjection::generateResults(int timeStep)
|
||||
{
|
||||
clearGeometry();
|
||||
|
||||
RigGeoMechCaseData* caseData = geoMechCase()->geoMechData();
|
||||
RigFemPartResultsCollection* resultCollection = caseData->femPartResults();
|
||||
RimGeoMechCellColors* cellColors = view()->cellResult();
|
||||
RigFemResultAddress resAddr = cellColors->resultAddress();
|
||||
if (!resAddr.isValid())
|
||||
return;
|
||||
|
||||
if (resAddr.fieldName == "PP")
|
||||
{
|
||||
resAddr.fieldName = "POR-Bar"; // More likely to be in memory than POR
|
||||
}
|
||||
if (resAddr.fieldName == "POR-Bar") resAddr.resultPosType = RIG_ELEMENT_NODAL;
|
||||
|
||||
m_resultValues = resultCollection->resultValues(resAddr, 0, timeStep);
|
||||
|
||||
size_t nCells = numberOfCells();
|
||||
m_aggregatedResults = std::vector<double>(nCells, std::numeric_limits<double>::infinity());
|
||||
|
||||
#pragma omp parallel for
|
||||
for (int index = 0; index < static_cast<int>(nCells); ++index)
|
||||
{
|
||||
cvf::Vec2ui ij = ijFromCellIndex(index);
|
||||
m_aggregatedResults[index] = calculateValueInMapCell(ij.x(), ij.y());
|
||||
}
|
||||
|
||||
m_currentResultAddr = resAddr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimGeoMechContourMapProjection::resultVariableChanged() const
|
||||
{
|
||||
RimGeoMechCellColors* cellColors = view()->cellResult();
|
||||
RigFemResultAddress resAddr = cellColors->resultAddress();
|
||||
|
||||
if (resAddr.fieldName == "PP")
|
||||
{
|
||||
resAddr.fieldName = "POR-Bar"; // More likely to be in memory than POR
|
||||
}
|
||||
if (resAddr.fieldName == "POR-Bar") resAddr.resultPosType = RIG_ELEMENT_NODAL;
|
||||
|
||||
return !(m_currentResultAddr == resAddr);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGeoMechContourMapProjection::clearResultVariable()
|
||||
{
|
||||
m_currentResultAddr = RigFemResultAddress();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimGridView* RimGeoMechContourMapProjection::baseView() const
|
||||
{
|
||||
return view();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<size_t> RimGeoMechContourMapProjection::findIntersectingCells(const cvf::BoundingBox& bbox) const
|
||||
{
|
||||
std::vector<size_t> allCellIndices;
|
||||
m_femPart->findIntersectingCellsWithExistingSearchTree(bbox, &allCellIndices);
|
||||
return allCellIndices;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RimGeoMechContourMapProjection::calculateOverlapVolume(size_t globalCellIdx,
|
||||
const cvf::BoundingBox& bbox,
|
||||
size_t* cellKLayerOut) const
|
||||
{
|
||||
CVF_ASSERT(cellKLayerOut != nullptr);
|
||||
|
||||
std::array<cvf::Vec3d, 8> hexCorners;
|
||||
|
||||
const std::vector<cvf::Vec3f>& nodeCoords = m_femPart->nodes().coordinates;
|
||||
const int* cornerIndices = m_femPart->connectivities(globalCellIdx);
|
||||
|
||||
hexCorners[0] = cvf::Vec3d(nodeCoords[cornerIndices[0]]);
|
||||
hexCorners[1] = cvf::Vec3d(nodeCoords[cornerIndices[1]]);
|
||||
hexCorners[2] = cvf::Vec3d(nodeCoords[cornerIndices[2]]);
|
||||
hexCorners[3] = cvf::Vec3d(nodeCoords[cornerIndices[3]]);
|
||||
hexCorners[4] = cvf::Vec3d(nodeCoords[cornerIndices[4]]);
|
||||
hexCorners[5] = cvf::Vec3d(nodeCoords[cornerIndices[5]]);
|
||||
hexCorners[6] = cvf::Vec3d(nodeCoords[cornerIndices[6]]);
|
||||
hexCorners[7] = cvf::Vec3d(nodeCoords[cornerIndices[7]]);
|
||||
|
||||
cvf::BoundingBox overlapBBox;
|
||||
std::array<cvf::Vec3d, 8> overlapCorners =
|
||||
RigCellGeometryTools::estimateHexOverlapWithBoundingBox(hexCorners, bbox, &overlapBBox);
|
||||
|
||||
double overlapVolume = RigCellGeometryTools::calculateCellVolume(overlapCorners);
|
||||
if (overlapVolume > 0.0)
|
||||
{
|
||||
size_t i, j, k;
|
||||
m_femPartGrid->ijkFromCellIndex(globalCellIdx, &i, &j, &k);
|
||||
*cellKLayerOut = k;
|
||||
|
||||
return overlapVolume;
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RimGeoMechContourMapProjection::calculateRayLengthInCell(size_t globalCellIdx,
|
||||
const cvf::Vec3d& highestPoint,
|
||||
const cvf::Vec3d& lowestPoint,
|
||||
size_t* cellKLayerOut) const
|
||||
{
|
||||
CVF_ASSERT(cellKLayerOut != nullptr);
|
||||
|
||||
std::array<cvf::Vec3d, 8> hexCorners;
|
||||
|
||||
const std::vector<cvf::Vec3f>& nodeCoords = m_femPart->nodes().coordinates;
|
||||
const int* cornerIndices = m_femPart->connectivities(globalCellIdx);
|
||||
|
||||
hexCorners[0] = cvf::Vec3d(nodeCoords[cornerIndices[0]]);
|
||||
hexCorners[1] = cvf::Vec3d(nodeCoords[cornerIndices[1]]);
|
||||
hexCorners[2] = cvf::Vec3d(nodeCoords[cornerIndices[2]]);
|
||||
hexCorners[3] = cvf::Vec3d(nodeCoords[cornerIndices[3]]);
|
||||
hexCorners[4] = cvf::Vec3d(nodeCoords[cornerIndices[4]]);
|
||||
hexCorners[5] = cvf::Vec3d(nodeCoords[cornerIndices[5]]);
|
||||
hexCorners[6] = cvf::Vec3d(nodeCoords[cornerIndices[6]]);
|
||||
hexCorners[7] = cvf::Vec3d(nodeCoords[cornerIndices[7]]);
|
||||
|
||||
std::vector<HexIntersectionInfo> intersections;
|
||||
|
||||
if (RigHexIntersectionTools::lineHexCellIntersection(highestPoint, lowestPoint, hexCorners.data(), 0, &intersections))
|
||||
{
|
||||
double lengthInCell = (intersections.back().m_intersectionPoint - intersections.front().m_intersectionPoint).length();
|
||||
|
||||
size_t i, j, k;
|
||||
m_femPartGrid->ijkFromCellIndex(globalCellIdx, &i, &j, &k);
|
||||
*cellKLayerOut = k;
|
||||
return lengthInCell;
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RimGeoMechContourMapProjection::getParameterWeightForCell(size_t globalCellIdx,
|
||||
const std::vector<double>& parameterWeights) const
|
||||
{
|
||||
if (parameterWeights.empty()) return 1.0;
|
||||
|
||||
return parameterWeights[globalCellIdx];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RimGeoMechContourMapProjection::gridCellValue(size_t globalCellIdx) const
|
||||
{
|
||||
RimGeoMechCellColors* cellColors = view()->cellResult();
|
||||
RigFemResultAddress resAddr = cellColors->resultAddress();
|
||||
|
||||
if (resAddr.fieldName == "PP")
|
||||
{
|
||||
resAddr.fieldName = "POR-Bar"; // More likely to be in memory than POR
|
||||
}
|
||||
if (resAddr.fieldName == "POR-Bar") resAddr.resultPosType = RIG_ELEMENT_NODAL;
|
||||
|
||||
RigFemResultPosEnum resultPosType = resAddr.resultPosType;
|
||||
|
||||
RigElementType elmType = m_femPart->elementType(globalCellIdx);
|
||||
|
||||
if (!(elmType == HEX8 || elmType == HEX8P)) return 0.0;
|
||||
|
||||
if (resultPosType == RIG_FORMATION_NAMES)
|
||||
{
|
||||
resultPosType = RIG_ELEMENT_NODAL; // formation indices are stored per element node result.
|
||||
}
|
||||
|
||||
if (resultPosType == RIG_ELEMENT)
|
||||
{
|
||||
return m_resultValues[globalCellIdx];
|
||||
}
|
||||
else if (resultPosType == RIG_ELEMENT_NODAL)
|
||||
{
|
||||
RiaWeightedMeanCalculator<float> cellAverage;
|
||||
for (int i = 0; i < 8; ++i)
|
||||
{
|
||||
size_t gridResultValueIdx = m_femPart->resultValueIdxFromResultPosType(resultPosType, static_cast<int>(globalCellIdx), i);
|
||||
cellAverage.addValueAndWeight(m_resultValues[gridResultValueIdx], 1.0);
|
||||
}
|
||||
|
||||
return cellAverage.weightedMean();
|
||||
}
|
||||
else
|
||||
{
|
||||
RiaWeightedMeanCalculator<float> cellAverage;
|
||||
const int* elmNodeIndices = m_femPart->connectivities(globalCellIdx);
|
||||
for (int i = 0; i < 8; ++i)
|
||||
{
|
||||
cellAverage.addValueAndWeight(m_resultValues[elmNodeIndices[i]], 1.0);
|
||||
}
|
||||
return cellAverage.weightedMean();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimGeoMechCase* RimGeoMechContourMapProjection::geoMechCase() const
|
||||
{
|
||||
RimGeoMechCase* geoMechCase = nullptr;
|
||||
firstAncestorOrThisOfType(geoMechCase);
|
||||
return geoMechCase;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimGeoMechContourMapView* RimGeoMechContourMapProjection::view() const
|
||||
{
|
||||
RimGeoMechContourMapView* view = nullptr;
|
||||
firstAncestorOrThisOfTypeAsserted(view);
|
||||
return view;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGeoMechContourMapProjection::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue)
|
||||
{
|
||||
RimContourMapProjection::fieldChangedByUi(changedField, oldValue, newValue);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QList<caf::PdmOptionItemInfo>
|
||||
RimGeoMechContourMapProjection::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly)
|
||||
{
|
||||
QList<caf::PdmOptionItemInfo> options;
|
||||
|
||||
if (fieldNeedingOptions == &m_resultAggregation)
|
||||
{
|
||||
std::vector<ResultAggregationEnum> validOptions = {RESULTS_TOP_VALUE,
|
||||
RESULTS_MEAN_VALUE,
|
||||
RESULTS_GEOM_VALUE,
|
||||
RESULTS_HARM_VALUE,
|
||||
RESULTS_MIN_VALUE,
|
||||
RESULTS_MAX_VALUE,
|
||||
RESULTS_SUM};
|
||||
|
||||
for (ResultAggregationEnum option : validOptions)
|
||||
{
|
||||
options.push_back(caf::PdmOptionItemInfo(ResultAggregation::uiText(option), option));
|
||||
}
|
||||
}
|
||||
return options;
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- 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 "RigFemPart.h"
|
||||
#include "RigFemResultAddress.h"
|
||||
|
||||
#include "RimCheckableNamedObject.h"
|
||||
#include "RimContourMapProjection.h"
|
||||
#include "RimGeoMechCase.h"
|
||||
#include "RimRegularLegendConfig.h"
|
||||
|
||||
#include "cafDisplayCoordTransform.h"
|
||||
#include "cafPdmChildField.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
#include "cvfArray.h"
|
||||
#include "cvfBoundingBox.h"
|
||||
#include "cvfGeometryBuilderFaceList.h"
|
||||
#include "cvfString.h"
|
||||
#include "cvfVector2.h"
|
||||
|
||||
class RimGeoMechContourMapView;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimGeoMechContourMapProjection : public RimContourMapProjection
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
public:
|
||||
|
||||
RimGeoMechContourMapProjection();
|
||||
~RimGeoMechContourMapProjection() override;
|
||||
|
||||
// GeoMech case overrides for contour map methods
|
||||
QString resultDescriptionText() const override;
|
||||
RimRegularLegendConfig* legendConfig() const override;
|
||||
void updateLegend() override;
|
||||
|
||||
protected:
|
||||
typedef RimContourMapProjection::CellIndexAndResult CellIndexAndResult;
|
||||
|
||||
cvf::ref<cvf::UByteArray> getCellVisibility() const override;
|
||||
void ensureOnlyValidPorBarVisible(cvf::UByteArray* visibility, int timeStep) const;
|
||||
void updateGridInformation() override;
|
||||
virtual std::vector<double> retrieveParameterWeights() override;
|
||||
void generateResults(int timeStep) override;
|
||||
bool resultVariableChanged() const override;
|
||||
void clearResultVariable() override;
|
||||
RimGridView* baseView() const override;
|
||||
std::vector<size_t> findIntersectingCells(const cvf::BoundingBox& bbox) const override;
|
||||
double calculateOverlapVolume(size_t globalCellIdx, const cvf::BoundingBox& bbox, size_t* cellKLayerOut) const override;
|
||||
double calculateRayLengthInCell(size_t globalCellIdx, const cvf::Vec3d& highestPoint, const cvf::Vec3d& lowestPoint, size_t* cellKLayerOut) const override;
|
||||
double getParameterWeightForCell(size_t globalCellIdx, const std::vector<double>& parameterWeights) const override;
|
||||
|
||||
// GeoMech implementation specific data generation methods
|
||||
double gridCellValue(size_t globalCellIdx) const override;
|
||||
|
||||
RimGeoMechCase* geoMechCase() const;
|
||||
RimGeoMechContourMapView* view() const;
|
||||
|
||||
|
||||
protected:
|
||||
// Framework overrides
|
||||
void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions,
|
||||
bool* useOptionsOnly) override;
|
||||
|
||||
protected:
|
||||
cvf::ref<RigFemPart> m_femPart;
|
||||
cvf::cref<RigFemPartGrid> m_femPartGrid;
|
||||
RigFemResultAddress m_currentResultAddr;
|
||||
|
||||
std::vector<float> m_resultValues;
|
||||
};
|
||||
|
||||
|
474
ApplicationCode/ProjectDataModel/RimGeoMechContourMapView.cpp
Normal file
474
ApplicationCode/ProjectDataModel/RimGeoMechContourMapView.cpp
Normal file
@ -0,0 +1,474 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- 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 "RimGeoMechContourMapView.h"
|
||||
#include "RivContourMapProjectionPartMgr.h"
|
||||
#include "RiuViewer.h"
|
||||
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
#include "RimCase.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimGeoMechCellColors.h"
|
||||
#include "RimGeoMechContourMapProjection.h"
|
||||
#include "RimGeoMechPropertyFilterCollection.h"
|
||||
#include "RimGridCollection.h"
|
||||
#include "RimScaleLegendConfig.h"
|
||||
#include "RimSimWellInViewCollection.h"
|
||||
#include "RimViewNameConfig.h"
|
||||
#include "cafPdmUiTreeOrdering.h"
|
||||
|
||||
#include "cvfCamera.h"
|
||||
#include "cvfModelBasicList.h"
|
||||
#include "cvfPart.h"
|
||||
#include "cvfScene.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimGeoMechContourMapView, "RimGeoMechContourMapView");
|
||||
|
||||
const cvf::Mat4d defaultViewMatrix(1, 0, 0, 0,
|
||||
0, 1, 0, 0,
|
||||
0, 0, 1, 1000,
|
||||
0, 0, 0, 1);
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimGeoMechContourMapView::RimGeoMechContourMapView()
|
||||
: m_cameraPositionLastUpdate(cvf::Vec3d::UNDEFINED)
|
||||
{
|
||||
CAF_PDM_InitObject("GeoMech Contour Map View", ":/2DMap16x16.png", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_contourMapProjection, "ContourMapProjection", "Contour Map Projection", "", "", "");
|
||||
m_contourMapProjection = new RimGeoMechContourMapProjection();
|
||||
|
||||
CAF_PDM_InitField(&m_showAxisLines, "ShowAxisLines", true, "Show Axis Lines", "", "", "");
|
||||
CAF_PDM_InitField(&m_showScaleLegend, "ShowScaleLegend", true, "Show Scale Legend", "", "", "");
|
||||
|
||||
m_gridCollection->setActive(false); // This is also not added to the tree view, so cannot be enabled.
|
||||
|
||||
setDefaultCustomName();
|
||||
|
||||
m_contourMapProjectionPartMgr = new RivContourMapProjectionPartMgr(contourMapProjection(), this);
|
||||
|
||||
((RiuViewerToViewInterface*)this)->setCameraPosition(defaultViewMatrix);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimGeoMechContourMapProjection* RimGeoMechContourMapView::contourMapProjection() const
|
||||
{
|
||||
return m_contourMapProjection().p();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimGeoMechContourMapView::createAutoName() const
|
||||
{
|
||||
QStringList autoName;
|
||||
|
||||
if (!nameConfig()->customName().isEmpty())
|
||||
{
|
||||
autoName.push_back(nameConfig()->customName());
|
||||
}
|
||||
|
||||
QStringList generatedAutoTags;
|
||||
|
||||
RimCase* ownerCase = nullptr;
|
||||
this->firstAncestorOrThisOfTypeAsserted(ownerCase);
|
||||
|
||||
if (nameConfig()->addCaseName())
|
||||
{
|
||||
generatedAutoTags.push_back(ownerCase->caseUserDescription());
|
||||
}
|
||||
|
||||
if (nameConfig()->addAggregationType())
|
||||
{
|
||||
generatedAutoTags.push_back(contourMapProjection()->resultAggregationText());
|
||||
}
|
||||
|
||||
if (nameConfig()->addProperty() && !contourMapProjection()->isColumnResult())
|
||||
{
|
||||
generatedAutoTags.push_back(cellResult()->resultFieldUiName());
|
||||
}
|
||||
|
||||
if (nameConfig()->addSampleSpacing())
|
||||
{
|
||||
generatedAutoTags.push_back(QString("%1").arg(contourMapProjection()->sampleSpacingFactor(), 3, 'f', 2));
|
||||
}
|
||||
|
||||
if (!generatedAutoTags.empty())
|
||||
{
|
||||
autoName.push_back(generatedAutoTags.join(", "));
|
||||
}
|
||||
return autoName.join(": ");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGeoMechContourMapView::setDefaultCustomName()
|
||||
{
|
||||
nameConfig()->setCustomName("Contour Map");
|
||||
nameConfig()->hideCaseNameField(false);
|
||||
nameConfig()->hideAggregationTypeField(false);
|
||||
nameConfig()->hidePropertyField(false);
|
||||
nameConfig()->hideSampleSpacingField(false);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGeoMechContourMapView::updatePickPointAndRedraw()
|
||||
{
|
||||
appendPickPointVisToModel();
|
||||
if (m_viewer)
|
||||
{
|
||||
m_viewer->update();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGeoMechContourMapView::updateCurrentTimeStepAndRedraw()
|
||||
{
|
||||
m_contourMapProjection->clearGeometry();
|
||||
RimGeoMechView::updateCurrentTimeStepAndRedraw();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimGeoMechContourMapView::isGridVisualizationMode() const
|
||||
{
|
||||
return m_contourMapProjection->isChecked();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGeoMechContourMapView::initAfterRead()
|
||||
{
|
||||
m_gridCollection->setActive(false); // This is also not added to the tree view, so cannot be enabled.
|
||||
disablePerspectiveProjectionField();
|
||||
setShowGridBox(false);
|
||||
meshMode.setValue(NO_MESH);
|
||||
surfaceMode.setValue(FAULTS);
|
||||
scheduleCreateDisplayModelAndRedraw();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGeoMechContourMapView::createDisplayModel()
|
||||
{
|
||||
RimGeoMechView::createDisplayModel();
|
||||
|
||||
if (!this->isTimeStepDependentDataVisible())
|
||||
{
|
||||
// Need to add geometry even if it hasn't happened during dynamic time step update.
|
||||
updateGeometry();
|
||||
}
|
||||
|
||||
if (this->viewer()->mainCamera()->viewMatrix() == defaultViewMatrix)
|
||||
{
|
||||
this->zoomAll();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGeoMechContourMapView::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
||||
{
|
||||
caf::PdmUiGroup* viewGroup = uiOrdering.addNewGroup("Viewer");
|
||||
viewGroup->add(this->userDescriptionField());
|
||||
viewGroup->add(this->backgroundColorField());
|
||||
viewGroup->add(&m_showAxisLines);
|
||||
viewGroup->add(&m_showScaleLegend);
|
||||
|
||||
caf::PdmUiGroup* nameGroup = uiOrdering.addNewGroup("Contour Map Name");
|
||||
nameConfig()->uiOrdering(uiConfigName, *nameGroup);
|
||||
|
||||
uiOrdering.skipRemainingFields(true);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGeoMechContourMapView::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/)
|
||||
{
|
||||
uiTreeOrdering.add(m_overlayInfoConfig());
|
||||
uiTreeOrdering.add(m_contourMapProjection);
|
||||
uiTreeOrdering.add(cellResult());
|
||||
cellResult()->uiCapability()->setUiReadOnly(m_contourMapProjection->isColumnResult());
|
||||
uiTreeOrdering.add(m_rangeFilterCollection());
|
||||
uiTreeOrdering.add(nativePropertyFilterCollection());
|
||||
|
||||
uiTreeOrdering.skipRemainingChildren();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGeoMechContourMapView::updateCurrentTimeStep()
|
||||
{
|
||||
updateGeometry();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGeoMechContourMapView::updateGeometry()
|
||||
{
|
||||
if (m_contourMapProjection->isChecked())
|
||||
{
|
||||
m_contourMapProjection->generateResultsIfNecessary(m_currentTimeStep());
|
||||
}
|
||||
updateLegends();
|
||||
|
||||
createContourMapGeometry();
|
||||
appendContourMapProjectionToModel();
|
||||
appendContourLinesToModel();
|
||||
|
||||
appendPickPointVisToModel();
|
||||
|
||||
m_overlayInfoConfig->update3DInfo();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGeoMechContourMapView::createContourMapGeometry()
|
||||
{
|
||||
if (m_viewer && m_contourMapProjection->isChecked())
|
||||
{
|
||||
m_contourMapProjectionPartMgr->createProjectionGeometry();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGeoMechContourMapView::appendContourMapProjectionToModel()
|
||||
{
|
||||
if (m_viewer && m_contourMapProjection->isChecked())
|
||||
{
|
||||
cvf::Scene* frameScene = m_viewer->frame(m_currentTimeStep);
|
||||
if (frameScene)
|
||||
{
|
||||
cvf::String name = "ContourMapProjection";
|
||||
this->removeModelByName(frameScene, name);
|
||||
|
||||
cvf::ref<cvf::ModelBasicList> contourMapProjectionModelBasicList = new cvf::ModelBasicList;
|
||||
contourMapProjectionModelBasicList->setName(name);
|
||||
|
||||
cvf::ref<caf::DisplayCoordTransform> transForm = this->displayCoordTransform();
|
||||
|
||||
m_contourMapProjectionPartMgr->appendProjectionToModel(contourMapProjectionModelBasicList.p(), transForm.p());
|
||||
contourMapProjectionModelBasicList->updateBoundingBoxesRecursive();
|
||||
frameScene->addModel(contourMapProjectionModelBasicList.p());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGeoMechContourMapView::appendContourLinesToModel()
|
||||
{
|
||||
if (m_viewer && m_contourMapProjection->isChecked())
|
||||
{
|
||||
cvf::Scene* frameScene = m_viewer->frame(m_currentTimeStep);
|
||||
if (frameScene)
|
||||
{
|
||||
cvf::String name = "ContourMapLines";
|
||||
this->removeModelByName(frameScene, name);
|
||||
|
||||
cvf::ref<cvf::ModelBasicList> contourMapLabelModelBasicList = new cvf::ModelBasicList;
|
||||
contourMapLabelModelBasicList->setName(name);
|
||||
|
||||
cvf::ref<caf::DisplayCoordTransform> transForm = this->displayCoordTransform();
|
||||
|
||||
m_contourMapProjectionPartMgr->appendContourLinesToModel(
|
||||
viewer()->mainCamera(), contourMapLabelModelBasicList.p(), transForm.p());
|
||||
contourMapLabelModelBasicList->updateBoundingBoxesRecursive();
|
||||
frameScene->addModel(contourMapLabelModelBasicList.p());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGeoMechContourMapView::appendPickPointVisToModel()
|
||||
{
|
||||
if (m_viewer && m_contourMapProjection->isChecked())
|
||||
{
|
||||
cvf::Scene* frameScene = m_viewer->frame(m_currentTimeStep);
|
||||
if (frameScene)
|
||||
{
|
||||
cvf::String name = "ContourMapPickPoint";
|
||||
this->removeModelByName(frameScene, name);
|
||||
|
||||
cvf::ref<cvf::ModelBasicList> contourMapProjectionModelBasicList = new cvf::ModelBasicList;
|
||||
contourMapProjectionModelBasicList->setName(name);
|
||||
|
||||
cvf::ref<caf::DisplayCoordTransform> transForm = this->displayCoordTransform();
|
||||
|
||||
m_contourMapProjectionPartMgr->appendPickPointVisToModel(contourMapProjectionModelBasicList.p(), transForm.p());
|
||||
contourMapProjectionModelBasicList->updateBoundingBoxesRecursive();
|
||||
frameScene->addModel(contourMapProjectionModelBasicList.p());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGeoMechContourMapView::updateLegends()
|
||||
{
|
||||
if (m_viewer)
|
||||
{
|
||||
m_viewer->removeAllColorLegends();
|
||||
|
||||
if (m_contourMapProjection && m_contourMapProjection->isChecked())
|
||||
{
|
||||
RimRegularLegendConfig* projectionLegend = m_contourMapProjection->legendConfig();
|
||||
if (projectionLegend)
|
||||
{
|
||||
m_contourMapProjection->updateLegend();
|
||||
if (projectionLegend->showLegend())
|
||||
{
|
||||
m_viewer->addColorLegendToBottomLeftCorner(projectionLegend->titledOverlayFrame());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_viewer->showScaleLegend(m_showScaleLegend());
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGeoMechContourMapView::updateViewWidgetAfterCreation()
|
||||
{
|
||||
if (m_viewer)
|
||||
{
|
||||
m_viewer->showAxisCross(false);
|
||||
m_viewer->showEdgeTickMarksXY(true, m_showAxisLines());
|
||||
m_viewer->enableNavigationRotation(false);
|
||||
}
|
||||
|
||||
Rim3dView::updateViewWidgetAfterCreation();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGeoMechContourMapView::updateViewFollowingRangeFilterUpdates()
|
||||
{
|
||||
m_contourMapProjection->setCheckState(true);
|
||||
scheduleCreateDisplayModelAndRedraw();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGeoMechContourMapView::onLoadDataAndUpdate()
|
||||
{
|
||||
RimGeoMechView::onLoadDataAndUpdate();
|
||||
if (m_viewer)
|
||||
{
|
||||
m_viewer->setView(cvf::Vec3d(0, 0, -1), cvf::Vec3d(0, 1, 0));
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGeoMechContourMapView::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue)
|
||||
{
|
||||
RimGeoMechView::fieldChangedByUi(changedField, oldValue, newValue);
|
||||
|
||||
if (changedField == &m_showAxisLines)
|
||||
{
|
||||
m_viewer->showEdgeTickMarksXY(true, m_showAxisLines());
|
||||
scheduleCreateDisplayModelAndRedraw();
|
||||
}
|
||||
else if (changedField == backgroundColorField())
|
||||
{
|
||||
scheduleCreateDisplayModelAndRedraw();
|
||||
}
|
||||
else if (changedField == &m_showScaleLegend)
|
||||
{
|
||||
updateLegends();
|
||||
scheduleCreateDisplayModelAndRedraw();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmFieldHandle* RimGeoMechContourMapView::userDescriptionField()
|
||||
{
|
||||
return nameConfig()->nameField();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QWidget* RimGeoMechContourMapView::createViewWidget(QWidget* mainWindowParent)
|
||||
{
|
||||
auto widget = Rim3dView::createViewWidget(mainWindowParent);
|
||||
|
||||
if (viewer())
|
||||
{
|
||||
viewer()->showZScaleLabel(false);
|
||||
viewer()->hideZScaleCheckbox(true);
|
||||
}
|
||||
return widget;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGeoMechContourMapView::onViewNavigationChanged()
|
||||
{
|
||||
cvf::Vec3d currentCameraPosition = viewer()->mainCamera()->position();
|
||||
if (m_cameraPositionLastUpdate.isUndefined() || zoomChangeAboveTreshold(currentCameraPosition))
|
||||
{
|
||||
appendContourLinesToModel();
|
||||
m_cameraPositionLastUpdate = currentCameraPosition;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimGeoMechContourMapView::zoomChangeAboveTreshold(const cvf::Vec3d& currentCameraPosition) const
|
||||
{
|
||||
double distance = std::max(std::fabs(m_cameraPositionLastUpdate.z()), std::fabs(currentCameraPosition.z()));
|
||||
const double threshold = 0.05 * distance;
|
||||
return std::fabs(m_cameraPositionLastUpdate.z() - currentCameraPosition.z()) > threshold;
|
||||
}
|
||||
|
||||
|
75
ApplicationCode/ProjectDataModel/RimGeoMechContourMapView.h
Normal file
75
ApplicationCode/ProjectDataModel/RimGeoMechContourMapView.h
Normal file
@ -0,0 +1,75 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- 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 "RimGeoMechView.h"
|
||||
#include "RimNameConfig.h"
|
||||
|
||||
class RimGeoMechContourMapProjection;
|
||||
class RimViewNameConfig;
|
||||
class RimScaleLegendConfig;
|
||||
class RivContourMapProjectionPartMgr;
|
||||
|
||||
class RimGeoMechContourMapView : public RimGeoMechView
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimGeoMechContourMapView();
|
||||
RimGeoMechContourMapProjection* contourMapProjection() const;
|
||||
|
||||
QString createAutoName() const override;
|
||||
void setDefaultCustomName();
|
||||
void updatePickPointAndRedraw();
|
||||
void updateCurrentTimeStepAndRedraw() override;
|
||||
bool isGridVisualizationMode() const override;
|
||||
|
||||
protected:
|
||||
void initAfterRead() override;
|
||||
void createDisplayModel() override;
|
||||
void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
||||
void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "") override;
|
||||
void updateCurrentTimeStep() override;
|
||||
void updateGeometry();
|
||||
void createContourMapGeometry();
|
||||
void appendContourMapProjectionToModel();
|
||||
void appendContourLinesToModel();
|
||||
void appendPickPointVisToModel();
|
||||
void updateLegends() override;
|
||||
void updateViewWidgetAfterCreation() override;
|
||||
void updateViewFollowingRangeFilterUpdates() override;
|
||||
void onLoadDataAndUpdate() override;
|
||||
void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
|
||||
caf::PdmFieldHandle* userDescriptionField() override;
|
||||
|
||||
QWidget* createViewWidget(QWidget* mainWindowParent) override;
|
||||
|
||||
void onViewNavigationChanged() override;
|
||||
|
||||
bool zoomChangeAboveTreshold(const cvf::Vec3d& currentCameraPosition) const;
|
||||
|
||||
private:
|
||||
cvf::ref<RivContourMapProjectionPartMgr> m_contourMapProjectionPartMgr;
|
||||
caf::PdmChildField<RimGeoMechContourMapProjection*> m_contourMapProjection;
|
||||
caf::PdmField<bool> m_showAxisLines;
|
||||
caf::PdmField<bool> m_showScaleLegend;
|
||||
cvf::Vec3d m_cameraPositionLastUpdate;
|
||||
};
|
||||
|
@ -0,0 +1,38 @@
|
||||
#include "RimGeoMechContourMapViewCollection.h"
|
||||
|
||||
#include "RimCase.h"
|
||||
#include "RimGeoMechContourMapView.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimGeoMechContourMapViewCollection, "GeoMech2dViewCollection");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimGeoMechContourMapViewCollection::RimGeoMechContourMapViewCollection()
|
||||
{
|
||||
CAF_PDM_InitObject("GeoMech Contour Maps", ":/2DMaps16x16.png", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_contourMapViews, "GeoMechViews", "Contour Maps", ":/CrossSection16x16.png", "", "");
|
||||
m_contourMapViews.uiCapability()->setUiTreeHidden(true);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimGeoMechContourMapViewCollection::~RimGeoMechContourMapViewCollection() {}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimGeoMechContourMapView*> RimGeoMechContourMapViewCollection::views()
|
||||
{
|
||||
return m_contourMapViews.childObjects();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGeoMechContourMapViewCollection::push_back(RimGeoMechContourMapView* contourMap)
|
||||
{
|
||||
m_contourMapViews.push_back(contourMap);
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2019- 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 "cafPdmChildArrayField.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
class RimGeoMechContourMapView;
|
||||
|
||||
class RimGeoMechContourMapViewCollection : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimGeoMechContourMapViewCollection();
|
||||
~RimGeoMechContourMapViewCollection() override;
|
||||
|
||||
std::vector<RimGeoMechContourMapView*> views();
|
||||
void push_back(RimGeoMechContourMapView* contourMap);
|
||||
|
||||
private:
|
||||
caf::PdmChildArrayField<RimGeoMechContourMapView*> m_contourMapViews;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -305,6 +305,14 @@ void RimGeoMechView::createDisplayModel()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimPropertyFilterCollection* RimGeoMechView::nativePropertyFilterCollection()
|
||||
{
|
||||
return m_propertyFilterCollection();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -105,13 +105,14 @@ protected:
|
||||
void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
||||
void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "") override;
|
||||
void onLoadDataAndUpdate() override;
|
||||
void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
|
||||
void createPartCollectionFromSelection(cvf::Collection<cvf::Part>* parts) override;
|
||||
|
||||
void createDisplayModel() override;
|
||||
RimPropertyFilterCollection* nativePropertyFilterCollection();
|
||||
private:
|
||||
QString createAutoName() const override;
|
||||
|
||||
void createDisplayModel() override;
|
||||
void updateScaleTransform() override;
|
||||
|
||||
void clampCurrentTimestep() override;
|
||||
@ -125,7 +126,6 @@ private:
|
||||
|
||||
void updateTensorLegendTextAndRanges(RimRegularLegendConfig* legendConfig, int timeStepIndex);
|
||||
|
||||
void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
void initAfterRead() override;
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user