mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Use const access for FixedArray. Added sorting of faults
This commit is contained in:
@@ -129,6 +129,8 @@ RimFault* RimFaultCollection::findFaultByName(QString name)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@@ -138,12 +140,29 @@ void RimFaultCollection::syncronizeFaults()
|
|||||||
|
|
||||||
cvf::ref<cvf::Color3fArray> partColors = RivColorTableArray::colorTableArray();
|
cvf::ref<cvf::Color3fArray> partColors = RivColorTableArray::colorTableArray();
|
||||||
|
|
||||||
const cvf::Collection<RigFault> rigFaults = m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->faults();
|
const cvf::Collection<RigFault> constRigFaults = m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->faults();
|
||||||
|
|
||||||
|
cvf::Collection<RigFault> rigFaults(constRigFaults);
|
||||||
|
|
||||||
|
// Sort based on name
|
||||||
|
class FaultComparator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
bool operator()(const cvf::ref<RigFault>& a, const cvf::ref<RigFault>& b) const
|
||||||
|
{
|
||||||
|
CVF_TIGHT_ASSERT(a.notNull() && b.notNull());
|
||||||
|
|
||||||
|
int compareValue = a->name().compare(b->name(), Qt::CaseInsensitive);
|
||||||
|
|
||||||
|
return (compareValue < 0);
|
||||||
|
}
|
||||||
|
} myFaultComparator;
|
||||||
|
|
||||||
|
std::sort(rigFaults.begin(), rigFaults.end(), myFaultComparator);
|
||||||
|
|
||||||
std::vector<caf::PdmPointer<RimFault> > newFaults;
|
std::vector<caf::PdmPointer<RimFault> > newFaults;
|
||||||
|
|
||||||
// Find corresponding fault from data model, or create a new
|
// Find corresponding fault from data model, or create a new
|
||||||
|
|
||||||
for (size_t fIdx = 0; fIdx < rigFaults.size(); ++fIdx)
|
for (size_t fIdx = 0; fIdx < rigFaults.size(); ++fIdx)
|
||||||
{
|
{
|
||||||
RimFault* rimFault = this->findFaultByName(rigFaults[fIdx]->name());
|
RimFault* rimFault = this->findFaultByName(rigFaults[fIdx]->name());
|
||||||
|
|||||||
@@ -24,7 +24,6 @@
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
RigFault::RigFault()
|
RigFault::RigFault()
|
||||||
{
|
{
|
||||||
m_cellRangesForFaces.resize(6);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@@ -33,7 +32,7 @@ RigFault::RigFault()
|
|||||||
void RigFault::addCellRangeForFace(cvf::StructGridInterface::FaceType face, const cvf::CellRange& cellRange)
|
void RigFault::addCellRangeForFace(cvf::StructGridInterface::FaceType face, const cvf::CellRange& cellRange)
|
||||||
{
|
{
|
||||||
size_t faceIndex = static_cast<size_t>(face);
|
size_t faceIndex = static_cast<size_t>(face);
|
||||||
CVF_ASSERT(faceIndex < m_cellRangesForFaces.size());
|
CVF_ASSERT(faceIndex < 6);
|
||||||
|
|
||||||
m_cellRangesForFaces[faceIndex].push_back(cellRange);
|
m_cellRangesForFaces[faceIndex].push_back(cellRange);
|
||||||
}
|
}
|
||||||
@@ -60,7 +59,7 @@ QString RigFault::name() const
|
|||||||
const std::vector<cvf::CellRange>& RigFault::cellRangeForFace(cvf::StructGridInterface::FaceType face) const
|
const std::vector<cvf::CellRange>& RigFault::cellRangeForFace(cvf::StructGridInterface::FaceType face) const
|
||||||
{
|
{
|
||||||
size_t faceIndex = static_cast<size_t>(face);
|
size_t faceIndex = static_cast<size_t>(face);
|
||||||
CVF_ASSERT(faceIndex < m_cellRangesForFaces.size());
|
CVF_ASSERT(faceIndex < 6);
|
||||||
|
|
||||||
return m_cellRangesForFaces[faceIndex];
|
return m_cellRangesForFaces[face];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include "cvfStructGrid.h"
|
#include "cvfStructGrid.h"
|
||||||
#include "cvfCellRange.h"
|
#include "cvfCellRange.h"
|
||||||
|
#include "cafFixedArray.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -46,5 +47,5 @@ public:
|
|||||||
private:
|
private:
|
||||||
QString m_name;
|
QString m_name;
|
||||||
|
|
||||||
std::vector< std::vector<cvf::CellRange> > m_cellRangesForFaces;
|
caf::FixedArray<std::vector<cvf::CellRange>, 6> m_cellRangesForFaces;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -49,8 +49,8 @@ class FixedArray
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
T m_array[size];
|
T m_array[size];
|
||||||
template<typename IndexType> T& operator[](const IndexType& index) { CVF_TIGHT_ASSERT(static_cast<size_t>(index) < size); return m_array[index]; }
|
template<typename IndexType> T& operator[](const IndexType& index) { CVF_TIGHT_ASSERT(static_cast<size_t>(index) < size); return m_array[index]; }
|
||||||
template<typename IndexType> T operator[](const IndexType& index) const { CVF_TIGHT_ASSERT(static_cast<size_t>(index) < size); return m_array[index]; }
|
template<typename IndexType> const T& operator[](const IndexType& index) const { CVF_TIGHT_ASSERT(static_cast<size_t>(index) < size); return m_array[index]; }
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef FixedArray<int, 3> IntArray3;
|
typedef FixedArray<int, 3> IntArray3;
|
||||||
|
|||||||
Reference in New Issue
Block a user