6#define BOOST_ALLOW_DEPRECATED_HEADERS
7#define BOOST_BIND_GLOBAL_PLACEHOLDERS
8#include <boost/spirit/include/qi.hpp>
10#include <OpenVolumeMesh/FileManager/FileManager.hh>
12#include "MeshGenerator.hpp"
14#include "Grammars/Tetmesh.hpp"
15#include "Grammars/Netgen.hpp"
18 std::cerr <<
"You need to specify a format and a source file to convert!" << std::endl << std::endl;
19 std::clog <<
"Usage: file_converter <format> <filename> [output_filename.ovm]" << std::endl << std::endl;
20 std::clog <<
"Available file formats:" << std::endl;
21 std::clog <<
" -t\tTetmesh" << std::endl;
22 std::clog <<
" -n\tNetgen" << std::endl;
23 std::clog << std::endl;
26int main(
int _argc,
char* _argv[]) {
28 if(_argc < 3 || _argc > 4 ||
29 (_argc > 1 && (std::strcmp(_argv[1],
"--help") == 0 || std::strcmp(_argv[1],
"-h") == 0))) {
34 std::ifstream iff(_argv[2], std::ios::in);
37 std::cerr <<
"Could not open file " << _argv[1] <<
" for reading!" << std::endl;
44 std::ostringstream oss;
47 std::string fileContent = oss.str();
55 if(std::strcmp(_argv[1],
"-t") == 0) {
58 r = boost::spirit::qi::phrase_parse(fileContent.begin(), fileContent.end(),
tetmesh_grammar, qi::space);
60 }
else if(std::strcmp(_argv[1],
"-n") == 0) {
63 r = boost::spirit::qi::phrase_parse(fileContent.begin(), fileContent.end(),
netgen_grammar, qi::space);
71 std::cout <<
"Successfully read file data!" << std::endl;
73 std::cout <<
"Parsing failed!" << std::endl;
76 std::cerr <<
"Converted " << mesh.n_vertices() <<
" vertices," << std::endl;
77 std::cerr <<
"\t " << mesh.n_edges() <<
" edges," << std::endl;
78 std::cerr <<
"\t " << mesh.n_faces() <<
" faces," << std::endl;
79 std::cerr <<
"\t " << mesh.n_cells() <<
" cells!" << std::endl;
87 std::string::size_type idx = filename.rfind(
'.');
89 filename = filename.substr(0, idx);
90 filename.append(
".ovm");
Read/Write mesh data from/to files.
bool writeFile(const std::string &_filename, const MeshT &_mesh) const
Write a mesh to a file.