Revert "Merge branch 'dev' of https://github.com/OPM/ResInsight into dev"

This reverts commit a536ac2626, reversing
changes made to b92384211b.
This commit is contained in:
Ruben Manuel Thoms 2020-09-25 17:31:46 +02:00
parent a536ac2626
commit 3ae60d0b30
7 changed files with 204 additions and 608 deletions

View File

@ -30,12 +30,9 @@
#include "RigEclipseResultAddress.h"
#include "RigMainGrid.h"
#include "cafDisplayCoordTransform.h"
#include "cafEffectGenerator.h"
#include "cvfDrawableGeo.h"
#include "cvfGeometryTools.h"
#include "cvfModelBasicList.h"
#include "cvfPart.h"
#include "cvfPrimitiveSetIndexedUInt.h"
@ -103,39 +100,30 @@ void RivElementVectorResultPartMgr::appendDynamicGeometryPartsToModel( cvf::Mode
}
float arrowScaling = arrowConstantScaling;
if ( result->scaleMethod() == RimElementVectorResult::ScaleMethod::RESULT )
if ( result->scaleMethod() == RimElementVectorResult::RESULT )
{
arrowScaling = arrowConstantScaling / maxAbsResult;
}
if ( result->scaleMethod() == RimElementVectorResult::ScaleMethod::RESULT_LOG )
{
arrowScaling = result->sizeScale() * scaleLogarithmically( maxAbsResult );
}
std::vector<RigEclipseResultAddress> addresses;
result->resultAddressesIJK( addresses );
result->resultAddressIJK( addresses );
std::vector<cvf::StructGridInterface::FaceType> directions;
std::vector<RigEclipseResultAddress> resultAddresses;
for ( size_t fluidIndex = 0; fluidIndex < addresses.size(); fluidIndex += 3 )
if ( result->showVectorI() )
{
if ( result->showVectorI() )
{
if ( fluidIndex == 0 ) directions.push_back( cvf::StructGridInterface::POS_I );
resultAddresses.push_back( addresses[0 + fluidIndex] );
}
if ( result->showVectorJ() )
{
if ( fluidIndex == 0 ) directions.push_back( cvf::StructGridInterface::POS_J );
resultAddresses.push_back( addresses[1 + fluidIndex] );
}
if ( result->showVectorK() )
{
if ( fluidIndex == 0 ) directions.push_back( cvf::StructGridInterface::POS_K );
resultAddresses.push_back( addresses[2 + fluidIndex] );
}
directions.push_back( cvf::StructGridInterface::POS_I );
resultAddresses.push_back( addresses[0] );
}
if ( result->showVectorJ() )
{
directions.push_back( cvf::StructGridInterface::POS_J );
resultAddresses.push_back( addresses[1] );
}
if ( result->showVectorK() )
{
directions.push_back( cvf::StructGridInterface::POS_K );
resultAddresses.push_back( addresses[2] );
}
RigCaseCellResultsData* resultsData = eclipseCaseData->results( RiaDefines::PorosityModelType::MATRIX_MODEL );
@ -148,139 +136,29 @@ void RivElementVectorResultPartMgr::appendDynamicGeometryPartsToModel( cvf::Mode
{
if ( !cells[gcIdx].isInvalid() && activeCellInfo->isActive( gcIdx ) )
{
size_t resultIdx = activeCellInfo->cellResultIndex( gcIdx );
if ( result->vectorView() == RimElementVectorResult::VectorView::INDIVIDUAL )
for ( int dir = 0; dir < static_cast<int>( directions.size() ); dir++ )
{
for ( int dir = 0; dir < static_cast<int>( directions.size() ); dir++ )
size_t resultIdx = activeCellInfo->cellResultIndex( gcIdx );
double resultValue = resultsData->cellScalarResults( resultAddresses[dir], timeStepIndex ).at( resultIdx );
if ( std::abs( resultValue ) >= result->threshold() )
{
double resultValue = 0.0;
for ( size_t flIdx = dir; flIdx < resultAddresses.size(); flIdx += directions.size() )
{
resultValue +=
resultsData->cellScalarResults( resultAddresses[flIdx], timeStepIndex ).at( resultIdx );
}
if ( std::abs( resultValue ) >= result->threshold() )
{
cvf::Vec3d faceCenter = cells[gcIdx].faceCenter( directions[dir] ) - offset;
cvf::Vec3d cellCenter = cells[gcIdx].center() - offset;
cvf::Vec3d faceNormal = ( faceCenter - cellCenter ).getNormalized() * arrowScaling;
if ( result->scaleMethod() == RimElementVectorResult::ScaleMethod::RESULT )
{
faceNormal *= std::abs( resultValue );
}
else if ( result->scaleMethod() == RimElementVectorResult::ScaleMethod::RESULT_LOG )
{
faceNormal *= std::abs( scaleLogarithmically( std::abs( resultValue ) ) );
}
tensorVisualizations.push_back(
ElementVectorResultVisualization( faceCenter,
faceNormal,
resultValue,
std::cbrt( cells[gcIdx].volume() / 3.0 ) ) );
}
}
}
else if ( result->vectorView() == RimElementVectorResult::VectorView::AGGREGATED )
{
cvf::Vec3d aggregatedVector;
cvf::Vec3d aggregatedResult;
for ( int dir = 0; dir < static_cast<int>( directions.size() ); dir++ )
{
double resultValue = 0.0;
for ( size_t flIdx = dir; flIdx < resultAddresses.size(); flIdx += directions.size() )
{
resultValue +=
resultsData->cellScalarResults( resultAddresses[flIdx], timeStepIndex ).at( resultIdx );
}
cvf::Vec3d faceCenter = cells[gcIdx].faceCenter( directions[dir] ) - offset;
cvf::Vec3d cellCenter = cells[gcIdx].center() - offset;
cvf::Vec3d faceNormal = ( faceCenter - cellCenter ).getNormalized() * arrowScaling;
aggregatedVector += faceNormal;
if ( result->scaleMethod() == RimElementVectorResult::ScaleMethod::RESULT )
if ( result->scaleMethod() == RimElementVectorResult::RESULT )
{
faceNormal *= resultValue;
}
else if ( result->scaleMethod() == RimElementVectorResult::ScaleMethod::RESULT_LOG )
{
faceNormal *= ( 1.0 - static_cast<double>( std::signbit( resultValue ) ) * 2.0 ) *
scaleLogarithmically( std::abs( resultValue ) );
faceNormal *= std::abs( resultValue );
}
aggregatedVector += faceNormal;
aggregatedResult += ( faceCenter - cellCenter ).getNormalized() * resultValue;
}
if ( aggregatedVector.length() > 0 )
{
tensorVisualizations.push_back(
ElementVectorResultVisualization( cells[gcIdx].center() - offset,
aggregatedVector,
aggregatedResult.length(),
std::cbrt( cells[gcIdx].volume() / 3.0 ) ) );
ElementVectorResultVisualization( faceCenter, faceNormal, resultValue ) );
}
}
}
}
RigNNCData* nncData = eclipseCaseData->mainGrid()->nncData();
size_t numNncConnections = nncData->connections().size();
if ( result->showNncData() )
{
std::vector<const std::vector<std::vector<double>>*> nncResultVals;
std::vector<RigEclipseResultAddress> combinedAddresses;
result->resultAddressesCombined( combinedAddresses );
for ( size_t flIdx = 0; flIdx < combinedAddresses.size(); flIdx++ )
{
if ( combinedAddresses[flIdx].m_resultCatType == RiaDefines::ResultCatType::DYNAMIC_NATIVE )
{
nncResultVals.push_back( nncData->dynamicConnectionScalarResult( combinedAddresses[flIdx] ) );
}
}
for ( size_t nIdx = 0; nIdx < numNncConnections; ++nIdx )
{
const RigConnection& conn = nncData->connections()[nIdx];
if ( conn.polygon().size() )
{
double resultValue = 0.0;
for ( size_t flIdx = 0; flIdx < nncResultVals.size(); flIdx++ )
{
if ( nIdx < nncResultVals.at( flIdx )->at( timeStepIndex ).size() )
{
resultValue += nncResultVals.at( flIdx )->at( timeStepIndex )[nIdx];
}
}
cvf::Vec3d connCenter =
static_cast<cvf::Vec3d>( cvf::GeometryTools::computePolygonCenter<cvf::Vec3f>( conn.polygon() ) );
cvf::Vec3d faceCenter = cells[conn.c1GlobIdx()].faceCenter( conn.face() ) - offset;
cvf::Vec3d cellCenter = cells[conn.c1GlobIdx()].center() - offset;
cvf::Vec3d connNormal = ( faceCenter - cellCenter ).getNormalized() * arrowScaling;
if ( result->scaleMethod() == RimElementVectorResult::ScaleMethod::RESULT )
{
connNormal *= std::abs( resultValue );
}
else if ( result->scaleMethod() == RimElementVectorResult::ScaleMethod::RESULT_LOG )
{
connNormal *= scaleLogarithmically( std::abs( resultValue ) );
}
tensorVisualizations.push_back(
ElementVectorResultVisualization( connCenter - offset,
connNormal,
resultValue,
std::cbrt( cells[conn.c1GlobIdx()].volume() / 3.0 ) ) );
}
}
}
if ( !tensorVisualizations.empty() )
{
cvf::ref<cvf::Part> partIdx = createPart( *result, tensorVisualizations );
@ -297,14 +175,11 @@ cvf::ref<cvf::Part>
RivElementVectorResultPartMgr::createPart( const RimElementVectorResult& result,
const std::vector<ElementVectorResultVisualization>& tensorVisualizations ) const
{
std::vector<uint> shaftIndices;
shaftIndices.reserve( tensorVisualizations.size() * 2 );
std::vector<uint> headIndices;
headIndices.reserve( tensorVisualizations.size() * 6 );
std::vector<uint> indices;
indices.reserve( tensorVisualizations.size() * 5 );
std::vector<cvf::Vec3f> vertices;
vertices.reserve( tensorVisualizations.size() * 7 );
vertices.reserve( tensorVisualizations.size() * 5 );
uint counter = 0;
for ( ElementVectorResultVisualization tensor : tensorVisualizations )
@ -314,34 +189,21 @@ cvf::ref<cvf::Part>
vertices.push_back( vertex );
}
for ( const uint& index : createArrowShaftIndices( counter ) )
for ( const uint& index : createArrowIndices( counter ) )
{
shaftIndices.push_back( index );
indices.push_back( index );
}
for ( const uint& index : createArrowHeadIndices( counter ) )
{
headIndices.push_back( index );
}
counter += 7;
counter += 5;
}
cvf::ref<cvf::PrimitiveSetIndexedUInt> indexedUIntShaft =
new cvf::PrimitiveSetIndexedUInt( cvf::PrimitiveType::PT_LINES );
cvf::ref<cvf::UIntArray> indexArrayShaft = new cvf::UIntArray( shaftIndices );
cvf::ref<cvf::PrimitiveSetIndexedUInt> indexedUIntHead =
new cvf::PrimitiveSetIndexedUInt( cvf::PrimitiveType::PT_TRIANGLES );
cvf::ref<cvf::UIntArray> indexArrayHead = new cvf::UIntArray( headIndices );
cvf::ref<cvf::PrimitiveSetIndexedUInt> indexedUInt = new cvf::PrimitiveSetIndexedUInt( cvf::PrimitiveType::PT_LINES );
cvf::ref<cvf::UIntArray> indexArray = new cvf::UIntArray( indices );
cvf::ref<cvf::DrawableGeo> drawable = new cvf::DrawableGeo();
indexedUIntShaft->setIndices( indexArrayShaft.p() );
drawable->addPrimitiveSet( indexedUIntShaft.p() );
indexedUIntHead->setIndices( indexArrayHead.p() );
drawable->addPrimitiveSet( indexedUIntHead.p() );
indexedUInt->setIndices( indexArray.p() );
drawable->addPrimitiveSet( indexedUInt.p() );
cvf::ref<cvf::Vec3fArray> vertexArray = new cvf::Vec3fArray( vertices );
drawable->setVertexArray( vertexArray.p() );
@ -358,7 +220,7 @@ cvf::ref<cvf::Part>
cvf::ref<cvf::Effect> effect;
auto vectorColors = result.vectorColors();
if ( vectorColors == RimElementVectorResult::TensorColors::RESULT_COLORS )
if ( vectorColors == RimElementVectorResult::RESULT_COLORS )
{
activeScalerMapper = result.legendConfig()->scalarMapper();
createResultColorTextureCoords( lineTexCoords.p(), tensorVisualizations, activeScalerMapper );
@ -393,12 +255,12 @@ void RivElementVectorResultPartMgr::createResultColorTextureCoords(
CVF_ASSERT( textureCoords );
CVF_ASSERT( mapper );
size_t vertexCount = elementVectorResultVisualizations.size() * 7;
size_t vertexCount = elementVectorResultVisualizations.size() * 5;
if ( textureCoords->size() != vertexCount ) textureCoords->reserve( vertexCount );
for ( auto evrViz : elementVectorResultVisualizations )
{
for ( size_t vxIdx = 0; vxIdx < 7; ++vxIdx )
for ( size_t vxIdx = 0; vxIdx < 5; ++vxIdx )
{
cvf::Vec2f texCoord = mapper->mapToTextureCoord( evrViz.result );
textureCoords->add( texCoord );
@ -409,48 +271,32 @@ void RivElementVectorResultPartMgr::createResultColorTextureCoords(
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::array<cvf::Vec3f, 7>
std::array<cvf::Vec3f, 5>
RivElementVectorResultPartMgr::createArrowVertices( const ElementVectorResultVisualization& evrViz ) const
{
std::array<cvf::Vec3f, 7> vertices;
RimElementVectorResult* result = m_rimReservoirView->elementVectorResult();
if ( !result ) return vertices;
std::array<cvf::Vec3f, 5> vertices;
cvf::Vec3f headTop = evrViz.faceCenter + evrViz.faceNormal;
cvf::Vec3f shaftStart = evrViz.faceCenter;
if ( result->vectorSuraceCrossingLocation() == RimElementVectorResult::VectorSurfaceCrossingLocation::VECTOR_CENTER &&
result->vectorView() == RimElementVectorResult::VectorView::INDIVIDUAL )
{
headTop = evrViz.faceCenter + evrViz.faceNormal / 2.0;
shaftStart = evrViz.faceCenter - evrViz.faceNormal / 2.0;
}
// Flip arrow for negative results
if ( evrViz.result < 0 && result->vectorView() != RimElementVectorResult::VectorView::AGGREGATED )
if ( evrViz.result < 0 )
{
std::swap( headTop, shaftStart );
}
// float headWidth = 0.05 * evrViz.faceNormal.length();
float headLength = std::min<float>( evrViz.characteristicCellSize / 5.0f, ( headTop - shaftStart ).length() / 2.0 );
float headWidth = 0.05 * evrViz.faceNormal.length();
// A fixed size is preferred here
cvf::Vec3f headBottom = headTop - ( headTop - shaftStart ).getNormalized() * headLength;
// cvf::Vec3f headBottom = headTop - ( headTop - shaftStart ) * 0.2f;
cvf::Vec3f headBottom = headTop - ( headTop - shaftStart ) * 0.2f;
cvf::Vec3f headBottomDirection1 = evrViz.faceNormal ^ evrViz.faceCenter;
cvf::Vec3f headBottomDirection2 = headBottomDirection1 ^ evrViz.faceNormal;
cvf::Vec3f arrowBottomSegment1 = headBottomDirection1.getNormalized() * headLength / 8.0f;
cvf::Vec3f arrowBottomSegment2 = headBottomDirection2.getNormalized() * headLength / 8.0f;
cvf::Vec3f headBottomDirection = evrViz.faceNormal ^ evrViz.faceCenter;
cvf::Vec3f arrowBottomSegment = headBottomDirection.getNormalized() * headWidth;
vertices[0] = shaftStart;
vertices[1] = headBottom;
vertices[2] = headBottom + arrowBottomSegment1;
vertices[3] = headBottom - arrowBottomSegment1;
vertices[2] = headBottom + arrowBottomSegment;
vertices[3] = headBottom - arrowBottomSegment;
vertices[4] = headTop;
vertices[5] = headBottom + arrowBottomSegment2;
vertices[6] = headBottom - arrowBottomSegment2;
return vertices;
}
@ -458,41 +304,18 @@ std::array<cvf::Vec3f, 7>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::array<uint, 2> RivElementVectorResultPartMgr::createArrowShaftIndices( uint startIndex ) const
std::array<uint, 8> RivElementVectorResultPartMgr::createArrowIndices( uint startIndex ) const
{
std::array<uint, 2> indices;
std::array<uint, 8> indices;
indices[0] = startIndex;
indices[1] = startIndex + 1;
return indices;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::array<uint, 6> RivElementVectorResultPartMgr::createArrowHeadIndices( uint startIndex ) const
{
std::array<uint, 6> indices;
indices[0] = startIndex + 2;
indices[1] = startIndex + 3;
indices[2] = startIndex + 4;
indices[3] = startIndex + 5;
indices[4] = startIndex + 6;
indices[2] = startIndex + 2;
indices[3] = startIndex + 3;
indices[4] = startIndex + 3;
indices[5] = startIndex + 4;
indices[6] = startIndex + 4;
indices[7] = startIndex + 2;
return indices;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RivElementVectorResultPartMgr::scaleLogarithmically( double value ) const
{
if ( value <= 1.0 )
{
value += 1.0;
}
return std::log10( value );
}

View File

@ -54,18 +54,16 @@ public:
private:
struct ElementVectorResultVisualization
{
ElementVectorResultVisualization( cvf::Vec3d faceCenter, cvf::Vec3d faceNormal, double result, double characteristicCellSize )
ElementVectorResultVisualization( cvf::Vec3d faceCenter, cvf::Vec3d faceNormal, double result )
: faceCenter( faceCenter )
, faceNormal( faceNormal )
, result( result )
, characteristicCellSize( characteristicCellSize )
{
}
cvf::Vec3f faceCenter;
cvf::Vec3f faceNormal;
double result;
double characteristicCellSize;
};
private:
@ -77,11 +75,8 @@ private:
const std::vector<ElementVectorResultVisualization>& elementVectorResultVisualizations,
const cvf::ScalarMapper* mapper );
std::array<cvf::Vec3f, 7> createArrowVertices( const ElementVectorResultVisualization& tensorVisualization ) const;
std::array<uint, 2> createArrowShaftIndices( uint startIndex ) const;
std::array<uint, 6> createArrowHeadIndices( uint startIndex ) const;
double scaleLogarithmically( double value ) const;
std::array<cvf::Vec3f, 5> createArrowVertices( const ElementVectorResultVisualization& tensorVisualization ) const;
std::array<uint, 8> createArrowIndices( uint startIndex ) const;
private:
caf::PdmPointer<RimEclipseView> m_rimReservoirView;

View File

@ -20,8 +20,6 @@
#include "RigCaseCellResultsData.h"
#include "RigEclipseCaseData.h"
#include "RigEclipseResultAddress.h"
#include "RigMainGrid.h"
#include "RigNNCData.h"
#include "Rim3dView.h"
#include "RimEclipseCase.h"
@ -40,38 +38,19 @@ namespace caf
template <>
void AppEnum<RimElementVectorResult::TensorColors>::setUp()
{
addItem( RimElementVectorResult::TensorColors::RESULT_COLORS, "RESULT_COLORS", "Result Colors" );
addItem( RimElementVectorResult::TensorColors::UNIFORM_COLOR, "UNIFORM_COLOR", "Uniform" );
addItem( RimElementVectorResult::RESULT_COLORS, "RESULT_COLORS", "Result Colors" );
addItem( RimElementVectorResult::UNIFORM_COLOR, "UNIFORM_COLOR", "Uniform" );
setDefault( RimElementVectorResult::TensorColors::RESULT_COLORS );
setDefault( RimElementVectorResult::RESULT_COLORS );
}
template <>
void AppEnum<RimElementVectorResult::ScaleMethod>::setUp()
{
addItem( RimElementVectorResult::ScaleMethod::RESULT, "RESULT", "Result" );
addItem( RimElementVectorResult::ScaleMethod::RESULT_LOG, "RESULT_LOG", "Result (logarithmic scaling)" );
addItem( RimElementVectorResult::ScaleMethod::CONSTANT, "CONSTANT", "Constant" );
addItem( RimElementVectorResult::RESULT, "RESULT", "Result" );
addItem( RimElementVectorResult::CONSTANT, "CONSTANT", "Constant" );
setDefault( RimElementVectorResult::ScaleMethod::RESULT );
}
template <>
void AppEnum<RimElementVectorResult::VectorView>::setUp()
{
addItem( RimElementVectorResult::VectorView::AGGREGATED, "AGGREGATED", "Aggregated" );
addItem( RimElementVectorResult::VectorView::INDIVIDUAL, "INDIVIDUAL", "Individual" );
setDefault( RimElementVectorResult::VectorView::AGGREGATED );
}
template <>
void AppEnum<RimElementVectorResult::VectorSurfaceCrossingLocation>::setUp()
{
addItem( RimElementVectorResult::VectorSurfaceCrossingLocation::VECTOR_ANCHOR, "VECTOR_ANCHOR", "At vector anchor" );
addItem( RimElementVectorResult::VectorSurfaceCrossingLocation::VECTOR_CENTER, "VECTOR_CENTER", "At vector center" );
setDefault( RimElementVectorResult::VectorSurfaceCrossingLocation::VECTOR_ANCHOR );
setDefault( RimElementVectorResult::RESULT );
}
} // namespace caf
@ -86,27 +65,15 @@ RimElementVectorResult::RimElementVectorResult()
m_legendConfig = new RimRegularLegendConfig();
m_legendConfig.uiCapability()->setUiHidden( true );
CAF_PDM_InitField( &m_showOil, "ShowOil", true, "Oil", "", "", "" );
CAF_PDM_InitField( &m_showGas, "ShowGas", false, "Gas", "", "", "" );
CAF_PDM_InitField( &m_showWater, "ShowWater", true, "Water", "", "", "" );
CAF_PDM_InitField( &m_resultName, "ResultVariable", QString( "Oil" ), "Value", "", "", "" );
m_resultName.uiCapability()->setUiEditorTypeName( caf::PdmUiListEditor::uiEditorTypeName() );
m_resultName.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP );
CAF_PDM_InitField( &m_showResult, "ShowResult", false, "", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_vectorView, "VectorView", "View vectors", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_vectorSurfaceCrossingLocation,
"VectorSurfaceCrossingLocation",
"Vectors touching surface",
"",
"",
"" );
m_vectorSurfaceCrossingLocation.uiCapability()->setUiReadOnly( m_vectorView() ==
RimElementVectorResult::VectorView::AGGREGATED );
CAF_PDM_InitField( &m_showVectorI, "ShowVectorI", true, "I", "", "", "" );
CAF_PDM_InitField( &m_showVectorJ, "ShowVectorJ", true, "J", "", "", "" );
CAF_PDM_InitField( &m_showVectorK, "ShowVectorK", true, "K", "", "", "" );
CAF_PDM_InitField( &m_showNncData, "ShowNncData", true, "Show NNC data", "", "", "" );
CAF_PDM_InitField( &m_threshold, "Threshold", 0.0f, "Threshold", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_vectorColor, "VectorColor", "Color", "", "", "" );
@ -144,38 +111,6 @@ bool RimElementVectorResult::showResult() const
return m_showResult();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimElementVectorResult::VectorView RimElementVectorResult::vectorView() const
{
return m_vectorView();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimElementVectorResult::showOil() const
{
return m_showOil();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimElementVectorResult::showGas() const
{
return m_showGas();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimElementVectorResult::showWater() const
{
return m_showWater();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -201,22 +136,6 @@ bool RimElementVectorResult::showVectorK() const
return m_showVectorK();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimElementVectorResult::showNncData() const
{
return m_showNncData();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimElementVectorResult::VectorSurfaceCrossingLocation RimElementVectorResult::vectorSuraceCrossingLocation() const
{
return m_vectorSurfaceCrossingLocation();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -262,157 +181,30 @@ const cvf::Color3f& RimElementVectorResult::getUniformVectorColor() const
//--------------------------------------------------------------------------------------------------
void RimElementVectorResult::mappingRange( double& min, double& max ) const
{
min = 0.0;
max = 0.0;
min = cvf::UNDEFINED_DOUBLE;
max = cvf::UNDEFINED_DOUBLE;
Rim3dView* view = nullptr;
firstAncestorOrThisOfType( view );
int currentTimeStep = view->currentTimeStep();
std::vector<RigEclipseResultAddress> resVarAddresses;
size_t directions = 1;
if ( !resultAddressesIJK( resVarAddresses ) ) return;
std::vector<RigEclipseResultAddress> cleanedResVarAddresses;
directions = 0;
std::vector<cvf::Vec3d> unitVectors;
RigEclipseResultAddress resVarAddr = resultAddressCombined();
if ( !resVarAddr.isValid() ) return;
for ( size_t fluidIndex = 0; fluidIndex < resVarAddresses.size(); fluidIndex += 3 )
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>( view );
RigCaseCellResultsData* resultsData =
eclipseView->eclipseCase()->eclipseCaseData()->results( RiaDefines::PorosityModelType::MATRIX_MODEL );
resultsData->ensureKnownResultLoaded( resVarAddr );
if ( m_legendConfig->rangeMode() == RimRegularLegendConfig::RangeModeType::AUTOMATIC_ALLTIMESTEPS )
{
if ( showVectorI() )
{
if ( fluidIndex == 0 )
{
directions++;
unitVectors.push_back( cvf::Vec3d( 1, 0, 0 ) );
}
cleanedResVarAddresses.push_back( resVarAddresses.at( 0 + fluidIndex ) );
}
if ( showVectorJ() )
{
if ( fluidIndex == 0 )
{
directions++;
unitVectors.push_back( cvf::Vec3d( 0, 1, 0 ) );
}
cleanedResVarAddresses.push_back( resVarAddresses.at( 1 + fluidIndex ) );
}
if ( showVectorK() )
{
if ( fluidIndex == 0 )
{
directions++;
unitVectors.push_back( cvf::Vec3d( 0, 0, 1 ) );
}
cleanedResVarAddresses.push_back( resVarAddresses.at( 2 + fluidIndex ) );
}
resultsData->minMaxCellScalarValues( resVarAddr, min, max );
}
resVarAddresses = cleanedResVarAddresses;
if ( directions > 0 )
else if ( m_legendConfig->rangeMode() == RimRegularLegendConfig::RangeModeType::AUTOMATIC_CURRENT_TIMESTEP )
{
std::vector<double> directionsMax;
directionsMax.resize( directions, 0.0 );
std::vector<double> directionsMin;
directionsMin.resize( directions, 0.0 );
for ( size_t index = 0; index < resVarAddresses.size(); index += directions )
{
cvf::Vec3d aggregatedVectorMax;
cvf::Vec3d aggregatedVectorMin;
for ( size_t dir = 0; dir < directions; dir += 1 )
{
double localMin = cvf::UNDEFINED_DOUBLE;
double localMax = cvf::UNDEFINED_DOUBLE;
RigEclipseResultAddress resVarAddr = resVarAddresses.at( index + dir );
if ( !resVarAddr.isValid() ) return;
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>( view );
RigCaseCellResultsData* resultsData =
eclipseView->eclipseCase()->eclipseCaseData()->results( RiaDefines::PorosityModelType::MATRIX_MODEL );
resultsData->ensureKnownResultLoaded( resVarAddr );
if ( m_legendConfig->rangeMode() == RimRegularLegendConfig::RangeModeType::AUTOMATIC_ALLTIMESTEPS )
{
resultsData->minMaxCellScalarValues( resVarAddr, localMin, localMax );
}
else if ( m_legendConfig->rangeMode() == RimRegularLegendConfig::RangeModeType::AUTOMATIC_CURRENT_TIMESTEP )
{
resultsData->minMaxCellScalarValues( resVarAddr, currentTimeStep, localMin, localMax );
}
if ( vectorView() == RimElementVectorResult::VectorView::AGGREGATED )
{
aggregatedVectorMax += unitVectors.at( dir ) * localMax;
aggregatedVectorMin += unitVectors.at( dir ) * localMin;
}
else
{
directionsMax[dir] += localMax;
directionsMin[dir] += localMin;
}
}
if ( vectorView() == RimElementVectorResult::VectorView::AGGREGATED )
{
directionsMax[0] += aggregatedVectorMax.length();
directionsMin[0] += aggregatedVectorMin.length();
}
}
min = directionsMin.front();
max = directionsMax.front();
if ( vectorView() != RimElementVectorResult::VectorView::AGGREGATED )
{
for ( size_t i = 0; i < directionsMax.size(); i++ )
{
max = std::max<double>( max, directionsMax.at( i ) );
min = std::min<double>( min, directionsMin.at( i ) );
}
}
else
{
max = std::max<double>( max, min );
min = 0.0;
}
}
if ( showNncData() )
{
RigNNCData* nncData =
dynamic_cast<RimEclipseView*>( view )->eclipseCase()->eclipseCaseData()->mainGrid()->nncData();
std::vector<RigEclipseResultAddress> combinedAddresses;
if ( !resultAddressesCombined( combinedAddresses ) ) return;
for ( size_t flIdx = 0; flIdx < combinedAddresses.size(); flIdx++ )
{
if ( combinedAddresses[flIdx].m_resultCatType == RiaDefines::ResultCatType::DYNAMIC_NATIVE )
{
if ( m_legendConfig->rangeMode() == RimRegularLegendConfig::RangeModeType::AUTOMATIC_ALLTIMESTEPS )
{
const std::vector<std::vector<double>>* nncResultVals =
nncData->dynamicConnectionScalarResult( combinedAddresses[flIdx] );
for ( size_t i = 0; i < nncResultVals->size(); i++ )
{
for ( size_t j = 0; j < nncResultVals->at( i ).size(); j++ )
{
max = std::max<double>( max, nncResultVals->at( i ).at( j ) );
min = std::min<double>( min, nncResultVals->at( i ).at( j ) );
}
}
}
else if ( m_legendConfig->rangeMode() == RimRegularLegendConfig::RangeModeType::AUTOMATIC_CURRENT_TIMESTEP )
{
const std::vector<double>* nncResultVals =
nncData->dynamicConnectionScalarResult( combinedAddresses[flIdx],
static_cast<size_t>( currentTimeStep ) );
for ( size_t i = 0; i < nncResultVals->size(); i++ )
{
max = std::max<double>( max, nncResultVals->at( i ) );
min = std::min<double>( min, nncResultVals->at( i ) );
}
}
}
}
resultsData->minMaxCellScalarValues( resVarAddr, currentTimeStep, min, max );
}
}
@ -422,29 +214,13 @@ void RimElementVectorResult::mappingRange( double& min, double& max ) const
void RimElementVectorResult::updateLegendRangesTextAndVisibility( RiuViewer* nativeOrOverrideViewer,
bool isUsingOverrideViewer )
{
QStringList resultNames;
if ( showOil() )
{
resultNames << QString( "Oil" );
}
if ( showGas() )
{
resultNames << QString( "Gas" );
}
if ( showWater() )
{
resultNames << QString( "Water" );
}
m_legendConfig->setTitle( QString( "Element Vector Result: \n" ) + resultNames.join( ", " ) );
m_legendConfig->setTitle( QString( "Element Vector Result: \n" ) + resultName() );
double minResultValue;
double maxResultValue;
mappingRange( minResultValue, maxResultValue );
m_legendConfig->setAutomaticRanges( minResultValue, maxResultValue, minResultValue, maxResultValue );
m_legendConfig->setMappingMode( RimRegularLegendConfig::MappingType::LINEAR_CONTINUOUS );
double posClosestToZero = HUGE_VAL;
double negClosestToZero = -HUGE_VAL;
m_legendConfig->setClosestToZeroValues( posClosestToZero, negClosestToZero, posClosestToZero, negClosestToZero );
@ -459,6 +235,27 @@ const RimRegularLegendConfig* RimElementVectorResult::legendConfig() const
return m_legendConfig();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimElementVectorResult::resultName() const
{
return m_resultName();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<std::string> RimElementVectorResult::getResultMetaDataForUIFieldSetting()
{
std::vector<std::string> fieldNames;
fieldNames.push_back( "Oil" );
fieldNames.push_back( "Water" );
fieldNames.push_back( "Gas" );
return fieldNames;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -470,11 +267,6 @@ void RimElementVectorResult::fieldChangedByUi( const caf::PdmFieldHandle* change
{
setShowResult( m_showResult );
}
if ( changedField == &m_vectorView )
{
m_vectorSurfaceCrossingLocation.uiCapability()->setUiReadOnly( vectorView() ==
RimElementVectorResult::VectorView::AGGREGATED );
}
RimEclipseView* view;
firstAncestorOrThisOfType( view );
@ -489,28 +281,45 @@ caf::PdmFieldHandle* RimElementVectorResult::objectToggleField()
return &m_showResult;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo>
RimElementVectorResult::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly )
{
QList<caf::PdmOptionItemInfo> options;
*useOptionsOnly = true;
if ( fieldNeedingOptions == &m_resultName )
{
std::vector<std::string> fieldCompNames = getResultMetaDataForUIFieldSetting();
for ( size_t oIdx = 0; oIdx < fieldCompNames.size(); ++oIdx )
{
options.push_back( caf::PdmOptionItemInfo( QString::fromStdString( fieldCompNames[oIdx] ),
QString::fromStdString( fieldCompNames[oIdx] ) ) );
}
}
return options;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimElementVectorResult::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
caf::PdmUiGroup* fluidsGroup = uiOrdering.addNewGroup( "Fluids" );
fluidsGroup->add( &m_showOil );
fluidsGroup->add( &m_showGas );
fluidsGroup->add( &m_showWater );
uiOrdering.add( &m_resultName );
caf::PdmUiGroup* visibilityGroup = uiOrdering.addNewGroup( "Visibility" );
visibilityGroup->add( &m_vectorView );
visibilityGroup->add( &m_vectorSurfaceCrossingLocation );
visibilityGroup->add( &m_showVectorI );
visibilityGroup->add( &m_showVectorJ );
visibilityGroup->add( &m_showVectorK );
visibilityGroup->add( &m_showNncData );
visibilityGroup->add( &m_threshold );
caf::PdmUiGroup* vectorColorsGroup = uiOrdering.addNewGroup( "Vector Colors" );
vectorColorsGroup->add( &m_vectorColor );
if ( m_vectorColor == TensorColors::UNIFORM_COLOR )
if ( m_vectorColor == UNIFORM_COLOR )
{
vectorColorsGroup->add( &m_uniformVectorColor );
}
@ -525,55 +334,75 @@ void RimElementVectorResult::defineUiOrdering( QString uiConfigName, caf::PdmUiO
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimElementVectorResult::resultAddressesCombined( std::vector<RigEclipseResultAddress>& addresses ) const
void RimElementVectorResult::defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute )
{
addresses.clear();
if ( showOil() )
if ( field == &m_resultName )
{
addresses.push_back( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE,
RiaDefines::combinedOilFluxResultName() ) );
caf::PdmUiListEditorAttribute* listEditAttr = dynamic_cast<caf::PdmUiListEditorAttribute*>( attribute );
if ( listEditAttr )
{
listEditAttr->m_heightHint = 50;
}
}
if ( showGas() )
{
addresses.push_back( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE,
RiaDefines::combinedGasFluxResultName() ) );
}
if ( showWater() )
{
addresses.push_back( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE,
RiaDefines::combinedWaterFluxResultName() ) );
}
return addresses.size() > 0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimElementVectorResult::resultAddressesIJK( std::vector<RigEclipseResultAddress>& addresses ) const
RigEclipseResultAddress RimElementVectorResult::resultAddressCombined() const
{
if ( resultName() == "Oil" )
{
return RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE,
RiaDefines::combinedOilFluxResultName() );
}
else if ( resultName() == "Gas" )
{
return RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE,
RiaDefines::combinedGasFluxResultName() );
}
else if ( resultName() == "Water" )
{
return RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE,
RiaDefines::combinedWaterFluxResultName() );
}
return RigEclipseResultAddress();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimElementVectorResult::resultAddressIJK( std::vector<RigEclipseResultAddress>& addresses ) const
{
addresses.clear();
if ( showOil() )
// TODO: use enum??
if ( resultName() == "Oil" )
{
addresses.push_back( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "FLROILI+" ) );
addresses.push_back( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "FLROILJ+" ) );
addresses.push_back( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "FLROILK+" ) );
return true;
}
if ( showGas() )
else if ( resultName() == "Gas" )
{
addresses.push_back( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "FLRGASI+" ) );
addresses.push_back( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "FLRGASJ+" ) );
addresses.push_back( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "FLRGASK+" ) );
return true;
}
if ( showWater() )
else if ( resultName() == "Water" )
{
addresses.push_back( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "FLRWATI+" ) );
addresses.push_back( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "FLRWATJ+" ) );
addresses.push_back( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "FLRWATK+" ) );
return true;
}
return addresses.size() > 0;
return false;
}
//--------------------------------------------------------------------------------------------------

View File

@ -44,85 +44,69 @@ class RimElementVectorResult : public caf::PdmObject
CAF_PDM_HEADER_INIT;
public:
enum class TensorColors
enum TensorColors
{
UNIFORM_COLOR,
RESULT_COLORS
};
enum class ScaleMethod
enum ScaleMethod
{
RESULT,
RESULT_LOG,
CONSTANT
};
enum class VectorView
{
AGGREGATED,
INDIVIDUAL
};
enum class VectorSurfaceCrossingLocation
{
VECTOR_ANCHOR,
VECTOR_CENTER
};
public:
RimElementVectorResult();
~RimElementVectorResult() override;
void setShowResult( bool enableResult );
bool showResult() const;
VectorView vectorView() const;
bool showOil() const;
bool showGas() const;
bool showWater() const;
bool showVectorI() const;
bool showVectorJ() const;
bool showVectorK() const;
bool showNncData() const;
VectorSurfaceCrossingLocation vectorSuraceCrossingLocation() const;
float threshold() const;
float sizeScale() const;
TensorColors vectorColors() const;
ScaleMethod scaleMethod() const;
void setShowResult( bool enableResult );
bool showResult() const;
bool showVectorI() const;
bool showVectorJ() const;
bool showVectorK() const;
float threshold() const;
float sizeScale() const;
TensorColors vectorColors() const;
ScaleMethod scaleMethod() const;
const cvf::Color3f& getUniformVectorColor() const;
const RimRegularLegendConfig* legendConfig() const;
void mappingRange( double& min, double& max ) const;
bool resultAddressesCombined( std::vector<RigEclipseResultAddress>& addresses ) const;
bool resultAddressesIJK( std::vector<RigEclipseResultAddress>& addresses ) const;
RigEclipseResultAddress resultAddressCombined() const;
bool resultAddressIJK( std::vector<RigEclipseResultAddress>& addresses ) const;
QString resultName() const;
void updateLegendRangesTextAndVisibility( RiuViewer* nativeOrOverrideViewer, bool isUsingOverrideViewer );
private:
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
caf::PdmFieldHandle* objectToggleField() override;
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
std::vector<std::string> getResultMetaDataForUIFieldSetting();
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
caf::PdmFieldHandle* objectToggleField() override;
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly ) override;
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute ) override;
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override;
static QString fieldNameFromUi( const QString& uiFieldName );
private:
caf::PdmField<bool> m_showResult;
caf::PdmField<bool> m_showOil;
caf::PdmField<bool> m_showGas;
caf::PdmField<bool> m_showWater;
caf::PdmField<caf::AppEnum<VectorView>> m_vectorView;
caf::PdmField<bool> m_showVectorI;
caf::PdmField<bool> m_showVectorJ;
caf::PdmField<bool> m_showVectorK;
caf::PdmField<bool> m_showNncData;
caf::PdmField<caf::AppEnum<VectorSurfaceCrossingLocation>> m_vectorSurfaceCrossingLocation;
caf::PdmField<float> m_threshold;
caf::PdmField<caf::AppEnum<TensorColors>> m_vectorColor;
caf::PdmField<cvf::Color3f> m_uniformVectorColor;
caf::PdmField<caf::AppEnum<ScaleMethod>> m_scaleMethod;
caf::PdmField<float> m_sizeScale;
caf::PdmField<RimRegularLegendConfig::RangeModeEnum> m_rangeMode;
caf::PdmChildField<RimRegularLegendConfig*> m_legendConfig;
caf::PdmField<bool> m_showResult;
caf::PdmField<QString> m_resultName;
caf::PdmField<bool> m_showVectorI;
caf::PdmField<bool> m_showVectorJ;
caf::PdmField<bool> m_showVectorK;
caf::PdmField<float> m_threshold;
caf::PdmField<caf::AppEnum<TensorColors>> m_vectorColor;
caf::PdmField<cvf::Color3f> m_uniformVectorColor;
caf::PdmField<caf::AppEnum<ScaleMethod>> m_scaleMethod;
caf::PdmField<float> m_sizeScale;
caf::PdmField<RimRegularLegendConfig::RangeModeEnum> m_rangeMode;
caf::PdmChildField<RimRegularLegendConfig*> m_legendConfig;
};

