OGS
appendLinesAlongPolyline.cpp File Reference

Detailed Description

Definition in file appendLinesAlongPolyline.cpp.

Include dependency graph for appendLinesAlongPolyline.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 23 of file appendLinesAlongPolyline.cpp.

24 {
25  TCLAP::CmdLine cmd(
26  "Append line elements into a mesh.\n\n"
27  "OpenGeoSys-6 software, version " +
29  ".\n"
30  "Copyright (c) 2012-2021, OpenGeoSys Community "
31  "(http://www.opengeosys.org)",
33  TCLAP::ValueArg<std::string> mesh_in(
34  "i", "mesh-input-file",
35  "the name of the file containing the input mesh", true, "",
36  "file name of input mesh");
37  cmd.add(mesh_in);
38  TCLAP::ValueArg<std::string> mesh_out(
39  "o", "mesh-output-file",
40  "the name of the file the mesh will be written to", true, "",
41  "file name of output mesh");
42  cmd.add(mesh_out);
43  TCLAP::ValueArg<std::string> geoFileArg(
44  "g", "geo-file",
45  "the name of the geometry file which contains polylines", true, "",
46  "the name of the geometry file");
47  cmd.add(geoFileArg);
48 
49  TCLAP::ValueArg<std::string> gmsh_path_arg("g", "gmsh-path",
50  "the path to the gmsh binary",
51  false, "", "path as string");
52  cmd.add(gmsh_path_arg);
53 
54  // parse arguments
55  cmd.parse(argc, argv);
56 
57  // read GEO objects
58  GeoLib::GEOObjects geo_objs;
59  FileIO::readGeometryFromFile(geoFileArg.getValue(), geo_objs,
60  gmsh_path_arg.getValue());
61 
62  auto const geo_names = geo_objs.getGeometryNames();
63  if (geo_names.empty())
64  {
65  ERR("No geometries found.");
66  return EXIT_FAILURE;
67  }
68  const GeoLib::PolylineVec* ply_vec(
69  geo_objs.getPolylineVecObj(geo_names[0]));
70  if (!ply_vec)
71  {
72  ERR("Could not find polylines in geometry '{:s}'.", geo_names.front());
73  return EXIT_FAILURE;
74  }
75 
76  // read a mesh
77  MeshLib::Mesh const* const mesh(
78  MeshLib::IO::readMeshFromFile(mesh_in.getValue()));
79  if (!mesh)
80  {
81  ERR("Mesh file '{:s}' not found", mesh_in.getValue());
82  return EXIT_FAILURE;
83  }
84  INFO("Mesh read: {:d} nodes, {:d} elements.", mesh->getNumberOfNodes(),
85  mesh->getNumberOfElements());
86 
87  // add line elements
88  std::unique_ptr<MeshLib::Mesh> new_mesh =
90  INFO("Mesh created: {:d} nodes, {:d} elements.",
91  new_mesh->getNumberOfNodes(), new_mesh->getNumberOfElements());
92 
93  MeshLib::IO::writeMeshToFile(*new_mesh, mesh_out.getValue());
94 
95  return EXIT_SUCCESS;
96 }
void INFO(char const *fmt, Args const &... args)
Definition: Logging.h:32
void ERR(char const *fmt, Args const &... args)
Definition: Logging.h:42
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
const PolylineVec * getPolylineVecObj(const std::string &name) const
Definition: GEOObjects.cpp:227
The class TemplateVec takes a unique name and manages a std::vector of pointers to data elements of t...
Definition: TemplateVec.h:40
void readGeometryFromFile(std::string const &fname, GeoLib::GEOObjects &geo_objs, std::string const &gmsh_path)
GITINFOLIB_EXPORT const std::string ogs_version
std::unique_ptr< MeshLib::Mesh > appendLinesAlongPolylines(const MeshLib::Mesh &mesh, const GeoLib::PolylineVec &ply_vec)
MeshLib::Mesh * readMeshFromFile(const std::string &file_name)
int writeMeshToFile(const MeshLib::Mesh &mesh, std::filesystem::path const &file_path, [[maybe_unused]] std::set< std::string > variable_output_names)

References MeshGeoToolsLib::appendLinesAlongPolylines(), ERR(), GeoLib::GEOObjects::getGeometryNames(), MeshLib::Mesh::getNumberOfElements(), MeshLib::Mesh::getNumberOfNodes(), GeoLib::GEOObjects::getPolylineVecObj(), INFO(), GitInfoLib::GitInfo::ogs_version, FileIO::readGeometryFromFile(), MeshLib::IO::readMeshFromFile(), and MeshLib::IO::writeMeshToFile().