Skip to content
Snippets Groups Projects
Commit d60c64f8 authored by Tom Fischer's avatar Tom Fischer
Browse files

[U/ME] Initial. impl. of MapGeometryToMeshSurface.

parent d094bec3
No related branches found
No related tags found
No related merge requests found
......@@ -26,6 +26,20 @@ if(QT4_FOUND)
set_target_properties(moveMeshNodes PROPERTIES FOLDER Utilities)
add_executable(MapGeometryToMeshSurface
MapGeometryToMeshSurface.cpp )
target_link_libraries(MapGeometryToMeshSurface
MeshLib
MeshGeoToolsLib
FileIO
InSituLib
${CATALYST_LIBRARIES}
${QT_LIBRARIES}
)
ADD_CATALYST_DEPENDENCY(MapGeometryToMeshSurface)
set_target_properties(MapGeometryToMeshSurface
PROPERTIES FOLDER Utilities)
endif() # QT4_FOUND
add_executable(removeMeshElements removeMeshElements.cpp)
......
/*
* \date 2015-04-20
* \brief Map geometric objects to the surface of the given mesh.
*
* \copyright
* Copyright (c) 2012-2015, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
*/
#include <algorithm>
#include <cstdlib>
#include <vector>
// TCLAP
#include "tclap/CmdLine.h"
// ThirdParty/logog
#include "logog/include/logog.hpp"
// BaseLib
#include "BaseLib/LogogSimpleFormatter.h"
// FileIO
#include "FileIO/readMeshFromFile.h"
#include "FileIO/XmlIO/Boost/BoostXmlGmlInterface.h"
#include "FileIO/XmlIO/Qt/XmlGmlInterface.h"
// GeoLib
#include "GeoLib/GEOObjects.h"
// MeshLib
#include "MeshLib/Mesh.h"
// MeshGeoToolsLib
#include "MeshGeoToolsLib/GeoMapper.h"
int main (int argc, char* argv[])
{
LOGOG_INITIALIZE();
logog::Cout* logog_cout (new logog::Cout);
BaseLib::LogogSimpleFormatter *custom_format (new BaseLib::LogogSimpleFormatter);
logog_cout->SetFormatter(*custom_format);
TCLAP::CmdLine cmd("Maps geometric objects to the surface of a given mesh.",
' ', "0.1");
TCLAP::ValueArg<std::string> mesh_in("m", "mesh-file",
"the name of the file containing the mesh", true,
"", "file name");
cmd.add(mesh_in);
TCLAP::ValueArg<std::string> input_geometry_fname("i", "input-geometry",
"the name of the file containing the input geometry", true,
"", "file name");
cmd.add(input_geometry_fname);
TCLAP::ValueArg<bool> advanced_mapping("", "advanced-mapping",
"if true advanced mapping algorithm will be applied", false,
true, "boolean value");
cmd.add(advanced_mapping);
TCLAP::ValueArg<std::string> output_geometry_fname("o", "output-geometry",
"the name of the file containing the input geometry", true,
"", "file name");
cmd.add(output_geometry_fname);
cmd.parse(argc, argv);
// *** read mesh
MeshLib::Mesh * mesh(FileIO::readMeshFromFile(mesh_in.getValue()));
// *** read geometry
GeoLib::GEOObjects geometries;
{
FileIO::BoostXmlGmlInterface xml_io(geometries);
if (xml_io.readFile(input_geometry_fname.getValue())) {
INFO("Read geometry from file \"%s\".",
input_geometry_fname.getValue().c_str());
} else {
delete mesh;
return EXIT_FAILURE;
}
}
std::string geo_name;
{
std::vector<std::string> geo_names;
geometries.getGeometryNames(geo_names);
geo_name = geo_names[0];
}
std::string new_geo_name(geo_name);
MeshGeoToolsLib::GeoMapper geo_mapper(geometries, geo_name);
if (advanced_mapping.getValue()) {
new_geo_name += "-Mapped";
geo_mapper.advancedMapOnMesh(mesh, new_geo_name);
} else {
geo_mapper.mapOnMesh(mesh);
}
{
FileIO::XmlGmlInterface xml_io(geometries);
xml_io.setNameForExport(new_geo_name);
xml_io.writeToFile(output_geometry_fname.getValue());
}
return EXIT_SUCCESS;
}
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