Refactored addition of well path models

Well path models can now be added to geo mech models. Moved code that
adds well path models to a scene from RimEclipseView to
RimView::addWellPathsToScene(). This new function is now used by both
RimEclipseView and RimGeoMechView. Made sure that it is not needed to
load a result before well paths appear. TODO: Compute characteristic hex
element size for geo mech models.
This commit is contained in:
Stein Dale
2015-06-11 13:44:21 +02:00
parent 3d0e0ace7a
commit b59695f352
4 changed files with 68 additions and 37 deletions

View File

@@ -431,6 +431,11 @@ void RimEclipseView::createDisplayModel()
// Create Scenes from the frameModels // Create Scenes from the frameModels
// Animation frames for results display, starts from frame 1 // Animation frames for results display, starts from frame 1
RimEclipseCase* eclCase = eclipseCase();
RigCaseData* caseData = eclCase ? eclCase->reservoirData() : NULL;
RigMainGrid* mainGrid = caseData ? caseData->mainGrid() : NULL;
CVF_ASSERT(mainGrid);
size_t frameIndex; size_t frameIndex;
for (frameIndex = 0; frameIndex < frameModels.size(); frameIndex++) for (frameIndex = 0; frameIndex < frameModels.size(); frameIndex++)
{ {
@@ -440,6 +445,9 @@ void RimEclipseView::createDisplayModel()
cvf::ref<cvf::Scene> scene = new cvf::Scene; cvf::ref<cvf::Scene> scene = new cvf::Scene;
scene->addModel(model); scene->addModel(model);
// Add well paths, if any
addWellPathsToScene(scene.p(), mainGrid->displayModelOffset(), mainGrid->characteristicIJCellSize(), currentActiveCellInfo()->geometryBoundingBox(), m_reservoirGridPartManager->scaleTransform());
if (frameIndex == 0) if (frameIndex == 0)
m_viewer->setMainScene(scene.p()); m_viewer->setMainScene(scene.p());
else else
@@ -586,7 +594,7 @@ void RimEclipseView::updateCurrentTimeStep()
this->updateFaultColors(); this->updateFaultColors();
// Well pipes and well paths // Well pipes
if (m_viewer) if (m_viewer)
{ {
cvf::Scene* frameScene = m_viewer->frame(m_currentTimeStep); cvf::Scene* frameScene = m_viewer->frame(m_currentTimeStep);
@@ -619,42 +627,14 @@ void RimEclipseView::updateCurrentTimeStep()
wellPipeModelBasicList->updateBoundingBoxesRecursive(); wellPipeModelBasicList->updateBoundingBoxesRecursive();
//printf("updateCurrentTimeStep: Add WellPipeModel to frameScene\n"); //printf("updateCurrentTimeStep: Add WellPipeModel to frameScene\n");
frameScene->addModel(wellPipeModelBasicList.p()); frameScene->addModel(wellPipeModelBasicList.p());
// Well paths
// ----------
cvf::String wellPathModelName = "WellPathModel";
std::vector<cvf::Model*> wellPathModels;
for (cvf::uint i = 0; i < frameScene->modelCount(); i++)
{
if (frameScene->model(i)->name() == wellPathModelName)
{
wellPathModels.push_back(frameScene->model(i));
}
}
for (size_t i = 0; i < wellPathModels.size(); i++) // Add well paths, if any
{ RimEclipseCase* eclCase = eclipseCase();
//printf("updateCurrentTimeStep: Remove WellPathModel %i from frameScene, for frame %i\n", i, m_currentTimeStep.v()); RigCaseData* caseData = eclCase ? eclCase->reservoirData() : NULL;
frameScene->removeModel(wellPathModels[i]); RigMainGrid* mainGrid = caseData ? caseData->mainGrid() : NULL;
} CVF_ASSERT(mainGrid);
// Append static Well Paths to model addWellPathsToScene(frameScene, mainGrid->displayModelOffset(), mainGrid->characteristicIJCellSize(), currentActiveCellInfo()->geometryBoundingBox(), m_reservoirGridPartManager->scaleTransform());
cvf::ref<cvf::ModelBasicList> wellPathModelBasicList = new cvf::ModelBasicList;
wellPathModelBasicList->setName(wellPathModelName);
RimOilField* oilFields = (RiaApplication::instance()->project()) ? RiaApplication::instance()->project()->activeOilField() : NULL;
RimWellPathCollection* wellPathCollection = (oilFields) ? oilFields->wellPathCollection() : NULL;
RivWellPathCollectionPartMgr* wellPathCollectionPartMgr = (wellPathCollection) ? wellPathCollection->wellPathCollectionPartMgr() : NULL;
if (wellPathCollectionPartMgr)
{
//printf("updateCurrentTimeStep: Append well paths for frame %i: ", m_currentTimeStep.v());
cvf::Vec3d displayModelOffset = eclipseCase()->reservoirData()->mainGrid()->displayModelOffset();
double characteristicCellSize = eclipseCase()->reservoirData()->mainGrid()->characteristicIJCellSize();
cvf::BoundingBox boundingBox = currentActiveCellInfo()->geometryBoundingBox();
wellPathCollectionPartMgr->appendStaticGeometryPartsToModel(wellPathModelBasicList.p(), displayModelOffset, m_reservoirGridPartManager->scaleTransform(), characteristicCellSize, boundingBox);
//printf("\n");
}
wellPathModelBasicList->updateBoundingBoxesRecursive();
frameScene->addModel(wellPathModelBasicList.p());
} }
} }