View File

@ -36,19 +36,6 @@ cvf::Vec3d
return centerCoord;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::Vec3d GeometryTools::computeTriangleCenter( const cvf::Vec3d& v0, const cvf::Vec3d& v1, const cvf::Vec3d& v2 )
{
cvf::Vec3d centerCoord = v0;
centerCoord += v1;
centerCoord += v2;
centerCoord /= 3.0;
return centerCoord;
}
//--------------------------------------------------------------------------------------------------
/// Ez = Plane normal, Ex = in XY plane (horizontal), Ey = semi vertical upwards
//--------------------------------------------------------------------------------------------------

View File

@ -36,9 +36,6 @@ class GeometryTools
public:
static cvf::Vec3d
computeFaceCenter( const cvf::Vec3d& v0, const cvf::Vec3d& v1, const cvf::Vec3d& v2, const cvf::Vec3d& v3 );
static cvf::Vec3d computeTriangleCenter( const cvf::Vec3d& v0, const cvf::Vec3d& v1, const cvf::Vec3d& v2 );
template <typename Vec3Type>
static Vec3Type computePolygonCenter( const std::vector<Vec3Type>& polygon );
static cvf::Mat3f computePlaneHorizontalRotationMx( const cvf::Vec3f& inPlaneVec0, const cvf::Vec3f& inPlaneVec1 );
static cvf::Vec3d projectPointOnLine( const cvf::Vec3d& p1,

View File

@ -21,25 +21,6 @@
namespace cvf
{
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template <typename Vec3Type>
Vec3Type GeometryTools::computePolygonCenter(const std::vector<Vec3Type>& polygon)
{
Vec3Type s;
for (size_t i = 0; i < polygon.size(); i++)
{
s.x() += polygon[i].x();
s.y() += polygon[i].y();
s.z() += polygon[i].z();
}
s /= polygon.size();
return s;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------