2015-04-24 08:53:50 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2015- Statoil ASA
|
|
|
|
// Copyright (C) 2015- Ceetron Solutions AS
|
2018-09-21 04:43:03 -05:00
|
|
|
//
|
2015-04-24 08:53:50 -05:00
|
|
|
// 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.
|
2018-09-21 04:43:03 -05:00
|
|
|
//
|
2015-04-24 08:53:50 -05:00
|
|
|
// 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.
|
2018-09-21 04:43:03 -05:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2015-04-24 08:53:50 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2019-01-10 09:16:49 -06:00
|
|
|
#include <cstdlib>
|
2016-10-18 00:31:02 -05:00
|
|
|
|
2021-10-06 19:12:42 -05:00
|
|
|
#include "RivFemPartPartMgr.h"
|
|
|
|
|
2015-04-24 08:53:50 -05:00
|
|
|
#include "RivGeoMechPartMgr.h"
|
|
|
|
|
|
|
|
#include "RiaPreferences.h"
|
|
|
|
|
2016-10-18 00:31:02 -05:00
|
|
|
#include "RifGeoMechReaderInterface.h"
|
|
|
|
|
2021-10-06 19:12:42 -05:00
|
|
|
#include "RigFemPart.h"
|
2016-10-18 00:31:02 -05:00
|
|
|
#include "RigFemPartResultsCollection.h"
|
|
|
|
#include "RigFemScalarResultFrames.h"
|
|
|
|
#include "RigGeoMechCaseData.h"
|
|
|
|
|
2015-05-21 03:34:38 -05:00
|
|
|
#include "RimEclipseView.h"
|
2015-06-25 06:32:00 -05:00
|
|
|
#include "RimGeoMechCellColors.h"
|
2015-06-17 08:07:20 -05:00
|
|
|
#include "RimGeoMechView.h"
|
2018-04-18 03:10:39 -05:00
|
|
|
#include "RimRegularLegendConfig.h"
|
2015-04-24 08:53:50 -05:00
|
|
|
|
2016-10-18 00:31:02 -05:00
|
|
|
#include "RivFemPickSourceInfo.h"
|
2018-09-21 04:36:32 -05:00
|
|
|
#include "RivMeshLinesSourceInfo.h"
|
2017-02-17 07:52:56 -06:00
|
|
|
#include "RivPartPriority.h"
|
2015-04-24 08:53:50 -05:00
|
|
|
#include "RivResultToTextureMapper.h"
|
|
|
|
#include "RivScalarMapperUtils.h"
|
|
|
|
#include "RivSourceInfo.h"
|
|
|
|
#include "RivTextureCoordsCreator.h"
|
|
|
|
|
|
|
|
#include "cafEffectGenerator.h"
|
|
|
|
|
|
|
|
#include "cvfDrawableGeo.h"
|
|
|
|
#include "cvfModelBasicList.h"
|
|
|
|
#include "cvfPart.h"
|
|
|
|
#include "cvfRenderStateBlending.h"
|
|
|
|
#include "cvfRenderStatePolygonOffset.h"
|
2018-09-21 04:43:03 -05:00
|
|
|
#include "cvfRenderState_FF.h"
|
2015-04-24 08:53:50 -05:00
|
|
|
#include "cvfShaderProgram.h"
|
|
|
|
#include "cvfShaderProgramGenerator.h"
|
|
|
|
#include "cvfShaderSourceProvider.h"
|
|
|
|
#include "cvfShaderSourceRepository.h"
|
|
|
|
#include "cvfStructGrid.h"
|
2017-02-24 04:07:15 -06:00
|
|
|
#include "cvfTransform.h"
|
2015-04-24 08:53:50 -05:00
|
|
|
#include "cvfUniform.h"
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-09-21 04:43:03 -05:00
|
|
|
///
|
2015-04-24 08:53:50 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2021-09-27 05:44:29 -05:00
|
|
|
RivFemPartPartMgr::RivFemPartPartMgr( const RigFemPart* part, cvf::Vec3d displayOffset )
|
|
|
|
: m_surfaceGenerator( part, displayOffset )
|
|
|
|
, m_part( part )
|
2019-09-06 03:40:57 -05:00
|
|
|
, m_opacityLevel( 1.0f )
|
|
|
|
, m_defaultColor( cvf::Color3::WHITE )
|
2015-04-24 08:53:50 -05:00
|
|
|
{
|
2021-09-27 05:44:29 -05:00
|
|
|
CVF_ASSERT( part );
|
|
|
|
m_partIdx = part->elementPartId();
|
2018-09-21 04:43:03 -05:00
|
|
|
m_cellVisibility = new cvf::UByteArray;
|
2015-04-24 08:53:50 -05:00
|
|
|
m_surfaceFacesTextureCoords = new cvf::Vec2fArray;
|
|
|
|
}
|
|
|
|
|
2021-09-27 05:44:29 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RivFemPartPartMgr::~RivFemPartPartMgr()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-04-24 08:53:50 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-09-21 04:43:03 -05:00
|
|
|
///
|
2015-04-24 08:53:50 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RivFemPartPartMgr::setTransform( cvf::Transform* scaleTransform )
|
2015-04-24 08:53:50 -05:00
|
|
|
{
|
|
|
|
m_scaleTransform = scaleTransform;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-09-21 04:43:03 -05:00
|
|
|
///
|
2015-04-24 08:53:50 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RivFemPartPartMgr::setCellVisibility( cvf::UByteArray* cellVisibilities )
|
2015-04-24 08:53:50 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
CVF_ASSERT( m_scaleTransform.notNull() );
|
|
|
|
CVF_ASSERT( cellVisibilities );
|
2015-04-24 08:53:50 -05:00
|
|
|
|
|
|
|
m_cellVisibility = cellVisibilities;
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
m_surfaceGenerator.setElementVisibility( cellVisibilities );
|
2015-04-24 08:53:50 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
generatePartGeometry( m_surfaceGenerator );
|
2015-04-24 08:53:50 -05:00
|
|
|
}
|
|
|
|
|
2021-10-06 19:12:42 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2023-02-26 03:48:40 -06:00
|
|
|
void RivFemPartPartMgr::setDisplacements( bool useDisplacements, double scalingFactor, const std::vector<cvf::Vec3f>& displacements )
|
2021-10-06 19:12:42 -05:00
|
|
|
{
|
|
|
|
size_t nodeCount = m_part->nodes().coordinates.size();
|
|
|
|
m_displacedNodeCoordinates.resize( nodeCount );
|
|
|
|
const auto coords = m_part->nodes().coordinates;
|
|
|
|
|
|
|
|
if ( useDisplacements )
|
|
|
|
{
|
|
|
|
for ( size_t i = 0; i < nodeCount; i++ )
|
|
|
|
{
|
|
|
|
m_displacedNodeCoordinates[i] = coords[i] + displacements[i] * scalingFactor;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for ( size_t i = 0; i < nodeCount; i++ )
|
|
|
|
{
|
|
|
|
m_displacedNodeCoordinates[i] = coords[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-21 04:36:32 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-09-21 04:43:03 -05:00
|
|
|
///
|
2018-09-21 04:36:32 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RivFemPartPartMgr::generatePartGeometry( RivFemPartGeometryGenerator& geoBuilder )
|
2015-04-24 08:53:50 -05:00
|
|
|
{
|
|
|
|
bool useBufferObjects = true;
|
|
|
|
// Surface geometry
|
2018-09-21 04:43:03 -05:00
|
|
|
{
|
2018-02-18 11:56:43 -06:00
|
|
|
m_surfaceFaces = nullptr; // To possibly free memory before adding the new stuff
|
2015-05-13 07:27:39 -05:00
|
|
|
|
2021-10-06 19:12:42 -05:00
|
|
|
cvf::ref<cvf::DrawableGeo> geo = geoBuilder.generateSurface( m_displacedNodeCoordinates );
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( geo.notNull() )
|
2015-04-24 08:53:50 -05:00
|
|
|
{
|
|
|
|
geo->computeNormals();
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( useBufferObjects )
|
2015-04-24 08:53:50 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
geo->setRenderMode( cvf::DrawableGeo::BUFFER_OBJECT );
|
2015-04-24 08:53:50 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
cvf::ref<cvf::Part> part = new cvf::Part;
|
2021-09-27 05:44:29 -05:00
|
|
|
part->setName( "FemPart " + cvf::String( m_partIdx ) );
|
|
|
|
part->setId( m_partIdx ); // Use part index as part ID
|
2019-09-06 03:40:57 -05:00
|
|
|
part->setDrawable( geo.p() );
|
|
|
|
part->setTransform( m_scaleTransform.p() );
|
2015-04-24 08:53:50 -05:00
|
|
|
|
2015-06-05 08:17:02 -05:00
|
|
|
// Set mapping from triangle face index to element index
|
2021-09-27 05:44:29 -05:00
|
|
|
cvf::ref<RivFemPickSourceInfo> si = new RivFemPickSourceInfo( m_partIdx, geoBuilder.triangleToElementMapper() );
|
2019-09-06 03:40:57 -05:00
|
|
|
part->setSourceInfo( si.p() );
|
2015-04-24 08:53:50 -05:00
|
|
|
|
|
|
|
part->updateBoundingBox();
|
2018-09-21 04:43:03 -05:00
|
|
|
|
2015-04-24 08:53:50 -05:00
|
|
|
// Set default effect
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::SurfaceEffectGenerator geometryEffgen( cvf::Color4f( cvf::Color3f::WHITE ), caf::PO_1 );
|
2018-09-21 04:43:03 -05:00
|
|
|
cvf::ref<cvf::Effect> geometryOnlyEffect = geometryEffgen.generateCachedEffect();
|
2019-09-06 03:40:57 -05:00
|
|
|
part->setEffect( geometryOnlyEffect.p() );
|
|
|
|
part->setEnableMask( surfaceBit );
|
2015-04-24 08:53:50 -05:00
|
|
|
m_surfaceFaces = part;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Mesh geometry
|
|
|
|
{
|
2018-02-18 11:56:43 -06:00
|
|
|
m_surfaceGridLines = nullptr; // To possibly free memory before adding the new stuff
|
2015-05-13 07:27:39 -05:00
|
|
|
|
2015-04-24 08:53:50 -05:00
|
|
|
cvf::ref<cvf::DrawableGeo> geoMesh = geoBuilder.createMeshDrawable();
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( geoMesh.notNull() )
|
2015-04-24 08:53:50 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( useBufferObjects )
|
2015-04-24 08:53:50 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
geoMesh->setRenderMode( cvf::DrawableGeo::BUFFER_OBJECT );
|
2015-04-24 08:53:50 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
cvf::ref<cvf::Part> part = new cvf::Part;
|
2021-09-27 05:44:29 -05:00
|
|
|
part->setName( "Grid mesh " + cvf::String( m_partIdx ) );
|
2019-09-06 03:40:57 -05:00
|
|
|
part->setDrawable( geoMesh.p() );
|
2015-04-24 08:53:50 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
part->setTransform( m_scaleTransform.p() );
|
2015-04-24 08:53:50 -05:00
|
|
|
part->updateBoundingBox();
|
|
|
|
|
2021-04-28 03:29:53 -05:00
|
|
|
RiaPreferences* prefs = RiaPreferences::current();
|
2015-04-24 08:53:50 -05:00
|
|
|
|
2018-09-21 04:43:03 -05:00
|
|
|
cvf::ref<cvf::Effect> eff;
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::MeshEffectGenerator effGen( prefs->defaultGridLineColors() );
|
2015-08-13 07:35:30 -05:00
|
|
|
eff = effGen.generateCachedEffect();
|
2015-04-24 08:53:50 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
part->setPriority( RivPartPriority::PartType::MeshLines );
|
2015-04-24 08:53:50 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
part->setEnableMask( meshSurfaceBit );
|
|
|
|
part->setEffect( eff.p() );
|
2018-09-21 04:36:32 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
part->setSourceInfo( new RivMeshLinesSourceInfo( nullptr ) );
|
2018-09-21 04:36:32 -05:00
|
|
|
|
2015-04-24 08:53:50 -05:00
|
|
|
m_surfaceGridLines = part;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-09-21 04:43:03 -05:00
|
|
|
///
|
2015-04-24 08:53:50 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RivFemPartPartMgr::appendPartsToModel( cvf::ModelBasicList* model )
|
2015-04-24 08:53:50 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
CVF_ASSERT( model != nullptr );
|
2015-04-24 08:53:50 -05:00
|
|
|
|
2021-09-27 05:44:29 -05:00
|
|
|
if ( m_part->enabled() )
|
|
|
|
{
|
|
|
|
if ( m_surfaceFaces.notNull() ) model->addPart( m_surfaceFaces.p() );
|
|
|
|
if ( m_surfaceGridLines.notNull() ) model->addPart( m_surfaceGridLines.p() );
|
|
|
|
}
|
2015-04-24 08:53:50 -05:00
|
|
|
}
|
|
|
|
|
2018-02-08 09:43:12 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-09-21 04:43:03 -05:00
|
|
|
///
|
2018-02-08 09:43:12 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
const RivFemPartGeometryGenerator* RivFemPartPartMgr::surfaceGenerator() const
|
|
|
|
{
|
|
|
|
return &m_surfaceGenerator;
|
|
|
|
}
|
|
|
|
|
2015-04-24 08:53:50 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-09-21 04:43:03 -05:00
|
|
|
///
|
2015-04-24 08:53:50 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RivFemPartPartMgr::updateCellColor( cvf::Color4f color )
|
2015-04-24 08:53:50 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_surfaceFaces.isNull() ) return;
|
2021-09-27 05:44:29 -05:00
|
|
|
if ( !m_part->enabled() ) return;
|
2015-04-24 08:53:50 -05:00
|
|
|
|
|
|
|
// Set default effect
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::SurfaceEffectGenerator geometryEffgen( color, caf::PO_1 );
|
2018-09-21 04:43:03 -05:00
|
|
|
cvf::ref<cvf::Effect> geometryOnlyEffect = geometryEffgen.generateCachedEffect();
|
2015-04-24 08:53:50 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_surfaceFaces.notNull() ) m_surfaceFaces->setEffect( geometryOnlyEffect.p() );
|
2015-04-24 08:53:50 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( color.a() < 1.0f )
|
2015-04-24 08:53:50 -05:00
|
|
|
{
|
|
|
|
// Set priority to make sure this transparent geometry are rendered last
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_surfaceFaces.notNull() ) m_surfaceFaces->setPriority( RivPartPriority::PartType::Transparent );
|
2015-04-24 08:53:50 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
m_opacityLevel = color.a();
|
|
|
|
m_defaultColor = color.toColor3f();
|
|
|
|
|
|
|
|
// Update mesh colors as well, in case of change
|
2021-04-28 03:29:53 -05:00
|
|
|
RiaPreferences* prefs = RiaPreferences::current();
|
2015-04-24 08:53:50 -05:00
|
|
|
|
|
|
|
cvf::ref<cvf::Effect> eff;
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_surfaceFaces.notNull() )
|
2015-04-24 08:53:50 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::MeshEffectGenerator effGen( prefs->defaultGridLineColors() );
|
2015-08-13 07:35:30 -05:00
|
|
|
eff = effGen.generateCachedEffect();
|
2019-09-06 03:40:57 -05:00
|
|
|
m_surfaceGridLines->setEffect( eff.p() );
|
2015-04-24 08:53:50 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-09-21 04:43:03 -05:00
|
|
|
///
|
2015-04-24 08:53:50 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2023-01-18 07:42:33 -06:00
|
|
|
void RivFemPartPartMgr::updateCellResultColor( int timeStepIndex, int frameIndex, RimGeoMechCellColors* cellResultColors )
|
2015-04-24 08:53:50 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
CVF_ASSERT( cellResultColors );
|
2015-04-24 08:53:50 -05:00
|
|
|
|
2021-09-27 05:44:29 -05:00
|
|
|
if ( !m_part->enabled() ) return;
|
|
|
|
|
2015-04-24 08:53:50 -05:00
|
|
|
cvf::ref<cvf::Color3ubArray> surfaceFacesColorArray;
|
|
|
|
|
|
|
|
// Outer surface
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_surfaceFaces.notNull() )
|
2015-05-04 11:16:57 -05:00
|
|
|
{
|
2015-06-25 07:34:20 -05:00
|
|
|
const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper();
|
2015-05-06 09:07:30 -05:00
|
|
|
|
2015-06-25 07:34:20 -05:00
|
|
|
RigGeoMechCaseData* caseData = cellResultColors->ownerCaseData();
|
2018-09-21 04:43:03 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !caseData ) return;
|
2015-05-06 09:07:30 -05:00
|
|
|
|
2015-06-25 07:34:20 -05:00
|
|
|
RigFemResultAddress resVarAddress = cellResultColors->resultAddress();
|
2015-05-08 03:34:57 -05:00
|
|
|
|
2015-09-28 00:39:57 -05:00
|
|
|
// Do a "Hack" to show elm nodal and not nodal POR results
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( resVarAddress.resultPosType == RIG_NODAL && resVarAddress.fieldName == "POR-Bar" )
|
2018-09-21 04:43:03 -05:00
|
|
|
{
|
|
|
|
resVarAddress.resultPosType = RIG_ELEMENT_NODAL;
|
|
|
|
}
|
2015-09-28 00:39:57 -05:00
|
|
|
|
2020-02-12 04:43:15 -06:00
|
|
|
const std::vector<float>& resultValues =
|
2023-01-18 07:42:33 -06:00
|
|
|
caseData->femPartResults()->resultValues( resVarAddress, m_partIdx, timeStepIndex, frameIndex );
|
2015-05-06 09:07:30 -05:00
|
|
|
|
2018-02-18 11:56:43 -06:00
|
|
|
const std::vector<size_t>* vxToResultMapping = nullptr;
|
2018-09-21 04:43:03 -05:00
|
|
|
int vxCount = 0;
|
2015-05-06 09:07:30 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( resVarAddress.resultPosType == RIG_NODAL )
|
2015-05-06 09:07:30 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
vxToResultMapping = &( m_surfaceGenerator.quadVerticesToNodeIdxMapping() );
|
2015-05-06 09:07:30 -05:00
|
|
|
}
|
2020-02-12 04:43:15 -06:00
|
|
|
else if ( resVarAddress.resultPosType == RIG_ELEMENT_NODAL || resVarAddress.resultPosType == RIG_INTEGRATION_POINT ||
|
2019-09-06 03:40:57 -05:00
|
|
|
resVarAddress.resultPosType == RIG_FORMATION_NAMES )
|
2015-05-06 09:07:30 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
vxToResultMapping = &( m_surfaceGenerator.quadVerticesToGlobalElmNodeIdx() );
|
2015-05-06 09:07:30 -05:00
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
else if ( resVarAddress.resultPosType == RIG_ELEMENT_NODAL_FACE )
|
2016-10-19 05:22:13 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
vxToResultMapping = &( m_surfaceGenerator.quadVerticesToGlobalElmFaceNodeIdx() );
|
2016-10-19 05:22:13 -05:00
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
else if ( resVarAddress.resultPosType == RIG_ELEMENT )
|
2018-01-10 07:14:36 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
vxToResultMapping = &( m_surfaceGenerator.quadVerticesToGlobalElmIdx() );
|
2018-01-10 07:14:36 -06:00
|
|
|
}
|
2018-09-21 04:43:03 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !vxToResultMapping ) return;
|
2018-09-21 04:43:03 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
vxCount = static_cast<int>( vxToResultMapping->size() );
|
|
|
|
m_surfaceFacesTextureCoords->resize( vxCount );
|
2015-05-04 11:16:57 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( resultValues.size() == 0 )
|
2015-05-04 11:16:57 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
m_surfaceFacesTextureCoords->setAll( cvf::Vec2f( 0.0, 1.0f ) );
|
2015-06-09 04:09:11 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cvf::Vec2f* rawPtr = m_surfaceFacesTextureCoords->ptr();
|
2015-05-04 11:16:57 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
#pragma omp parallel for schedule( dynamic )
|
|
|
|
for ( int quadStartIdx = 0; quadStartIdx < vxCount; quadStartIdx += 4 )
|
2015-05-04 11:16:57 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
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 )
|
2015-06-09 04:09:11 -05:00
|
|
|
{
|
2018-09-21 04:43:03 -05:00
|
|
|
rawPtr[quadStartIdx][1] = 1.0f;
|
|
|
|
rawPtr[quadStartIdx + 1][1] = 1.0f;
|
|
|
|
rawPtr[quadStartIdx + 2][1] = 1.0f;
|
|
|
|
rawPtr[quadStartIdx + 3][1] = 1.0f;
|
2015-06-09 04:09:11 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
rawPtr[quadStartIdx] = mapper->mapToTextureCoord( resultValue1 );
|
|
|
|
rawPtr[quadStartIdx + 1] = mapper->mapToTextureCoord( resultValue2 );
|
|
|
|
rawPtr[quadStartIdx + 2] = mapper->mapToTextureCoord( resultValue3 );
|
|
|
|
rawPtr[quadStartIdx + 3] = mapper->mapToTextureCoord( resultValue4 );
|
2015-06-09 04:09:11 -05:00
|
|
|
}
|
2015-05-04 11:16:57 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-12 14:41:34 -05:00
|
|
|
auto view = cellResultColors->firstAncestorOrThisOfTypeAsserted<Rim3dView>();
|
2019-09-06 03:40:57 -05:00
|
|
|
|
|
|
|
RivScalarMapperUtils::applyTextureResultsToPart( m_surfaceFaces.p(),
|
|
|
|
m_surfaceFacesTextureCoords.p(),
|
|
|
|
mapper,
|
|
|
|
m_opacityLevel,
|
|
|
|
caf::FC_NONE,
|
|
|
|
view->isLightingDisabled() );
|
2015-05-04 11:16:57 -05:00
|
|
|
}
|
2015-04-24 08:53:50 -05:00
|
|
|
}
|