mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Rename ApplicationCode to ApplicationLibCode
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
|
||||
set (SOURCE_GROUP_HEADER_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RivFemPartGeometryGenerator.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RivFemPartPartMgr.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RivGeoMechPartMgr.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RivGeoMechPartMgrCache.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RivGeoMechVizLogic.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RivFemPickSourceInfo.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RivFemElmVisibilityCalculator.h
|
||||
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RivFemPartGeometryGenerator.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RivFemPartPartMgr.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RivGeoMechPartMgr.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RivGeoMechPartMgrCache.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RivGeoMechVizLogic.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RivFemPickSourceInfo.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RivFemElmVisibilityCalculator.cpp
|
||||
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
${SOURCE_GROUP_HEADER_FILES}
|
||||
)
|
||||
|
||||
list(APPEND CODE_SOURCE_FILES
|
||||
${SOURCE_GROUP_SOURCE_FILES}
|
||||
)
|
||||
|
||||
source_group( "GeoMechViz" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake )
|
||||
@@ -0,0 +1,280 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RivFemElmVisibilityCalculator.h"
|
||||
|
||||
#include "RigCaseToCaseCellMapper.h"
|
||||
#include "RigFemPart.h"
|
||||
#include "RigFemPartGrid.h"
|
||||
#include "RigFemPartResultsCollection.h"
|
||||
#include "RigGeoMechCaseData.h"
|
||||
|
||||
#include "RimEclipsePropertyFilter.h"
|
||||
#include "RimGeoMechCase.h"
|
||||
#include "RimGeoMechPropertyFilter.h"
|
||||
#include "RimGeoMechPropertyFilterCollection.h"
|
||||
#include "RimGeoMechResultDefinition.h"
|
||||
#include "RimGeoMechView.h"
|
||||
#include "RimViewController.h"
|
||||
#include "RimViewLinker.h"
|
||||
|
||||
#include "cvfStructGrid.h"
|
||||
#include "cvfStructGridGeometryGenerator.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivFemElmVisibilityCalculator::computeAllVisible( cvf::UByteArray* elmVisibilities, const RigFemPart* femPart )
|
||||
{
|
||||
elmVisibilities->resize( femPart->elementCount() );
|
||||
elmVisibilities->setAll( true );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivFemElmVisibilityCalculator::computeRangeVisibility( cvf::UByteArray* elmVisibilities,
|
||||
const RigFemPart* femPart,
|
||||
const cvf::CellRangeFilter& rangeFilter )
|
||||
{
|
||||
elmVisibilities->resize( femPart->elementCount() );
|
||||
|
||||
const RigFemPartGrid* grid = femPart->getOrCreateStructGrid();
|
||||
|
||||
if ( rangeFilter.hasIncludeRanges() )
|
||||
{
|
||||
for ( int elmIdx = 0; elmIdx < femPart->elementCount(); ++elmIdx )
|
||||
{
|
||||
size_t mainGridI;
|
||||
size_t mainGridJ;
|
||||
size_t mainGridK;
|
||||
|
||||
grid->ijkFromCellIndex( elmIdx, &mainGridI, &mainGridJ, &mainGridK );
|
||||
( *elmVisibilities )[elmIdx] = rangeFilter.isCellVisible( mainGridI, mainGridJ, mainGridK, false );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( int elmIdx = 0; elmIdx < femPart->elementCount(); ++elmIdx )
|
||||
{
|
||||
size_t mainGridI;
|
||||
size_t mainGridJ;
|
||||
size_t mainGridK;
|
||||
|
||||
grid->ijkFromCellIndex( elmIdx, &mainGridI, &mainGridJ, &mainGridK );
|
||||
( *elmVisibilities )[elmIdx] = !rangeFilter.isCellExcluded( mainGridI, mainGridJ, mainGridK, false );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivFemElmVisibilityCalculator::computePropertyVisibility( cvf::UByteArray* cellVisibility,
|
||||
const RigFemPart* grid,
|
||||
int timeStepIndex,
|
||||
const cvf::UByteArray* rangeFilterVisibility,
|
||||
RimGeoMechPropertyFilterCollection* propFilterColl )
|
||||
{
|
||||
CVF_ASSERT( cellVisibility != nullptr );
|
||||
CVF_ASSERT( rangeFilterVisibility != nullptr );
|
||||
CVF_ASSERT( propFilterColl != nullptr );
|
||||
|
||||
CVF_ASSERT( grid->elementCount() > 0 );
|
||||
CVF_ASSERT( rangeFilterVisibility->size() == static_cast<size_t>( grid->elementCount() ) );
|
||||
|
||||
// Copy if not equal
|
||||
if ( cellVisibility != rangeFilterVisibility ) ( *cellVisibility ) = *rangeFilterVisibility;
|
||||
const int elementCount = grid->elementCount();
|
||||
|
||||
if ( !propFilterColl->hasActiveFilters() ) return;
|
||||
|
||||
for ( size_t i = 0; i < propFilterColl->propertyFilters().size(); i++ )
|
||||
{
|
||||
RimGeoMechPropertyFilter* propertyFilter = propFilterColl->propertyFilters()[i];
|
||||
|
||||
if ( !propertyFilter->isActiveAndHasResult() ) continue;
|
||||
|
||||
const RimCellFilter::FilterModeType filterType = propertyFilter->filterMode();
|
||||
|
||||
RigGeoMechCaseData* caseData = propFilterColl->reservoirView()->geoMechCase()->geoMechData();
|
||||
|
||||
RigFemResultAddress resVarAddress = propertyFilter->resultDefinition->resultAddress();
|
||||
|
||||
// Do a "Hack" to use elm nodal and not nodal POR results
|
||||
if ( resVarAddress.resultPosType == RIG_NODAL && resVarAddress.fieldName == "POR-Bar" )
|
||||
resVarAddress.resultPosType = RIG_ELEMENT_NODAL;
|
||||
|
||||
const std::vector<float>& resVals =
|
||||
caseData->femPartResults()->resultValues( resVarAddress, grid->elementPartId(), timeStepIndex );
|
||||
|
||||
if ( !propertyFilter->isActive() ) continue;
|
||||
if ( !propertyFilter->resultDefinition->hasResult() ) continue;
|
||||
|
||||
const double lowerBound = propertyFilter->lowerBound();
|
||||
const double upperBound = propertyFilter->upperBound();
|
||||
|
||||
if ( propertyFilter->resultDefinition->resultAddress().resultPosType == RIG_FORMATION_NAMES )
|
||||
{
|
||||
std::vector<int> integerVector = propertyFilter->selectedCategoryValues();
|
||||
std::set<int> integerSet;
|
||||
for ( auto val : integerVector )
|
||||
{
|
||||
integerSet.insert( val );
|
||||
}
|
||||
|
||||
for ( int cellIndex = 0; cellIndex < elementCount; cellIndex++ )
|
||||
{
|
||||
if ( !( *cellVisibility )[cellIndex] ) continue;
|
||||
|
||||
size_t resultValueIndex = grid->elementNodeResultIdx( cellIndex, 0 );
|
||||
double scalarValue = resVals[resultValueIndex];
|
||||
int intValue = nearbyint( scalarValue );
|
||||
if ( integerSet.find( intValue ) != integerSet.end() )
|
||||
{
|
||||
if ( filterType == RimCellFilter::EXCLUDE )
|
||||
{
|
||||
( *cellVisibility )[cellIndex] = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( filterType == RimCellFilter::INCLUDE )
|
||||
{
|
||||
( *cellVisibility )[cellIndex] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( resVarAddress.resultPosType == RIG_ELEMENT )
|
||||
{
|
||||
#pragma omp parallel for schedule( dynamic )
|
||||
for ( int cellIndex = 0; cellIndex < elementCount; cellIndex++ )
|
||||
{
|
||||
if ( !( *cellVisibility )[cellIndex] ) continue;
|
||||
|
||||
double scalarValue = resVals[cellIndex];
|
||||
evaluateAndSetCellVisibiliy( cellIndex, scalarValue, lowerBound, upperBound, filterType, cellVisibility );
|
||||
}
|
||||
}
|
||||
else if ( resVarAddress.resultPosType == RIG_ELEMENT_NODAL_FACE )
|
||||
{
|
||||
#pragma omp parallel for schedule( dynamic )
|
||||
for ( int cellIndex = 0; cellIndex < elementCount; cellIndex++ )
|
||||
{
|
||||
if ( !( *cellVisibility )[cellIndex] ) continue;
|
||||
|
||||
for ( int fpIdx = 0; fpIdx < 24; ++fpIdx )
|
||||
{
|
||||
double scalarValue = resVals[cellIndex * 24 + fpIdx];
|
||||
evaluateAndSetCellVisibiliy( cellIndex, scalarValue, lowerBound, upperBound, filterType, cellVisibility );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#pragma omp parallel for schedule( dynamic )
|
||||
for ( int cellIndex = 0; cellIndex < elementCount; cellIndex++ )
|
||||
{
|
||||
if ( !( *cellVisibility )[cellIndex] ) continue;
|
||||
|
||||
RigElementType eType = grid->elementType( cellIndex );
|
||||
int elmNodeCount = RigFemTypes::elementNodeCount( eType );
|
||||
|
||||
const int* elmNodeIndices = grid->connectivities( cellIndex );
|
||||
for ( int enIdx = 0; enIdx < elmNodeCount; ++enIdx )
|
||||
{
|
||||
size_t resultValueIndex = cvf::UNDEFINED_SIZE_T;
|
||||
if ( resVarAddress.resultPosType == RIG_NODAL )
|
||||
{
|
||||
resultValueIndex = elmNodeIndices[enIdx];
|
||||
}
|
||||
else
|
||||
{
|
||||
resultValueIndex = grid->elementNodeResultIdx( cellIndex, enIdx );
|
||||
}
|
||||
|
||||
double scalarValue = resVals[resultValueIndex];
|
||||
evaluateAndSetCellVisibiliy( cellIndex, scalarValue, lowerBound, upperBound, filterType, cellVisibility );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivFemElmVisibilityCalculator::evaluateAndSetCellVisibiliy( int cellIndex,
|
||||
double scalarValue,
|
||||
double lowerBound,
|
||||
double upperBound,
|
||||
const RimCellFilter::FilterModeType filterType,
|
||||
cvf::UByteArray* cellVisibility )
|
||||
{
|
||||
if ( lowerBound <= scalarValue && scalarValue <= upperBound )
|
||||
{
|
||||
if ( filterType == RimCellFilter::EXCLUDE )
|
||||
{
|
||||
( *cellVisibility )[cellIndex] = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( filterType == RimCellFilter::INCLUDE )
|
||||
{
|
||||
( *cellVisibility )[cellIndex] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivFemElmVisibilityCalculator::computeOverriddenCellVisibility( cvf::UByteArray* elmVisibilities,
|
||||
const RigFemPart* femPart,
|
||||
RimViewController* masterViewLink )
|
||||
{
|
||||
CVF_ASSERT( elmVisibilities != nullptr );
|
||||
CVF_ASSERT( femPart != nullptr );
|
||||
|
||||
RimGridView* masterView = masterViewLink->ownerViewLinker()->masterView();
|
||||
cvf::ref<cvf::UByteArray> totCellVisibility = masterView->currentTotalCellVisibility();
|
||||
|
||||
int elmCount = femPart->elementCount();
|
||||
elmVisibilities->resize( elmCount );
|
||||
elmVisibilities->setAll( false );
|
||||
|
||||
const RigCaseToCaseCellMapper* cellMapper = masterViewLink->cellMapper();
|
||||
|
||||
for ( int elmIdx = 0; elmIdx < elmCount; ++elmIdx )
|
||||
{
|
||||
// We are assuming that there is only one part.
|
||||
int cellCount = 0;
|
||||
const int* cellIndicesInMasterCase = cellMapper->masterCaseCellIndices( elmIdx, &cellCount );
|
||||
|
||||
for ( int mcIdx = 0; mcIdx < cellCount; ++mcIdx )
|
||||
{
|
||||
( *elmVisibilities )[elmIdx] |= ( *totCellVisibility )[cellIndicesInMasterCase[mcIdx]]; // If any is
|
||||
// visible, show
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cvfArray.h"
|
||||
|
||||
#include "RimCellFilter.h"
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
class CellRangeFilter;
|
||||
}
|
||||
|
||||
class RigFemPart;
|
||||
class RimGeoMechPropertyFilterCollection;
|
||||
class RimViewController;
|
||||
|
||||
class RivFemElmVisibilityCalculator
|
||||
{
|
||||
public:
|
||||
static void computeAllVisible( cvf::UByteArray* elmVisibilities, const RigFemPart* femPart );
|
||||
static void computeRangeVisibility( cvf::UByteArray* elmVisibilities,
|
||||
const RigFemPart* femPart,
|
||||
const cvf::CellRangeFilter& rangeFilter );
|
||||
|
||||
static void computePropertyVisibility( cvf::UByteArray* cellVisibility,
|
||||
const RigFemPart* grid,
|
||||
int timeStepIndex,
|
||||
const cvf::UByteArray* rangeFilterVisibility,
|
||||
RimGeoMechPropertyFilterCollection* propFilterColl );
|
||||
|
||||
static void evaluateAndSetCellVisibiliy( int cellIndex,
|
||||
double scalarValue,
|
||||
double lowerBound,
|
||||
double upperBound,
|
||||
const RimCellFilter::FilterModeType filterType,
|
||||
cvf::UByteArray* cellVisibility );
|
||||
|
||||
static void computeOverriddenCellVisibility( cvf::UByteArray* elmVisibilities,
|
||||
const RigFemPart* femPart,
|
||||
RimViewController* masterViewLink );
|
||||
};
|
||||
@@ -0,0 +1,345 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RivFemPartGeometryGenerator.h"
|
||||
|
||||
#include "RigFemPart.h"
|
||||
|
||||
#include "cvfArray.h"
|
||||
#include "cvfDebugTimer.h"
|
||||
#include "cvfDrawableGeo.h"
|
||||
#include "cvfOutlineEdgeExtractor.h"
|
||||
#include "cvfPrimitiveSetIndexedUInt.h"
|
||||
#include "cvfScalarMapper.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
|
||||
using namespace cvf;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivFemPartGeometryGenerator::RivFemPartGeometryGenerator( const RigFemPart* part )
|
||||
: m_part( part )
|
||||
{
|
||||
CVF_ASSERT( part );
|
||||
m_triangleMapper = new RivFemPartTriangleToElmMapper;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivFemPartGeometryGenerator::~RivFemPartGeometryGenerator()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Generate surface drawable geo from the specified region
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
ref<DrawableGeo> RivFemPartGeometryGenerator::generateSurface()
|
||||
{
|
||||
computeArrays();
|
||||
|
||||
CVF_ASSERT( m_quadVertices.notNull() );
|
||||
|
||||
if ( m_quadVertices->size() == 0 ) return nullptr;
|
||||
|
||||
ref<DrawableGeo> geo = new DrawableGeo;
|
||||
geo->setFromQuadVertexArray( m_quadVertices.p() );
|
||||
|
||||
return geo;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Generates simplified mesh as line drawing
|
||||
/// Must call generateSurface first
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
ref<DrawableGeo> RivFemPartGeometryGenerator::createMeshDrawable()
|
||||
{
|
||||
if ( !( m_quadVertices.notNull() && m_quadVertices->size() != 0 ) ) return nullptr;
|
||||
|
||||
ref<DrawableGeo> geo = new DrawableGeo;
|
||||
geo->setVertexArray( m_quadVertices.p() );
|
||||
|
||||
ref<UIntArray> indices = lineIndicesFromQuadVertexArray( m_quadVertices.p() );
|
||||
ref<PrimitiveSetIndexedUInt> prim = new PrimitiveSetIndexedUInt( PT_LINES );
|
||||
prim->setIndices( indices.p() );
|
||||
|
||||
geo->addPrimitiveSet( prim.p() );
|
||||
return geo;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
ref<DrawableGeo> RivFemPartGeometryGenerator::createOutlineMeshDrawable( double creaseAngle )
|
||||
{
|
||||
if ( !( m_quadVertices.notNull() && m_quadVertices->size() != 0 ) ) return nullptr;
|
||||
|
||||
cvf::OutlineEdgeExtractor ee( creaseAngle, *m_quadVertices );
|
||||
|
||||
ref<UIntArray> indices = lineIndicesFromQuadVertexArray( m_quadVertices.p() );
|
||||
ee.addPrimitives( 4, *indices );
|
||||
|
||||
ref<cvf::UIntArray> lineIndices = ee.lineIndices();
|
||||
if ( lineIndices->size() == 0 )
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ref<PrimitiveSetIndexedUInt> prim = new PrimitiveSetIndexedUInt( PT_LINES );
|
||||
prim->setIndices( lineIndices.p() );
|
||||
|
||||
ref<DrawableGeo> geo = new DrawableGeo;
|
||||
geo->setVertexArray( m_quadVertices.p() );
|
||||
geo->addPrimitiveSet( prim.p() );
|
||||
|
||||
return geo;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
ref<UIntArray> RivFemPartGeometryGenerator::lineIndicesFromQuadVertexArray( const Vec3fArray* vertexArray )
|
||||
{
|
||||
CVF_ASSERT( vertexArray );
|
||||
|
||||
size_t numVertices = vertexArray->size();
|
||||
int numQuads = static_cast<int>( numVertices / 4 );
|
||||
CVF_ASSERT( numVertices % 4 == 0 );
|
||||
|
||||
ref<UIntArray> indices = new UIntArray;
|
||||
indices->resize( numQuads * 8 );
|
||||
|
||||
#pragma omp parallel for
|
||||
for ( int i = 0; i < numQuads; i++ )
|
||||
{
|
||||
int idx = 8 * i;
|
||||
indices->set( idx + 0, i * 4 + 0 );
|
||||
indices->set( idx + 1, i * 4 + 1 );
|
||||
indices->set( idx + 2, i * 4 + 1 );
|
||||
indices->set( idx + 3, i * 4 + 2 );
|
||||
indices->set( idx + 4, i * 4 + 2 );
|
||||
indices->set( idx + 5, i * 4 + 3 );
|
||||
indices->set( idx + 6, i * 4 + 3 );
|
||||
indices->set( idx + 7, i * 4 + 0 );
|
||||
}
|
||||
|
||||
return indices;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivFemPartGeometryGenerator::computeArrays()
|
||||
{
|
||||
std::vector<Vec3f> vertices;
|
||||
std::vector<int>& trianglesToElements = m_triangleMapper->triangleToElmIndexMap();
|
||||
std::vector<char>& trianglesToElementFaces = m_triangleMapper->triangleToElmFaceMap();
|
||||
|
||||
m_quadVerticesToNodeIdx.clear();
|
||||
m_quadVerticesToGlobalElmNodeIdx.clear();
|
||||
m_quadVerticesToGlobalElmFaceNodeIdx.clear();
|
||||
m_quadVerticesToGlobalElmIdx.clear();
|
||||
trianglesToElements.clear();
|
||||
trianglesToElementFaces.clear();
|
||||
|
||||
size_t estimatedQuadVxCount = m_part->elementCount() * 6 * 4;
|
||||
|
||||
vertices.reserve( estimatedQuadVxCount );
|
||||
m_quadVerticesToNodeIdx.reserve( estimatedQuadVxCount );
|
||||
m_quadVerticesToGlobalElmNodeIdx.reserve( estimatedQuadVxCount );
|
||||
m_quadVerticesToGlobalElmIdx.reserve( estimatedQuadVxCount );
|
||||
trianglesToElements.reserve( estimatedQuadVxCount / 2 );
|
||||
trianglesToElementFaces.reserve( estimatedQuadVxCount / 2 );
|
||||
|
||||
cvf::Vec3d displayOffset = m_part->boundingBox().min();
|
||||
const std::vector<cvf::Vec3f>& nodeCoordinates = m_part->nodes().coordinates;
|
||||
|
||||
#pragma omp parallel for schedule( dynamic )
|
||||
for ( int elmIdx = 0; elmIdx < static_cast<int>( m_part->elementCount() ); elmIdx++ )
|
||||
{
|
||||
if ( m_elmVisibility.isNull() || ( *m_elmVisibility )[elmIdx] )
|
||||
{
|
||||
RigElementType eType = m_part->elementType( elmIdx );
|
||||
int faceCount = RigFemTypes::elementFaceCount( eType );
|
||||
|
||||
const int* elmNodeIndices = m_part->connectivities( elmIdx );
|
||||
|
||||
int elmNodFaceResIdxElmStart = elmIdx * 24; // HACK should get from part
|
||||
|
||||
for ( int lfIdx = 0; lfIdx < faceCount; ++lfIdx )
|
||||
{
|
||||
int elmNeighbor = m_part->elementNeighbor( elmIdx, lfIdx );
|
||||
|
||||
if ( elmNeighbor != -1 && ( m_elmVisibility.isNull() || ( *m_elmVisibility )[elmNeighbor] ) )
|
||||
{
|
||||
continue; // Invisible face
|
||||
}
|
||||
|
||||
int faceNodeCount = 0;
|
||||
const int* localElmNodeIndicesForFace =
|
||||
RigFemTypes::localElmNodeIndicesForFace( eType, lfIdx, &faceNodeCount );
|
||||
if ( faceNodeCount == 4 )
|
||||
{
|
||||
cvf::Vec3f quadVxs0( cvf::Vec3d( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[0]]] ) -
|
||||
displayOffset );
|
||||
cvf::Vec3f quadVxs1( cvf::Vec3d( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[1]]] ) -
|
||||
displayOffset );
|
||||
cvf::Vec3f quadVxs2( cvf::Vec3d( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[2]]] ) -
|
||||
displayOffset );
|
||||
cvf::Vec3f quadVxs3( cvf::Vec3d( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[3]]] ) -
|
||||
displayOffset );
|
||||
|
||||
int qNodeIdx[4];
|
||||
qNodeIdx[0] = elmNodeIndices[localElmNodeIndicesForFace[0]];
|
||||
qNodeIdx[1] = elmNodeIndices[localElmNodeIndicesForFace[1]];
|
||||
qNodeIdx[2] = elmNodeIndices[localElmNodeIndicesForFace[2]];
|
||||
qNodeIdx[3] = elmNodeIndices[localElmNodeIndicesForFace[3]];
|
||||
|
||||
size_t qElmNodeResIdx[4];
|
||||
qElmNodeResIdx[0] = m_part->elementNodeResultIdx( elmIdx, localElmNodeIndicesForFace[0] );
|
||||
qElmNodeResIdx[1] = m_part->elementNodeResultIdx( elmIdx, localElmNodeIndicesForFace[1] );
|
||||
qElmNodeResIdx[2] = m_part->elementNodeResultIdx( elmIdx, localElmNodeIndicesForFace[2] );
|
||||
qElmNodeResIdx[3] = m_part->elementNodeResultIdx( elmIdx, localElmNodeIndicesForFace[3] );
|
||||
|
||||
#pragma omp critical( critical_section_RivFemPartGeometryGenerator_computeArrays )
|
||||
{
|
||||
vertices.push_back( quadVxs0 );
|
||||
vertices.push_back( quadVxs1 );
|
||||
vertices.push_back( quadVxs2 );
|
||||
vertices.push_back( quadVxs3 );
|
||||
|
||||
m_quadVerticesToNodeIdx.push_back( qNodeIdx[0] );
|
||||
m_quadVerticesToNodeIdx.push_back( qNodeIdx[1] );
|
||||
m_quadVerticesToNodeIdx.push_back( qNodeIdx[2] );
|
||||
m_quadVerticesToNodeIdx.push_back( qNodeIdx[3] );
|
||||
|
||||
m_quadVerticesToGlobalElmNodeIdx.push_back( qElmNodeResIdx[0] );
|
||||
m_quadVerticesToGlobalElmNodeIdx.push_back( qElmNodeResIdx[1] );
|
||||
m_quadVerticesToGlobalElmNodeIdx.push_back( qElmNodeResIdx[2] );
|
||||
m_quadVerticesToGlobalElmNodeIdx.push_back( qElmNodeResIdx[3] );
|
||||
|
||||
int elmNodFaceResIdxFaceStart = elmNodFaceResIdxElmStart + lfIdx * 4; // HACK
|
||||
|
||||
m_quadVerticesToGlobalElmFaceNodeIdx.push_back( elmNodFaceResIdxFaceStart + 0 );
|
||||
m_quadVerticesToGlobalElmFaceNodeIdx.push_back( elmNodFaceResIdxFaceStart + 1 );
|
||||
m_quadVerticesToGlobalElmFaceNodeIdx.push_back( elmNodFaceResIdxFaceStart + 2 );
|
||||
m_quadVerticesToGlobalElmFaceNodeIdx.push_back( elmNodFaceResIdxFaceStart + 3 );
|
||||
|
||||
m_quadVerticesToGlobalElmIdx.push_back( elmIdx );
|
||||
m_quadVerticesToGlobalElmIdx.push_back( elmIdx );
|
||||
m_quadVerticesToGlobalElmIdx.push_back( elmIdx );
|
||||
m_quadVerticesToGlobalElmIdx.push_back( elmIdx );
|
||||
|
||||
trianglesToElements.push_back( elmIdx );
|
||||
trianglesToElements.push_back( elmIdx );
|
||||
trianglesToElementFaces.push_back( lfIdx );
|
||||
trianglesToElementFaces.push_back( lfIdx );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Handle triangles and 6 node and 8 node faces
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_quadVertices = new cvf::Vec3fArray;
|
||||
m_quadVertices->assign( vertices );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivFemPartGeometryGenerator::setElementVisibility( const cvf::UByteArray* cellVisibility )
|
||||
{
|
||||
m_elmVisibility = cellVisibility;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::DrawableGeo>
|
||||
RivFemPartGeometryGenerator::createMeshDrawableFromSingleElement( const RigFemPart* part,
|
||||
size_t elmIdx,
|
||||
const cvf::Vec3d& displayModelOffset )
|
||||
{
|
||||
cvf::ref<cvf::Vec3fArray> quadVertices;
|
||||
|
||||
{
|
||||
std::vector<Vec3f> vertices;
|
||||
|
||||
const std::vector<cvf::Vec3f>& nodeCoordinates = part->nodes().coordinates;
|
||||
|
||||
RigElementType eType = part->elementType( elmIdx );
|
||||
int faceCount = RigFemTypes::elementFaceCount( eType );
|
||||
|
||||
const int* elmNodeIndices = part->connectivities( elmIdx );
|
||||
|
||||
// cvf::Vec3d displayOffset = part->boundingBox().min();
|
||||
|
||||
for ( int lfIdx = 0; lfIdx < faceCount; ++lfIdx )
|
||||
{
|
||||
int faceNodeCount = 0;
|
||||
const int* localElmNodeIndicesForFace = RigFemTypes::localElmNodeIndicesForFace( eType, lfIdx, &faceNodeCount );
|
||||
if ( faceNodeCount == 4 )
|
||||
{
|
||||
vertices.push_back( cvf::Vec3f(
|
||||
cvf::Vec3d( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[0]]] ) - displayModelOffset ) );
|
||||
vertices.push_back( cvf::Vec3f(
|
||||
cvf::Vec3d( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[1]]] ) - displayModelOffset ) );
|
||||
vertices.push_back( cvf::Vec3f(
|
||||
cvf::Vec3d( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[2]]] ) - displayModelOffset ) );
|
||||
vertices.push_back( cvf::Vec3f(
|
||||
cvf::Vec3d( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[3]]] ) - displayModelOffset ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Handle triangles and 6 node and 8 node faces
|
||||
}
|
||||
}
|
||||
|
||||
quadVertices = new cvf::Vec3fArray;
|
||||
quadVertices->assign( vertices );
|
||||
}
|
||||
|
||||
if ( !( quadVertices.notNull() && quadVertices->size() != 0 ) ) return nullptr;
|
||||
|
||||
ref<DrawableGeo> geo = new DrawableGeo;
|
||||
geo->setVertexArray( quadVertices.p() );
|
||||
|
||||
ref<UIntArray> indices = lineIndicesFromQuadVertexArray( quadVertices.p() );
|
||||
ref<PrimitiveSetIndexedUInt> prim = new PrimitiveSetIndexedUInt( PT_LINES );
|
||||
prim->setIndices( indices.p() );
|
||||
|
||||
geo->addPrimitiveSet( prim.p() );
|
||||
return geo;
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cvfArray.h"
|
||||
#include "cvfObject.h"
|
||||
|
||||
#include "RigFemPart.h"
|
||||
#include "cvfStructGrid.h"
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
class DrawableGeo;
|
||||
class ScalarMapper;
|
||||
|
||||
} // namespace cvf
|
||||
|
||||
class RigFemPartScalarDataAccess;
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
class RivFemPartTriangleToElmMapper : public cvf::Object
|
||||
{
|
||||
public:
|
||||
size_t triangleCount() const { return m_trianglesToElementIndex.size(); }
|
||||
|
||||
int elementIndex( size_t triangleIdx ) const { return m_trianglesToElementIndex[triangleIdx]; }
|
||||
char elementFace( size_t triangleIdx ) const { return m_trianglesToElmFace[triangleIdx]; }
|
||||
|
||||
// Interface for building the mappings
|
||||
std::vector<int>& triangleToElmIndexMap() { return m_trianglesToElementIndex; }
|
||||
std::vector<char>& triangleToElmFaceMap() { return m_trianglesToElmFace; }
|
||||
|
||||
private:
|
||||
std::vector<int> m_trianglesToElementIndex;
|
||||
std::vector<char> m_trianglesToElmFace;
|
||||
};
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
class RivFemPartGeometryGenerator : public cvf::Object
|
||||
{
|
||||
public:
|
||||
explicit RivFemPartGeometryGenerator( const RigFemPart* part );
|
||||
~RivFemPartGeometryGenerator() override;
|
||||
|
||||
// Setup methods
|
||||
|
||||
void setElementVisibility( const cvf::UByteArray* cellVisibility );
|
||||
|
||||
// Access, valid after generation is done
|
||||
|
||||
const RigFemPart* activePart() { return m_part.p(); }
|
||||
|
||||
// Generated geometry
|
||||
|
||||
cvf::ref<cvf::DrawableGeo> generateSurface();
|
||||
cvf::ref<cvf::DrawableGeo> createMeshDrawable();
|
||||
cvf::ref<cvf::DrawableGeo> createOutlineMeshDrawable( double creaseAngle );
|
||||
|
||||
const std::vector<size_t>& quadVerticesToNodeIdxMapping() const { return m_quadVerticesToNodeIdx; }
|
||||
const std::vector<size_t>& quadVerticesToGlobalElmNodeIdx() const { return m_quadVerticesToGlobalElmNodeIdx; }
|
||||
const std::vector<size_t>& quadVerticesToGlobalElmFaceNodeIdx() const
|
||||
{
|
||||
return m_quadVerticesToGlobalElmFaceNodeIdx;
|
||||
}
|
||||
const std::vector<size_t>& quadVerticesToGlobalElmIdx() const { return m_quadVerticesToGlobalElmIdx; }
|
||||
|
||||
RivFemPartTriangleToElmMapper* triangleToElementMapper() { return m_triangleMapper.p(); }
|
||||
|
||||
static cvf::ref<cvf::DrawableGeo> createMeshDrawableFromSingleElement( const RigFemPart* grid,
|
||||
size_t elementIndex,
|
||||
const cvf::Vec3d& displayModelOffset );
|
||||
|
||||
private:
|
||||
static cvf::ref<cvf::UIntArray> lineIndicesFromQuadVertexArray( const cvf::Vec3fArray* vertexArray );
|
||||
void computeArrays();
|
||||
|
||||
private:
|
||||
// Input
|
||||
cvf::cref<RigFemPart> m_part; // The part being processed
|
||||
cvf::cref<cvf::UByteArray> m_elmVisibility;
|
||||
|
||||
// Created arrays
|
||||
cvf::ref<cvf::Vec3fArray> m_quadVertices;
|
||||
// cvf::ref<cvf::Vec3fArray> m_triangleVertices; // If needed, we will do it like this, I think
|
||||
std::vector<size_t> m_quadVerticesToNodeIdx;
|
||||
std::vector<size_t> m_quadVerticesToGlobalElmNodeIdx;
|
||||
std::vector<size_t> m_quadVerticesToGlobalElmFaceNodeIdx;
|
||||
std::vector<size_t> m_quadVerticesToGlobalElmIdx;
|
||||
|
||||
// Mappings
|
||||
cvf::ref<RivFemPartTriangleToElmMapper> m_triangleMapper;
|
||||
};
|
||||
@@ -0,0 +1,340 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "RivGeoMechPartMgr.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaPreferences.h"
|
||||
|
||||
#include "RifGeoMechReaderInterface.h"
|
||||
|
||||
#include "RigFemPartResultsCollection.h"
|
||||
#include "RigFemScalarResultFrames.h"
|
||||
#include "RigGeoMechCaseData.h"
|
||||
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimGeoMechCellColors.h"
|
||||
#include "RimGeoMechView.h"
|
||||
#include "RimRegularLegendConfig.h"
|
||||
|
||||
#include "RivFemPickSourceInfo.h"
|
||||
#include "RivMeshLinesSourceInfo.h"
|
||||
#include "RivPartPriority.h"
|
||||
#include "RivResultToTextureMapper.h"
|
||||
#include "RivScalarMapperUtils.h"
|
||||
#include "RivSourceInfo.h"
|
||||
#include "RivTextureCoordsCreator.h"
|
||||
|
||||
#include "cafEffectGenerator.h"
|
||||
|
||||
#include "cvfDrawableGeo.h"
|
||||
#include "cvfMath.h"
|
||||
#include "cvfModelBasicList.h"
|
||||
#include "cvfPart.h"
|
||||
#include "cvfRenderStateBlending.h"
|
||||
#include "cvfRenderStatePolygonOffset.h"
|
||||
#include "cvfRenderState_FF.h"
|
||||
#include "cvfShaderProgram.h"
|
||||
#include "cvfShaderProgramGenerator.h"
|
||||
#include "cvfShaderSourceProvider.h"
|
||||
#include "cvfShaderSourceRepository.h"
|
||||
#include "cvfStructGrid.h"
|
||||
#include "cvfTransform.h"
|
||||
#include "cvfUniform.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivFemPartPartMgr::RivFemPartPartMgr( const RigFemPart* grid )
|
||||
: m_surfaceGenerator( grid )
|
||||
, m_grid( grid )
|
||||
, m_opacityLevel( 1.0f )
|
||||
, m_defaultColor( cvf::Color3::WHITE )
|
||||
{
|
||||
CVF_ASSERT( grid );
|
||||
m_gridIdx = grid->elementPartId();
|
||||
m_cellVisibility = new cvf::UByteArray;
|
||||
m_surfaceFacesTextureCoords = new cvf::Vec2fArray;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivFemPartPartMgr::setTransform( cvf::Transform* scaleTransform )
|
||||
{
|
||||
m_scaleTransform = scaleTransform;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivFemPartPartMgr::setCellVisibility( cvf::UByteArray* cellVisibilities )
|
||||
{
|
||||
CVF_ASSERT( m_scaleTransform.notNull() );
|
||||
CVF_ASSERT( cellVisibilities );
|
||||
|
||||
m_cellVisibility = cellVisibilities;
|
||||
|
||||
m_surfaceGenerator.setElementVisibility( cellVisibilities );
|
||||
|
||||
generatePartGeometry( m_surfaceGenerator );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivFemPartPartMgr::generatePartGeometry( RivFemPartGeometryGenerator& geoBuilder )
|
||||
{
|
||||
bool useBufferObjects = true;
|
||||
// Surface geometry
|
||||
{
|
||||
m_surfaceFaces = nullptr; // To possibly free memory before adding the new stuff
|
||||
|
||||
cvf::ref<cvf::DrawableGeo> geo = geoBuilder.generateSurface();
|
||||
if ( geo.notNull() )
|
||||
{
|
||||
geo->computeNormals();
|
||||
|
||||
if ( useBufferObjects )
|
||||
{
|
||||
geo->setRenderMode( cvf::DrawableGeo::BUFFER_OBJECT );
|
||||
}
|
||||
|
||||
cvf::ref<cvf::Part> part = new cvf::Part;
|
||||
part->setName( "FemPart " + cvf::String( m_gridIdx ) );
|
||||
part->setId( m_gridIdx ); // Use grid index as part ID
|
||||
part->setDrawable( geo.p() );
|
||||
part->setTransform( m_scaleTransform.p() );
|
||||
|
||||
// Set mapping from triangle face index to element index
|
||||
cvf::ref<RivFemPickSourceInfo> si = new RivFemPickSourceInfo( m_gridIdx, geoBuilder.triangleToElementMapper() );
|
||||
part->setSourceInfo( si.p() );
|
||||
|
||||
part->updateBoundingBox();
|
||||
|
||||
// Set default effect
|
||||
caf::SurfaceEffectGenerator geometryEffgen( cvf::Color4f( cvf::Color3f::WHITE ), caf::PO_1 );
|
||||
cvf::ref<cvf::Effect> geometryOnlyEffect = geometryEffgen.generateCachedEffect();
|
||||
part->setEffect( geometryOnlyEffect.p() );
|
||||
part->setEnableMask( surfaceBit );
|
||||
m_surfaceFaces = part;
|
||||
}
|
||||
}
|
||||
|
||||
// Mesh geometry
|
||||
{
|
||||
m_surfaceGridLines = nullptr; // To possibly free memory before adding the new stuff
|
||||
|
||||
cvf::ref<cvf::DrawableGeo> geoMesh = geoBuilder.createMeshDrawable();
|
||||
if ( geoMesh.notNull() )
|
||||
{
|
||||
if ( useBufferObjects )
|
||||
{
|
||||
geoMesh->setRenderMode( cvf::DrawableGeo::BUFFER_OBJECT );
|
||||
}
|
||||
|
||||
cvf::ref<cvf::Part> part = new cvf::Part;
|
||||
part->setName( "Grid mesh " + cvf::String( m_gridIdx ) );
|
||||
part->setDrawable( geoMesh.p() );
|
||||
|
||||
part->setTransform( m_scaleTransform.p() );
|
||||
part->updateBoundingBox();
|
||||
|
||||
RiaPreferences* prefs = RiaApplication::instance()->preferences();
|
||||
|
||||
cvf::ref<cvf::Effect> eff;
|
||||
caf::MeshEffectGenerator effGen( prefs->defaultGridLineColors() );
|
||||
eff = effGen.generateCachedEffect();
|
||||
|
||||
part->setPriority( RivPartPriority::PartType::MeshLines );
|
||||
|
||||
part->setEnableMask( meshSurfaceBit );
|
||||
part->setEffect( eff.p() );
|
||||
|
||||
part->setSourceInfo( new RivMeshLinesSourceInfo( nullptr ) );
|
||||
|
||||
m_surfaceGridLines = part;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivFemPartPartMgr::appendPartsToModel( cvf::ModelBasicList* model )
|
||||
{
|
||||
CVF_ASSERT( model != nullptr );
|
||||
|
||||
if ( m_surfaceFaces.notNull() ) model->addPart( m_surfaceFaces.p() );
|
||||
if ( m_surfaceGridLines.notNull() ) model->addPart( m_surfaceGridLines.p() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const RivFemPartGeometryGenerator* RivFemPartPartMgr::surfaceGenerator() const
|
||||
{
|
||||
return &m_surfaceGenerator;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivFemPartPartMgr::updateCellColor( cvf::Color4f color )
|
||||
{
|
||||
if ( m_surfaceFaces.isNull() ) return;
|
||||
|
||||
// Set default effect
|
||||
caf::SurfaceEffectGenerator geometryEffgen( color, caf::PO_1 );
|
||||
cvf::ref<cvf::Effect> geometryOnlyEffect = geometryEffgen.generateCachedEffect();
|
||||
|
||||
if ( m_surfaceFaces.notNull() ) m_surfaceFaces->setEffect( geometryOnlyEffect.p() );
|
||||
|
||||
if ( color.a() < 1.0f )
|
||||
{
|
||||
// Set priority to make sure this transparent geometry are rendered last
|
||||
if ( m_surfaceFaces.notNull() ) m_surfaceFaces->setPriority( RivPartPriority::PartType::Transparent );
|
||||
}
|
||||
|
||||
m_opacityLevel = color.a();
|
||||
m_defaultColor = color.toColor3f();
|
||||
|
||||
// Update mesh colors as well, in case of change
|
||||
RiaPreferences* prefs = RiaApplication::instance()->preferences();
|
||||
|
||||
cvf::ref<cvf::Effect> eff;
|
||||
if ( m_surfaceFaces.notNull() )
|
||||
{
|
||||
caf::MeshEffectGenerator effGen( prefs->defaultGridLineColors() );
|
||||
eff = effGen.generateCachedEffect();
|
||||
m_surfaceGridLines->setEffect( eff.p() );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivFemPartPartMgr::updateCellResultColor( size_t timeStepIndex, RimGeoMechCellColors* cellResultColors )
|
||||
{
|
||||
CVF_ASSERT( cellResultColors );
|
||||
|
||||
cvf::ref<cvf::Color3ubArray> surfaceFacesColorArray;
|
||||
|
||||
// Outer surface
|
||||
if ( m_surfaceFaces.notNull() )
|
||||
{
|
||||
const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper();
|
||||
|
||||
RigGeoMechCaseData* caseData = cellResultColors->ownerCaseData();
|
||||
|
||||
if ( !caseData ) return;
|
||||
|
||||
RigFemResultAddress resVarAddress = cellResultColors->resultAddress();
|
||||
|
||||
// Do a "Hack" to show elm nodal and not nodal POR results
|
||||
if ( resVarAddress.resultPosType == RIG_NODAL && resVarAddress.fieldName == "POR-Bar" )
|
||||
{
|
||||
resVarAddress.resultPosType = RIG_ELEMENT_NODAL;
|
||||
}
|
||||
|
||||
const std::vector<float>& resultValues =
|
||||
caseData->femPartResults()->resultValues( resVarAddress, m_gridIdx, (int)timeStepIndex );
|
||||
|
||||
const std::vector<size_t>* vxToResultMapping = nullptr;
|
||||
int vxCount = 0;
|
||||
|
||||
if ( resVarAddress.resultPosType == RIG_NODAL )
|
||||
{
|
||||
vxToResultMapping = &( m_surfaceGenerator.quadVerticesToNodeIdxMapping() );
|
||||
}
|
||||
else if ( resVarAddress.resultPosType == RIG_ELEMENT_NODAL || resVarAddress.resultPosType == RIG_INTEGRATION_POINT ||
|
||||
resVarAddress.resultPosType == RIG_FORMATION_NAMES )
|
||||
{
|
||||
vxToResultMapping = &( m_surfaceGenerator.quadVerticesToGlobalElmNodeIdx() );
|
||||
}
|
||||
else if ( resVarAddress.resultPosType == RIG_ELEMENT_NODAL_FACE )
|
||||
{
|
||||
vxToResultMapping = &( m_surfaceGenerator.quadVerticesToGlobalElmFaceNodeIdx() );
|
||||
}
|
||||
else if ( resVarAddress.resultPosType == RIG_ELEMENT )
|
||||
{
|
||||
vxToResultMapping = &( m_surfaceGenerator.quadVerticesToGlobalElmIdx() );
|
||||
}
|
||||
|
||||
if ( !vxToResultMapping ) return;
|
||||
|
||||
vxCount = static_cast<int>( vxToResultMapping->size() );
|
||||
m_surfaceFacesTextureCoords->resize( vxCount );
|
||||
|
||||
if ( resultValues.size() == 0 )
|
||||
{
|
||||
m_surfaceFacesTextureCoords->setAll( cvf::Vec2f( 0.0, 1.0f ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
cvf::Vec2f* rawPtr = m_surfaceFacesTextureCoords->ptr();
|
||||
|
||||
#pragma omp parallel for schedule( dynamic )
|
||||
for ( int quadStartIdx = 0; quadStartIdx < vxCount; quadStartIdx += 4 )
|
||||
{
|
||||
float resultValue1 = resultValues[( *vxToResultMapping )[quadStartIdx + 0]];
|
||||
float resultValue2 = resultValues[( *vxToResultMapping )[quadStartIdx + 1]];
|
||||
float resultValue3 = resultValues[( *vxToResultMapping )[quadStartIdx + 2]];
|
||||
float resultValue4 = resultValues[( *vxToResultMapping )[quadStartIdx + 3]];
|
||||
|
||||
if ( resultValue1 == HUGE_VAL || resultValue1 != resultValue1 // a != a is true for NAN's
|
||||
|| resultValue2 == HUGE_VAL || resultValue2 != resultValue2 || resultValue3 == HUGE_VAL ||
|
||||
resultValue3 != resultValue3 || resultValue4 == HUGE_VAL || resultValue4 != resultValue4 )
|
||||
{
|
||||
rawPtr[quadStartIdx][1] = 1.0f;
|
||||
rawPtr[quadStartIdx + 1][1] = 1.0f;
|
||||
rawPtr[quadStartIdx + 2][1] = 1.0f;
|
||||
rawPtr[quadStartIdx + 3][1] = 1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
rawPtr[quadStartIdx] = mapper->mapToTextureCoord( resultValue1 );
|
||||
rawPtr[quadStartIdx + 1] = mapper->mapToTextureCoord( resultValue2 );
|
||||
rawPtr[quadStartIdx + 2] = mapper->mapToTextureCoord( resultValue3 );
|
||||
rawPtr[quadStartIdx + 3] = mapper->mapToTextureCoord( resultValue4 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rim3dView* view = nullptr;
|
||||
cellResultColors->firstAncestorOrThisOfType( view );
|
||||
CVF_ASSERT( view );
|
||||
|
||||
RivScalarMapperUtils::applyTextureResultsToPart( m_surfaceFaces.p(),
|
||||
m_surfaceFacesTextureCoords.p(),
|
||||
mapper,
|
||||
m_opacityLevel,
|
||||
caf::FC_NONE,
|
||||
view->isLightingDisabled() );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivFemPartPartMgr::~RivFemPartPartMgr()
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cvfObject.h"
|
||||
|
||||
#include "RivFemPartGeometryGenerator.h"
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
class StructGridInterface;
|
||||
class ModelBasicList;
|
||||
class Transform;
|
||||
class Part;
|
||||
class Effect;
|
||||
} // namespace cvf
|
||||
|
||||
class RimGeoMechCellColors;
|
||||
class RigFemPart;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
/// RivGridGeometry: Class to handle visualization structures that embodies a specific grid at a specific time step.
|
||||
/// frame on a certain level
|
||||
/// LGR's have their own instance and the parent grid as well
|
||||
///
|
||||
//==================================================================================================
|
||||
|
||||
class RivFemPartPartMgr : public cvf::Object
|
||||
{
|
||||
public:
|
||||
explicit RivFemPartPartMgr( const RigFemPart* femPart );
|
||||
~RivFemPartPartMgr() override;
|
||||
void setTransform( cvf::Transform* scaleTransform );
|
||||
void setCellVisibility( cvf::UByteArray* cellVisibilities );
|
||||
cvf::ref<cvf::UByteArray> cellVisibility() { return m_cellVisibility; }
|
||||
|
||||
void updateCellColor( cvf::Color4f color );
|
||||
void updateCellResultColor( size_t timeStepIndex, RimGeoMechCellColors* cellResultColors );
|
||||
|
||||
void appendPartsToModel( cvf::ModelBasicList* model );
|
||||
|
||||
const RivFemPartGeometryGenerator* surfaceGenerator() const;
|
||||
|
||||
private:
|
||||
void generatePartGeometry( RivFemPartGeometryGenerator& geoBuilder );
|
||||
|
||||
private:
|
||||
int m_gridIdx;
|
||||
cvf::cref<RigFemPart> m_grid;
|
||||
|
||||
cvf::ref<cvf::Transform> m_scaleTransform;
|
||||
float m_opacityLevel;
|
||||
cvf::Color3f m_defaultColor;
|
||||
|
||||
// Surface visualization
|
||||
RivFemPartGeometryGenerator m_surfaceGenerator;
|
||||
|
||||
cvf::ref<cvf::Part> m_surfaceFaces;
|
||||
cvf::ref<cvf::Vec2fArray> m_surfaceFacesTextureCoords;
|
||||
|
||||
cvf::ref<cvf::Part> m_surfaceGridLines;
|
||||
|
||||
cvf::ref<cvf::UByteArray> m_cellVisibility;
|
||||
};
|
||||
@@ -0,0 +1,38 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RivFemPickSourceInfo.h"
|
||||
|
||||
#include "RivFemPartGeometryGenerator.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivFemPickSourceInfo::RivFemPickSourceInfo( int partIndex, RivFemPartTriangleToElmMapper* triangleToElmMapper )
|
||||
: m_fempartIndex( partIndex )
|
||||
, m_triangleToElmMapper( triangleToElmMapper )
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivFemPickSourceInfo::~RivFemPickSourceInfo()
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cvfObject.h"
|
||||
|
||||
class RivFemPartTriangleToElmMapper;
|
||||
|
||||
class RivFemPickSourceInfo : public cvf::Object
|
||||
{
|
||||
public:
|
||||
RivFemPickSourceInfo( int partIndex, RivFemPartTriangleToElmMapper* triangleToElmMapper );
|
||||
~RivFemPickSourceInfo() override;
|
||||
|
||||
int femPartIndex() const { return m_fempartIndex; }
|
||||
const RivFemPartTriangleToElmMapper* triangleToElmMapper() const { return m_triangleToElmMapper.p(); }
|
||||
|
||||
private:
|
||||
int m_fempartIndex;
|
||||
cvf::cref<RivFemPartTriangleToElmMapper> m_triangleToElmMapper;
|
||||
};
|
||||
@@ -0,0 +1,142 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RivGeoMechPartMgr.h"
|
||||
#include "cvfModelBasicList.h"
|
||||
#include "cvfPart.h"
|
||||
#include <cstdlib>
|
||||
|
||||
#include "RigFemPartCollection.h"
|
||||
#include "RigGeoMechCaseData.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivGeoMechPartMgr::RivGeoMechPartMgr()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivGeoMechPartMgr::~RivGeoMechPartMgr()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivGeoMechPartMgr::clearAndSetReservoir( const RigGeoMechCaseData* geoMechCase )
|
||||
{
|
||||
m_femPartPartMgrs.clear();
|
||||
|
||||
if ( geoMechCase )
|
||||
{
|
||||
const RigFemPartCollection* femParts = geoMechCase->femParts();
|
||||
|
||||
for ( int i = 0; i < femParts->partCount(); ++i )
|
||||
{
|
||||
m_femPartPartMgrs.push_back( new RivFemPartPartMgr( femParts->part( i ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivGeoMechPartMgr::setTransform( cvf::Transform* scaleTransform )
|
||||
{
|
||||
for ( size_t i = 0; i < m_femPartPartMgrs.size(); ++i )
|
||||
{
|
||||
m_femPartPartMgrs[i]->setTransform( scaleTransform );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivGeoMechPartMgr::setCellVisibility( size_t gridIndex, cvf::UByteArray* cellVisibilities )
|
||||
{
|
||||
CVF_ASSERT( gridIndex < m_femPartPartMgrs.size() );
|
||||
m_femPartPartMgrs[gridIndex]->setCellVisibility( cellVisibilities );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::UByteArray> RivGeoMechPartMgr::cellVisibility( size_t gridIdx )
|
||||
{
|
||||
CVF_ASSERT( gridIdx < m_femPartPartMgrs.size() );
|
||||
return m_femPartPartMgrs[gridIdx]->cellVisibility();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivGeoMechPartMgr::updateCellColor( cvf::Color4f color )
|
||||
{
|
||||
for ( size_t i = 0; i < m_femPartPartMgrs.size(); ++i )
|
||||
{
|
||||
m_femPartPartMgrs[i]->updateCellColor( color );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivGeoMechPartMgr::updateCellResultColor( size_t timeStepIndex, RimGeoMechCellColors* cellResultColors )
|
||||
{
|
||||
for ( size_t i = 0; i < m_femPartPartMgrs.size(); ++i )
|
||||
{
|
||||
m_femPartPartMgrs[i]->updateCellResultColor( timeStepIndex, cellResultColors );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivGeoMechPartMgr::appendGridPartsToModel( cvf::ModelBasicList* model )
|
||||
{
|
||||
for ( size_t i = 0; i < m_femPartPartMgrs.size(); ++i )
|
||||
{
|
||||
m_femPartPartMgrs[i]->appendPartsToModel( model );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivGeoMechPartMgr::appendGridPartsToModel( cvf::ModelBasicList* model, const std::vector<size_t>& gridIndices )
|
||||
{
|
||||
for ( size_t i = 0; i < gridIndices.size(); ++i )
|
||||
{
|
||||
if ( gridIndices[i] < m_femPartPartMgrs.size() )
|
||||
{
|
||||
m_femPartPartMgrs[gridIndices[i]]->appendPartsToModel( model );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const cvf::Collection<RivFemPartPartMgr> RivGeoMechPartMgr::femPartMgrs() const
|
||||
{
|
||||
return m_femPartPartMgrs;
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cvfArray.h"
|
||||
#include "cvfCollection.h"
|
||||
|
||||
#include "RivFemPartPartMgr.h"
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
class ModelBasicList;
|
||||
class Transform;
|
||||
} // namespace cvf
|
||||
|
||||
class RimGeoMechCellColors;
|
||||
class RigGeoMechCaseData;
|
||||
class RimGeoMechView;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
/// Class to handle visualization structures that embodies a complete Geo-mech reservoir at a specific
|
||||
/// time step.
|
||||
///
|
||||
//==================================================================================================
|
||||
|
||||
class RivGeoMechPartMgr : public cvf::Object
|
||||
{
|
||||
public:
|
||||
RivGeoMechPartMgr();
|
||||
~RivGeoMechPartMgr() override;
|
||||
|
||||
int initializedFemPartCount() { return static_cast<int>( m_femPartPartMgrs.size() ); }
|
||||
void clearAndSetReservoir( const RigGeoMechCaseData* geoMechCase );
|
||||
void setTransform( cvf::Transform* scaleTransform );
|
||||
void setCellVisibility( size_t partIndex, cvf::UByteArray* cellVisibilities );
|
||||
|
||||
cvf::ref<cvf::UByteArray> cellVisibility( size_t partIndex );
|
||||
|
||||
void updateCellColor( cvf::Color4f color );
|
||||
void updateCellResultColor( size_t timeStepIndex, RimGeoMechCellColors* cellResultColors );
|
||||
|
||||
void appendGridPartsToModel( cvf::ModelBasicList* model, const std::vector<size_t>& partIndices );
|
||||
void appendGridPartsToModel( cvf::ModelBasicList* model );
|
||||
|
||||
const cvf::Collection<RivFemPartPartMgr> femPartMgrs() const;
|
||||
|
||||
private:
|
||||
cvf::Collection<RivFemPartPartMgr> m_femPartPartMgrs;
|
||||
};
|
||||
@@ -0,0 +1,115 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RivGeoMechPartMgrCache.h"
|
||||
#include "RivGeoMechPartMgr.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivGeoMechPartMgrCache::RivGeoMechPartMgrCache()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivGeoMechPartMgrCache::~RivGeoMechPartMgrCache()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RivGeoMechPartMgrCache::isNeedingRegeneration( const Key& key ) const
|
||||
{
|
||||
std::map<Key, CacheEntry>::const_iterator ceIt = m_partMgrs.find( key );
|
||||
if ( ceIt != m_partMgrs.end() )
|
||||
{
|
||||
return ceIt->second.needsRegen;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivGeoMechPartMgrCache::scheduleRegeneration( const Key& key )
|
||||
{
|
||||
std::map<Key, CacheEntry>::iterator ceIt = m_partMgrs.find( key );
|
||||
if ( ceIt != m_partMgrs.end() )
|
||||
{
|
||||
ceIt->second.needsRegen = true;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivGeoMechPartMgrCache::setGenerationFinished( const Key& key )
|
||||
{
|
||||
m_partMgrs[key].needsRegen = false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivGeoMechPartMgr* RivGeoMechPartMgrCache::partMgr( const Key& key )
|
||||
{
|
||||
CacheEntry& ce = m_partMgrs[key];
|
||||
if ( ce.partMgr.isNull() )
|
||||
{
|
||||
ce.partMgr = new RivGeoMechPartMgr;
|
||||
}
|
||||
|
||||
return ce.partMgr.p();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivGeoMechPartMgrCache::Key::set( RivCellSetEnum aGeometryType, int aFrameIndex )
|
||||
{
|
||||
m_frameIndex = aFrameIndex;
|
||||
m_geometryType = aGeometryType;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RivGeoMechPartMgrCache::Key::operator<( const Key& other ) const
|
||||
{
|
||||
if ( m_frameIndex != other.m_frameIndex )
|
||||
{
|
||||
return ( m_frameIndex < other.m_frameIndex );
|
||||
}
|
||||
return ( m_geometryType < other.m_geometryType );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivGeoMechPartMgrCache::Key::Key( RivCellSetEnum aGeometryType, int aFrameIndex )
|
||||
: m_geometryType( aGeometryType )
|
||||
, m_frameIndex( aFrameIndex )
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RivCellSetEnum.h"
|
||||
#include "RivGeoMechPartMgr.h"
|
||||
|
||||
#include "cvfObject.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <map>
|
||||
|
||||
class RivGeoMechPartMgrGeneratorInterface;
|
||||
|
||||
class RivGeoMechPartMgrCache : public cvf::Object
|
||||
{
|
||||
public:
|
||||
RivGeoMechPartMgrCache();
|
||||
~RivGeoMechPartMgrCache() override;
|
||||
|
||||
class Key
|
||||
{
|
||||
public:
|
||||
Key()
|
||||
: m_geometryType( -1 )
|
||||
, m_frameIndex( -1 )
|
||||
{
|
||||
}
|
||||
|
||||
Key( RivCellSetEnum aGeometryType, int aFrameIndex );
|
||||
|
||||
void set( RivCellSetEnum aGeometryType, int aFrameIndex );
|
||||
|
||||
int frameIndex() const { return m_frameIndex; }
|
||||
unsigned short geometryType() const { return m_geometryType; }
|
||||
|
||||
bool operator<( const Key& other ) const;
|
||||
|
||||
private:
|
||||
int m_frameIndex;
|
||||
unsigned short m_geometryType;
|
||||
};
|
||||
|
||||
bool isNeedingRegeneration( const Key& key ) const;
|
||||
void scheduleRegeneration( const Key& key );
|
||||
void setGenerationFinished( const Key& key );
|
||||
RivGeoMechPartMgr* partMgr( const Key& key );
|
||||
|
||||
private:
|
||||
class CacheEntry
|
||||
{
|
||||
public:
|
||||
CacheEntry()
|
||||
: needsRegen( true )
|
||||
{
|
||||
}
|
||||
|
||||
bool needsRegen;
|
||||
cvf::ref<RivGeoMechPartMgr> partMgr;
|
||||
};
|
||||
|
||||
std::map<Key, CacheEntry> m_partMgrs;
|
||||
};
|
||||
@@ -0,0 +1,292 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RivGeoMechVizLogic.h"
|
||||
|
||||
#include "RigFemPartCollection.h"
|
||||
#include "RigFemPartResultsCollection.h"
|
||||
#include "RigGeoMechCaseData.h"
|
||||
|
||||
#include "Rim3dView.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimGeoMechCase.h"
|
||||
#include "RimGeoMechCellColors.h"
|
||||
#include "RimGeoMechPropertyFilterCollection.h"
|
||||
#include "RimGeoMechView.h"
|
||||
#include "RimViewController.h"
|
||||
|
||||
#include "RivCellSetEnum.h"
|
||||
#include "RivFemElmVisibilityCalculator.h"
|
||||
#include "RivGeoMechPartMgr.h"
|
||||
#include "RivGeoMechPartMgrCache.h"
|
||||
#include "RivReservoirViewPartMgr.h"
|
||||
|
||||
#include "cvfModelBasicList.h"
|
||||
#include "cvfStructGridGeometryGenerator.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivGeoMechVizLogic::RivGeoMechVizLogic( RimGeoMechView* geomView )
|
||||
{
|
||||
CVF_ASSERT( geomView );
|
||||
m_geomechView = geomView;
|
||||
m_partMgrCache = new RivGeoMechPartMgrCache;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivGeoMechVizLogic::~RivGeoMechVizLogic()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivGeoMechVizLogic::appendNoAnimPartsToModel( cvf::ModelBasicList* model )
|
||||
{
|
||||
this->appendPartsToModel( -1, model );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivGeoMechVizLogic::appendPartsToModel( int timeStepIndex, cvf::ModelBasicList* model )
|
||||
{
|
||||
std::vector<RivGeoMechPartMgrCache::Key> visiblePartMgrs = keysToVisiblePartMgrs( timeStepIndex );
|
||||
for ( size_t pmIdx = 0; pmIdx < visiblePartMgrs.size(); ++pmIdx )
|
||||
{
|
||||
RivGeoMechPartMgr* partMgr = getUpdatedPartMgr( visiblePartMgrs[pmIdx] );
|
||||
|
||||
partMgr->appendGridPartsToModel( model );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivGeoMechVizLogic::updateCellResultColor( int timeStepIndex, RimGeoMechCellColors* cellResultColors )
|
||||
{
|
||||
std::vector<RivGeoMechPartMgrCache::Key> visiblePartMgrs = keysToVisiblePartMgrs( timeStepIndex );
|
||||
for ( size_t pmIdx = 0; pmIdx < visiblePartMgrs.size(); ++pmIdx )
|
||||
{
|
||||
RivGeoMechPartMgr* partMgr = m_partMgrCache->partMgr( visiblePartMgrs[pmIdx] );
|
||||
partMgr->updateCellResultColor( timeStepIndex, cellResultColors );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivGeoMechVizLogic::updateStaticCellColors( int timeStepIndex )
|
||||
{
|
||||
std::vector<RivGeoMechPartMgrCache::Key> visiblePartMgrs = keysToVisiblePartMgrs( timeStepIndex );
|
||||
for ( size_t pmIdx = 0; pmIdx < visiblePartMgrs.size(); ++pmIdx )
|
||||
{
|
||||
RivGeoMechPartMgr* partMgr = m_partMgrCache->partMgr( visiblePartMgrs[pmIdx] );
|
||||
auto color = staticCellColor();
|
||||
partMgr->updateCellColor( cvf::Color4f( color ) );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivGeoMechVizLogic::scheduleGeometryRegen( RivCellSetEnum geometryType )
|
||||
{
|
||||
this->scheduleRegenOfDirectlyDependentGeometry( geometryType );
|
||||
|
||||
int frameCount = 0;
|
||||
if ( m_geomechView->geoMechCase() && m_geomechView->geoMechCase()->geoMechData() )
|
||||
{
|
||||
frameCount = m_geomechView->geoMechCase()->geoMechData()->femPartResults()->frameCount();
|
||||
}
|
||||
|
||||
for ( int fIdx = -1; fIdx < frameCount; ++fIdx )
|
||||
{
|
||||
RivGeoMechPartMgrCache::Key geomToRegen( geometryType, fIdx );
|
||||
m_partMgrCache->scheduleRegeneration( geomToRegen );
|
||||
}
|
||||
}
|
||||
|
||||
void RivGeoMechVizLogic::scheduleRegenOfDirectlyDependentGeometry( RivCellSetEnum geometryType )
|
||||
{
|
||||
if ( geometryType == RANGE_FILTERED )
|
||||
{
|
||||
this->scheduleGeometryRegen( PROPERTY_FILTERED );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RivGeoMechPartMgrCache::Key> RivGeoMechVizLogic::keysToVisiblePartMgrs( int timeStepIndex ) const
|
||||
{
|
||||
std::vector<RivGeoMechPartMgrCache::Key> visiblePartMgrs;
|
||||
if ( m_geomechView->viewController() && m_geomechView->viewController()->isVisibleCellsOveridden() )
|
||||
{
|
||||
visiblePartMgrs.push_back( RivGeoMechPartMgrCache::Key( OVERRIDDEN_CELL_VISIBILITY, -1 ) );
|
||||
}
|
||||
else if ( m_geomechView->isGridVisualizationMode() )
|
||||
{
|
||||
if ( timeStepIndex >= 0 && m_geomechView->geoMechPropertyFilterCollection()->hasActiveFilters() )
|
||||
{
|
||||
visiblePartMgrs.push_back( RivGeoMechPartMgrCache::Key( PROPERTY_FILTERED, timeStepIndex ) );
|
||||
}
|
||||
else if ( m_geomechView->rangeFilterCollection()->hasActiveFilters() )
|
||||
{
|
||||
visiblePartMgrs.push_back( RivGeoMechPartMgrCache::Key( RANGE_FILTERED, -1 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
visiblePartMgrs.push_back( RivGeoMechPartMgrCache::Key( ALL_CELLS, -1 ) );
|
||||
}
|
||||
}
|
||||
return visiblePartMgrs;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const cvf::ref<RivGeoMechPartMgrCache> RivGeoMechVizLogic::partMgrCache() const
|
||||
{
|
||||
return m_partMgrCache;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Color3f RivGeoMechVizLogic::staticCellColor()
|
||||
{
|
||||
return cvf::Color3f::ORANGE;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivGeoMechPartMgr* RivGeoMechVizLogic::getUpdatedPartMgr( RivGeoMechPartMgrCache::Key pMgrKey )
|
||||
{
|
||||
if ( !m_partMgrCache->isNeedingRegeneration( pMgrKey ) )
|
||||
{
|
||||
return m_partMgrCache->partMgr( pMgrKey );
|
||||
}
|
||||
|
||||
RivGeoMechPartMgr* partMgrToUpdate = m_partMgrCache->partMgr( pMgrKey );
|
||||
int partCount = 0;
|
||||
RigGeoMechCaseData* caseData = nullptr;
|
||||
if ( m_geomechView->geoMechCase() )
|
||||
{
|
||||
caseData = m_geomechView->geoMechCase()->geoMechData();
|
||||
partCount = caseData->femParts()->partCount();
|
||||
}
|
||||
|
||||
if ( partMgrToUpdate->initializedFemPartCount() != partCount )
|
||||
{
|
||||
partMgrToUpdate->clearAndSetReservoir( caseData );
|
||||
}
|
||||
|
||||
for ( int femPartIdx = 0; femPartIdx < partCount; ++femPartIdx )
|
||||
{
|
||||
cvf::ref<cvf::UByteArray> elmVisibility = partMgrToUpdate->cellVisibility( femPartIdx );
|
||||
partMgrToUpdate->setTransform( m_geomechView->scaleTransform() );
|
||||
|
||||
if ( pMgrKey.geometryType() == RANGE_FILTERED )
|
||||
{
|
||||
cvf::CellRangeFilter cellRangeFilter;
|
||||
m_geomechView->rangeFilterCollection()->compoundCellRangeFilter( &cellRangeFilter, femPartIdx );
|
||||
RivFemElmVisibilityCalculator::computeRangeVisibility( elmVisibility.p(),
|
||||
caseData->femParts()->part( femPartIdx ),
|
||||
cellRangeFilter );
|
||||
}
|
||||
else if ( pMgrKey.geometryType() == PROPERTY_FILTERED )
|
||||
{
|
||||
RivGeoMechPartMgr* rangefiltered = nullptr;
|
||||
if ( m_geomechView->rangeFilterCollection()->hasActiveFilters() )
|
||||
{
|
||||
rangefiltered = getUpdatedPartMgr( RivGeoMechPartMgrCache::Key( RANGE_FILTERED, -1 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
rangefiltered = getUpdatedPartMgr( RivGeoMechPartMgrCache::Key( ALL_CELLS, -1 ) );
|
||||
}
|
||||
cvf::ref<cvf::UByteArray> rangeFiltVisibility = rangefiltered->cellVisibility( femPartIdx );
|
||||
|
||||
RivFemElmVisibilityCalculator::computePropertyVisibility( elmVisibility.p(),
|
||||
caseData->femParts()->part( femPartIdx ),
|
||||
pMgrKey.frameIndex(),
|
||||
rangeFiltVisibility.p(),
|
||||
m_geomechView->geoMechPropertyFilterCollection() );
|
||||
}
|
||||
else if ( pMgrKey.geometryType() == OVERRIDDEN_CELL_VISIBILITY )
|
||||
{
|
||||
RivFemElmVisibilityCalculator::computeOverriddenCellVisibility( elmVisibility.p(),
|
||||
caseData->femParts()->part( femPartIdx ),
|
||||
m_geomechView->viewController() );
|
||||
}
|
||||
|
||||
else if ( pMgrKey.geometryType() == ALL_CELLS )
|
||||
{
|
||||
RivFemElmVisibilityCalculator::computeAllVisible( elmVisibility.p(), caseData->femParts()->part( femPartIdx ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
CVF_ASSERT( false ); // Unsupported CellSet Enum
|
||||
}
|
||||
|
||||
partMgrToUpdate->setCellVisibility( femPartIdx, elmVisibility.p() );
|
||||
}
|
||||
|
||||
m_partMgrCache->setGenerationFinished( pMgrKey );
|
||||
|
||||
return partMgrToUpdate;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivGeoMechVizLogic::calculateCurrentTotalCellVisibility( cvf::UByteArray* totalVisibility, int timeStepIndex )
|
||||
{
|
||||
if ( !m_geomechView->geoMechCase() ) return;
|
||||
|
||||
size_t gridCount = m_geomechView->femParts()->partCount();
|
||||
|
||||
if ( gridCount == 0 ) return;
|
||||
|
||||
RigFemPart* part = m_geomechView->femParts()->part( 0 );
|
||||
int elmCount = part->elementCount();
|
||||
|
||||
totalVisibility->resize( elmCount );
|
||||
totalVisibility->setAll( false );
|
||||
|
||||
std::vector<RivGeoMechPartMgrCache::Key> visiblePartMgrs = keysToVisiblePartMgrs( timeStepIndex );
|
||||
for ( size_t pmIdx = 0; pmIdx < visiblePartMgrs.size(); ++pmIdx )
|
||||
{
|
||||
RivGeoMechPartMgr* partMgr = getUpdatedPartMgr( visiblePartMgrs[pmIdx] );
|
||||
CVF_ASSERT( partMgr );
|
||||
if ( partMgr )
|
||||
{
|
||||
cvf::ref<cvf::UByteArray> visibility = partMgr->cellVisibility( 0 );
|
||||
for ( int elmIdx = 0; elmIdx < elmCount; ++elmIdx )
|
||||
{
|
||||
( *totalVisibility )[elmIdx] |= ( *visibility )[elmIdx];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RivCellSetEnum.h"
|
||||
#include "RivGeoMechPartMgrCache.h"
|
||||
#include "cvfArray.h"
|
||||
#include "cvfColor4.h"
|
||||
#include "cvfObject.h"
|
||||
#include <cstddef>
|
||||
|
||||
#include <vector>
|
||||
|
||||
class RimGeoMechView;
|
||||
class RimGeoMechCellColors;
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
class ModelBasicList;
|
||||
}
|
||||
|
||||
class RivGeoMechVizLogic : public cvf::Object
|
||||
{
|
||||
public:
|
||||
explicit RivGeoMechVizLogic( RimGeoMechView* geomView );
|
||||
~RivGeoMechVizLogic() override;
|
||||
|
||||
void appendNoAnimPartsToModel( cvf::ModelBasicList* model );
|
||||
void appendPartsToModel( int timeStepIndex, cvf::ModelBasicList* model );
|
||||
void updateCellResultColor( int timeStepIndex, RimGeoMechCellColors* cellResultColors );
|
||||
void updateStaticCellColors( int timeStepIndex );
|
||||
void scheduleGeometryRegen( RivCellSetEnum geometryType );
|
||||
void calculateCurrentTotalCellVisibility( cvf::UByteArray* totalVisibility, int timeStepIndex );
|
||||
std::vector<RivGeoMechPartMgrCache::Key> keysToVisiblePartMgrs( int timeStepIndex ) const;
|
||||
const cvf::ref<RivGeoMechPartMgrCache> partMgrCache() const;
|
||||
|
||||
static cvf::Color3f staticCellColor();
|
||||
|
||||
private:
|
||||
RivGeoMechPartMgr* getUpdatedPartMgr( RivGeoMechPartMgrCache::Key partMgrKey );
|
||||
void scheduleRegenOfDirectlyDependentGeometry( RivCellSetEnum geometryType );
|
||||
|
||||
cvf::ref<RivGeoMechPartMgrCache> m_partMgrCache;
|
||||
RimGeoMechView* m_geomechView;
|
||||
};
|
||||
Reference in New Issue
Block a user