mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Ensemble Surface improvements
* Performance : Improve surface import * Performance: Use opm when importing files * Surface : Use the triangle size as basis for the maximum search distance * Performance : Resample surfaces in parallell * Performance: Import file surfaces in parallell * Ensemble Surface : Create one ensemble per surface
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RifSurfaceImporter.h"
|
||||
#include "RiaStdStringTools.h"
|
||||
#include "RigGocadData.h"
|
||||
|
||||
#include "cafProgressInfo.h"
|
||||
@@ -61,7 +62,12 @@ void RifSurfaceImporter::readGocadFile( const QString& filename, RigGocadData* g
|
||||
std::vector<std::vector<float>> propertyValues;
|
||||
|
||||
{
|
||||
std::ifstream stream( filename.toLatin1().data() );
|
||||
std::stringstream stream;
|
||||
{
|
||||
// Read the file content into a stringstream to avoid expensive file operations
|
||||
std::ifstream t( filename.toLatin1().data() );
|
||||
stream << t.rdbuf();
|
||||
}
|
||||
|
||||
bool isInTfaceSection = false;
|
||||
GocadZPositive zDir = GocadZPositive::Unknown;
|
||||
@@ -71,75 +77,77 @@ void RifSurfaceImporter::readGocadFile( const QString& filename, RigGocadData* g
|
||||
std::string line;
|
||||
std::getline( stream, line );
|
||||
|
||||
std::transform( line.begin(), line.end(), line.begin(), ::toupper );
|
||||
|
||||
std::istringstream lineStream( line );
|
||||
auto tokens = RiaStdStringTools::splitString( line, ' ' );
|
||||
|
||||
std::string firstToken;
|
||||
lineStream >> firstToken;
|
||||
if ( !tokens.empty() ) firstToken = tokens.front();
|
||||
|
||||
if ( isInTfaceSection )
|
||||
{
|
||||
if ( firstToken.compare( "VRTX" ) == 0 )
|
||||
{
|
||||
int vertexId = -1;
|
||||
double x{ std::numeric_limits<double>::infinity() };
|
||||
double y{ std::numeric_limits<double>::infinity() };
|
||||
double z{ std::numeric_limits<double>::infinity() };
|
||||
std::string endVertex;
|
||||
|
||||
lineStream >> vertexId >> x >> y >> z >> endVertex;
|
||||
|
||||
if ( vertexId > -1 )
|
||||
if ( tokens.size() > 4 )
|
||||
{
|
||||
if ( zDir == GocadZPositive::Depth )
|
||||
{
|
||||
z = -z;
|
||||
}
|
||||
int vertexId = RiaStdStringTools::toInt( tokens[1] );
|
||||
double x = RiaStdStringTools::toDouble( tokens[2] );
|
||||
double y = RiaStdStringTools::toDouble( tokens[3] );
|
||||
double z = RiaStdStringTools::toDouble( tokens[4] );
|
||||
|
||||
vertices.emplace_back( cvf::Vec3d( x, y, z ) );
|
||||
vertexIdToIndex[vertexId] = static_cast<unsigned>( vertices.size() - 1 );
|
||||
if ( vertexId > -1 )
|
||||
{
|
||||
if ( zDir == GocadZPositive::Depth )
|
||||
{
|
||||
z = -z;
|
||||
}
|
||||
|
||||
vertices.emplace_back( cvf::Vec3d( x, y, z ) );
|
||||
vertexIdToIndex[vertexId] = static_cast<unsigned>( vertices.size() - 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( firstToken.compare( "PVRTX" ) == 0 )
|
||||
{
|
||||
int vertexId = -1;
|
||||
double x{ std::numeric_limits<double>::infinity() };
|
||||
double y{ std::numeric_limits<double>::infinity() };
|
||||
double z{ std::numeric_limits<double>::infinity() };
|
||||
|
||||
lineStream >> vertexId >> x >> y >> z;
|
||||
|
||||
if ( vertexId > -1 )
|
||||
if ( tokens.size() > 4 )
|
||||
{
|
||||
if ( zDir == GocadZPositive::Depth ) z = -z;
|
||||
int vertexId = RiaStdStringTools::toInt( tokens[1] );
|
||||
double x = RiaStdStringTools::toDouble( tokens[2] );
|
||||
double y = RiaStdStringTools::toDouble( tokens[3] );
|
||||
double z = RiaStdStringTools::toDouble( tokens[4] );
|
||||
|
||||
vertices.emplace_back( cvf::Vec3d( x, y, z ) );
|
||||
vertexIdToIndex[vertexId] = static_cast<unsigned>( vertices.size() - 1 );
|
||||
}
|
||||
if ( vertexId > -1 )
|
||||
{
|
||||
if ( zDir == GocadZPositive::Depth ) z = -z;
|
||||
|
||||
for ( size_t i = 0; i < propertyNames.size(); i++ )
|
||||
{
|
||||
float value = std::numeric_limits<double>::infinity();
|
||||
vertices.emplace_back( cvf::Vec3d( x, y, z ) );
|
||||
vertexIdToIndex[vertexId] = static_cast<unsigned>( vertices.size() - 1 );
|
||||
|
||||
lineStream >> value;
|
||||
for ( size_t i = 0; i < propertyNames.size(); i++ )
|
||||
{
|
||||
float value = std::numeric_limits<double>::infinity();
|
||||
|
||||
propertyValues[i].push_back( value );
|
||||
auto tokenIndex = 5 + i;
|
||||
if ( tokenIndex < tokens.size() )
|
||||
value = RiaStdStringTools::toDouble( tokens[tokenIndex] );
|
||||
|
||||
propertyValues[i].push_back( value );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( firstToken.compare( "TRGL" ) == 0 )
|
||||
{
|
||||
int id1{ -1 };
|
||||
int id2{ -1 };
|
||||
int id3{ -1 };
|
||||
|
||||
lineStream >> id1 >> id2 >> id3;
|
||||
|
||||
if ( id1 >= 0 && id2 >= 0 && id3 >= 0 )
|
||||
if ( tokens.size() > 3 )
|
||||
{
|
||||
trianglesByIds.emplace_back( static_cast<unsigned int>( id1 ) );
|
||||
trianglesByIds.emplace_back( static_cast<unsigned int>( id2 ) );
|
||||
trianglesByIds.emplace_back( static_cast<unsigned int>( id3 ) );
|
||||
auto id1 = RiaStdStringTools::toInt( tokens[1] );
|
||||
auto id2 = RiaStdStringTools::toInt( tokens[2] );
|
||||
auto id3 = RiaStdStringTools::toInt( tokens[3] );
|
||||
|
||||
if ( id1 >= 0 && id2 >= 0 && id3 >= 0 )
|
||||
{
|
||||
trianglesByIds.emplace_back( static_cast<unsigned int>( id1 ) );
|
||||
trianglesByIds.emplace_back( static_cast<unsigned int>( id2 ) );
|
||||
trianglesByIds.emplace_back( static_cast<unsigned int>( id3 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( firstToken.compare( "END" ) == 0 )
|
||||
@@ -153,19 +161,9 @@ void RifSurfaceImporter::readGocadFile( const QString& filename, RigGocadData* g
|
||||
}
|
||||
else if ( firstToken.compare( "PROPERTIES" ) == 0 )
|
||||
{
|
||||
QString qstringLine = QString::fromStdString( line );
|
||||
|
||||
qstringLine.remove( "PROPERTIES" );
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK( 5, 15, 0 )
|
||||
QStringList words = qstringLine.split( " ", Qt::SkipEmptyParts );
|
||||
#else
|
||||
QStringList words = qstringLine.split( " ", QString::SkipEmptyParts );
|
||||
#endif
|
||||
|
||||
for ( auto w : words )
|
||||
for ( size_t i = 1; i < tokens.size(); i++ )
|
||||
{
|
||||
propertyNames.push_back( w );
|
||||
propertyNames.push_back( QString::fromStdString( tokens[i] ) );
|
||||
}
|
||||
|
||||
propertyValues.resize( propertyNames.size() );
|
||||
@@ -173,8 +171,8 @@ void RifSurfaceImporter::readGocadFile( const QString& filename, RigGocadData* g
|
||||
else if ( firstToken.compare( "ZPOSITIVE" ) == 0 )
|
||||
{
|
||||
std::string secondToken;
|
||||
lineStream >> secondToken;
|
||||
|
||||
if ( tokens.size() > 1 ) secondToken = RiaStdStringTools::toUpper( tokens[1] );
|
||||
if ( secondToken == "DEPTH" )
|
||||
{
|
||||
zDir = GocadZPositive::Depth;
|
||||
@@ -368,8 +366,8 @@ std::pair<std::vector<cvf::Vec3d>, std::vector<unsigned>>
|
||||
auto to2d = []( const cvf::Vec3d vector ) -> cvf::Vec2d { return cvf::Vec2d( vector.x(), vector.y() ); };
|
||||
auto to3d = []( const cvf::Vec2d vector ) -> cvf::Vec3d { return cvf::Vec3d( vector.x(), vector.y(), 0.0 ); };
|
||||
|
||||
// Checks if the given vector is a possible new candidate for an axis vector and adds it to the given list of
|
||||
// axesVectorCandidates. Also increases the number of occurrences of vector candidates.
|
||||
// Checks if the given vector is a possible new candidate for an axis vector and adds it to the given list
|
||||
// of axesVectorCandidates. Also increases the number of occurrences of vector candidates.
|
||||
auto maybeInsertAxisVectorCandidate =
|
||||
[epsilon]( const cvf::Vec2d vector,
|
||||
std::map<cvf::Vec2d, double, vec2dCompare>& axesVectorCandidates,
|
||||
|
||||
Reference in New Issue
Block a user