A.I.M.S


surfaceOperation.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  * Surface class
36  */
37 #ifndef AIMS_SURFACE_SURFACEOPERATION_H
38 #define AIMS_SURFACE_SURFACEOPERATION_H
39 
40 #include <aims/mesh/surface.h>
41 #include <cartobase/smart/rcptr.h>
42 #include <set>
43 #include <vector>
44 #include <map>
45 #include <list>
46 
47 namespace aims
48 {
49  class AffineTransformation3d;
50 }
52 template<typename T> class TimeTexture;
53 template<typename T> class Texture;
54 
55 namespace carto
56 {
57  template <typename T> class Volume;
58 }
59 
60 
61 namespace aims
62 {
63 
65  {
66  public:
67  template<int D, class T> static std::vector<std::set<uint> >
68  surfaceNeighbours( const AimsSurface<D,T> & surf );
69 
70  template<int D, class T> static std::vector<std::set<uint> >
72 
73  template<int D, class T> static std::vector<std::set<uint> >
75 
76  template<int D, class T> static std::vector<std::map<uint, float> >
78 
79  template<int D, class T>
80  static void invertSurfacePolygons( AimsTimeSurface<D,T> & surface );
81 
82  static void cutMesh( const AimsSurfaceTriangle & insurf,
83  const Point4df & plane, AimsSurfaceTriangle & cut,
84  AimsTimeSurface<2, Void> & borderline );
85  static void
86  cutMesh( const std::vector<const AimsSurfaceTriangle *> & insurf,
87  const Point4df & plane,
88  std::vector<carto::rc_ptr<AimsSurfaceTriangle> > & cut,
89  AimsTimeSurface<2, Void> & borderline );
90  static void cutMesh( const AimsSurfaceTriangle & insurf,
91  const Point4df & plane, AimsSurfaceTriangle & cut,
92  AimsSurfaceTriangle & planemesh,
93  bool checkplane = true );
94  static void
95  cutMesh( const std::vector<const AimsSurfaceTriangle *> & insurf,
96  const Point4df & plane,
97  std::vector<carto::rc_ptr<AimsSurfaceTriangle> > & cut,
98  AimsSurfaceTriangle & planemesh,
99  bool checkplane = true );
100  static void cutMesh( const AimsSurfaceTriangle & insurf,
101  const Point4df & plane, AimsSurfaceTriangle & cut,
102  AimsSurfaceTriangle & planemesh,
103  AimsTimeSurface<2, Void> & borderline,
104  bool checkplane = true );
105  static void
106  cutMesh( const std::vector<const AimsSurfaceTriangle *> & insurf,
107  const Point4df & plane,
108  std::vector<carto::rc_ptr<AimsSurfaceTriangle> > & cut,
109  AimsSurfaceTriangle & planemesh,
110  AimsTimeSurface<2, Void> & borderline,
111  bool checkplane = true );
112  static void cutMesh( const AimsSurfaceTriangle & insurf,
113  const Point4df & plane, AimsSurfaceTriangle & cut,
114  AimsSurfaceTriangle & planemesh,
115  AimsTimeSurface<2, Void> & borderline,
116  bool meshplane, bool checkplane );
117  static void
118  cutMesh( const std::vector<const AimsSurfaceTriangle *> & insurf,
119  const Point4df & plane,
120  std::vector<carto::rc_ptr<AimsSurfaceTriangle> > & cut,
121  AimsSurfaceTriangle & planemesh,
122  AimsTimeSurface<2, Void> & borderline,
123  bool meshplane, bool checkplane );
125  static void cutMesh( const AimsSurfaceTriangle & insurf,
126  const Point4df & plane,
127  AimsTimeSurface<2, Void> & borderline,
128  int timestep = 0 );
130  static void cutMesh( const AimsSurface<3, Void> & insurf,
131  const Point4df & plane,
132  AimsTimeSurface<2, Void> & borderline );
133  static void meshPlanarPolygon( const Point4df & plane,
134  const AimsTimeSurface<2, Void> & border,
135  AimsSurfaceTriangle & outmesh );
139  static bool checkMesh( const AimsSurfaceTriangle & insurf,
140  AimsSurfaceTriangle *outsurf = 0 );
141  static float meshArea( const AimsSurfaceTriangle & surf );
142  static float meshVolume( const AimsSurfaceTriangle & surf );
144  template<int D, class T>
145  static void meshMerge( AimsTimeSurface<D,T> & dst,
146  const AimsTimeSurface<D,T> & add );
148  template<int D, class T>
149  static void meshMerge( AimsTimeSurface<D,T> & dst,
150  const std::list<AimsTimeSurface<D,T> > & src );
152  template<int D, typename T>
153  static void meshTransform( AimsTimeSurface<D,T> & mesh,
154  const Motion & trans );
155  template <int D, typename T>
156  static AimsTimeSurface<D,T> *
157  meshExtract( const AimsTimeSurface<D,T> & mesh,
158  const TimeTexture<int16_t> & tex, int16_t value,
159  std::vector<size_t> ** overtIndex = 0 );
164  template <typename T>
165  static AimsSurface<2,Void> *
167  const Texture<T> & tex, T region );
172  template <typename T>
173  static AimsTimeSurface<2,Void> *
175  const TimeTexture<T> & tex, T region );
181  static Point3df nearestPointToMesh( const Point3df & pos,
182  const AimsSurfaceTriangle & mesh,
183  unsigned nneighbours = 1,
184  unsigned* index = 0 );
185 
192  const AimsSurfaceTriangle & mesh,
193  const std::vector<uint> & selectedPolygons = std::vector<uint>() );
198  template <int D, typename T>
200  bool asDistance = false );
204  template <int D, typename T>
206  const AimsTimeSurface<D,T> & nummesh,
207  const AimsTimeSurface<D,T> & denommesh );
208 
210  static bool checkMeshIntersect( const AimsSurfaceTriangle &,
211  const AimsSurfaceTriangle & );
212 
214  static std::vector<Point3df>* lineDirections(
215  const AimsTimeSurface<2, Void> & );
216 
221  template <int D, typename T>
222  static void sortPolygonsAlongDirection(
223  AimsTimeSurface<D,T> & mesh, int timestep, const Point3df & direction );
224 
227  template <int D, typename T>
228  static void rasterizeMeshWireframe(
229  const AimsTimeSurface<D,T> & mesh,
230  carto::rc_ptr<carto::Volume<int16_t> > & volume, int value = 1 );
231 
234  static void rasterizeMesh(
235  const AimsTimeSurface<3, Void> & mesh,
236  carto::rc_ptr<carto::Volume<int16_t> > & volume, int value = 2 );
237 
238  };
239 
240 }
241 
242 
243 #endif
static std::vector< Point3df > * lineDirections(const AimsTimeSurface< 2, Void > &)
calculate directions of a line mesh, fora each vertex
static std::vector< std::set< uint > > surfaceNeighbours2ndOrder(const AimsTimeSurface< D, T > &surf)
static void invertSurfacePolygons(AimsTimeSurface< D, T > &surface)
static TimeTexture< float > * meshEdgeLengthRatioTexture(const AimsTimeSurface< D, T > &nummesh, const AimsTimeSurface< D, T > &denommesh)
Calculate an edge length ratio in edges of two meshes with the same topology.
static float meshArea(const AimsSurfaceTriangle &surf)
static TimeTexture< float > * meshDensity(const AimsTimeSurface< D, T > &mesh, bool asDistance=false)
Calculate a mesh density: inverse of the average edges distance If asDistance is true, then the average distance is returned instead of the density.
AIMSDATA_API AimsTimeSurface< 3, Void > AimsSurfaceTriangle
Definition: surface.h:547
static void meshTransform(AimsTimeSurface< D, T > &mesh, const Motion &trans)
Applies a transformation to a mesh.
static bool checkMeshIntersect(const AimsSurfaceTriangle &, const AimsSurfaceTriangle &)
Checks if two meshes intersect.
static void cutMesh(const AimsSurfaceTriangle &insurf, const Point4df &plane, AimsSurfaceTriangle &cut, AimsTimeSurface< 2, Void > &borderline)
static AimsTimeSurface< D, T > * meshExtract(const AimsTimeSurface< D, T > &mesh, const TimeTexture< int16_t > &tex, int16_t value, std::vector< size_t > **overtIndex=0)
aims::AffineTransformation3d Motion
static void meshPlanarPolygon(const Point4df &plane, const AimsTimeSurface< 2, Void > &border, AimsSurfaceTriangle &outmesh)
The template class to manage a mesh with time if needed.
Definition: surface.h:290
static std::vector< std::set< uint > > surfaceNeighbours(const AimsSurface< D, T > &surf)
static Point3df nearestPointToMesh(const Point3df &pos, const AimsSurfaceTriangle &mesh, unsigned nneighbours=1, unsigned *index=0)
computes the position of the point in the mesh nearest to the given position, averaging across the nn...
static void sortPolygonsAlongDirection(AimsTimeSurface< D, T > &mesh, int timestep, const Point3df &direction)
Sort polygons along a given direction.
static AimsSurfaceTriangle * refineMeshTri4(const AimsSurfaceTriangle &mesh, const std::vector< uint > &selectedPolygons=std::vector< uint >())
Refine a mesh by subdivising every triangle into 4 smaller ones.
static void rasterizeMesh(const AimsTimeSurface< 3, Void > &mesh, carto::rc_ptr< carto::Volume< int16_t > > &volume, int value=2)
Rasterize polygons into a volume.
static void rasterizeMeshWireframe(const AimsTimeSurface< D, T > &mesh, carto::rc_ptr< carto::Volume< int16_t > > &volume, int value=1)
Rasterize polygons edges into a volume.
The template class to manage a mesh.
Definition: surface.h:56
static float meshVolume(const AimsSurfaceTriangle &surf)
static std::vector< std::map< uint, float > > surfaceNeighbourDistance(const AimsTimeSurface< D, T > &surf)
static void meshMerge(AimsTimeSurface< D, T > &dst, const AimsTimeSurface< D, T > &add)
concatenates 2 meshes into one (adds the second to the first one)
static AimsSurface< 2, Void > * meshTextureBoundary(const AimsSurface< 3, Void > &mesh, const Texture< T > &tex, T region)
Extracts the boundary of region of value of the input texture, on the mesh.
static bool checkMesh(const AimsSurfaceTriangle &insurf, AimsSurfaceTriangle *outsurf=0)
Check mesh for intersecting triangles.
Affine 3D transformation.