diff --git a/ApplicationCode/ReservoirDataModel/RigFault.cpp b/ApplicationCode/ReservoirDataModel/RigFault.cpp index 0b85aa2039..bac522816f 100644 --- a/ApplicationCode/ReservoirDataModel/RigFault.cpp +++ b/ApplicationCode/ReservoirDataModel/RigFault.cpp @@ -17,6 +17,7 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RigFault.h" +#include "RigMainGrid.h" //-------------------------------------------------------------------------------------------------- @@ -56,10 +57,73 @@ QString RigFault::name() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const std::vector& RigFault::cellRangeForFace(cvf::StructGridInterface::FaceType face) const +std::vector& RigFault::faultFaces() { - size_t faceIndex = static_cast(face); - CVF_ASSERT(faceIndex < 6); - - return m_cellRangesForFaces[face]; + return m_faultFaces; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::vector& RigFault::faultFaces() const +{ + return m_faultFaces; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFault::computeFaultFacesFromCellRanges(const RigMainGrid* grid) +{ + if (!grid) return; + + m_faultFaces.clear(); + + for (size_t faceType = 0; faceType < 6; faceType++) + { + cvf::StructGridInterface::FaceType faceEnum = cvf::StructGridInterface::FaceType(faceType); + + const std::vector& cellRanges = m_cellRangesForFaces[faceType]; + + for (size_t i = 0; i < cellRanges.size(); i++) + { + const cvf::CellRange& cellRange = cellRanges[i]; + + cvf::Vec3st min, max; + cellRange.range(min, max); + + for (size_t i = min.x(); i <= max.x(); i++) + { + if (i >= grid->cellCountI()) + { + continue; + } + + for (size_t j = min.y(); j <= max.y(); j++) + { + if (j >= grid->cellCountJ()) + { + continue; + } + + for (size_t k = min.z(); k <= max.z(); k++) + { + if (k >= grid->cellCountK()) + { + continue; + } + + size_t localCellIndex = grid->cellIndexFromIJK(i, j, k); + + // Do not need to compute global grid cell index as for a maingrid localIndex == globalIndex + //size_t globalCellIndex = grid->globalGridCellIndex(localCellIndex); + + m_faultFaces.push_back(FaultFace(localCellIndex, faceEnum)); + } + } + } + } + } +} + + diff --git a/ApplicationCode/ReservoirDataModel/RigFault.h b/ApplicationCode/ReservoirDataModel/RigFault.h index fbac0a354d..025c474905 100644 --- a/ApplicationCode/ReservoirDataModel/RigFault.h +++ b/ApplicationCode/ReservoirDataModel/RigFault.h @@ -30,10 +30,24 @@ #include "cvfCellRange.h" #include "cafFixedArray.h" +class RigMainGrid; class RigFault : public cvf::Object { +public: + + struct FaultFace + { + FaultFace(size_t globalCellIndex, cvf::StructGridInterface::FaceType face) : + m_globalCellIndex(globalCellIndex), + m_face(face) + { } + + size_t m_globalCellIndex; + cvf::StructGridInterface::FaceType m_face; + }; + public: RigFault(); @@ -41,11 +55,15 @@ public: QString name() const; void addCellRangeForFace(cvf::StructGridInterface::FaceType face, const cvf::CellRange& cellRange); + void computeFaultFacesFromCellRanges(const RigMainGrid* grid); - const std::vector& cellRangeForFace(cvf::StructGridInterface::FaceType face) const; + std::vector& faultFaces(); + const std::vector& faultFaces() const; private: QString m_name; caf::FixedArray, 6> m_cellRangesForFaces; + + std::vector m_faultFaces; }; diff --git a/ApplicationCode/ReservoirDataModel/RigGridBase.cpp b/ApplicationCode/ReservoirDataModel/RigGridBase.cpp index 9f40006ee2..02946cd3d7 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridBase.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGridBase.cpp @@ -544,6 +544,11 @@ cvf::BoundingBox RigGridBase::boundingBox() void RigGridBase::setFaults(const cvf::Collection& faults) { m_faults = faults; + + for (size_t i = 0; i < m_faults.size(); i++) + { + m_faults[i]->computeFaultFacesFromCellRanges(this->mainGrid()); + } } //--------------------------------------------------------------------------------------------------