mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#11088 Use non-optimized version for old projects to compute active cells BB
The performance to compute geometry BB for active cells has improved. The original code also set displayModelOffset based on the BB of active cells. To make sure that existing project files produce identically the the same, the non-optimized version is used in this case.
This commit is contained in:
@@ -453,10 +453,14 @@ void RigEclipseCaseData::computeActiveCellIJKBBox()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigEclipseCaseData::computeActiveCellBoundingBoxes()
|
||||
void RigEclipseCaseData::computeActiveCellBoundingBoxes( bool useOptimizedVersion )
|
||||
{
|
||||
computeActiveCellIJKBBox();
|
||||
computeActiveCellsGeometryBoundingBox();
|
||||
|
||||
if ( useOptimizedVersion )
|
||||
computeActiveCellsGeometryBoundingBoxOptimized();
|
||||
else
|
||||
computeActiveCellsGeometryBoundingBoxSlow();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -627,7 +631,7 @@ bool RigEclipseCaseData::hasFractureResults() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigEclipseCaseData::computeActiveCellsGeometryBoundingBox()
|
||||
void RigEclipseCaseData::computeActiveCellsGeometryBoundingBoxSlow()
|
||||
{
|
||||
if ( m_activeCellInfo.isNull() || m_fractureActiveCellInfo.isNull() )
|
||||
{
|
||||
@@ -646,6 +650,60 @@ void RigEclipseCaseData::computeActiveCellsGeometryBoundingBox()
|
||||
activeInfos[0] = m_fractureActiveCellInfo.p();
|
||||
activeInfos[1] = m_activeCellInfo.p(); // Last, to make this bb.min become display offset
|
||||
|
||||
cvf::BoundingBox bb;
|
||||
for ( int acIdx = 0; acIdx < 2; ++acIdx )
|
||||
{
|
||||
bb.reset();
|
||||
if ( m_mainGrid->nodes().empty() )
|
||||
{
|
||||
bb.add( cvf::Vec3d::ZERO );
|
||||
}
|
||||
else
|
||||
{
|
||||
std::array<cvf::Vec3d, 8> hexCorners;
|
||||
for ( size_t i = 0; i < m_mainGrid->cellCount(); i++ )
|
||||
{
|
||||
if ( activeInfos[acIdx]->isActive( i ) )
|
||||
{
|
||||
m_mainGrid->cellCornerVertices( i, hexCorners.data() );
|
||||
for ( const auto& corner : hexCorners )
|
||||
{
|
||||
bb.add( corner );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
activeInfos[acIdx]->setGeometryBoundingBox( bb );
|
||||
}
|
||||
|
||||
// This design choice is unfortunate, as the bounding box of active cells can be computed in different ways.
|
||||
// Must keep the code to make sure existing projects display 3D model at the same location in the scene.
|
||||
m_mainGrid->setDisplayModelOffset( bb.min() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigEclipseCaseData::computeActiveCellsGeometryBoundingBoxOptimized()
|
||||
{
|
||||
if ( m_activeCellInfo.isNull() || m_fractureActiveCellInfo.isNull() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ( m_mainGrid.isNull() )
|
||||
{
|
||||
cvf::BoundingBox bb;
|
||||
m_activeCellInfo->setGeometryBoundingBox( bb );
|
||||
m_fractureActiveCellInfo->setGeometryBoundingBox( bb );
|
||||
return;
|
||||
}
|
||||
|
||||
RigActiveCellInfo* activeInfos[2];
|
||||
activeInfos[0] = m_fractureActiveCellInfo.p();
|
||||
activeInfos[1] = m_activeCellInfo.p();
|
||||
|
||||
cvf::BoundingBox bb;
|
||||
for ( int acIdx = 0; acIdx < 2; ++acIdx )
|
||||
{
|
||||
@@ -682,7 +740,10 @@ void RigEclipseCaseData::computeActiveCellsGeometryBoundingBox()
|
||||
activeInfos[acIdx]->setGeometryBoundingBox( bb );
|
||||
}
|
||||
|
||||
m_mainGrid->setDisplayModelOffset( bb.min() );
|
||||
auto bbMainGrid = m_mainGrid->boundingBox();
|
||||
|
||||
// Use center of bounding box as display offset. This point will be stable and independent of the active cell bounding box.
|
||||
m_mainGrid->setDisplayModelOffset( bbMainGrid.center() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -103,7 +103,7 @@ public:
|
||||
const RigWellResultPoint& sourceWellCellResult,
|
||||
const RigWellResultPoint& otherWellCellResult ) const;
|
||||
|
||||
void computeActiveCellBoundingBoxes();
|
||||
void computeActiveCellBoundingBoxes( bool useOptimizedVersion );
|
||||
|
||||
RiaDefines::EclipseUnitSystem unitsType() const { return m_unitsType; }
|
||||
void setUnitsType( RiaDefines::EclipseUnitSystem unitsType ) { m_unitsType = unitsType; }
|
||||
@@ -126,7 +126,8 @@ public:
|
||||
private:
|
||||
void computeActiveCellIJKBBox();
|
||||
void computeWellCellsPrGrid();
|
||||
void computeActiveCellsGeometryBoundingBox();
|
||||
void computeActiveCellsGeometryBoundingBoxSlow();
|
||||
void computeActiveCellsGeometryBoundingBoxOptimized();
|
||||
|
||||
const RigFormationNames* activeFormationNames() const;
|
||||
|
||||
|
||||
@@ -159,7 +159,8 @@ void RigReservoirBuilder::createGridsAndCells( RigEclipseCaseData* eclipseCase )
|
||||
activeCellInfo->setGridActiveCellCounts( 0, eclipseCase->mainGrid()->globalCellArray().size() );
|
||||
activeCellInfo->computeDerivedData();
|
||||
|
||||
eclipseCase->computeActiveCellBoundingBoxes();
|
||||
bool useOptimizedVersion = true;
|
||||
eclipseCase->computeActiveCellBoundingBoxes( useOptimizedVersion );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user