#5418 Consolidate near identical code

This commit is contained in:
Jacob Støren
2020-01-28 10:37:22 +01:00
parent f1ab745097
commit 0720ab3453
3 changed files with 24 additions and 163 deletions

View File

@@ -306,17 +306,11 @@ void RiuViewerCommands::displayContextMenu( QMouseEvent* event )
else if ( surfIntersectSourceInfo )
{
findCellAndGridIndex( mainOrComparisonView,
surfIntersectSourceInfo,
firstPartTriangleIndex,
surfIntersectSourceInfo->intersection()->activeSeparateResultDefinition(),
surfIntersectSourceInfo->triangleToCellIndex()[firstPartTriangleIndex],
&m_currentCellIndex,
&m_currentGridIdx );
// findCellAndGridIndex( mainOrComparisonView,
// surfIntersectSourceInfo->intersection()->activeSeparateResultDefinition(),
// surfIntersectSourceInfo->triangleToCellIndex()[firstPartTriangleIndex],
// &m_currentCellIndex,
// &m_currentGridIdx );
m_currentFaceIndex = cvf::StructGridInterface::NO_FACE;
RiuSelectionItem* selItem = new RiuGeneralSelectionItem( surfIntersectSourceInfo->intersection() );
@@ -331,10 +325,11 @@ void RiuViewerCommands::displayContextMenu( QMouseEvent* event )
else if ( crossSectionSourceInfo )
{
findCellAndGridIndex( mainOrComparisonView,
crossSectionSourceInfo,
firstPartTriangleIndex,
crossSectionSourceInfo->intersection()->activeSeparateResultDefinition(),
crossSectionSourceInfo->triangleToCellIndex()[firstPartTriangleIndex],
&m_currentCellIndex,
&m_currentGridIdx );
m_currentFaceIndex = cvf::StructGridInterface::NO_FACE;
RiuSelectionItem* selItem = new RiuGeneralSelectionItem( crossSectionSourceInfo->intersection() );
@@ -355,10 +350,11 @@ void RiuViewerCommands::displayContextMenu( QMouseEvent* event )
else if ( intersectionBoxSourceInfo )
{
findCellAndGridIndex( mainOrComparisonView,
intersectionBoxSourceInfo,
firstPartTriangleIndex,
intersectionBoxSourceInfo->intersectionBox()->activeSeparateResultDefinition(),
intersectionBoxSourceInfo->triangleToCellIndex()[firstPartTriangleIndex],
&m_currentCellIndex,
&m_currentGridIdx );
m_currentFaceIndex = cvf::StructGridInterface::NO_FACE;
RiuSelectionItem* selItem = new RiuGeneralSelectionItem( intersectionBoxSourceInfo->intersectionBox() );
@@ -1064,126 +1060,6 @@ void RiuViewerCommands::findCellAndGridIndex( Rim3dView* m
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuViewerCommands::findCellAndGridIndex( Rim3dView* mainOrComparisonView,
const RivReservoirSurfaceIntersectionSourceInfo* crossSectionSourceInfo,
cvf::uint firstPartTriangleIndex,
size_t* cellIndex,
size_t* gridIndex )
{
CVF_ASSERT( cellIndex && gridIndex );
RimEclipseCase* eclipseCase = nullptr;
if ( RimIntersectionResultDefinition* sepInterResDef =
crossSectionSourceInfo->intersection()->activeSeparateResultDefinition() )
{
if ( sepInterResDef->isEclipseResultDefinition() )
{
eclipseCase = dynamic_cast<RimEclipseCase*>( sepInterResDef->activeCase() );
}
}
else
{
eclipseCase = dynamic_cast<RimEclipseCase*>( mainOrComparisonView->ownerCase() );
}
size_t globalCellIndex = crossSectionSourceInfo->triangleToCellIndex()[firstPartTriangleIndex];
if ( eclipseCase )
{
const RigCell& cell = eclipseCase->mainGrid()->globalCellArray()[globalCellIndex];
*cellIndex = cell.gridLocalCellIndex();
*gridIndex = cell.hostGrid()->gridIndex();
}
else
{
*cellIndex = crossSectionSourceInfo->triangleToCellIndex()[firstPartTriangleIndex];
*gridIndex = 0;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuViewerCommands::findCellAndGridIndex( Rim3dView* mainOrComparisonView,
const RivExtrudedCurveIntersectionSourceInfo* crossSectionSourceInfo,
cvf::uint firstPartTriangleIndex,
size_t* cellIndex,
size_t* gridIndex )
{
CVF_ASSERT( cellIndex && gridIndex );
RimEclipseCase* eclipseCase = nullptr;
if ( RimIntersectionResultDefinition* sepInterResDef =
crossSectionSourceInfo->intersection()->activeSeparateResultDefinition() )
{
if ( sepInterResDef->isEclipseResultDefinition() )
{
eclipseCase = dynamic_cast<RimEclipseCase*>( sepInterResDef->activeCase() );
}
}
else
{
eclipseCase = dynamic_cast<RimEclipseCase*>( mainOrComparisonView->ownerCase() );
}
size_t globalCellIndex = crossSectionSourceInfo->triangleToCellIndex()[firstPartTriangleIndex];
if ( eclipseCase )
{
const RigCell& cell = eclipseCase->mainGrid()->globalCellArray()[globalCellIndex];
*cellIndex = cell.gridLocalCellIndex();
*gridIndex = cell.hostGrid()->gridIndex();
}
else
{
*cellIndex = crossSectionSourceInfo->triangleToCellIndex()[firstPartTriangleIndex];
*gridIndex = 0;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuViewerCommands::findCellAndGridIndex( Rim3dView* mainOrComparisonView,
const RivBoxIntersectionSourceInfo* intersectionBoxSourceInfo,
cvf::uint firstPartTriangleIndex,
size_t* cellIndex,
size_t* gridIndex )
{
CVF_ASSERT( cellIndex && gridIndex );
RimEclipseCase* eclipseCase = nullptr;
if ( RimIntersectionResultDefinition* sepInterResDef =
intersectionBoxSourceInfo->intersectionBox()->activeSeparateResultDefinition() )
{
if ( sepInterResDef->isEclipseResultDefinition() )
{
eclipseCase = dynamic_cast<RimEclipseCase*>( sepInterResDef->activeCase() );
}
}
else
{
eclipseCase = dynamic_cast<RimEclipseCase*>( mainOrComparisonView->ownerCase() );
}
size_t globalCellIndex = intersectionBoxSourceInfo->triangleToCellIndex()[firstPartTriangleIndex];
if ( eclipseCase )
{
const RigCell& cell = eclipseCase->mainGrid()->globalCellArray()[globalCellIndex];
*cellIndex = cell.gridLocalCellIndex();
*gridIndex = cell.hostGrid()->gridIndex();
}
else
{
*cellIndex = intersectionBoxSourceInfo->triangleToCellIndex()[firstPartTriangleIndex];
*gridIndex = 0;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------