mirror of
https://github.com/OPM/ResInsight.git
synced 2026-09-03 20:53:13 -05:00
WIP: Surface : Add export of surface to PTL file format #5957
- restructured according to issue - but issue indicate export of K-layer only despite RimGridCaseSurface did support I/ slices, too? - if so, test and possibly extend RimGridCaseSurface methods extractDataFromGrid() and getStructGridIndex() - need to check whether all offsets are taken care of
This commit is contained in:
committed by
Magne Sjaastad
parent
0424202461
commit
9a3dace180
@@ -55,6 +55,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RifRoffReader.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifColorLegendData.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifElasticPropertiesReader.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifFractureModelPlotExporter.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifSurfaceExporter.h
|
||||
|
||||
|
||||
# HDF5 file reader is directly included in ResInsight main CmakeList.txt
|
||||
#${CMAKE_CURRENT_LIST_DIR}/RifHdf5Reader.h
|
||||
@@ -114,6 +116,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RifRoffReader.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifColorLegendData.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifElasticPropertiesReader.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifFractureModelPlotExporter.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifSurfaceExporter.cpp
|
||||
|
||||
# HDF5 file reader is directly included in ResInsight main CmakeList.txt
|
||||
#${CMAKE_CURRENT_LIST_DIR}/RifHdf5Reader.cpp
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020- Equinor ASA
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RifSurfaceExporter.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QTextStream>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifSurfaceExporter::writeGocadTSurfFile( const QString& fileName,
|
||||
const QString& headerText,
|
||||
const std::vector<cvf::Vec3d>& vertices,
|
||||
const std::vector<unsigned>& triangleIndices )
|
||||
{
|
||||
QFile exportFile( fileName );
|
||||
|
||||
if ( !exportFile.open( QIODevice::WriteOnly | QIODevice::Text ) ) return false;
|
||||
|
||||
QTextStream out( &exportFile );
|
||||
|
||||
QString headerForExport = headerText;
|
||||
if ( headerText.isEmpty() ) headerForExport = "surface";
|
||||
|
||||
out << "GOCAD TSurf 1 \n";
|
||||
out << "HEADER { \n";
|
||||
out << "name:" + headerText + " \n";
|
||||
out << "} \n";
|
||||
out << "GOCAD_ORIGINAL_COORDINATE_SYSTEM \n";
|
||||
out << "NAME Default \n";
|
||||
out << "AXIS_NAME \"X\" \"Y\" \"Z\" \n";
|
||||
out << "AXIS_UNIT \"m\" \"m\" \"m\" \n";
|
||||
out << "ZPOSITIVE Depth \n";
|
||||
out << "END_ORIGINAL_COORDINATE_SYSTEM \n";
|
||||
|
||||
out << "TFACE \n";
|
||||
|
||||
size_t i = 1;
|
||||
for ( auto v : vertices )
|
||||
{
|
||||
out << "VRTX " << i << " ";
|
||||
out << v.x() << " ";
|
||||
out << v.y() << " ";
|
||||
out << -v.z() << " ";
|
||||
out << "CNXYZ\n";
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
for ( size_t triIndex = 0; triIndex < triangleIndices.size(); triIndex += 3 )
|
||||
{
|
||||
out << "TRGL ";
|
||||
out << " " << 1 + triangleIndices[triIndex + 0];
|
||||
out << " " << 1 + triangleIndices[triIndex + 1];
|
||||
out << " " << 1 + triangleIndices[triIndex + 2];
|
||||
out << " \n";
|
||||
}
|
||||
|
||||
out << "END\n";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifSurfaceExporter::writePetrellPtlFile( const QString& fileName,
|
||||
const std::vector<cvf::Vec3d>& vertices,
|
||||
const std::vector<std::pair<unsigned int, unsigned int>>& columnRowIndices )
|
||||
{
|
||||
if ( vertices.size() != columnRowIndices.size() ) return false;
|
||||
|
||||
QFile exportFile( fileName );
|
||||
|
||||
if ( !exportFile.open( QIODevice::WriteOnly | QIODevice::Text ) ) return false;
|
||||
|
||||
QTextStream out( &exportFile );
|
||||
|
||||
out << "#Type: scattered data \n";
|
||||
out << "#Version: 6 \n";
|
||||
out << "#Description: No description \n";
|
||||
out << "#Format: free \n";
|
||||
out << "#Field: 1 x \n";
|
||||
out << "#Field: 2 y \n";
|
||||
out << "#Field: 3 z meters \n";
|
||||
out << "#Field: 4 column \n";
|
||||
out << "#Field: 5 row \n";
|
||||
out << "#Projection: Local Rectangular \n";
|
||||
out << "#Units: meters \n";
|
||||
out << "#End: \n";
|
||||
out << "#Information from grid \n";
|
||||
out << "#Grid_size: Not_avaiable \n";
|
||||
out << "#Grid_space: Not_available \n";
|
||||
out << "#Z_field: z \n";
|
||||
out << "#Vertical_faults: Not_available \n";
|
||||
out << "#History: No history \n";
|
||||
out << "#Z_units: meters \n";
|
||||
|
||||
for ( int i = 0; i < vertices.size(); i++ )
|
||||
{
|
||||
out << vertices[i].x() << " ";
|
||||
out << vertices[i].y() << " ";
|
||||
out << vertices[i].z() << " "; // SIGN? depth or Z, Z needed on PTL?
|
||||
|
||||
out << columnRowIndices[i].first << " ";
|
||||
out << columnRowIndices[i].second;
|
||||
|
||||
out << "\n";
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020- Equinor ASA
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cvfVector3.h"
|
||||
#include <vector>
|
||||
|
||||
class QString;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RifSurfaceExporter
|
||||
{
|
||||
public:
|
||||
static bool writeGocadTSurfFile( const QString& fileName,
|
||||
const QString& headerText,
|
||||
const std::vector<cvf::Vec3d>& vertices,
|
||||
const std::vector<unsigned>& triangleIndices );
|
||||
|
||||
static bool writePetrellPtlFile( const QString& fileName,
|
||||
const std::vector<cvf::Vec3d>& vertices,
|
||||
const std::vector<std::pair<unsigned int, unsigned int>>& columnRowIndices );
|
||||
};
|
||||
Reference in New Issue
Block a user