Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Tetmesh.hpp
1 /*
2  * Tetmesh.hpp
3  *
4  * Created on: Mar 20, 2012
5  * Author: kremer
6  */
7 
8 #include <boost/spirit/include/qi.hpp>
9 
10 #include <boost/bind.hpp>
11 
12 #include "../MeshGenerator.hpp"
13 
14 #include <iostream>
15 
16 #ifndef TETMESH_HPP_
17 #define TETMESH_HPP_
18 
19 namespace qi = boost::spirit::qi;
20 namespace spirit = boost::spirit;
21 
22 template <typename Iterator>
23 class tetmesh_grammar : public qi::grammar<Iterator, qi::space_type> {
24 public:
25  tetmesh_grammar(MeshGenerator& _generator) :
26  tetmesh_grammar::base_type(content),
27  generator_(_generator) {
28 
29  content = node_section_header >> *node >> element_section_header >> *element;
30 
31  node_section_header = spirit::lit("Vertices") >> qi::int_;
32 
33  node = qi::double_[boost::bind(&MeshGenerator::add_vertex_component, &generator_, ::_1)] >>
34  qi::double_[boost::bind(&MeshGenerator::add_vertex_component, &generator_, ::_1)] >>
35  qi::double_[boost::bind(&MeshGenerator::add_vertex_component, &generator_, ::_1)] >>
36  qi::double_;
37 
38  element_section_header = spirit::lit("Tetrahedra") >>
39  qi::int_[boost::bind(&MeshGenerator::set_num_cells, &generator_, ::_1)];
40 
41  element = qi::int_[boost::bind(&MeshGenerator::add_cell_vertex, &generator_, ::_1)] >>
42  qi::int_[boost::bind(&MeshGenerator::add_cell_vertex, &generator_, ::_1)] >>
43  qi::int_[boost::bind(&MeshGenerator::add_cell_vertex, &generator_, ::_1)] >>
44  qi::int_[boost::bind(&MeshGenerator::add_cell_vertex, &generator_, ::_1)];
45  }
46 
47 private:
48 
49  qi::rule<Iterator, qi::space_type> node_section_header, element_section_header, node, element, content;
50 
51  MeshGenerator& generator_;
52 };
53 
54 #endif /* TETMESH_HPP_ */
bool bind(osg::GeometryPtr &_geo, Mesh &_mesh)
Definition: bindT.hh:106