#5379 Surface : Add grid case surface

This commit is contained in:
Magne Sjaastad
2020-05-03 11:29:33 +02:00
parent 4d114e36f8
commit 77734b8b57
15 changed files with 641 additions and 85 deletions

View File

@@ -36,7 +36,6 @@ RimSurface::RimSurface()
CAF_PDM_InitObject( "Surface", ":/ReservoirSurface16x16.png", "", "" );
CAF_PDM_InitFieldNoDefault( &m_userDescription, "SurfaceUserDecription", "Name", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_surfaceDefinitionFilePath, "SurfaceFilePath", "File", "", "", "" );
CAF_PDM_InitField( &m_color, "SurfaceColor", cvf::Color3f( 0.5f, 0.3f, 0.2f ), "Color", "", "", "" );
}
@@ -47,26 +46,6 @@ RimSurface::~RimSurface()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSurface::setSurfaceFilePath( const QString& filePath )
{
m_surfaceDefinitionFilePath = filePath;
if ( m_userDescription().isEmpty() )
{
m_userDescription = QFileInfo( filePath ).fileName();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimSurface::surfaceFilePath()
{
return m_surfaceDefinitionFilePath().path();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -91,6 +70,30 @@ QString RimSurface::userDescription()
return m_userDescription();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimSurface::loadData()
{
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSurface::setUserDescription( const QString& description )
{
m_userDescription = description;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSurface::setSurfaceData( RigSurface* surface )
{
m_surfaceData = surface;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -112,54 +115,10 @@ caf::PdmFieldHandle* RimSurface::userDescriptionField()
//--------------------------------------------------------------------------------------------------
void RimSurface::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
{
if ( changedField == &m_surfaceDefinitionFilePath )
{
updateSurfaceDataFromFile();
RimSurfaceCollection* surfColl;
this->firstAncestorOrThisOfTypeAsserted( surfColl );
surfColl->updateViews( {this} );
}
else if ( changedField == &m_color )
if ( changedField == &m_color )
{
RimSurfaceCollection* surfColl;
this->firstAncestorOrThisOfTypeAsserted( surfColl );
surfColl->updateViews( {this} );
}
}
//--------------------------------------------------------------------------------------------------
/// Returns false for fatal failure
//--------------------------------------------------------------------------------------------------
bool RimSurface::updateSurfaceDataFromFile()
{
QString filePath = this->surfaceFilePath();
std::vector<unsigned> tringleIndices;
std::vector<cvf::Vec3d> vertices;
if ( filePath.endsWith( "ptl", Qt::CaseInsensitive ) )
{
auto surface = RifSurfaceReader::readPetrelFile( filePath );
vertices = surface.first;
tringleIndices = surface.second;
}
else if ( filePath.endsWith( "ts", Qt::CaseInsensitive ) )
{
auto surface = RifSurfaceReader::readGocadFile( filePath );
vertices = surface.first;
tringleIndices = surface.second;
}
if ( !vertices.empty() && !tringleIndices.empty() )
{
m_surfaceData = new RigSurface();
m_surfaceData->setTriangleData( tringleIndices, vertices );
return true;
}
return false;
}