aimsalgo  5.1.2
Neuroimaging image processing
geometric.h
Go to the documentation of this file.
1 /* This software and supporting documentation are distributed by
2  * Institut Federatif de Recherche 49
3  * CEA/NeuroSpin, Batiment 145,
4  * 91191 Gif-sur-Yvette cedex
5  * France
6  *
7  * This software is governed by the CeCILL-B license under
8  * French law and abiding by the rules of distribution of free software.
9  * You can use, modify and/or redistribute the software under the
10  * terms of the CeCILL-B license as circulated by CEA, CNRS
11  * and INRIA at the following URL "http://www.cecill.info".
12  *
13  * As a counterpart to the access to the source code and rights to copy,
14  * modify and redistribute granted by the license, users are provided only
15  * with a limited warranty and the software's author, the holder of the
16  * economic rights, and the successive licensors have only limited
17  * liability.
18  *
19  * In this respect, the user's attention is drawn to the risks associated
20  * with loading, using, modifying and/or developing or reproducing the
21  * software by the user in light of its specific status of free software,
22  * that may mean that it is complicated to manipulate, and that also
23  * therefore means that it is reserved for developers and experienced
24  * professionals having in-depth computer knowledge. Users are therefore
25  * encouraged to load and test the software's suitability as regards their
26  * requirements in conditions enabling the security of their systems and/or
27  * data to be ensured and, more generally, to use and operate it in the
28  * same conditions as regards security.
29  *
30  * The fact that you are presently reading this means that you have had
31  * knowledge of the CeCILL-B license and that you accept its terms.
32  */
33 
34 
35 
36 #ifndef AIMS_MESH_GEOMETRIC_H
37 #define AIMS_MESH_GEOMETRIC_H
38 
39 #include <aims/mesh/texture.h>
40 #include <aims/mesh/surface.h>
41 #include <aims/mesh/mesh_graph.h>
42 #include <cartobase/smart/rcptr.h>
43 #include <list>
44 
45 template <class T>
46 inline float sign(T x)
47 {
48  if (x>(T)0) return(1);
49  else
50  if (x<(T)0) return(-1);
51  else
52  return(0);
53 }
54 
55 
56 
57 // Cross product between two 3D points
58 inline Point3df cross( const Point3df & a, const Point3df & b )
59 {
60 
61  Point3df n;
62  n[0] = a[1]*b[2] - a[2]*b[1];
63  n[1] = a[2]*b[0] - a[0]*b[2];
64  n[2] = a[0]*b[1] - a[1]*b[0];
65  return n;
66 }
67 
68 // Cross product between two 2D points
69 inline float cross( const Point2df & a, const Point2df & b )
70 {
71  return (a[0] * b[1]) - (a[1] * b[0]);
72 }
73 
74 namespace aims
75 {
76 
78  {
79  public:
80  typedef std::list<unsigned> Neighborhood;
81  typedef std::vector< Neighborhood > NeighborList;
82  typedef std::vector< std::list<float> > WeightNeighborList;
83  typedef std::vector<float> WeightList;
84  typedef typename
87 
93 
94  const WeightNeighborList & getPhi() const ;
95  const WeightNeighborList & getTheta() const ;
96  const WeightNeighborList & getDot() const ;
97  const WeightNeighborList & getSurface() const ;
98  const WeightList & getAlpha() const ;
99  const WeightList & getSimpleAlpha() const ;
100  const WeightList & getBeta() const ;
101  const AimsSurfaceTriangle & getMesh() const;
103  const NeighborList & getNeighbor() const;
108  { return _graphvertices; }
110  { return _graphvertices; }
111  meshgraph::MeshGraphFaces & getFaces() { return _graphfaces; }
113  { return _graphfaces; }
114 
115 // protected:
116  void doPhi();
117  void doTheta();
118  void doAlpha();
120  void doBeta();
121  void doDot();
122  void doSurface();
123  void doNeighbor();
124  void sortPolygons( Neighborhood &npoly );
126  void doGraph();
127  void graphToMesh();
128 
129  private:
130  const AimsSurfaceTriangle & _mesh;
132  NeighborList _neighbourso ;
133  NeighborList _triangleNeighbourso ;
134  WeightNeighborList _phi ;
135  WeightNeighborList _theta;
136  WeightList _alpha; // this represents sum(l*l*cotan(alpha))
137  WeightList _simplealpha; // this is just sum(alpha)
138  WeightList _beta;
139  WeightNeighborList _dot;
140  WeightNeighborList _surface;
141  NeighborList doTriangleNeighbor() ;
142  // using meshgraph
143  meshgraph::MeshGraphVertices _graphvertices;
144  meshgraph::MeshGraphFaces _graphfaces;
145 
146  friend class VertexRemover;
147 
148  };
149 
151  {
152  public:
155  virtual ~Curvature();
156  virtual Texture<float> doIt() = 0; //car defini dnas les classes derivees -> classe abstraite non instantiable
157  static void regularize(Texture<float> & tex, float ratio); // pas lie a une instance de la classe
158  static void getTextureProperties(const Texture<float> & tex); // pas lie a une instance de la classe
159  };
160 
162  {
163  public:
165  const std::string & method );
167  const std::string & method );
168 
169  };
170 
172  {
173  public:
177  virtual Texture<float> doIt();
178  };
179 
180 
181  // All these are Mean Curvature estimates
182 
183  class BoixCurvature : public Curvature
184  {
185  public:
188  virtual ~BoixCurvature();
189  virtual Texture<float> doIt();
190  };
191 
193  {
194  public:
198  virtual Texture<float> doIt();
199  };
200 
201  // This is a Gaussian Curvature estimate
202 
204  {
205  public:
209  virtual Texture<float> doIt();
210  };
211 
212  // This is another Gaussian Curvature estimate (from aims-til/Cathier)
213 
215  {
216  public:
220  virtual Texture<float> doIt();
221  void localProcess( size_t i_vert, float & gaussianCurvature,
222  float & meanCurvature,
223  std::pair<float, float> & principalCurvatures,
224  float & orientedMeanCurvature,
225  float & orientedGaussianCurvature,
226  Point3df & normal, float & voronoiArea );
227  void localProcess( const VertexPointer & i,
228  float & gaussianCurvature,
229  float & meanCurvature,
230  std::pair<float, float> & principalCurvatures,
231  float & orientedMeanCurvature,
232  float & orientedGaussianCurvature,
233  Point3df & normal, float & voronoiArea );
234  };
235 
236 
245  {
246  public: // typedefs
247 
250 
251  // constructors
252 
255 
256  // set & get
257 
259  { return *_geom; }
261 
262  // functions
263 
264 // bool operator()( size_t i );
266 
267  private: // functions
268 
269  // NB: neighbors should be a std::vector so far
270  // template < typename Neighborhood >
271  std::vector<Point2df>
272  simple_neighborhood_flattening(
273  const Point3df & point,
274  const GeometricProperties::Neighborhood & neighbors );
275 
276  std::vector<Point2df>
277  simple_neighborhood_flattening(
278  const Point3df & point,
279  const std::vector<VertexPointer> & neighbors );
280 
281  // data, input
283 
284  };
285 
286 
295  std::list<AimsVector<uint, 3> >
296  simple_delaunay_triangulation( const std::vector<Point2df> & points );
297 
298 }
299 
300 
301 
302 #endif
BarycenterCurvature(carto::rc_ptr< AimsSurfaceTriangle > mesh)
virtual Texture< float > doIt()
BarycenterCurvature(const AimsSurfaceTriangle &mesh)
BoixCurvature(carto::rc_ptr< AimsSurfaceTriangle > mesh)
virtual Texture< float > doIt()
virtual ~BoixCurvature()
BoixCurvature(const AimsSurfaceTriangle &mesh)
BoixGaussianCurvature(carto::rc_ptr< AimsSurfaceTriangle > mesh)
BoixGaussianCurvature(const AimsSurfaceTriangle &mesh)
virtual Texture< float > doIt()
Curvature * createCurvature(const AimsSurfaceTriangle &mesh, const std::string &method)
Curvature * createCurvature(carto::rc_ptr< AimsSurfaceTriangle > mesh, const std::string &method)
virtual Texture< float > doIt()=0
Curvature(carto::rc_ptr< AimsSurfaceTriangle > mesh)
static void getTextureProperties(const Texture< float > &tex)
Curvature(const AimsSurfaceTriangle &mesh)
virtual ~Curvature()
static void regularize(Texture< float > &tex, float ratio)
FiniteElementCurvature(carto::rc_ptr< AimsSurfaceTriangle > mesh)
virtual Texture< float > doIt()
FiniteElementCurvature(const AimsSurfaceTriangle &mesh)
void localProcess(size_t i_vert, float &gaussianCurvature, float &meanCurvature, std::pair< float, float > &principalCurvatures, float &orientedMeanCurvature, float &orientedGaussianCurvature, Point3df &normal, float &voronoiArea)
void localProcess(const VertexPointer &i, float &gaussianCurvature, float &meanCurvature, std::pair< float, float > &principalCurvatures, float &orientedMeanCurvature, float &orientedGaussianCurvature, Point3df &normal, float &voronoiArea)
virtual Texture< float > doIt()
GaussianCurvature(const AimsSurfaceTriangle &mesh)
GaussianCurvature(carto::rc_ptr< AimsSurfaceTriangle > mesh)
const WeightList & getAlpha() const
const meshgraph::MeshGraphVertices & getVertices() const
Definition: geometric.h:109
std::list< unsigned > Neighborhood
Definition: geometric.h:80
NeighborList & getTriangleNeighbor()
meshgraph::MeshGraphVertices & getVertices()
Definition: geometric.h:107
GeometricProperties(carto::rc_ptr< AimsSurfaceTriangle > mesh)
constructor working on a non-const mesh
carto::rc_ptr< AimsSurfaceTriangle > getRcMesh()
const WeightNeighborList & getPhi() const
meshgraph::MeshGraphFaces & getFaces()
Definition: geometric.h:111
const meshgraph::MeshGraphFaces & getFaces() const
Definition: geometric.h:112
const WeightNeighborList & getTheta() const
const NeighborList & getNeighbor() const
NeighborList & getNeighbor()
std::vector< float > WeightList
Definition: geometric.h:83
const AimsSurfaceTriangle & getMesh() const
const WeightList & getBeta() const
std::vector< Neighborhood > NeighborList
Definition: geometric.h:81
const WeightList & getSimpleAlpha() const
void sortPolygons(Neighborhood &npoly)
const WeightNeighborList & getDot() const
meshgraph::MeshVertexNode< uint >::VertexIndexCollection::value_type VertexPointer
Definition: geometric.h:86
void buildSortVerticesNeighborhood(size_t i)
const WeightNeighborList & getSurface() const
GeometricProperties(const AimsSurfaceTriangle &mesh)
constructor working on a const mesh
std::vector< std::list< float > > WeightNeighborList
Definition: geometric.h:82
const NeighborList & getTriangleNeighbor() const
A class to remove a vertex from a mesh, and remeshing the hole.
Definition: geometric.h:245
VertexRemover(carto::rc_ptr< AimsSurfaceTriangle > mesh)
meshgraph::MeshVertexNode< uint >::VertexIndexCollection::value_type VertexPointer
Definition: geometric.h:249
GeometricProperties & geometricProperties()
Definition: geometric.h:260
VertexRemover(carto::rc_ptr< GeometricProperties > geom)
bool operator()(VertexPointer &i)
const GeometricProperties & geometricProperties() const
Definition: geometric.h:258
Mesh described as a graph, with nodes and edges.
Definition: mesh_graph.h:64
Point3df cross(const Point3df &a, const Point3df &b)
Definition: geometric.h:58
float sign(T x)
Definition: geometric.h:46
std::list< MeshGraphFace > MeshGraphFaces
Definition: mesh_graph.h:105
std::list< MeshGraphVertex > MeshGraphVertices
Definition: mesh_graph.h:104
std::list< AimsVector< uint, 3 > > simple_delaunay_triangulation(const std::vector< Point2df > &points)
SimpleDelaunayTriangulation.
AIMSDATA_API AimsTimeSurface< 3, Void > AimsSurfaceTriangle