wip import pvd

This commit is contained in:
Magne Sjaastad
2025-01-28 18:05:32 +01:00
parent 06ae0314b7
commit d3bd64d91d
6 changed files with 51 additions and 10 deletions

View File

@@ -45,7 +45,7 @@ void RicImportSurfacesFeature::onActionTriggered( bool isChecked )
QStringList fileNames = RiuFileDialogTools::getOpenFileNames( Riu3DMainWindowTools::mainWindowWidget(),
"Import Surfaces",
defaultDir,
"Surface files (*.ptl *.ts *.dat *.vtu *.xyz);;All Files (*.*)" );
"Surface files (*.ptl *.ts *.dat *.vtu *.pvd *.xyz);;All Files (*.*)" );
if ( fileNames.isEmpty() ) return;

View File

@@ -237,7 +237,7 @@ std::vector<RifVtkSurfaceImporter::PvdDataset> parsePvdDatasets( const std::stri
double timestep = std::stod( timestepStr );
std::string fullPath = std::filesystem::absolute( std::filesystem::path( baseDir ) / file ).string();
datasets.push_back( { timestep, fullPath, {} } );
datasets.push_back( { timestep, fullPath } );
}
datasetElem = datasetElem->NextSiblingElement( "DataSet" );

View File

@@ -41,9 +41,8 @@ namespace RifVtkSurfaceImporter
struct PvdDataset
{
double timestep;
std::string filename;
std::map<std::string, std::vector<float>> properties;
double timestep;
std::string filename;
};
bool importFromFile( std::string filename, RigGocadData* gocadData );

View File

@@ -119,6 +119,12 @@ void RimFractureSurface::fieldChangedByUi( const caf::PdmFieldHandle* changedFie
bool RimFractureSurface::updateSurfaceData()
{
bool result = true;
if ( m_surfacePerTimeStep.empty() )
{
loadDataFromFile();
}
/*
if ( m_vertices.empty() )
{
@@ -157,6 +163,9 @@ bool RimFractureSurface::updateSurfaceData()
//--------------------------------------------------------------------------------------------------
void RimFractureSurface::clearCachedNativeData()
{
m_secondsSinceSimulationStart.clear();
m_surfacePerTimeStep.clear();
/*
m_vertices.clear();
m_tringleIndices.clear();
@@ -168,6 +177,18 @@ void RimFractureSurface::clearCachedNativeData()
//--------------------------------------------------------------------------------------------------
bool RimFractureSurface::loadDataFromFile()
{
auto surfaceInfo = RifVtkSurfaceImporter::parsePvdDatasets( m_surfaceDefinitionFilePath().path().toStdString() );
for ( const auto& s : surfaceInfo )
{
RigGocadData gocadData;
if ( RifVtkSurfaceImporter::importFromFile( s.filename, &gocadData ) )
{
m_secondsSinceSimulationStart.push_back( s.timestep );
m_surfacePerTimeStep.push_back( gocadData );
}
}
return false;
/*

View File

@@ -20,6 +20,11 @@
#include "RimSurface.h"
#include "cafPdmChildArrayField.h"
class RimFileSurface;
class RigGocadData;
class RimFractureSurface : public RimSurface
{
CAF_PDM_HEADER_INIT;
@@ -45,4 +50,7 @@ private:
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
caf::PdmField<caf::FilePath> m_surfaceDefinitionFilePath;
std::vector<size_t> m_secondsSinceSimulationStart;
std::vector<RigGocadData> m_surfacePerTimeStep;
};

View File

@@ -41,6 +41,7 @@
#include "cafPdmFieldScriptingCapability.h"
#include "cafPdmObjectScriptingCapability.h"
#include "RimFractureSurface.h"
#include <QFile>
#include <QFileInfo>
@@ -142,14 +143,26 @@ RimSurface* RimSurfaceCollection::importSurfacesFromFiles( const QStringList& fi
for ( const QString& newFileName : fileNames )
{
RimFileSurface* newSurface = new RimFileSurface;
RimSurface* newSurface = nullptr;
if ( newFileName.endsWith( ".pvd" ) )
{
RimFractureSurface* fractureSurface = new RimFractureSurface;
fractureSurface->setSurfaceFilePath( newFileName );
newSurface = fractureSurface;
}
else
{
RimFileSurface* fileSurface = new RimFileSurface;
fileSurface->setSurfaceFilePath( newFileName );
newSurface = fileSurface;
}
auto newColor = RiaColorTables::categoryPaletteColors().cycledColor3f( existingSurfCount + newSurfCount );
newSurface->setSurfaceFilePath( newFileName );
newSurface->setUserDescription( QFileInfo( newFileName ).fileName() );
newSurface->setColor( newColor );
newSurface->setUserDescription( QFileInfo( newFileName ).fileName() );
if ( !newSurface->onLoadData() )
{