cheshirekow  v0.1.0
Simplex.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Josh Bialkowski (jbialk@mit.edu)
3  *
4  * This file is part of mpblocks.
5  *
6  * mpblocks is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * mpblocks is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with mpblocks. If not, see <http://www.gnu.org/licenses/>.
18  */
27 #ifndef MPBLOCKS_SIMPLEX_TREE_SIMPLEX_H_
28 #define MPBLOCKS_SIMPLEX_TREE_SIMPLEX_H_
29 
30 #include <Eigen/Dense>
31 #include <vector>
32 #include <list>
33 
34 namespace mpblocks {
35 namespace simplex_tree {
36 
38 
47 template <class Traits>
48 class Simplex
49 {
50  public:
52  typedef typename Traits::Format Format_t;
53  typedef typename Traits::Node Node_t;
54 
55  typedef unsigned int Index_t;
56  typedef Eigen::Matrix<Format_t,Traits::NDim,1> Vector_t;
57  typedef Eigen::Matrix<Format_t,Traits::NDim,1> Point_t;
58  typedef Eigen::Matrix<Format_t,Traits::NDim+1,Traits::NDim> Normals_t;
59  typedef Eigen::Matrix<Format_t,Traits::NDim+1,1> Offsets_t;
60 
61  typedef std::vector<Simplex_t*> SimplexList_t;
62  typedef std::vector<Node_t*> NodeList_t;
63 
64  protected:
66  Point_t m_v;
68 
72 
76 
78 
82  void split();
83 
84  public:
85  bool isInterior(){ return m_children.size() == 0; }
86  bool isLeaf() { return !isInterior(); }
87 
90  void initAsLeaf(Simplex_t* parent, Index_t i, Point_t& v);
91 
93  bool contains( Node_t* );
94 
97  void insert( Node_t* );
98 
101  void setFace(Index_t i, const Vector_t& n, Format_t d );
102 
103 
104 
105 
106 };
107 
108 
109 
110 
111 
112 
113 } // namespace simplex_tree
114 } // namespace mpblocks
115 
116 
117 
118 
119 
120 
121 
122 
123 
124 
125 
126 
127 #endif // SIMPLEX_H_
Eigen::Matrix< Format_t, Traits::NDim+1, 1 > Offsets_t
Definition: Simplex.h:59
Normals_t m_n
vertex of the parent which is replaced in creating this node
Definition: Simplex.h:70
SimplexList_t m_children
offsets of the faces
Definition: Simplex.h:73
std::vector< Simplex_t * > SimplexList_t
Definition: Simplex.h:61
Eigen::Matrix< Format_t, Traits::NDim+1, Traits::NDim > Normals_t
Definition: Simplex.h:58
Simplex< Traits > Simplex_t
Definition: Simplex.h:51
Eigen::Matrix< Format_t, Traits::NDim, 1 > Vector_t
Definition: Simplex.h:56
void insert(Node_t *)
insert the point into the simplex, recursively inserting into children or splitting as necessary ...
Definition: Simplex.hpp:77
bool contains(Node_t *)
return true if the simplex contains the point
void setFace(Index_t i, const Vector_t &n, Format_t d)
set the i'th face of this simplex with the specified normal and distance
Offsets_t m_d
normals of the faces
Definition: Simplex.h:71
void initAsLeaf(Simplex_t *parent, Index_t i, Point_t &v)
initialize the simplex as leaf, reserving storage for all the child node pointers ...
Definition: Simplex.hpp:70
std::vector< Node_t * > NodeList_t
Definition: Simplex.h:62
SimplexList_t m_neighbors
list of neighbors
Definition: Simplex.h:75
void split()
list of points in this node, if it's a leaf
Definition: Simplex.hpp:35
base class for nodes, implements storage and interface for the simplex tree
Definition: Simplex.h:48
Point_t m_v
index of the vertex of the parent which is replaced in creating this node
Definition: Simplex.h:67
Eigen::Matrix< Format_t, Traits::NDim, 1 > Point_t
Definition: Simplex.h:57