Skip to content
Snippets Groups Projects
Unverified Commit f0f5765c authored by Dmitri Naumov's avatar Dmitri Naumov Committed by GitHub
Browse files

Merge pull request #2547 from rinkk/TSurfaceInterface

[FileIO] Gocad TSurface interface
parents 476edd41 0e3aaebc
No related branches found
No related tags found
No related merge requests found
Showing with 24536 additions and 51 deletions
......@@ -31,6 +31,7 @@ public:
FEFLOW,
GMS,
GMSH,
GOCAD_TSURF,
#ifdef OGS_USE_NETCDF
NETCDF,
#endif // OGS_USE_NETCDF
......@@ -50,6 +51,8 @@ public:
return "GMS";
if (t == ImportFileType::GMSH)
return "GMSH";
if (t == ImportFileType::GOCAD_TSURF)
return "Gocad TSurface";
#ifdef OGS_USE_NETCDF
if (t == ImportFileType::NETCDF)
return "NetCDF";
......@@ -84,6 +87,8 @@ public:
return "GMS files (*.txt *.3dm)";
if (t == ImportFileType::GMSH)
return "GMSH mesh files (*.msh)";
if (t == ImportFileType::GOCAD_TSURF)
return "Gocad TSurface files (*.ts)";
#ifdef OGS_USE_NETCDF
if (t == ImportFileType::NETCDF)
return "NetCDF files (*.nc)";
......
......@@ -39,6 +39,7 @@
#include "Applications/FileIO/GMSInterface.h"
#include "Applications/FileIO/Gmsh/GMSHInterface.h"
#include "Applications/FileIO/Gmsh/GmshReader.h"
#include "Applications/FileIO/GocadIO/GocadTSurfaceReader.h"
#include "Applications/FileIO/Legacy/OGSIOVer4.h"
#include "Applications/FileIO/PetrelInterface.h"
#include "Applications/FileIO/TetGenInterface.h"
......@@ -611,6 +612,25 @@ void MainWindow::loadFile(ImportFileType::type t, const QString &fileName)
}
settings.setValue("lastOpenedFileDirectory", dir.absolutePath());
}
else if (t == ImportFileType::GOCAD_TSURF)
{
std::string file_name(fileName.toStdString());
FileIO::Gocad::GocadTSurfaceReader gcts;
std::vector<std::unique_ptr<MeshLib::Mesh>> meshes;
if (gcts.readFile(file_name, meshes))
{
for (auto& mesh : meshes)
{
if (mesh != nullptr)
_meshModel->addMesh(std::move(mesh));
}
}
else
{
OGSError::box("Error reading file.");
}
settings.setValue("lastOpenedFileDirectory", dir.absolutePath());
}
#ifdef OGS_USE_NETCDF
else if (t == ImportFileType::NETCDF) // CH 01.2012
{
......@@ -751,6 +771,9 @@ QMenu* MainWindow::createImportFilesMenu()
QAction* gmshFiles = importFiles->addAction("&GMSH Files...");
connect(gmshFiles, SIGNAL(triggered()), signal_mapper, SLOT(map()));
signal_mapper->setMapping(gmshFiles, ImportFileType::GMSH);
QAction* gocadTsFiles = importFiles->addAction("&Gocad TSurface...");
connect(gocadTsFiles, SIGNAL(triggered()), signal_mapper, SLOT(map()));
signal_mapper->setMapping(gocadTsFiles, ImportFileType::GOCAD_TSURF);
#ifdef OGS_USE_NETCDF
QAction* netcdfFiles = importFiles->addAction("&NetCDF Files...");
connect(netcdfFiles, SIGNAL(triggered()), signal_mapper, SLOT(map()));
......
......@@ -9,7 +9,9 @@
#include <iostream>
#include <logog/include/logog.hpp>
#include <boost/tokenizer.hpp>
#include <boost/algorithm/string/trim.hpp>
#include "CoordinateSystem.h"
......@@ -17,10 +19,27 @@ namespace FileIO
{
namespace Gocad
{
std::string parseName(std::string const& str)
{
std::string name;
std::size_t const start = str.find_first_of('\"');
if (start != str.npos)
{
std::size_t const end = str.find_last_of('\"');
name = str.substr(start+1, end-start-1);
}
else
{
name = str.substr(str.find_first_of(' '), str.length());
}
boost::algorithm::trim(name);
return name;
}
bool CoordinateSystem::parse(std::istream& in)
{
std::string line; // string used for reading a line
boost::char_separator<char> sep("-;| \"");
std::getline(in, line); // NAME name
......@@ -30,58 +49,59 @@ bool CoordinateSystem::parse(std::istream& in)
{
return false;
}
it++;
name = *it;
name = parseName(line);
projection = "";
datum = "";
std::getline(in, line); // AXIS_NAME "n1" "n2" "n3"
tok.assign(line);
it = tok.begin();
if (*it != "AXIS_NAME")
while ( std::getline(in, line))
{
return false;
tok.assign(line);
it = tok.begin();
if (*it == "AXIS_NAME")
{
++it;
axis_name_u = *it;
++it;
axis_name_v = *it;
++it;
axis_name_w = *it;
}
else if (*it == "AXIS_UNIT")
{
++it;
axis_unit_u = *it;
++it;
axis_unit_v = *it;
++it;
axis_unit_w = *it;
}
else if (*it == "ZPOSITIVE")
{
++it;
if (*it == "Depth")
{
z_positive = ZPOSITIVE::Depth;
}
else
{
z_positive = ZPOSITIVE::Elevation;
}
}
else if (*it == "PROJECTION")
{
projection = parseName(line);
}
else if (*it == "DATUM")
{
datum = parseName(line);
}
else if (*it == "END_ORIGINAL_COORDINATE_SYSTEM")
return true;
else
WARN("CoordinateSystem::parse() - Unknown keyword found: %s", line.c_str());
}
++it;
axis_name_u = *it;
++it;
axis_name_v = *it;
++it;
axis_name_w = *it;
std::getline(in, line); // AXIS_UNIT "u1" "u2" "u3"
tok.assign(line);
it = tok.begin();
if (*it != "AXIS_UNIT")
{
return false;
}
++it;
axis_unit_u = *it;
++it;
axis_unit_v = *it;
++it;
axis_unit_w = *it;
std::getline(in, line); // ZPOSITIVE Depth || Elevation
tok.assign(line);
it = tok.begin();
if (*it != "ZPOSITIVE")
{
return false;
}
++it;
if (*it != "Depth")
{
z_positive = ZPOSITIVE::Depth;
}
else
{
z_positive = ZPOSITIVE::Elevation;
}
std::getline(in, line); // END_ORIGINAL_COORDINATE_SYSTEM
tok.assign(line);
it = tok.begin();
return *it == "END_ORIGINAL_COORDINATE_SYSTEM";
ERR ("Error: Unexpected end of file.");
return false;
}
std::ostream& operator<<(std::ostream& os, CoordinateSystem const& c)
......
......@@ -26,6 +26,8 @@ public:
};
std::string name;
std::string projection;
std::string datum;
std::string axis_name_u, axis_name_v, axis_name_w;
std::string axis_unit_u, axis_unit_v, axis_unit_w;
ZPOSITIVE z_positive;
......
/**
*
* @copyright
* Copyright (c) 2012-2019, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/LICENSE.txt
*/
#include "GocadTSurfaceReader.h"
#include <logog/include/logog.hpp>
#include <fstream>
#include "Applications/FileIO/GocadIO/CoordinateSystem.h"
#include "BaseLib/FileTools.h"
#include "BaseLib/StringTools.h"
#include "MeshLib/Elements/Tri.h"
#include "MeshLib/Mesh.h"
#include "MeshLib/Node.h"
namespace FileIO
{
namespace Gocad
{
const std::string mat_id_name = "MaterialIDs";
const std::string eof_error = "Error: Unexpected end of file.";
GocadTSurfaceReader::GocadTSurfaceReader()
{
}
bool GocadTSurfaceReader::readFile(
std::string const& file_name,
std::vector<std::unique_ptr<MeshLib::Mesh>>& meshes)
{
std::ifstream in(file_name.c_str());
if (!in.is_open())
{
ERR("GocadTSurfaceReader::readFile(): Could not open file %s.",
file_name.c_str());
return false;
}
while (TSurfaceFound(in))
{
std::string mesh_name = BaseLib::dropFileExtension(file_name) +
std::to_string(meshes.size() + 1);
std::unique_ptr<MeshLib::Mesh> mesh(readMesh(in, mesh_name));
if (mesh == nullptr)
{
ERR("File parsing aborted...")
return false;
}
meshes.push_back(std::move(mesh));
}
return true;
}
MeshLib::Mesh* GocadTSurfaceReader::readMesh(std::ifstream& in,
std::string& mesh_name)
{
if (!parseHeader(in, mesh_name))
return nullptr;
MeshLib::Properties mesh_prop;
mesh_prop.createNewPropertyVector<int>(mat_id_name,
MeshLib::MeshItemType::Cell, 1);
std::string line("");
while (std::getline(in, line))
{
std::vector<std::string> str = BaseLib::splitString(line);
if (line.empty() || isCommentLine(line))
continue;
else if (str[0] == "GOCAD_ORIGINAL_COORDINATE_SYSTEM")
{
Gocad::CoordinateSystem coordinate_system;
if (!coordinate_system.parse(in))
{
ERR("Error parsing coordinate system.");
return nullptr;
}
}
else if (str[0] == "GEOLOGICAL_FEATURE" ||
str[0] == "GEOLOGICAL_TYPE" ||
str[0] == "STRATIGRAPHIC_POSITION")
{
// geological and stratigraphic information - currently ignored
}
else if (str[0] == "PROPERTY_CLASS_HEADER")
{
if (!parsePropertyClass(in))
{
ERR("Error parsing PROPERTY_CLASS_HEADER.");
return nullptr;
}
}
else if (str[0] == "PROPERTIES")
{
if (!parseProperties(in, str, mesh_prop))
{
ERR("Error parsing PROPERTIES");
return nullptr;
}
}
else if (str[0] == "TFACE")
{
std::vector<MeshLib::Node*> nodes;
std::vector<MeshLib::Element*> elems;
std::map<std::size_t, std::size_t> node_id_map;
INFO ("Parsing surface %s", mesh_name.c_str());
if (!parseSurface(in, nodes, elems, node_id_map, mesh_prop))
{
ERR("Error parsing Surface %s.", mesh_name.c_str());
clearData(nodes, elems);
return nullptr;
}
return new MeshLib::Mesh(mesh_name, nodes, elems, mesh_prop);
}
else
{
WARN("GocadTSurfaceReader::readMesh() - Unknown keyword found: %s",
line.c_str());
}
}
ERR("%s", eof_error.c_str());
return nullptr;
}
bool GocadTSurfaceReader::TSurfaceFound(std::ifstream& in) const
{
std::string line("");
while (std::getline(in, line))
{
if (line.empty() || isCommentLine(line))
continue;
else if (line.substr(0, 11) == "GOCAD TSurf")
return true;
// No idea why this is allowed in a *.ts file.
// It should be a whole different file type.
else if (line.substr(0, 13) == "GOCAD Model3d")
{
if (!skipModel3d(in))
{
ERR("Error parsing Model3d");
return false;
}
}
else
{
ERR("No TSurf-identifier found...");
return false;
}
}
return false;
}
bool GocadTSurfaceReader::isCommentLine(std::string const& str) const
{
return (str.substr(0, 1) == "#");
}
bool GocadTSurfaceReader::parseHeader(std::ifstream& in, std::string& mesh_name)
{
std::string line("");
while (std::getline(in, line))
{
if (line.substr(0, 5) == "name:")
{
mesh_name = line.substr(5, line.length() - 5);
BaseLib::trim(mesh_name, ' ');
}
else if (line.substr(0, 1) == "}")
return true;
// ignore all other header parameters
}
ERR("%s", eof_error.c_str());
return false;
}
bool GocadTSurfaceReader::parsePropertyClass(std::ifstream& in) const
{
std::string line("");
while (std::getline(in, line))
{
if (line.substr(0, 1) == "}")
return true;
}
ERR("%s", eof_error.c_str());
return false;
}
/// Checks if the current line starts with one of the allowed keywords
std::string propertyCheck(std::string const& strng)
{
std::array<std::string, 7> const property_keywords = {
{"PROPERTY_CLASSES", "PROP_LEGAL_RANGES", "NO_DATA_VALUES",
"PROPERTY_KINDS", "PROPERTY_SUBCLASSES", "UNITS", "ESIZES"}};
std::vector<std::string> str = BaseLib::splitString(strng);
for (std::string key : property_keywords)
{
if (str[0] == key)
return key;
}
return std::string("");
}
bool GocadTSurfaceReader::parseProperties(std::ifstream& in,
std::vector<std::string> const& names,
MeshLib::Properties& mesh_prop)
{
// Because properties have no end-tag, the position of the last line is
// stored, so the stream can be set back if none of the allowed property-
// related keywords is found.
std::streampos pos = in.tellg();
std::string line("");
while (getline(in, line))
{
std::string const key = propertyCheck(line);
// This is the intended way to exit this method:
// No property-related keyword has been found, so the stream is set
// back one line and the (unrelated) keyword can be read again in the
// parent method.
if (key.empty())
{
in.seekg(pos);
return true;
}
// Currently all property parameters except array name and size are
// ignored.
if (key == "ESIZES")
{
std::vector<std::string> prop_size = BaseLib::splitString(line);
if (names.size() != prop_size.size())
{
ERR("Error: Number of PROPERTY-names (%d) does not match "
"number of ESIZES (%d)", names.size(), prop_size.size());
return false;
}
std::size_t const n_names (names.size());
for (std::size_t i = 1; i < n_names; ++i)
{
mesh_prop.createNewPropertyVector<double>(
names[i],
MeshLib::MeshItemType::Node,
BaseLib::str2number<std::size_t>(prop_size[i]));
}
}
// Remember current position in case the properties black ends now.
pos = in.tellg();
}
ERR("%s", eof_error.c_str());
return false;
}
bool GocadTSurfaceReader::parseSurface(
std::ifstream& in,
std::vector<MeshLib::Node*>& nodes,
std::vector<MeshLib::Element*>& elems,
std::map<std::size_t, std::size_t>& node_id_map,
MeshLib::Properties& mesh_prop)
{
if (!parseNodes(in, nodes, node_id_map, mesh_prop))
return false;
if (!parseElements(in, nodes, elems, node_id_map, mesh_prop))
return false;
std::string line("");
while (std::getline(in, line))
{
std::vector<std::string> str = BaseLib::splitString(line);
if (str[0] == "TFACE")
{
parseSurface(in, nodes, elems, node_id_map, mesh_prop);
return true;
}
else if (str[0] == "BSTONE")
{
// borderstone definition - currently ignored
}
else if (str[0] == "BORDER")
{
// border tracking direction - currently ignored
}
else if (line == "END")
{
return true;
}
else
{
WARN(
"GocadTSurfaceReader::parseSurface() - Unknown keyword found: "
"%s",
line.c_str());
}
}
ERR("%s", eof_error.c_str());
return false;
}
MeshLib::Node* createNode(std::stringstream& sstr)
{
std::string keyword;
std::size_t id;
std::array<double, 3> data;
sstr >> keyword >> id >> data[0] >> data[1] >> data[2];
return new MeshLib::Node(data, id);
}
bool GocadTSurfaceReader::parseNodes(
std::ifstream& in,
std::vector<MeshLib::Node*>& nodes,
std::map<std::size_t, std::size_t>& node_id_map,
MeshLib::Properties& mesh_prop)
{
NODE_TYPE t = NODE_TYPE::UNSPECIFIED;
double value;
std::vector<std::string> const array_names =
mesh_prop.getPropertyVectorNames();
std::streampos pos = in.tellg();
std::string line("");
while (std::getline(in, line))
{
std::vector<std::string> str = BaseLib::splitString(line);
if (line.substr(0, 4) == "TRGL")
{
in.seekg(pos);
return true;
}
if (line.empty() || isCommentLine(line))
continue;
if (!(line.substr(0, 4) == "VRTX" || line.substr(0, 5) == "PVRTX" ||
line.substr(0, 4) == "ATOM"))
{
WARN(
"GocadTSurfaceReader::parseNodes() - Unknown keyword found: %s",
line.c_str());
continue;
}
std::stringstream sstr(line);
if (line.substr(0, 4) == "VRTX" && t != NODE_TYPE::PVRTX)
{
nodes.push_back(createNode(sstr));
}
else if (line.substr(0, 5) == "PVRTX" && t != NODE_TYPE::VRTX)
{
nodes.push_back(createNode(sstr));
for (std::string const& name : array_names)
{
if (name == mat_id_name)
continue;
sstr >> value;
mesh_prop.getPropertyVector<double>(name)->push_back(value);
}
}
else if (line.substr(0, 4) == "ATOM")
{
std::size_t new_id, ref_id;
std::string keyword;
sstr >> keyword >> new_id >> ref_id;
nodes.push_back(new MeshLib::Node(nodes[ref_id]->getCoords(), new_id));
}
node_id_map[nodes.back()->getID()] = nodes.size() - 1;
pos = in.tellg();
}
ERR("%s", eof_error.c_str());
return false;
}
bool GocadTSurfaceReader::parseElements(
std::ifstream& in,
std::vector<MeshLib::Node*>& nodes,
std::vector<MeshLib::Element*>& elems,
std::map<std::size_t, std::size_t> const& node_id_map,
MeshLib::Properties& mesh_prop)
{
std::string keyword;
std::array<std::size_t, 3> data;
MeshLib::PropertyVector<int>& mat_ids =
*mesh_prop.getPropertyVector<int>(mat_id_name);
int current_mat_id(0);
if (!mat_ids.empty())
current_mat_id = (*std::max_element(mat_ids.begin(), mat_ids.end()))++;
std::streampos pos = in.tellg();
std::size_t id(0);
std::string line("");
while (std::getline(in, line))
{
if (line.empty() || isCommentLine(line))
continue;
if (line.substr(0, 4) == "TRGL")
{
std::stringstream sstr(line);
sstr >> keyword >> data[0] >> data[1] >> data[2];
std::array<MeshLib::Node*, 3> elem_nodes;
for (std::size_t i = 0; i < 3; ++i)
{
auto const it = node_id_map.find(data[i]);
if (it == node_id_map.end() || it->second >= nodes.size())
{
ERR("Error: Node ID (%d) out of range (0, %d).", data[i],
nodes.back()->getID());
return false;
}
elem_nodes[i] = nodes[it->second];
}
elems.push_back(new MeshLib::Tri(elem_nodes, id++));
mat_ids.push_back(current_mat_id);
}
else
{
in.seekg(pos);
return true;
}
pos = in.tellg();
}
ERR("%s", eof_error.c_str());
return false;
}
bool GocadTSurfaceReader::skipModel3d(std::ifstream& in) const
{
std::string line("");
while (std::getline(in, line))
{
if (line == "END")
return true;
}
ERR("%s", eof_error.c_str());
return false;
}
void GocadTSurfaceReader::clearData(std::vector<MeshLib::Node*>& nodes,
std::vector<MeshLib::Element*>& elems)
{
for (MeshLib::Element* e : elems)
delete e;
for (MeshLib::Node* n : nodes)
delete n;
}
} // end namespace Gocad
} // end namespace FileIO
/**
*
* @copyright
* Copyright (c) 2012-2019, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/LICENSE.txt
*/
#pragma once
#include <iosfwd>
#include <memory>
#include <string>
#include "MeshLib/Properties.h"
namespace MeshLib
{
class Mesh;
class Node;
class Element;
}
namespace FileIO
{
namespace Gocad
{
class GocadTSurfaceReader final
{
public:
/**
* Constructor takes as argument the Gocad .sg text file.
* @param fname file name
*/
explicit GocadTSurfaceReader();
GocadTSurfaceReader(GocadTSurfaceReader&& src) = delete;
GocadTSurfaceReader(GocadTSurfaceReader const& src) = delete;
GocadTSurfaceReader& operator=(GocadTSurfaceReader&& rhs) = delete;
GocadTSurfaceReader& operator=(GocadTSurfaceReader const& rhs) = delete;
/// Reads the specified file and writes data into internal mesh vector
bool readFile(std::string const& file_name, std::vector<std::unique_ptr<MeshLib::Mesh>>& meshes);
private:
/// Reads one mesh contained in the file (there may be more than one!)
MeshLib::Mesh* readMesh(std::ifstream& in, std::string& mesh_name);
/// Checks if the current line is a comment
bool isCommentLine(std::string const& str) const;
/// Checks if a TSurf identifier is found at the current stream position.
bool TSurfaceFound(std::ifstream& in) const;
/// Parses the HEADER section (everything except the name is ignored right now)
bool parseHeader(std::ifstream& in, std::string& mesh_name);
/// Reads PROPERTY_CLASS_HEADER sections of the file.
/// All this information is currently ignored.
bool parsePropertyClass(std::ifstream& in) const;
/// Parses information of node properties.
/// Only property names and array sizes are currently used.
bool parseProperties(std::ifstream& in,
std::vector<std::string> const& names,
MeshLib::Properties& mesh_prop);
/// Parses the surface information (nodes, triangles, properties)
bool parseSurface(std::ifstream& in, std::vector<MeshLib::Node*>& nodes,
std::vector<MeshLib::Element*>& elems,
std::map<std::size_t, std::size_t>& node_id_map,
MeshLib::Properties& mesh_prop);
/// Parses the node data for the current mesh
bool parseNodes(std::ifstream& in, std::vector<MeshLib::Node*>& nodes,
std::map<std::size_t, std::size_t>& node_id_map,
MeshLib::Properties& mesh_prop);
/// Parses the element data for the current mesh
bool parseElements(std::ifstream& in, std::vector<MeshLib::Node*>& nodes,
std::vector<MeshLib::Element*>& elems,
std::map<std::size_t, std::size_t> const& node_id_map,
MeshLib::Properties& mesh_prop);
/// Skips over the Model3d sections of the file, should there be any.
bool skipModel3d(std::ifstream& in) const;
/// Clears the memory if an error occured
void clearData(std::vector<MeshLib::Node*>& nodes,
std::vector<MeshLib::Element*>& elems);
enum class NODE_TYPE
{
UNSPECIFIED,
VRTX,
PVRTX
};
}; // end class GocadTSurfaceReader
} // end namespace Gocad
} // end namespace FileIO
......@@ -52,6 +52,14 @@ target_link_libraries(GocadSGridReader
${Boost_LIBRARIES}
)
add_executable(GocadTSurfaceReader GocadTSurfaceReader.cpp)
set_target_properties(GocadTSurfaceReader PROPERTIES FOLDER Utilities)
target_link_libraries(GocadTSurfaceReader
MeshLib
ApplicationsFileIO
${Boost_LIBRARIES}
)
add_executable(Mesh2Raster MeshToRaster.cpp)
set_target_properties(Mesh2Raster PROPERTIES FOLDER Utilities)
target_link_libraries(Mesh2Raster MeshLib)
......
/**
*
* @copyright
* Copyright (c) 2012-2019, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/LICENSE.txt
*/
#include <tclap/CmdLine.h>
#include "BaseLib/BuildInfo.h"
#include "MeshLib/Mesh.h"
#include "MeshLib/IO/VtkIO/VtuInterface.h"
#include "Applications/ApplicationsLib/LogogSetup.h"
#include "Applications/FileIO/GocadIO/GocadTSurfaceReader.h"
std::string getDelim(std::string const& str)
{
std::size_t const bslash = str.find_first_of('\\');
char const delim = (bslash == str.npos) ? '/' : '\\';
return (str.back() == delim) ? "" : std::string(1, delim);
}
int main(int argc, char* argv[])
{
ApplicationsLib::LogogSetup logog_setup;
TCLAP::CmdLine cmd(
"Reads a Gocad triangular surfaces file (*.ts) and writes the "
"data into one or more VTU unstructured grids.\n\n"
"OpenGeoSys-6 software, version " +
BaseLib::BuildInfo::ogs_version +
".\n"
"Copyright (c) 2012-2019, OpenGeoSys Community "
"(http://www.opengeosys.org)",
' ', BaseLib::BuildInfo::ogs_version);
TCLAP::ValueArg<std::string> input_arg(
"i", "input-file", "Gocad triangular surfaces file (*.ts)", true, "",
"filename.ts");
cmd.add(input_arg);
TCLAP::ValueArg<std::string> output_arg(
"o", "output-dir", "output directory", true, "",
"output dir");
cmd.add(output_arg);
TCLAP::SwitchArg write_binary_arg(
"b", "write-binary",
"if set, OGS-Meshes will be written in binary format");
cmd.add(write_binary_arg);
cmd.parse(argc, argv);
std::string const file_name (input_arg.getValue());
FileIO::Gocad::GocadTSurfaceReader gcts;
std::vector<std::unique_ptr<MeshLib::Mesh>> meshes;
if (!gcts.readFile(file_name, meshes))
{
ERR("Error reading file.");
return 1;
}
std::string const dir = output_arg.getValue();
bool const write_binary = write_binary_arg.getValue();
std::string const delim = getDelim(dir);
for (auto& mesh : meshes)
{
INFO("Writing mesh \"%s\"", mesh->getName().c_str());
int data_mode = (write_binary) ? 2 : 0;
bool compressed = (write_binary) ? true : false;
MeshLib::IO::VtuInterface vtu(mesh.get(), data_mode, compressed);
vtu.writeToFile(dir + delim + mesh->getName() + ".vtu");
}
return 0;
}
......@@ -243,3 +243,24 @@ MeshTest(
REQUIREMENTS NOT OGS_USE_MPI
DIFF_DATA Back.vtu Back.vtu 1e-16
)
MeshTest(
NAME GocadTSurface_Mesh_Test
PATH MeshLib/
EXECUTABLE GocadTSurfaceReader
EXECUTABLE_ARGS -i Top-Lower-Shaly.ts -o ${Data_BINARY_DIR}/MeshLib -b
REQUIREMENTS NOT OGS_USE_MPI
DIFF_DATA Top-Lower-Shaly.vtu Top-Lower-Shaly.vtu 1e-16
)
AddTest(
NAME GocadTSurface_Array_Test
PATH MeshLib/
EXECUTABLE GocadTSurfaceReader
EXECUTABLE_ARGS -i Top-Lower-Shaly.ts -o ${Data_BINARY_DIR}/MeshLib -b
REQUIREMENTS NOT OGS_USE_MPI
TESTER vtkdiff
DIFF_DATA
Top-Lower-Shaly.vtu Top-Lower-Shaly.vtu Reshape_Thickness Reshape_Thickness 1e-16 0
Top-Lower-Shaly.vtu Top-Lower-Shaly.vtu Measured_Depth Measured_Depth 1e-16 0
)
......@@ -28,7 +28,7 @@ pipeline {
agent { label "master"}
steps {
sh "git config core.whitespace -blank-at-eof"
sh "git diff --check `git merge-base origin/master HEAD` HEAD -- . ':!*.md' ':!*.pandoc' ':!*.asc' ':!*.dat'"
sh "git diff --check `git merge-base origin/master HEAD` HEAD -- . ':!*.md' ':!*.pandoc' ':!*.asc' ':!*.dat' ':!*.ts'"
dir('scripts/jenkins') { stash(name: 'known_hosts', includes: 'known_hosts') }
ciSkip action: 'check' // Check for [ci skip] or [web] commit message.
......
This diff is collapsed.
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment