aimsdata  5.0.5
Neuroimaging data handling
surfacemanip.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 #ifndef AIMS_MESH_SURFACEMANIP_H
35 #define AIMS_MESH_SURFACEMANIP_H
36 
37 #include <aims/mesh/surface.h>
38 #include <cartobase/smart/rcptr.h>
39 #include <set>
40 #include <vector>
41 #include <map>
42 #include <list>
43 
44 namespace aims
45 {
46  class AffineTransformation3d;
47 }
49 template<typename T> class TimeTexture;
50 template<typename T> class Texture;
51 
52 namespace carto
53 {
54  template <typename T> class Volume;
55 }
56 
57 
58 namespace aims
59 {
60 
62  {
63  public:
64  template<int D, class T> static std::vector<std::set<uint> >
65  surfaceNeighbours( const AimsSurface<D,T> & surf );
66 
67  template<int D, class T> static std::vector<std::set<uint> >
68  surfaceNeighbours( const AimsTimeSurface<D,T> & surf );
69 
70  template<int D, class T> static std::vector<std::set<uint> >
71  surfaceNeighbours2ndOrder( const AimsTimeSurface<D,T> & surf );
72 
73  template<int D, class T> static std::vector<std::map<uint, float> >
74  surfaceNeighbourDistance( const AimsTimeSurface<D,T> & surf );
75 
76  template<int D, class T>
77  static void invertSurfacePolygons( AimsTimeSurface<D,T> & surface );
78 
79  static void cutMesh( const AimsSurfaceTriangle & insurf,
80  const Point4df & plane, AimsSurfaceTriangle & cut,
81  AimsTimeSurface<2, Void> & borderline );
82  static void
83  cutMesh( const std::vector<const AimsSurfaceTriangle *> & insurf,
84  const Point4df & plane,
85  std::vector<carto::rc_ptr<AimsSurfaceTriangle> > & cut,
86  AimsTimeSurface<2, Void> & borderline );
87  static void cutMesh( const AimsSurfaceTriangle & insurf,
88  const Point4df & plane, AimsSurfaceTriangle & cut,
89  AimsSurfaceTriangle & planemesh,
90  bool checkplane = true );
91  static void
92  cutMesh( const std::vector<const AimsSurfaceTriangle *> & insurf,
93  const Point4df & plane,
94  std::vector<carto::rc_ptr<AimsSurfaceTriangle> > & cut,
95  AimsSurfaceTriangle & planemesh,
96  bool checkplane = true );
97  static void cutMesh( const AimsSurfaceTriangle & insurf,
98  const Point4df & plane, AimsSurfaceTriangle & cut,
99  AimsSurfaceTriangle & planemesh,
100  AimsTimeSurface<2, Void> & borderline,
101  bool checkplane = true );
102  static void
103  cutMesh( const std::vector<const AimsSurfaceTriangle *> & insurf,
104  const Point4df & plane,
105  std::vector<carto::rc_ptr<AimsSurfaceTriangle> > & cut,
106  AimsSurfaceTriangle & planemesh,
107  AimsTimeSurface<2, Void> & borderline,
108  bool checkplane = true );
109  static void cutMesh( const AimsSurfaceTriangle & insurf,
110  const Point4df & plane, AimsSurfaceTriangle & cut,
111  AimsSurfaceTriangle & planemesh,
112  AimsTimeSurface<2, Void> & borderline,
113  bool meshplane, bool checkplane );
114  static void
115  cutMesh( const std::vector<const AimsSurfaceTriangle *> & insurf,
116  const Point4df & plane,
117  std::vector<carto::rc_ptr<AimsSurfaceTriangle> > & cut,
118  AimsSurfaceTriangle & planemesh,
119  AimsTimeSurface<2, Void> & borderline,
120  bool meshplane, bool checkplane );
122  static void cutMesh( const AimsSurfaceTriangle & insurf,
123  const Point4df & plane,
124  AimsTimeSurface<2, Void> & borderline,
125  int timestep = 0 );
127  static void cutMesh( const AimsSurface<3, Void> & insurf,
128  const Point4df & plane,
129  AimsTimeSurface<2, Void> & borderline );
130  static void meshPlanarPolygon( const Point4df & plane,
131  const AimsTimeSurface<2, Void> & border,
132  AimsSurfaceTriangle & outmesh );
136  static bool checkMesh( const AimsSurfaceTriangle & insurf,
137  AimsSurfaceTriangle *outsurf = 0 );
138  static float meshArea( const AimsSurfaceTriangle & surf );
139  static float meshArea( const AimsSurface<3, Void> & surf );
140  static float meshVolume( const AimsSurfaceTriangle & surf );
141  static float meshVolume( const AimsSurface<3, Void> & surf );
143  template<int D, class T>
144  static void meshMerge( AimsTimeSurface<D,T> & dst,
145  const AimsTimeSurface<D,T> & add );
147  template<int D, class T>
148  static void meshMerge( AimsTimeSurface<D,T> & dst,
149  const std::list<AimsTimeSurface<D,T> > & src );
151  template<int D, typename T>
152  static void meshTransform( AimsTimeSurface<D,T> & mesh,
153  const Motion & trans );
154  template <int D, typename T>
155  static AimsTimeSurface<D,T> *
156  meshExtract( const AimsTimeSurface<D,T> & mesh,
157  const TimeTexture<int16_t> & tex, int16_t value,
158  std::vector<size_t> ** overtIndex = 0 );
163  template <typename T>
164  static AimsSurface<2,Void> *
165  meshTextureBoundary( const AimsSurface<3,Void> & mesh,
166  const Texture<T> & tex, T region );
171  template <typename T>
172  static AimsTimeSurface<2,Void> *
173  meshTextureBoundary( const AimsSurfaceTriangle & mesh,
174  const TimeTexture<T> & tex, T region );
180  static Point3df nearestPointToMesh( const Point3df & pos,
181  const AimsSurfaceTriangle & mesh,
182  unsigned nneighbours = 1,
183  unsigned* index = 0 );
184 
190  static AimsSurfaceTriangle* refineMeshTri4(
191  const AimsSurfaceTriangle & mesh,
192  const std::vector<uint> & selectedPolygons = std::vector<uint>() );
197  template <int D, typename T>
198  static TimeTexture<float>* meshDensity( const AimsTimeSurface<D,T> & mesh,
199  bool asDistance = false );
203  template <int D, typename T>
204  static TimeTexture<float>* meshEdgeLengthRatioTexture(
205  const AimsTimeSurface<D,T> & nummesh,
206  const AimsTimeSurface<D,T> & denommesh );
207 
209  static bool checkMeshIntersect( const AimsSurfaceTriangle &,
210  const AimsSurfaceTriangle & );
211 
213  static std::vector<Point3df>* lineDirections(
214  const AimsTimeSurface<2, Void> & );
215 
220  template <int D, typename T>
221  static void sortPolygonsAlongDirection(
222  AimsTimeSurface<D,T> & mesh, int timestep, const Point3df & direction );
223 
226  template <int D, typename T>
227  static void rasterizeMeshWireframe(
228  const AimsTimeSurface<D,T> & mesh,
229  carto::rc_ptr<carto::Volume<int16_t> > & volume, int value = 1 );
230 
233  static void rasterizeMesh(
234  const AimsTimeSurface<3, Void> & mesh,
235  carto::rc_ptr<carto::Volume<int16_t> > & volume, int value = 2 );
236 
241  template <typename T>
242  static void rasterizeLine(
243  const Point3df & p0, const Point3df & direction, float lmax,
244  T & volume, int value );
245 
246  };
247 
248 }
249 
250 
251 #endif
AIMSDATA_API AimsTimeSurface< 3, Void > AimsSurfaceTriangle
Definition: surface.h:547
The class for EcatSino data write operation.
Definition: border.h:44
The template class to manage a mesh with time if needed.
Definition: surface.h:290
The template class to manage a mesh.
Definition: surface.h:56
aims::AffineTransformation3d Motion
Definition: surfacemanip.h:48
Affine 3D transformation.