Last iteration.

This commit is contained in:
Ruben Manuel Thoms 2020-09-25 16:56:30 +02:00
parent 4bf19acf75
commit e22247f1f6
3 changed files with 37 additions and 22 deletions

View File

@ -103,15 +103,14 @@ void RivElementVectorResultPartMgr::appendDynamicGeometryPartsToModel( cvf::Mode
}
float arrowScaling = arrowConstantScaling;
if ( result->scaleMethod() == RimElementVectorResult::ScaleMethod::RESULT ||
result->scaleMethod() == RimElementVectorResult::ScaleMethod::RESULT_LOG )
if ( result->scaleMethod() == RimElementVectorResult::ScaleMethod::RESULT )
{
arrowScaling = arrowConstantScaling / maxAbsResult;
}
if ( result->scaleMethod() == RimElementVectorResult::ScaleMethod::RESULT_LOG )
{
arrowScaling = scaleLogarithmically( arrowScaling );
arrowScaling = result->sizeScale() * scaleLogarithmically( maxAbsResult );
}
std::vector<RigEclipseResultAddress> addresses;
@ -200,13 +199,16 @@ void RivElementVectorResultPartMgr::appendDynamicGeometryPartsToModel( cvf::Mode
cvf::Vec3d cellCenter = cells[gcIdx].center() - offset;
cvf::Vec3d faceNormal = ( faceCenter - cellCenter ).getNormalized() * arrowScaling;
aggregatedVector += faceNormal;
if ( result->scaleMethod() == RimElementVectorResult::ScaleMethod::RESULT )
{
faceNormal *= std::abs( resultValue );
faceNormal *= resultValue;
}
else if ( result->scaleMethod() == RimElementVectorResult::ScaleMethod::RESULT_LOG )
{
faceNormal *= scaleLogarithmically( std::abs( resultValue ) );
faceNormal *= ( 1.0 - static_cast<double>( std::signbit( resultValue ) ) * 2.0 ) *
scaleLogarithmically( std::abs( resultValue ) );
}
aggregatedVector += faceNormal;
@ -259,6 +261,7 @@ void RivElementVectorResultPartMgr::appendDynamicGeometryPartsToModel( cvf::Mode
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 )
@ -298,10 +301,10 @@ cvf::ref<cvf::Part>
shaftIndices.reserve( tensorVisualizations.size() * 2 );
std::vector<uint> headIndices;
headIndices.reserve( tensorVisualizations.size() * 3 );
headIndices.reserve( tensorVisualizations.size() * 6 );
std::vector<cvf::Vec3f> vertices;
vertices.reserve( tensorVisualizations.size() * 5 );
vertices.reserve( tensorVisualizations.size() * 7 );
uint counter = 0;
for ( ElementVectorResultVisualization tensor : tensorVisualizations )
@ -321,7 +324,7 @@ cvf::ref<cvf::Part>
headIndices.push_back( index );
}
counter += 5;
counter += 7;
}
cvf::ref<cvf::PrimitiveSetIndexedUInt> indexedUIntShaft =
@ -390,12 +393,12 @@ void RivElementVectorResultPartMgr::createResultColorTextureCoords(
CVF_ASSERT( textureCoords );
CVF_ASSERT( mapper );
size_t vertexCount = elementVectorResultVisualizations.size() * 5;
size_t vertexCount = elementVectorResultVisualizations.size() * 7;
if ( textureCoords->size() != vertexCount ) textureCoords->reserve( vertexCount );
for ( auto evrViz : elementVectorResultVisualizations )
{
for ( size_t vxIdx = 0; vxIdx < 5; ++vxIdx )
for ( size_t vxIdx = 0; vxIdx < 7; ++vxIdx )
{
cvf::Vec2f texCoord = mapper->mapToTextureCoord( evrViz.result );
textureCoords->add( texCoord );
@ -406,10 +409,10 @@ void RivElementVectorResultPartMgr::createResultColorTextureCoords(
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::array<cvf::Vec3f, 5>
std::array<cvf::Vec3f, 7>
RivElementVectorResultPartMgr::createArrowVertices( const ElementVectorResultVisualization& evrViz ) const
{
std::array<cvf::Vec3f, 5> vertices;
std::array<cvf::Vec3f, 7> vertices;
RimElementVectorResult* result = m_rimReservoirView->elementVectorResult();
if ( !result ) return vertices;
@ -424,7 +427,7 @@ std::array<cvf::Vec3f, 5>
}
// Flip arrow for negative results
if ( evrViz.result < 0 )
if ( evrViz.result < 0 && result->vectorView() != RimElementVectorResult::VectorView::AGGREGATED )
{
std::swap( headTop, shaftStart );
}
@ -436,14 +439,18 @@ std::array<cvf::Vec3f, 5>
cvf::Vec3f headBottom = headTop - ( headTop - shaftStart ).getNormalized() * headLength;
// cvf::Vec3f headBottom = headTop - ( headTop - shaftStart ) * 0.2f;
cvf::Vec3f headBottomDirectionH = evrViz.faceNormal ^ evrViz.faceCenter;
cvf::Vec3f arrowBottomSegmentH = headBottomDirectionH.getNormalized() * headLength / 8.0f;
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;
vertices[0] = shaftStart;
vertices[1] = headBottom;
vertices[2] = headBottom + arrowBottomSegmentH;
vertices[3] = headBottom - arrowBottomSegmentH;
vertices[2] = headBottom + arrowBottomSegment1;
vertices[3] = headBottom - arrowBottomSegment1;
vertices[4] = headTop;
vertices[5] = headBottom + arrowBottomSegment2;
vertices[6] = headBottom - arrowBottomSegment2;
return vertices;
}
@ -464,13 +471,17 @@ std::array<uint, 2> RivElementVectorResultPartMgr::createArrowShaftIndices( uint
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::array<uint, 3> RivElementVectorResultPartMgr::createArrowHeadIndices( uint startIndex ) const
std::array<uint, 6> RivElementVectorResultPartMgr::createArrowHeadIndices( uint startIndex ) const
{
std::array<uint, 3> indices;
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[5] = startIndex + 4;
return indices;
}

View File

@ -77,9 +77,9 @@ private:
const std::vector<ElementVectorResultVisualization>& elementVectorResultVisualizations,
const cvf::ScalarMapper* mapper );
std::array<cvf::Vec3f, 5> createArrowVertices( const ElementVectorResultVisualization& tensorVisualization ) const;
std::array<cvf::Vec3f, 7> createArrowVertices( const ElementVectorResultVisualization& tensorVisualization ) const;
std::array<uint, 2> createArrowShaftIndices( uint startIndex ) const;
std::array<uint, 3> createArrowHeadIndices( uint startIndex ) const;
std::array<uint, 6> createArrowHeadIndices( uint startIndex ) const;
double scaleLogarithmically( double value ) const;

View File

@ -369,6 +369,11 @@ void RimElementVectorResult::mappingRange( double& min, double& max ) const
min = std::min<double>( min, directionsMin.at( i ) );
}
}
else
{
max = std::max<double>( max, min );
min = 0.0;
}
}
if ( showNncData() )
@ -382,7 +387,6 @@ void RimElementVectorResult::mappingRange( double& min, double& max ) const
{
if ( combinedAddresses[flIdx].m_resultCatType == RiaDefines::ResultCatType::DYNAMIC_NATIVE )
{
const std::vector<std::vector<double>>* nncResultVals;
if ( m_legendConfig->rangeMode() == RimRegularLegendConfig::RangeModeType::AUTOMATIC_ALLTIMESTEPS )
{
const std::vector<std::vector<double>>* nncResultVals =