cheshirekow  v0.1.0
example_traits.hpp
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 EDELSBRUNNER96_EXAMPLETRAITS_H_
28 #define EDELSBRUNNER96_EXAMPLETRAITS_H_
29 
30 #include <vector>
31 #include <Eigen/Dense>
32 #include <edelsbrunner96.hpp>
33 
34 namespace edelsbrunner96 {
35 
38 struct ExampleTraits {
40  static const unsigned int NDim = 2;
41 
43  typedef double Scalar;
44 
47  typedef Eigen::Matrix<Scalar, NDim, 1> Point;
48 
52 
57  typedef Point* PointRef;
58 
64 
68 
73  typedef Simplex* SimplexRef;
74 
76 
86  class Storage {
88  return *p;
89  }
90 
92  return nullptr;
93  }
94 
96  return *s;
97  }
98 
100  return nullptr;
101  }
102 
104  SimplexRef result = nullptr;
105  if (!free_.empty()) {
106  result = free_.back();
107  free_.pop_back();
108  } else {
109  result = new Simplex();
110  }
111  return result;
112  }
113 
114  void Retire(SimplexRef simplex) {
115  simplex->version++;
116  free_.push_back(simplex);
117  }
118 
119  private:
120  std::vector<Simplex*> free_;
121  };
122 };
123 
124 } // namespace edelsbrunner
125 
126 #endif // EDELSBRUNNER96_EXAMPLETRAITS_H_
SimplexBase< ExampleTraits > Simplex
the simplex type, this may be a structure with extra methods and such but it should provide the same ...
double Scalar
numeric type for scalars
A simplex in the triangulation. A simplex is the convex hull of Ndim+1 points in R^NDim.
Definition: simplex.h:89
Storage abstraction for simplices and points.
Point * PointRef
type which points to a Point structure, this is what is stored inside simplices. Here we simply use a...
Simplex * SimplexRef
How we will refer to simplices within the simplex store. For this example the simplex store is a simp...
Example of a traits class suitable for instantiation an edelsbrunner triangulation object...
static const unsigned int NDim
dimension of the triangulation
uint16_t version
incremented when flipped
Definition: simplex.h:103
Eigen::Matrix< Scalar, NDim, 1 > Point
the type used for a NDim point, requires some of the interface of an Eigen::Matrix. For now that is probably the only option