2015-11-09 10:42:55 -06:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) Statoil ASA
|
|
|
|
// Copyright (C) Ceetron Solutions AS
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2015-11-09 10:42:55 -06: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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2015-11-09 10:42:55 -06: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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2015-11-09 10:42:55 -06:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RivSingleCellPartGenerator.h"
|
|
|
|
|
2017-01-10 02:51:39 -06:00
|
|
|
#include "RigEclipseCaseData.h"
|
2015-11-11 06:38:54 -06:00
|
|
|
#include "RigFemPartCollection.h"
|
|
|
|
#include "RigGeoMechCaseData.h"
|
2017-01-09 12:51:15 -06:00
|
|
|
#include "RigGridBase.h"
|
2015-11-11 06:38:54 -06:00
|
|
|
|
|
|
|
#include "RimGeoMechCase.h"
|
|
|
|
|
|
|
|
#include "RivFemPartGeometryGenerator.h"
|
2017-02-17 07:52:56 -06:00
|
|
|
#include "RivPartPriority.h"
|
2015-11-09 10:42:55 -06:00
|
|
|
|
|
|
|
#include "cafEffectGenerator.h"
|
|
|
|
#include "cvfPart.h"
|
|
|
|
#include "cvfRenderStateDepth.h"
|
|
|
|
#include "cvfStructGridGeometryGenerator.h"
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-11-09 10:42:55 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-28 03:31:01 -06:00
|
|
|
RivSingleCellPartGenerator::RivSingleCellPartGenerator( RigEclipseCaseData* rigCaseData,
|
|
|
|
size_t gridIndex,
|
|
|
|
size_t cellIndex,
|
|
|
|
const cvf::Vec3d& displayModelOffset )
|
2019-09-06 03:40:57 -05:00
|
|
|
: m_rigCaseData( rigCaseData )
|
|
|
|
, m_gridIndex( gridIndex )
|
|
|
|
, m_cellIndex( cellIndex )
|
|
|
|
, m_geoMechCase( nullptr )
|
2019-11-28 03:31:01 -06:00
|
|
|
, m_displayModelOffset( displayModelOffset )
|
2015-11-11 06:38:54 -06:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-11-11 06:38:54 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-11-28 03:31:01 -06:00
|
|
|
RivSingleCellPartGenerator::RivSingleCellPartGenerator( RimGeoMechCase* rimGeoMechCase,
|
|
|
|
size_t gridIndex,
|
|
|
|
size_t cellIndex,
|
|
|
|
const cvf::Vec3d& displayModelOffset )
|
2019-09-06 03:40:57 -05:00
|
|
|
: m_geoMechCase( rimGeoMechCase )
|
|
|
|
, m_gridIndex( gridIndex )
|
|
|
|
, m_cellIndex( cellIndex )
|
|
|
|
, m_rigCaseData( nullptr )
|
2019-11-28 03:31:01 -06:00
|
|
|
, m_displayModelOffset( displayModelOffset )
|
2015-11-09 10:42:55 -06:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-11-09 10:42:55 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
cvf::ref<cvf::Part> RivSingleCellPartGenerator::createPart( const cvf::Color3f color )
|
2015-11-09 10:42:55 -06:00
|
|
|
{
|
|
|
|
cvf::ref<cvf::Part> part = new cvf::Part;
|
2019-09-06 03:40:57 -05:00
|
|
|
part->setName( cvf::String( "Hightlight part for cell index " ) + cvf::String( (cvf::int64)m_cellIndex ) );
|
|
|
|
part->setDrawable( createMeshDrawable().p() );
|
2015-11-09 10:42:55 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
cvf::ref<cvf::Effect> eff;
|
|
|
|
caf::MeshEffectGenerator effGen( color );
|
2015-11-09 10:42:55 -06:00
|
|
|
eff = effGen.generateUnCachedEffect();
|
|
|
|
|
|
|
|
cvf::ref<cvf::RenderStateDepth> depth = new cvf::RenderStateDepth;
|
2019-09-06 03:40:57 -05:00
|
|
|
depth->enableDepthTest( false );
|
|
|
|
eff->setRenderState( depth.p() );
|
2015-11-09 10:42:55 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
part->setEffect( eff.p() );
|
2015-11-09 10:42:55 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
part->setPriority( RivPartPriority::PartType::Highlight );
|
2015-11-11 06:38:54 -06:00
|
|
|
|
2015-11-09 10:42:55 -06:00
|
|
|
return part;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-11-09 10:42:55 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
cvf::ref<cvf::DrawableGeo> RivSingleCellPartGenerator::createMeshDrawable()
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_rigCaseData && m_cellIndex != cvf::UNDEFINED_SIZE_T )
|
2015-11-09 10:42:55 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
return cvf::StructGridGeometryGenerator::createMeshDrawableFromSingleCell( m_rigCaseData->grid( m_gridIndex ),
|
2019-11-28 03:31:01 -06:00
|
|
|
m_cellIndex,
|
|
|
|
m_displayModelOffset );
|
2015-11-09 10:42:55 -06:00
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
else if ( m_geoMechCase && m_cellIndex != cvf::UNDEFINED_SIZE_T )
|
2015-11-11 06:38:54 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
CVF_ASSERT( m_geoMechCase->geoMechData() );
|
|
|
|
CVF_ASSERT( m_geoMechCase->geoMechData()->femParts()->partCount() > static_cast<int>( m_gridIndex ) );
|
2015-11-11 06:38:54 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
RigFemPart* femPart = m_geoMechCase->geoMechData()->femParts()->part( m_gridIndex );
|
|
|
|
CVF_ASSERT( femPart );
|
2015-11-11 06:38:54 -06:00
|
|
|
|
2020-02-12 04:43:15 -06:00
|
|
|
return RivFemPartGeometryGenerator::createMeshDrawableFromSingleElement( femPart, m_cellIndex, m_displayModelOffset );
|
2015-11-11 06:38:54 -06:00
|
|
|
}
|
2015-11-09 10:42:55 -06:00
|
|
|
|
2018-02-18 11:56:43 -06:00
|
|
|
return nullptr;
|
2015-11-09 10:42:55 -06:00
|
|
|
}
|