Developer Documentation

Netgen.hpp
1 /*
2 * Netgen.hpp
3 *
4 * Created on: Apr 16, 2012
5 * Author: kremer
6 */
7
8 #ifndef NETGEN_HPP_
9 #define NETGEN_HPP_
10
11 #include <boost/spirit/include/qi.hpp>
12
13 #include <boost/bind.hpp>
14
15 #include "../MeshGenerator.hpp"
16
17 #include <iostream>
18
19 namespace qi = boost::spirit::qi;
20 namespace spirit = boost::spirit;
21
22 void print() {
23 static int c = 0;
24 std::cerr << "Hey there!" << c++ << std::endl;
25 }
26
27 template <typename Iterator>
28 class netgen_grammar : public qi::grammar<Iterator/*, qi::space_type*/> {
29 public:
30 explicit netgen_grammar(MeshGenerator& _generator) :
31 netgen_grammar::base_type(content),
32 generator_(_generator) {
33
34 content = node_section_header >> *node >>
35 element_section_header >> *element >>
36 face_section_header >> *face;
37
38 node_section_header = qi::int_ /* Number of vertices */ >> spirit::eol;
39
40 node = *space >> qi::double_[boost::bind(&MeshGenerator::add_vertex_component, &generator_, ::_1)] >>
41 *space >> qi::double_[boost::bind(&MeshGenerator::add_vertex_component, &generator_, ::_1)] >>
42 *space >> qi::double_[boost::bind(&MeshGenerator::add_vertex_component, &generator_, ::_1)] >> spirit::eol;
43
44 element_section_header = qi::int_[boost::bind(&MeshGenerator::set_num_cells, &generator_, ::_1)] /* Number of tetrahedra */ >>
45 spirit::eol;;
46
47 element = *space >> qi::int_ >>
48 *space >> qi::int_[boost::bind(&MeshGenerator::add_cell_vertex, &generator_, ::_1)] >>
49 *space >> qi::int_[boost::bind(&MeshGenerator::add_cell_vertex, &generator_, ::_1)] >>
50 *space >> qi::int_[boost::bind(&MeshGenerator::add_cell_vertex, &generator_, ::_1)] >>
51 *space >> qi::int_[boost::bind(&MeshGenerator::add_cell_vertex, &generator_, ::_1)] >>
52 spirit::eol;
53
54 face_section_header = qi::int_ /* Number of faces */ >> spirit::eol;
55
56 face = *space >> qi::int_ >>
57 *space >> qi::int_ >>
58 *space >> qi::int_ >>
59 *space >> qi::int_ >>
60 spirit::eol;
61
62 space = spirit::ascii::space - spirit::eol;
63 }
64
65 private:
66
67 qi::rule<Iterator/*, qi::space_type*/> node_section_header, element_section_header, face_section_header,
68 node, element, face, space, content;
69
70 MeshGenerator& generator_;
71 };
72
73 #endif /* NETGEN_HPP_ */
OpenMesh::Kernel_OSG::bind
bool bind(osg::GeometryPtr &_geo, Mesh &_mesh)
Definition: bindT.hh:101
netgen_grammar
Definition: Netgen.hpp:28
MeshGenerator
Definition: MeshGenerator.hpp:24