View File

@@ -243,6 +243,10 @@ void RimGeoMechView::createDisplayModel()
m_viewer->setMainScene(scene.p()); m_viewer->setMainScene(scene.p());
else else
m_viewer->addFrame(scene.p()); m_viewer->addFrame(scene.p());
// !! TODO: Compute characteristic cell size
double characteristicCellSize_HARDCODED = 300;
addWellPathsToScene(scene.p(), cvf::Vec3d(0, 0, 0), characteristicCellSize_HARDCODED, m_viewer->mainScene()->boundingBox(), scaleTransform());
} }
// If the animation was active before recreating everything, make viewer view current frame // If the animation was active before recreating everything, make viewer view current frame
@@ -278,6 +282,10 @@ void RimGeoMechView::updateCurrentTimeStep()
frameParts->updateBoundingBoxesRecursive(); frameParts->updateBoundingBoxesRecursive();
frameScene->removeAllModels(); frameScene->removeAllModels();
frameScene->addModel(frameParts.p()); frameScene->addModel(frameParts.p());
// !! TODO: Compute characteristic cell size
double characteristicCellSize_HARDCODED = 300;
addWellPathsToScene(frameScene, cvf::Vec3d(0, 0, 0), characteristicCellSize_HARDCODED, m_viewer->mainScene()->boundingBox(), scaleTransform());
} }
} }
@@ -290,7 +298,6 @@ void RimGeoMechView::updateCurrentTimeStep()
} }
overlayInfoConfig()->update3DInfo(); overlayInfoConfig()->update3DInfo();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@@ -9,6 +9,10 @@
#include "cafCeetronPlusNavigation.h" #include "cafCeetronPlusNavigation.h"
#include "cafCadNavigation.h" #include "cafCadNavigation.h"
#include "cvfCamera.h" #include "cvfCamera.h"
#include "cvfModel.h"
#include "cvfModelBasicList.h"
#include "cvfPart.h"
#include "cvfScene.h"
#include "cvfViewport.h" #include "cvfViewport.h"
#include "cafFrameAnimationControl.h" #include "cafFrameAnimationControl.h"
@@ -441,5 +445,42 @@ void RimView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QV
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView::addWellPathsToScene(cvf::Scene* scene, const cvf::Vec3d& displayModelOffset, double characteristicCellSize, const cvf::BoundingBox& boundingBox, cvf::Transform* scaleTransform)
{
CVF_ASSERT(scene);
CVF_ASSERT(scaleTransform);
cvf::String wellPathModelName = "WellPathModel";
std::vector<cvf::Model*> wellPathModels;
for (cvf::uint i = 0; i < scene->modelCount(); i++)
{
if (scene->model(i)->name() == wellPathModelName)
{
wellPathModels.push_back(scene->model(i));
}
}
for (size_t i = 0; i < wellPathModels.size(); i++)
{
scene->removeModel(wellPathModels[i]);
}
// Append static Well Paths to model
cvf::ref<cvf::ModelBasicList> wellPathModelBasicList = new cvf::ModelBasicList;
wellPathModelBasicList->setName(wellPathModelName);
RimOilField* oilFields = RiaApplication::instance()->project() ? RiaApplication::instance()->project()->activeOilField() : NULL;
RimWellPathCollection* wellPathCollection = oilFields ? oilFields->wellPathCollection() : NULL;
RivWellPathCollectionPartMgr* wellPathCollectionPartMgr = wellPathCollection ? wellPathCollection->wellPathCollectionPartMgr() : NULL;
if (wellPathCollectionPartMgr)
{
wellPathCollectionPartMgr->appendStaticGeometryPartsToModel(wellPathModelBasicList.p(), displayModelOffset, scaleTransform, characteristicCellSize, boundingBox);
}
wellPathModelBasicList->updateBoundingBoxesRecursive();
scene->addModel(wellPathModelBasicList.p());
}

View File

@@ -32,6 +32,8 @@ class RimCellRangeFilterCollection;
namespace cvf namespace cvf
{ {
class BoundingBox;
class Scene;
class Transform; class Transform;
} }
@@ -108,6 +110,7 @@ public:
protected: protected:
void setDefaultView(); void setDefaultView();
void addWellPathsToScene(cvf::Scene* scene, const cvf::Vec3d& displayModelOffset, double characteristicCellSize, const cvf::BoundingBox& boundingBox, cvf::Transform* scaleTransform);
virtual void createDisplayModel() = 0; virtual void createDisplayModel() = 0;
virtual void updateDisplayModelVisibility() = 0; virtual void updateDisplayModelVisibility() = 0;