From bca5720968a1c2d12b142f1e83ebd1fda39154b4 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 16 Nov 2015 07:16:30 +0100 Subject: [PATCH] (#266) Added interface for all/activeCellsBoundingBox and displayModelOffset --- .../GeoMech/GeoMechDataModel/RigFemPart.cpp | 2 +- .../GeoMech/GeoMechDataModel/RigFemPart.h | 4 +- .../GeoMechDataModel/RigFemPartCollection.cpp | 2 +- .../GeoMechDataModel/RigFemPartCollection.h | 2 +- .../GridBox/RivGridBoxGenerator.cpp | 177 ++++++++++++------ .../GridBox/RivGridBoxGenerator.h | 24 ++- .../GridBox/RivPatchGenerator.cpp | 40 ---- ApplicationCode/ProjectDataModel/RimCase.cpp | 11 +- ApplicationCode/ProjectDataModel/RimCase.h | 12 ++ .../ProjectDataModel/RimEclipseCase.cpp | 47 ++++- .../ProjectDataModel/RimEclipseCase.h | 8 +- .../ProjectDataModel/RimEclipseView.cpp | 31 ++- .../ProjectDataModel/RimEclipseView.h | 2 + .../ProjectDataModel/RimGeoMechCase.cpp | 34 +++- .../ProjectDataModel/RimGeoMechCase.h | 3 + .../ProjectDataModel/RimGeoMechView.cpp | 2 - ApplicationCode/ProjectDataModel/RimView.cpp | 32 ++++ ApplicationCode/ProjectDataModel/RimView.h | 2 + ApplicationCode/UserInterface/RiuViewer.cpp | 54 ++---- ApplicationCode/UserInterface/RiuViewer.h | 12 +- 20 files changed, 337 insertions(+), 164 deletions(-) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPart.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPart.cpp index 56c941da84..2f86eb7f10 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPart.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPart.cpp @@ -326,7 +326,7 @@ float RigFemPart::characteristicElementSize() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::BoundingBox RigFemPart::boundingBox() +cvf::BoundingBox RigFemPart::boundingBox() const { if (m_boundingBox.isValid()) return m_boundingBox; diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPart.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPart.h index 2cf13f7bfc..7c8230e35c 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPart.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPart.h @@ -77,7 +77,7 @@ public: int neighborFace(int elementIndex, int faceIndex) const { return m_elmNeighbors[elementIndex].faceInNeighborElm[faceIndex]; } - cvf::BoundingBox boundingBox(); + cvf::BoundingBox boundingBox() const; float characteristicElementSize(); const std::vector& possibleGridCornerElements() const { return m_possibleGridCornerElements; } void findIntersectingCells(const cvf::BoundingBox& inputBB, std::vector* elementIndices) const; @@ -107,7 +107,7 @@ private: std::vector m_possibleGridCornerElements; float m_characteristicElementSize; - cvf::BoundingBox m_boundingBox; + mutable cvf::BoundingBox m_boundingBox; mutable cvf::ref m_elementSearchTree; diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartCollection.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartCollection.cpp index 6afa7383cb..cd735dea19 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartCollection.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartCollection.cpp @@ -103,7 +103,7 @@ float RigFemPartCollection::characteristicElementSize() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::BoundingBox RigFemPartCollection::boundingBox() +cvf::BoundingBox RigFemPartCollection::boundingBox() const { cvf::BoundingBox bBox; for (int i = 0; i < partCount(); i++) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartCollection.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartCollection.h index 99af25738c..5f172de9b7 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartCollection.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartCollection.h @@ -37,7 +37,7 @@ public: size_t totalElementCount() const; float characteristicElementSize(); - cvf::BoundingBox boundingBox(); + cvf::BoundingBox boundingBox() const; private: diff --git a/ApplicationCode/ModelVisualization/GridBox/RivGridBoxGenerator.cpp b/ApplicationCode/ModelVisualization/GridBox/RivGridBoxGenerator.cpp index 81a393da58..849ef34c43 100644 --- a/ApplicationCode/ModelVisualization/GridBox/RivGridBoxGenerator.cpp +++ b/ApplicationCode/ModelVisualization/GridBox/RivGridBoxGenerator.cpp @@ -38,42 +38,53 @@ RivGridBoxGenerator::RivGridBoxGenerator() { m_gridBoxModel = new cvf::ModelBasicList; - m_linDiscreteScalarMapper = new cvf::ScalarMapperDiscreteLinear; + m_scaleZ = 1.0; + m_displayModelOffset = cvf::Vec3d::ZERO; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivGridBoxGenerator::setTransform(cvf::Transform* scaleTransform) +void RivGridBoxGenerator::setScaleZ(double scaleZ) { - m_scaleTransform = scaleTransform; + m_scaleZ = scaleZ; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivGridBoxGenerator::setBoundingBox(const cvf::BoundingBox& boundingBox) +void RivGridBoxGenerator::setDisplayModelOffset(cvf::Vec3d offset) { - m_boundingBox = boundingBox; + m_displayModelOffset = offset; +} - m_xValues.clear(); - m_yValues.clear(); - m_zValues.clear(); +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivGridBoxGenerator::setGridBoxDomainCoordBoundingBox(const cvf::BoundingBox& bb) +{ + m_domainCoordsBoundingBox = bb; - cvf::Vec3d min = m_boundingBox.min(); - cvf::Vec3d max = m_boundingBox.max(); + m_domainCoordsXValues.clear(); + m_domainCoordsYValues.clear(); + m_domainCoordsZValues.clear(); - m_linDiscreteScalarMapper->setRange(min.x(), max.x()); - m_linDiscreteScalarMapper->setLevelCount(5, true); - m_linDiscreteScalarMapper->majorTickValues(&m_xValues); + cvf::Vec3d min = m_domainCoordsBoundingBox.min(); + cvf::Vec3d max = m_domainCoordsBoundingBox.max(); - m_linDiscreteScalarMapper->setRange(min.y(), max.y()); - m_linDiscreteScalarMapper->setLevelCount(5, true); - m_linDiscreteScalarMapper->majorTickValues(&m_yValues); + cvf::ScalarMapperDiscreteLinear m_linDiscreteScalarMapper; - m_linDiscreteScalarMapper->setRange(min.z(), max.z()); - m_linDiscreteScalarMapper->setLevelCount(5, true); - m_linDiscreteScalarMapper->majorTickValues(&m_zValues); + m_linDiscreteScalarMapper.setRange(min.x(), max.x()); + m_linDiscreteScalarMapper.setLevelCount(5, true); + m_linDiscreteScalarMapper.majorTickValues(&m_domainCoordsXValues); + + m_linDiscreteScalarMapper.setRange(min.y(), max.y()); + m_linDiscreteScalarMapper.setLevelCount(5, true); + m_linDiscreteScalarMapper.majorTickValues(&m_domainCoordsYValues); + + m_linDiscreteScalarMapper.setRange(min.z(), max.z()); + m_linDiscreteScalarMapper.setLevelCount(5, true); + m_linDiscreteScalarMapper.majorTickValues(&m_domainCoordsZValues); } //-------------------------------------------------------------------------------------------------- @@ -81,6 +92,8 @@ void RivGridBoxGenerator::setBoundingBox(const cvf::BoundingBox& boundingBox) //-------------------------------------------------------------------------------------------------- void RivGridBoxGenerator::createGridBoxParts() { + computeDisplayCoords(); + createGridBoxSideParts(); createGridBoxLegendParts(); } @@ -128,9 +141,13 @@ void RivGridBoxGenerator::createGridBoxSideParts() { m_gridBoxSideParts.clear(); - cvf::Vec3d min = m_boundingBox.min(); - cvf::Vec3d max = m_boundingBox.max(); + CVF_ASSERT(m_displayCoordsBoundingBox.isValid()); + CVF_ASSERT(m_displayCoordsXValues.size() > 0); + CVF_ASSERT(m_displayCoordsYValues.size() > 0); + CVF_ASSERT(m_displayCoordsZValues.size() > 0); + cvf::Vec3d min = m_displayCoordsBoundingBox.min(); + cvf::Vec3d max = m_displayCoordsBoundingBox.max(); for (int face = POS_X; face <= NEG_Z; face++) { @@ -141,37 +158,37 @@ void RivGridBoxGenerator::createGridBoxSideParts() { patchGen.setOrigin(cvf::Vec3d(max.x(), 0.0, 0.0)); patchGen.setAxes(cvf::Vec3d::Y_AXIS, cvf::Vec3d::Z_AXIS); - patchGen.setSubdivisions(m_yValues, m_zValues); + patchGen.setSubdivisions(m_displayCoordsYValues, m_displayCoordsZValues); } else if (face == NEG_X) { patchGen.setOrigin(cvf::Vec3d(min.x(), 0.0, 0.0)); patchGen.setAxes(cvf::Vec3d::Y_AXIS, cvf::Vec3d::Z_AXIS); - patchGen.setSubdivisions(m_yValues, m_zValues); + patchGen.setSubdivisions(m_displayCoordsYValues, m_displayCoordsZValues); } else if (face == POS_Y) { patchGen.setOrigin(cvf::Vec3d(0.0, max.y(), 0.0)); patchGen.setAxes(cvf::Vec3d::X_AXIS, cvf::Vec3d::Z_AXIS); - patchGen.setSubdivisions(m_xValues, m_zValues); + patchGen.setSubdivisions(m_displayCoordsXValues, m_displayCoordsZValues); } else if (face == NEG_Y) { patchGen.setOrigin(cvf::Vec3d(0.0, min.y(), 0.0)); patchGen.setAxes(cvf::Vec3d::X_AXIS, cvf::Vec3d::Z_AXIS); - patchGen.setSubdivisions(m_xValues, m_zValues); + patchGen.setSubdivisions(m_displayCoordsXValues, m_displayCoordsZValues); } else if (face == POS_Z) { patchGen.setOrigin(cvf::Vec3d(0.0, 0.0, max.z())); patchGen.setAxes(cvf::Vec3d::X_AXIS, cvf::Vec3d::Y_AXIS); - patchGen.setSubdivisions(m_xValues, m_yValues); + patchGen.setSubdivisions(m_displayCoordsXValues, m_displayCoordsYValues); } else if (face == NEG_Z) { patchGen.setOrigin(cvf::Vec3d(0.0, 0.0, min.z())); patchGen.setAxes(cvf::Vec3d::X_AXIS, cvf::Vec3d::Y_AXIS); - patchGen.setSubdivisions(m_xValues, m_yValues); + patchGen.setSubdivisions(m_displayCoordsXValues, m_displayCoordsYValues); } else { @@ -196,7 +213,6 @@ void RivGridBoxGenerator::createGridBoxSideParts() part->setName("Grid box "); part->setDrawable(geo.p()); - part->setTransform(m_scaleTransform.p()); part->updateBoundingBox(); cvf::ref eff; @@ -217,6 +233,11 @@ void RivGridBoxGenerator::createGridBoxLegendParts() { m_gridBoxLegendParts.clear(); + CVF_ASSERT(m_displayCoordsBoundingBox.isValid()); + CVF_ASSERT(m_displayCoordsXValues.size() > 0); + CVF_ASSERT(m_displayCoordsYValues.size() > 0); + CVF_ASSERT(m_displayCoordsZValues.size() > 0); + for (int edge = POS_Z_POS_X; edge <= NEG_X_NEG_Y; edge++) { cvf::Collection parts; @@ -230,6 +251,17 @@ void RivGridBoxGenerator::createGridBoxLegendParts() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Vec3d RivGridBoxGenerator::displayModelCoordFromDomainCoord(const cvf::Vec3d& domainCoord) const +{ + cvf::Vec3d coord = domainCoord - m_displayModelOffset; + coord.z() *= m_scaleZ; + + return coord; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -238,10 +270,9 @@ void RivGridBoxGenerator::createLegend(EdgeType edge, cvf::Collection cvf::Vec3d posMin; cvf::Vec3d posMax; - cvf::Vec3d min = m_boundingBox.min(); - cvf::Vec3d max = m_boundingBox.max(); + cvf::Vec3d min = m_displayCoordsBoundingBox.min(); + cvf::Vec3d max = m_displayCoordsBoundingBox.max(); - std::vector* tickValues = NULL; AxisType axis; cvf::Vec3f tickMarkDir; @@ -250,84 +281,72 @@ void RivGridBoxGenerator::createLegend(EdgeType edge, cvf::Collection { case RivGridBoxGenerator::POS_Z_POS_X: axis = Y_AXIS; - tickValues = &m_yValues; posMin.set(max.x(), min.y(), max.z()); posMax.set(max.x(), max.y(), max.z()); tickMarkDir = cornerDirection(POS_Z, POS_X); break; case RivGridBoxGenerator::POS_Z_NEG_X: axis = Y_AXIS; - tickValues = &m_yValues; posMin.set(min.x(), min.y(), max.z()); posMax.set(min.x(), max.y(), max.z()); tickMarkDir = cornerDirection(POS_Z, NEG_X); break; case RivGridBoxGenerator::POS_Z_POS_Y: axis = X_AXIS; - tickValues = &m_xValues; posMin.set(min.x(), max.y(), max.z()); posMax.set(max.x(), max.y(), max.z()); tickMarkDir = cornerDirection(POS_Z, POS_Y); break; case RivGridBoxGenerator::POS_Z_NEG_Y: axis = X_AXIS; - tickValues = &m_xValues; posMin.set(min.x(), min.y(), max.z()); posMax.set(max.x(), min.y(), max.z()); tickMarkDir = cornerDirection(POS_Z, NEG_Y); break; case RivGridBoxGenerator::NEG_Z_POS_X: axis = Y_AXIS; - tickValues = &m_yValues; posMin.set(max.x(), min.y(), min.z()); posMax.set(max.x(), max.y(), min.z()); tickMarkDir = cornerDirection(NEG_Z, POS_X); break; case RivGridBoxGenerator::NEG_Z_NEG_X: axis = Y_AXIS; - tickValues = &m_yValues; posMin.set(min.x(), min.y(), min.z()); posMax.set(min.x(), max.y(), min.z()); tickMarkDir = cornerDirection(NEG_Z, NEG_X); break; case RivGridBoxGenerator::NEG_Z_POS_Y: axis = X_AXIS; - tickValues = &m_xValues; posMin.set(min.x(), max.y(), min.z()); posMax.set(max.x(), max.y(), min.z()); tickMarkDir = cornerDirection(NEG_Z, POS_Y); break; case RivGridBoxGenerator::NEG_Z_NEG_Y: axis = X_AXIS; - tickValues = &m_xValues; posMin.set(min.x(), min.y(), min.z()); posMax.set(max.x(), min.y(), min.z()); tickMarkDir = cornerDirection(NEG_Z, NEG_Y); break; case RivGridBoxGenerator::POS_X_POS_Y: axis = Z_AXIS; - tickValues = &m_zValues; posMin.set(max.x(), max.y(), min.z()); posMax.set(max.x(), max.y(), max.z()); tickMarkDir = cornerDirection(POS_X, POS_Y); break; case RivGridBoxGenerator::POS_X_NEG_Y: axis = Z_AXIS; - tickValues = &m_zValues; posMin.set(max.x(), min.y(), min.z()); posMax.set(max.x(), min.y(), max.z()); tickMarkDir = cornerDirection(POS_X, NEG_Y); break; case RivGridBoxGenerator::NEG_X_POS_Y: axis = Z_AXIS; - tickValues = &m_zValues; posMin.set(min.x(), max.y(), min.z()); posMax.set(min.x(), max.y(), max.z()); tickMarkDir = cornerDirection(NEG_X, POS_Y); break; case RivGridBoxGenerator::NEG_X_NEG_Y: axis = Z_AXIS; - tickValues = &m_zValues; posMin.set(min.x(), min.y(), min.z()); posMax.set(min.x(), min.y(), max.z()); tickMarkDir = cornerDirection(NEG_X, NEG_Y); @@ -336,10 +355,30 @@ void RivGridBoxGenerator::createLegend(EdgeType edge, cvf::Collection break; } - CVF_ASSERT(tickValues); + std::vector* displayCoordsTickValues = NULL; + std::vector* domainCoordsTickValues = NULL; - size_t numVerts = (tickValues->size()) * 2; - size_t numLines = (tickValues->size()) + 1; + if (axis == X_AXIS) + { + displayCoordsTickValues = &m_displayCoordsXValues; + domainCoordsTickValues = &m_domainCoordsXValues; + } + else if (axis == Y_AXIS) + { + displayCoordsTickValues = &m_displayCoordsYValues; + domainCoordsTickValues = &m_domainCoordsYValues; + } + else if (axis == Z_AXIS) + { + displayCoordsTickValues = &m_displayCoordsZValues; + domainCoordsTickValues = &m_domainCoordsZValues; + } + + CVF_ASSERT(displayCoordsTickValues); + CVF_ASSERT(domainCoordsTickValues); + + size_t numVerts = (displayCoordsTickValues->size()) * 2; + size_t numLines = (displayCoordsTickValues->size()) + 1; cvf::ref vertices = new cvf::Vec3fArray; vertices->reserve(numVerts); @@ -348,15 +387,15 @@ void RivGridBoxGenerator::createLegend(EdgeType edge, cvf::Collection indices->reserve(2 * numLines); - float tickLength = static_cast(m_boundingBox.extent().length() / 100.0); + float tickLength = static_cast(m_displayCoordsBoundingBox.extent().length() / 100.0); cvf::Vec3f point = cvf::Vec3f(posMin); cvf::Vec3f tickPoint; // Tick marks - for (size_t i = 0; i < tickValues->size(); ++i) + for (size_t i = 0; i < displayCoordsTickValues->size(); ++i) { - point[axis] = static_cast(tickValues->at(i)); + point[axis] = static_cast(displayCoordsTickValues->at(i)); vertices->add(point); tickPoint = point + tickLength*tickMarkDir;; @@ -383,7 +422,6 @@ void RivGridBoxGenerator::createLegend(EdgeType edge, cvf::Collection part->setName("Legend lines "); part->setDrawable(geo.p()); - part->setTransform(m_scaleTransform.p()); part->updateBoundingBox(); cvf::ref eff; @@ -395,7 +433,6 @@ void RivGridBoxGenerator::createLegend(EdgeType edge, cvf::Collection parts->push_back(part.p()); } - { // Text labels @@ -406,14 +443,13 @@ void RivGridBoxGenerator::createLegend(EdgeType edge, cvf::Collection geo->setDrawBorder(false); //textGeo->setCheckPosVisible(false); - for (size_t idx = 0; idx < tickValues->size(); idx++) + for (size_t idx = 0; idx < domainCoordsTickValues->size(); idx++) { - geo->addText(cvf::String(tickValues->at(idx)), vertices->get(idx*2 + 1) + (0.5f * tickLength) * tickMarkDir); + geo->addText(cvf::String(domainCoordsTickValues->at(idx)), vertices->get(idx*2 + 1) + (0.5f * tickLength) * tickMarkDir); } cvf::ref part = new cvf::Part; part->setDrawable(geo.p()); - part->setTransform(m_scaleTransform.p()); part->updateBoundingBox(); cvf::ref eff = new cvf::Effect; @@ -462,12 +498,12 @@ cvf::Vec3d RivGridBoxGenerator::pointOnSide(FaceType face) case RivGridBoxGenerator::POS_X: case RivGridBoxGenerator::POS_Y: case RivGridBoxGenerator::POS_Z: - return cvf::Vec3d(m_boundingBox.max()); + return cvf::Vec3d(m_displayCoordsBoundingBox.max()); case RivGridBoxGenerator::NEG_X: case RivGridBoxGenerator::NEG_Y: case RivGridBoxGenerator::NEG_Z: - return cvf::Vec3d(m_boundingBox.min()); + return cvf::Vec3d(m_displayCoordsBoundingBox.min()); default: break; } @@ -485,3 +521,32 @@ cvf::Vec3f RivGridBoxGenerator::cornerDirection(FaceType face1, FaceType face2) return dir; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivGridBoxGenerator::computeDisplayCoords() +{ + m_displayCoordsBoundingBox.reset(); + m_displayCoordsXValues.clear(); + m_displayCoordsYValues.clear(); + m_displayCoordsZValues.clear(); + + m_displayCoordsBoundingBox.add(displayModelCoordFromDomainCoord(m_domainCoordsBoundingBox.min())); + m_displayCoordsBoundingBox.add(displayModelCoordFromDomainCoord(m_domainCoordsBoundingBox.max())); + + for (size_t i = 0; i < m_domainCoordsXValues.size(); i++) + { + m_displayCoordsXValues.push_back(m_domainCoordsXValues[i] - m_displayModelOffset.x()); + } + + for (size_t i = 0; i < m_domainCoordsYValues.size(); i++) + { + m_displayCoordsYValues.push_back(m_domainCoordsYValues[i] - m_displayModelOffset.y()); + } + + for (size_t i = 0; i < m_domainCoordsZValues.size(); i++) + { + m_displayCoordsZValues.push_back(m_scaleZ * (m_domainCoordsZValues[i] - m_displayModelOffset.z())); + } +} diff --git a/ApplicationCode/ModelVisualization/GridBox/RivGridBoxGenerator.h b/ApplicationCode/ModelVisualization/GridBox/RivGridBoxGenerator.h index 666b90b69c..9d5594a3dd 100644 --- a/ApplicationCode/ModelVisualization/GridBox/RivGridBoxGenerator.h +++ b/ApplicationCode/ModelVisualization/GridBox/RivGridBoxGenerator.h @@ -44,8 +44,9 @@ class RivGridBoxGenerator public: RivGridBoxGenerator(); - void setTransform(cvf::Transform* scaleTransform); - void setBoundingBox(const cvf::BoundingBox& boundingBox); + void setScaleZ(double scaleZ); + void setDisplayModelOffset(cvf::Vec3d offset); + void setGridBoxDomainCoordBoundingBox(const cvf::BoundingBox& boundingBox); void createGridBoxParts(); void updateFromCamera(const cvf::Camera* camera); @@ -93,12 +94,15 @@ private: void createGridBoxSideParts(); void createGridBoxLegendParts(); + cvf::Vec3d displayModelCoordFromDomainCoord(const cvf::Vec3d& domainCoord) const; + void createLegend(EdgeType edge, cvf::Collection* parts); cvf::Vec3f sideNormalOutwards(FaceType face); cvf::Vec3d pointOnSide(FaceType face); cvf::Vec3f cornerDirection(FaceType face1, FaceType face2); + void computeDisplayCoords(); private: cvf::Collection m_gridBoxSideParts; @@ -106,13 +110,17 @@ private: cvf::ref m_gridBoxModel; - cvf::ref m_scaleTransform; - cvf::BoundingBox m_boundingBox; + cvf::BoundingBox m_domainCoordsBoundingBox; + std::vector m_domainCoordsXValues; + std::vector m_domainCoordsYValues; + std::vector m_domainCoordsZValues; - cvf::ref m_linDiscreteScalarMapper; + cvf::BoundingBox m_displayCoordsBoundingBox; + std::vector m_displayCoordsXValues; + std::vector m_displayCoordsYValues; + std::vector m_displayCoordsZValues; - std::vector m_xValues; - std::vector m_yValues; - std::vector m_zValues; + double m_scaleZ; + cvf::Vec3d m_displayModelOffset; }; diff --git a/ApplicationCode/ModelVisualization/GridBox/RivPatchGenerator.cpp b/ApplicationCode/ModelVisualization/GridBox/RivPatchGenerator.cpp index e08862d935..773603c6a6 100644 --- a/ApplicationCode/ModelVisualization/GridBox/RivPatchGenerator.cpp +++ b/ApplicationCode/ModelVisualization/GridBox/RivPatchGenerator.cpp @@ -87,46 +87,6 @@ void RivPatchGenerator::setWindingCCW(bool windingCCW) //-------------------------------------------------------------------------------------------------- void RivPatchGenerator::generate(cvf::GeometryBuilder* builder) { -/* - CVF_ASSERT(m_cellCountU > 0); - CVF_ASSERT(m_cellCountV > 0); - - size_t numVertices = (m_cellCountU + 1)*(m_cellCountV + 1); - - Vec3fArray vertices; - vertices.reserve(numVertices); - - const Vec3d unitU = (m_extentU*m_axisU)/m_cellCountU; - const Vec3d unitV = (m_extentV*m_axisV)/m_cellCountV; - - uint v; - for (v = 0; v <= m_cellCountV; v++) - { - Vec3d rowOrigo(m_origin + unitV*v); - - uint u; - for (u = 0; u <= m_cellCountU; u++) - { - vertices.add(Vec3f(rowOrigo + unitU*u)); - } - } - - uint baseNodeIdx = builder->addVertices(vertices); - - if (m_useQuads) - { - UIntArray conn; - GeometryUtils::tesselatePatchAsQuads(m_cellCountU + 1, m_cellCountV + 1, baseNodeIdx, m_windingCCW, &conn); - builder->addQuads(conn); - } - else - { - UIntArray conn; - GeometryUtils::tesselatePatchAsTriangles(m_cellCountU + 1, m_cellCountV + 1, baseNodeIdx, m_windingCCW, &conn); - builder->addTriangles(conn); - } -*/ - CVF_ASSERT(m_uValues.size() > 0); CVF_ASSERT(m_vValues.size() > 0); diff --git a/ApplicationCode/ProjectDataModel/RimCase.cpp b/ApplicationCode/ProjectDataModel/RimCase.cpp index 09e06d6f75..1baf6e8942 100644 --- a/ApplicationCode/ProjectDataModel/RimCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimCase.cpp @@ -18,6 +18,7 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RimCase.h" + #include "cafPdmObjectFactory.h" #include @@ -203,4 +204,12 @@ QString RimCase::relocateFile(const QString& orgFileName, const QString& orgNew if (foundFile) *foundFile = false; return fileName; -} \ No newline at end of file +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Vec3d RimCase::displayModelOffset() const +{ + return cvf::Vec3d::ZERO; +} diff --git a/ApplicationCode/ProjectDataModel/RimCase.h b/ApplicationCode/ProjectDataModel/RimCase.h index 9a8c8519b5..37dc1a9229 100644 --- a/ApplicationCode/ProjectDataModel/RimCase.h +++ b/ApplicationCode/ProjectDataModel/RimCase.h @@ -18,13 +18,20 @@ ///////////////////////////////////////////////////////////////////////////////// #pragma once + #include "cafPdmField.h" #include "cafPdmObject.h" +#include "cvfVector3.h" + #include class RimView; +namespace cvf { + class BoundingBox; +} + class RimCase : public caf::PdmObject { CAF_PDM_HEADER_INIT; @@ -44,6 +51,11 @@ public: virtual QStringList timeStepStrings() = 0; virtual QString timeStepName(int frameIdx) = 0; + virtual cvf::BoundingBox activeCellsBoundingBox() const = 0; + virtual cvf::BoundingBox allCellsBoundingBox() const = 0; + + virtual cvf::Vec3d displayModelOffset() const; + protected: static QString relocateFile(const QString& fileName, const QString& newProjectPath, const QString& oldProjectPath, bool* foundFile, std::vector* searchedPaths); diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp index 04becf0527..3f6ae1084a 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp @@ -356,6 +356,51 @@ void RimEclipseCase::setReservoirData(RigCaseData* eclipseCase) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::BoundingBox RimEclipseCase::activeCellsBoundingBox() const +{ + if (m_rigEclipseCase.notNull() && m_rigEclipseCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)) + { + return m_rigEclipseCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->geometryBoundingBox(); + } + else + { + return cvf::BoundingBox(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::BoundingBox RimEclipseCase::allCellsBoundingBox() const +{ + if (m_rigEclipseCase.notNull() && m_rigEclipseCase->mainGrid()) + { + return m_rigEclipseCase->mainGrid()->boundingBox(); + } + else + { + return cvf::BoundingBox(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Vec3d RimEclipseCase::displayModelOffset() const +{ + if (m_rigEclipseCase.notNull() && m_rigEclipseCase->mainGrid()) + { + return m_rigEclipseCase->mainGrid()->displayModelOffset(); + } + else + { + return cvf::Vec3d::ZERO; + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -468,4 +513,4 @@ QString RimEclipseCase::timeStepName(int frameIdx) QDateTime date = results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->timeStepDate(0,frameIdx); return date.toString(m_timeStepFormatString); -} \ No newline at end of file +} diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCase.h b/ApplicationCode/ProjectDataModel/RimEclipseCase.h index c3be567624..47521175c2 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCase.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseCase.h @@ -71,9 +71,9 @@ public: RigCaseData* reservoirData(); const RigCaseData* reservoirData() const; - RimReservoirCellResultsStorage* results(RifReaderInterface::PorosityModelResultType porosityModel); + RimReservoirCellResultsStorage* results(RifReaderInterface::PorosityModelResultType porosityModel); - RimEclipseView* createAndAddReservoirView(); + RimEclipseView* createAndAddReservoirView(); void removeResult(const QString& resultName); @@ -88,6 +88,10 @@ public: virtual QStringList timeStepStrings(); virtual QString timeStepName(int frameIdx); + virtual cvf::BoundingBox activeCellsBoundingBox() const; + virtual cvf::BoundingBox allCellsBoundingBox() const; + virtual cvf::Vec3d displayModelOffset() const; + // Overridden methods from PdmObject public: diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index 57bf83ae7a..718d4cbce6 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -70,6 +70,7 @@ #include #include +#include "RivGridBoxGenerator.h" @@ -227,6 +228,8 @@ void RimEclipseView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c } else if (changedField == &showInactiveCells) { + this->updateGridBoxData(); + this->scheduleGeometryRegen(INACTIVE); this->scheduleGeometryRegen(RANGE_FILTERED_INACTIVE); @@ -480,8 +483,6 @@ void RimEclipseView::createDisplayModel() m_overlayInfoConfig()->update3DInfo(); updateLegends(); } - - m_viewer->showGridBox(true); } @@ -1682,6 +1683,32 @@ void RimEclipseView::calculateCurrentTotalCellVisibility(cvf::UByteArray* totalV } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseView::updateGridBoxData() +{ + if (viewer()) + { + RivGridBoxGenerator* gridBoxGen = viewer()->gridBoxGenerator(); + + gridBoxGen->setScaleZ(scaleZ); + + if (showInactiveCells) + { + gridBoxGen->setGridBoxDomainCoordBoundingBox(ownerCase()->allCellsBoundingBox()); + } + else + { + gridBoxGen->setGridBoxDomainCoordBoundingBox(ownerCase()->activeCellsBoundingBox()); + } + + gridBoxGen->setDisplayModelOffset(ownerCase()->displayModelOffset()); + + gridBoxGen->createGridBoxParts(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.h b/ApplicationCode/ProjectDataModel/RimEclipseView.h index c4cbc3af5c..fd523f5f9e 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.h @@ -126,6 +126,8 @@ public: const std::vector& visibleGridParts() const { return m_visibleGridParts;} cvf::cref reservoirGridPartManager() const { return m_reservoirGridPartManager.p(); } + virtual void updateGridBoxData(); + // Does this belong here, really ? void calculateVisibleWellCellsIncFence(cvf::UByteArray* visibleCells, RigGridBase * grid); diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp index 17a8230f17..a58f74bd0a 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp @@ -18,14 +18,19 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RimGeoMechCase.h" -#include "RimGeoMechView.h" + #include "RiaApplication.h" #include "RiaPreferences.h" + #include "RifOdbReader.h" -#include "RigGeoMechCaseData.h" + +#include "RigFemPartCollection.h" #include "RigFemPartResultsCollection.h" -#include "RimProject.h" +#include "RigGeoMechCaseData.h" + +#include "RimGeoMechView.h" #include "RimMainPlotCollection.h" +#include "RimProject.h" #include "RimWellLogPlotCollection.h" #include @@ -179,3 +184,26 @@ QString RimGeoMechCase::timeStepName(int frameIdx) return QString::fromStdString(stepNames[frameIdx]); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::BoundingBox RimGeoMechCase::activeCellsBoundingBox() const +{ + return allCellsBoundingBox(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::BoundingBox RimGeoMechCase::allCellsBoundingBox() const +{ + if (m_geoMechCaseData.notNull() && m_geoMechCaseData->femParts()) + { + return m_geoMechCaseData->femParts()->boundingBox(); + } + else + { + return cvf::BoundingBox(); + } +} diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.h b/ApplicationCode/ProjectDataModel/RimGeoMechCase.h index a5304f29b9..ff65abe38e 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCase.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.h @@ -59,6 +59,9 @@ public: virtual QStringList timeStepStrings(); virtual QString timeStepName(int frameIdx); + virtual cvf::BoundingBox activeCellsBoundingBox() const; + virtual cvf::BoundingBox allCellsBoundingBox() const; + // Fields: caf::PdmChildArrayField geoMechViews; diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index f1be68b085..f81f574e99 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -250,8 +250,6 @@ void RimGeoMechView::createDisplayModel() m_vizLogic->updateStaticCellColors(-1); m_overlayInfoConfig()->update3DInfo(); } - - m_viewer->showGridBox(true); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimView.cpp b/ApplicationCode/ProjectDataModel/RimView.cpp index f2a6247c25..7ff03ce908 100644 --- a/ApplicationCode/ProjectDataModel/RimView.cpp +++ b/ApplicationCode/ProjectDataModel/RimView.cpp @@ -19,6 +19,7 @@ #include "RiuMainWindow.h" #include "RiuViewer.h" +#include "RivGridBoxGenerator.h" #include "RivWellPathCollectionPartMgr.h" #include "cafFrameAnimationControl.h" @@ -178,6 +179,7 @@ void RimView::updateViewerWidget() m_viewer = new RiuViewer(glFormat, NULL); m_viewer->setOwnerReservoirView(this); + this->updateGridBoxData(); RiuMainWindow::instance()->addViewer(m_viewer->layoutWidget(), windowGeometry()); m_viewer->setMinNearPlaneDistance(10); @@ -246,6 +248,17 @@ void RimView::setCurrentTimeStep(int frameIndex) m_currentReservoirCellVisibility = NULL; } this->updateCurrentTimeStep(); + + cvf::Scene* frameScene = m_viewer->frame(m_currentTimeStep); + if (frameScene) + { + frameScene->removeModel(m_viewer->gridBoxGenerator()->model()); + + if (true) + { + frameScene->addModel(m_viewer->gridBoxGenerator()->model()); + } + } } //-------------------------------------------------------------------------------------------------- /// @@ -464,6 +477,8 @@ void RimView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QV { if (scaleZ < 1) scaleZ = 1; + this->updateGridBoxData(); + // Regenerate well paths RimOilField* oilFields = RiaApplication::instance()->project() ? RiaApplication::instance()->project()->activeOilField() : NULL; RimWellPathCollection* wellPathCollection = (oilFields) ? oilFields->wellPathCollection() : NULL; @@ -771,3 +786,20 @@ void RimView::removeModelByName(cvf::Scene* scene, const cvf::String& modelName) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimView::updateGridBoxData() +{ + if (viewer()) + { + RivGridBoxGenerator* gridBoxGen = viewer()->gridBoxGenerator(); + + gridBoxGen->setScaleZ(scaleZ); + gridBoxGen->setDisplayModelOffset(cvf::Vec3d::ZERO); + gridBoxGen->setGridBoxDomainCoordBoundingBox(ownerCase()->allCellsBoundingBox()); + + gridBoxGen->createGridBoxParts(); + } +} + diff --git a/ApplicationCode/ProjectDataModel/RimView.h b/ApplicationCode/ProjectDataModel/RimView.h index 09ebd2d0dc..7b8b20769c 100644 --- a/ApplicationCode/ProjectDataModel/RimView.h +++ b/ApplicationCode/ProjectDataModel/RimView.h @@ -137,6 +137,8 @@ public: cvf::ref currentTotalCellVisibility(); + virtual void updateGridBoxData(); + public: virtual void loadDataAndUpdate() = 0; virtual RimCase* ownerCase() = 0; diff --git a/ApplicationCode/UserInterface/RiuViewer.cpp b/ApplicationCode/UserInterface/RiuViewer.cpp index 160d6e74f5..b1c9f05da4 100644 --- a/ApplicationCode/UserInterface/RiuViewer.cpp +++ b/ApplicationCode/UserInterface/RiuViewer.cpp @@ -163,7 +163,6 @@ RiuViewer::RiuViewer(const QGLFormat& format, QWidget* parent) // which solves the problem setContextMenuPolicy(Qt::PreventContextMenu); - m_showGridBox = true; m_gridBoxGenerator = new RivGridBoxGenerator; } @@ -173,12 +172,12 @@ RiuViewer::RiuViewer(const QGLFormat& format, QWidget* parent) //-------------------------------------------------------------------------------------------------- RiuViewer::~RiuViewer() { - if (m_reservoirView) + if (m_rimView) { - m_reservoirView->showWindow = false; - m_reservoirView->uiCapability()->updateUiIconFromToggleField(); + m_rimView->showWindow = false; + m_rimView->uiCapability()->updateUiIconFromToggleField(); - m_reservoirView->cameraPosition = m_mainCamera->viewMatrix(); + m_rimView->cameraPosition = m_mainCamera->viewMatrix(); } delete m_InfoLabel; delete m_animationProgress; @@ -258,7 +257,7 @@ void RiuViewer::slotEndAnimation() cvf::Rendering* firstRendering = m_renderingSequence->firstRendering(); CVF_ASSERT(firstRendering); - if (m_reservoirView) m_reservoirView->endAnimation(); + if (m_rimView) m_rimView->endAnimation(); caf::Viewer::slotEndAnimation(); @@ -272,12 +271,12 @@ void RiuViewer::slotSetCurrentFrame(int frameIndex) { setCurrentFrame(frameIndex); - if (m_reservoirView) + if (m_rimView) { - RimViewLinker* viewLinker = m_reservoirView->assosiatedViewLinker(); + RimViewLinker* viewLinker = m_rimView->assosiatedViewLinker(); if (viewLinker) { - viewLinker->updateTimeStep(m_reservoirView, frameIndex); + viewLinker->updateTimeStep(m_rimView, frameIndex); } } } @@ -303,7 +302,7 @@ void RiuViewer::setPointOfInterest(cvf::Vec3d poi) //-------------------------------------------------------------------------------------------------- void RiuViewer::setOwnerReservoirView(RimView * owner) { - m_reservoirView = owner; + m_rimView = owner; m_viewerCommands->setOwnerView(owner); } @@ -340,7 +339,7 @@ void RiuViewer::paintOverlayItems(QPainter* painter) if (showAnimBar && m_showAnimProgress) { - QString stepName = m_reservoirView->ownerCase()->timeStepName(currentFrameIndex()); + QString stepName = m_rimView->ownerCase()->timeStepName(currentFrameIndex()); m_animationProgress->setFormat("Time Step: %v/%m " + stepName); m_animationProgress->setMinimum(0); m_animationProgress->setMaximum(static_cast(frameCount()) - 1); @@ -501,17 +500,12 @@ void RiuViewer::navigationPolicyUpdate() { caf::Viewer::navigationPolicyUpdate(); - if (m_reservoirView) + if (m_rimView) { - RimViewLinker* viewLinker = m_reservoirView->assosiatedViewLinker(); + RimViewLinker* viewLinker = m_rimView->assosiatedViewLinker(); if (viewLinker) { - viewLinker->updateCamera(m_reservoirView); - } - - if (m_showGridBox) - { - m_gridBoxGenerator->updateFromCamera(mainCamera()); + viewLinker->updateCamera(m_rimView); } } } @@ -524,7 +518,7 @@ void RiuViewer::setCurrentFrame(int frameIndex) cvf::Rendering* firstRendering = m_renderingSequence->firstRendering(); CVF_ASSERT(firstRendering); - if (m_reservoirView) m_reservoirView->setCurrentTimeStep(frameIndex); + if (m_rimView) m_rimView->setCurrentTimeStep(frameIndex); caf::Viewer::slotSetCurrentFrame(frameIndex); } @@ -534,27 +528,13 @@ void RiuViewer::setCurrentFrame(int frameIndex) //-------------------------------------------------------------------------------------------------- RimView* RiuViewer::ownerReservoirView() { - return m_reservoirView; + return m_rimView; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuViewer::showGridBox(bool enable) +RivGridBoxGenerator* RiuViewer::gridBoxGenerator() const { - m_showGridBox = enable; - - if (!enable) - { - currentScene()->removeModel(m_gridBoxGenerator->model()); - } - else - { - m_gridBoxGenerator->setBoundingBox(mainScene()->boundingBox()); -// m_gridBoxGenerator->setTransform(); - m_gridBoxGenerator->updateFromCamera(mainCamera()); - m_gridBoxGenerator->createGridBoxParts(); - - currentScene()->addModel(m_gridBoxGenerator->model()); - } + return m_gridBoxGenerator; } diff --git a/ApplicationCode/UserInterface/RiuViewer.h b/ApplicationCode/UserInterface/RiuViewer.h index e32aa09a7a..a9bec34b4b 100644 --- a/ApplicationCode/UserInterface/RiuViewer.h +++ b/ApplicationCode/UserInterface/RiuViewer.h @@ -69,7 +69,7 @@ public: void setHistogram(double min, double max, const std::vector& histogram); void setHistogramPercentiles(double pmin, double pmax, double mean); - void showGridBox(bool enable); + RivGridBoxGenerator* gridBoxGenerator() const; void showAnimationProgress(bool enable); @@ -92,7 +92,6 @@ private: void mouseReleaseEvent(QMouseEvent* event); void mousePressEvent(QMouseEvent* event); - QLabel* m_InfoLabel; QLabel* m_versionInfoLabel; bool m_showInfoText; @@ -107,12 +106,11 @@ private: cvf::Collection m_visibleLegends; - caf::PdmPointer m_reservoirView; - QPoint m_lastMousePressPosition; + caf::PdmPointer m_rimView; + QPoint m_lastMousePressPosition; - RiuViewerCommands* m_viewerCommands; + RiuViewerCommands* m_viewerCommands; - bool m_showGridBox; - RivGridBoxGenerator* m_gridBoxGenerator; + RivGridBoxGenerator* m_gridBoxGenerator; };