mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#5379 Surface : Add grid case surface
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user