OGS
MapGeometryToMeshSurface.cpp File Reference
#include <tclap/CmdLine.h>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include "GeoLib/GEOObjects.h"
#include "GeoLib/IO/XmlIO/Boost/BoostXmlGmlInterface.h"
#include "InfoLib/GitInfo.h"
#include "MeshGeoToolsLib/GeoMapper.h"
#include "MeshLib/IO/readMeshFromFile.h"
#include "MeshLib/Mesh.h"
Include dependency graph for MapGeometryToMeshSurface.cpp:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 24 of file MapGeometryToMeshSurface.cpp.

25 {
26  TCLAP::CmdLine cmd(
27  "Maps geometric objects to the surface of a given mesh. "
28  "The documentation is available at "
29  "https://docs.opengeosys.org/docs/tools/model-preparation/"
30  "map-geometric-object-to-the-surface-of-a-mesh.\n\n"
31  "OpenGeoSys-6 software, version " +
33  ".\n"
34  "Copyright (c) 2012-2021, OpenGeoSys Community "
35  "(http://www.opengeosys.org)",
37  TCLAP::ValueArg<std::string> mesh_in(
38  "m", "mesh-file", "the name of the file containing the mesh", true, "",
39  "file name");
40  cmd.add(mesh_in);
41  TCLAP::ValueArg<std::string> input_geometry_fname(
42  "i", "input-geometry",
43  "the name of the file containing the input geometry", true, "",
44  "file name");
45  cmd.add(input_geometry_fname);
46  TCLAP::SwitchArg additional_insert_mapping(
47  "a", "additional-insert-mapping",
48  "Advanced mapping algorithm will be applied, i.e. a new geometry will "
49  "be created and possibly new points will be inserted.");
50  cmd.add(additional_insert_mapping);
51  TCLAP::ValueArg<std::string> output_geometry_fname(
52  "o", "output-geometry",
53  "the name of the file containing the input geometry", true, "",
54  "file name");
55  cmd.add(output_geometry_fname);
56  cmd.parse(argc, argv);
57 
58  // *** read geometry
59  GeoLib::GEOObjects geometries;
60  {
61  GeoLib::IO::BoostXmlGmlInterface xml_io(geometries);
62  if (xml_io.readFile(input_geometry_fname.getValue()))
63  {
64  INFO("Read geometry from file '{:s}'.",
65  input_geometry_fname.getValue());
66  }
67  else
68  {
69  return EXIT_FAILURE;
70  }
71  }
72 
73  auto const geo_name = geometries.getGeometryNames()[0];
74 
75  MeshGeoToolsLib::GeoMapper geo_mapper(geometries, geo_name);
76 
77  // *** read mesh
78  std::unique_ptr<MeshLib::Mesh> mesh(
79  MeshLib::IO::readMeshFromFile(mesh_in.getValue()));
80 
81  if (additional_insert_mapping.getValue())
82  {
83  geo_mapper.advancedMapOnMesh(*mesh);
84  }
85  else
86  {
87  geo_mapper.mapOnMesh(mesh.get());
88  }
89 
90  {
91  GeoLib::IO::BoostXmlGmlInterface xml_io(geometries);
92  xml_io.export_name = geo_name;
93  BaseLib::IO::writeStringToFile(xml_io.writeToString(),
94  output_geometry_fname.getValue());
95  }
96  return EXIT_SUCCESS;
97 }
void INFO(char const *fmt, Args const &... args)
Definition: Logging.h:32
Container class for geometric objects.
Definition: GEOObjects.h:61
std::vector< std::string > getGeometryNames() const
Returns the names of all geometry vectors.
Definition: GEOObjects.cpp:401
A set of tools for mapping the elevation of geometric objects.
Definition: GeoMapper.h:40
int writeStringToFile(std::string content, std::filesystem::path const &file_path)
Definition: Writer.cpp:45
GITINFOLIB_EXPORT const std::string ogs_version
MeshLib::Mesh * readMeshFromFile(const std::string &file_name)

References MeshGeoToolsLib::GeoMapper::advancedMapOnMesh(), BaseLib::IO::XMLInterface::export_name, GeoLib::GEOObjects::getGeometryNames(), INFO(), MeshGeoToolsLib::GeoMapper::mapOnMesh(), GitInfoLib::GitInfo::ogs_version, GeoLib::IO::BoostXmlGmlInterface::readFile(), MeshLib::IO::readMeshFromFile(), BaseLib::IO::writeStringToFile(), and BaseLib::IO::Writer::writeToString().