diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index 9a51615947..04e03dacc0 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -431,6 +431,11 @@ void RimEclipseView::createDisplayModel() // Create Scenes from the frameModels // 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; for (frameIndex = 0; frameIndex < frameModels.size(); frameIndex++) { @@ -440,6 +445,9 @@ void RimEclipseView::createDisplayModel() cvf::ref scene = new cvf::Scene; scene->addModel(model); + // Add well paths, if any + addWellPathsToScene(scene.p(), mainGrid->displayModelOffset(), mainGrid->characteristicIJCellSize(), currentActiveCellInfo()->geometryBoundingBox(), m_reservoirGridPartManager->scaleTransform()); + if (frameIndex == 0) m_viewer->setMainScene(scene.p()); else @@ -586,7 +594,7 @@ void RimEclipseView::updateCurrentTimeStep() this->updateFaultColors(); - // Well pipes and well paths + // Well pipes if (m_viewer) { cvf::Scene* frameScene = m_viewer->frame(m_currentTimeStep); @@ -619,42 +627,14 @@ void RimEclipseView::updateCurrentTimeStep() wellPipeModelBasicList->updateBoundingBoxesRecursive(); //printf("updateCurrentTimeStep: Add WellPipeModel to frameScene\n"); frameScene->addModel(wellPipeModelBasicList.p()); - - // Well paths - // ---------- - cvf::String wellPathModelName = "WellPathModel"; - std::vector 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++) - { - //printf("updateCurrentTimeStep: Remove WellPathModel %i from frameScene, for frame %i\n", i, m_currentTimeStep.v()); - frameScene->removeModel(wellPathModels[i]); - } - - // Append static Well Paths to model - cvf::ref 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()); + // Add well paths, if any + RimEclipseCase* eclCase = eclipseCase(); + RigCaseData* caseData = eclCase ? eclCase->reservoirData() : NULL; + RigMainGrid* mainGrid = caseData ? caseData->mainGrid() : NULL; + CVF_ASSERT(mainGrid); + + addWellPathsToScene(frameScene, mainGrid->displayModelOffset(), mainGrid->characteristicIJCellSize(), currentActiveCellInfo()->geometryBoundingBox(), m_reservoirGridPartManager->scaleTransform()); } } diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index 910e1874ad..36c2ef71a3 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -243,6 +243,10 @@ void RimGeoMechView::createDisplayModel() m_viewer->setMainScene(scene.p()); else 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 @@ -278,6 +282,10 @@ void RimGeoMechView::updateCurrentTimeStep() frameParts->updateBoundingBoxesRecursive(); frameScene->removeAllModels(); 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(); - } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimView.cpp b/ApplicationCode/ProjectDataModel/RimView.cpp index 478c5ea045..847eddce78 100644 --- a/ApplicationCode/ProjectDataModel/RimView.cpp +++ b/ApplicationCode/ProjectDataModel/RimView.cpp @@ -9,6 +9,10 @@ #include "cafCeetronPlusNavigation.h" #include "cafCadNavigation.h" #include "cvfCamera.h" +#include "cvfModel.h" +#include "cvfModelBasicList.h" +#include "cvfPart.h" +#include "cvfScene.h" #include "cvfViewport.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 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 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()); +} diff --git a/ApplicationCode/ProjectDataModel/RimView.h b/ApplicationCode/ProjectDataModel/RimView.h index 9d3774a2f3..6e065acf57 100644 --- a/ApplicationCode/ProjectDataModel/RimView.h +++ b/ApplicationCode/ProjectDataModel/RimView.h @@ -32,6 +32,8 @@ class RimCellRangeFilterCollection; namespace cvf { + class BoundingBox; + class Scene; class Transform; } @@ -108,6 +110,7 @@ public: protected: 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 updateDisplayModelVisibility() = 0;