aimsdata 6.0.0
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
44namespace aims
45{
47}
49template<typename T> class TimeTexture;
50template<typename T> class Texture;
51
52namespace carto
53{
54 template <typename T> class Volume;
55}
56
57
58namespace 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> >
69
70 template<int D, class T> static std::vector<std::set<uint> >
72
73 template<int D, class T> static std::vector<std::map<uint, float> >
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 std::map<int, float> meshArea( const AimsSurfaceTriangle & surf,
141 const TimeTexture<int16_t> & tex );
142 static std::map<int, float> meshArea( const AimsSurface<3, Void> & surf,
143 const Texture<int16_t> *tex );
144 static std::map<int, float> meshArea( const AimsSurfaceTriangle & surf,
145 const Texture<int16_t> & tex );
146 static float meshVolume( const AimsSurfaceTriangle & surf );
147 static float meshVolume( const AimsSurface<3, Void> & surf );
149 template<int D, class T>
150 static void meshMerge( AimsTimeSurface<D,T> & dst,
151 const AimsTimeSurface<D,T> & add );
153 template<int D, class T>
154 static void meshMerge( AimsTimeSurface<D,T> & dst,
155 const std::list<AimsTimeSurface<D,T> > & src );
157 template<int D, typename T>
158 static void meshTransform( AimsTimeSurface<D,T> & mesh,
159 const Motion & trans );
162 template <int D, typename T>
163 static AimsTimeSurface<D,T> *
164 meshExtract( const AimsTimeSurface<D,T> & mesh,
165 const TimeTexture<int16_t> & tex, int16_t value,
166 std::vector<size_t> ** overtIndex = 0 );
171 template <typename T>
172 static AimsSurface<2,Void> *
174 const Texture<T> & tex, T region );
179 template <typename T>
182 const TimeTexture<T> & tex, T region );
189 const AimsSurfaceTriangle & mesh,
190 unsigned nneighbours = 1,
191 unsigned* index = 0 );
192
199 const AimsSurfaceTriangle & mesh,
200 const std::vector<uint> & selectedPolygons = std::vector<uint>() );
205 template <int D, typename T>
207 bool asDistance = false );
211 template <int D, typename T>
213 const AimsTimeSurface<D,T> & nummesh,
214 const AimsTimeSurface<D,T> & denommesh );
215
218 const AimsSurfaceTriangle & );
219
221 static std::vector<Point3df>* lineDirections(
222 const AimsTimeSurface<2, Void> & );
223
228 template <int D, typename T>
229 static void sortPolygonsAlongDirection(
230 AimsTimeSurface<D,T> & mesh, int timestep, const Point3df & direction );
231
234 template <int D, typename T>
235 static void rasterizeMeshWireframe(
236 const AimsTimeSurface<D,T> & mesh,
237 carto::rc_ptr<carto::Volume<int16_t> > & volume, int value = 1 );
238
241 static void rasterizeMesh(
242 const AimsTimeSurface<3, Void> & mesh,
243 carto::rc_ptr<carto::Volume<int16_t> > & volume, int value = 2 );
244
249 template <typename T>
250 static void rasterizeLine(
251 const Point3df & p0, const Point3df & direction, float lmax,
252 T & volume, int value );
253
255 template <int D, typename T>
256 static std::pair<carto::rc_ptr<AimsTimeSurface<D, Void> >,
258 splitTexturedMesh( const AimsTimeSurface<D, T> & texmesh );
259
261 template <int D, typename T>
264 const TimeTexture<T> & texture );
265
266 };
267
268}
269
270
271#endif
The template class to manage a mesh.
Definition surface.h:69
The template class to manage a mesh with time if needed.
Definition surface.h:317
static void sortPolygonsAlongDirection(AimsTimeSurface< D, T > &mesh, int timestep, const Point3df &direction)
Sort polygons along a given direction.
static AimsTimeSurface< D, T > * meshExtract(const AimsTimeSurface< D, T > &mesh, const TimeTexture< int16_t > &tex, int16_t value, std::vector< size_t > **overtIndex=0)
Extracts a sub-mesh region from a label texture.
static void cutMesh(const std::vector< const AimsSurfaceTriangle * > &insurf, const Point4df &plane, std::vector< carto::rc_ptr< AimsSurfaceTriangle > > &cut, AimsSurfaceTriangle &planemesh, AimsTimeSurface< 2, Void > &borderline, bool meshplane, bool checkplane)
static void invertSurfacePolygons(AimsTimeSurface< D, T > &surface)
static std::map< int, float > meshArea(const AimsSurfaceTriangle &surf, const Texture< int16_t > &tex)
static std::map< int, float > meshArea(const AimsSurfaceTriangle &surf, const TimeTexture< int16_t > &tex)
static void cutMesh(const AimsSurface< 3, Void > &insurf, const Point4df &plane, AimsTimeSurface< 2, Void > &borderline)
This variant only computes the border line.
static std::map< int, float > meshArea(const AimsSurface< 3, Void > &surf, const Texture< int16_t > *tex)
static std::vector< Point3df > * lineDirections(const AimsTimeSurface< 2, Void > &)
calculate directions of a line mesh, fora each vertex
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 bool checkMesh(const AimsSurfaceTriangle &insurf, AimsSurfaceTriangle *outsurf=0)
Check mesh for intersecting triangles.
static std::vector< std::map< uint, float > > surfaceNeighbourDistance(const AimsTimeSurface< D, T > &surf)
static void meshPlanarPolygon(const Point4df &plane, const AimsTimeSurface< 2, Void > &border, AimsSurfaceTriangle &outmesh)
static void cutMesh(const AimsSurfaceTriangle &insurf, const Point4df &plane, AimsSurfaceTriangle &cut, AimsSurfaceTriangle &planemesh, AimsTimeSurface< 2, Void > &borderline, bool meshplane, bool checkplane)
static void cutMesh(const AimsSurfaceTriangle &insurf, const Point4df &plane, AimsSurfaceTriangle &cut, AimsSurfaceTriangle &planemesh, bool checkplane=true)
static void meshTransform(AimsTimeSurface< D, T > &mesh, const Motion &trans)
Applies a transformation to a mesh.
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 cutMesh(const AimsSurfaceTriangle &insurf, const Point4df &plane, AimsTimeSurface< 2, Void > &borderline, int timestep=0)
This variant only computes the border line.
static void cutMesh(const std::vector< const AimsSurfaceTriangle * > &insurf, const Point4df &plane, std::vector< carto::rc_ptr< AimsSurfaceTriangle > > &cut, AimsTimeSurface< 2, Void > &borderline)
static void cutMesh(const std::vector< const AimsSurfaceTriangle * > &insurf, const Point4df &plane, std::vector< carto::rc_ptr< AimsSurfaceTriangle > > &cut, AimsSurfaceTriangle &planemesh, AimsTimeSurface< 2, Void > &borderline, bool checkplane=true)
static float meshVolume(const AimsSurface< 3, Void > &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 void cutMesh(const AimsSurfaceTriangle &insurf, const Point4df &plane, AimsSurfaceTriangle &cut, AimsSurfaceTriangle &planemesh, AimsTimeSurface< 2, Void > &borderline, bool checkplane=true)
static std::pair< carto::rc_ptr< AimsTimeSurface< D, Void > >, carto::rc_ptr< TimeTexture< T > > > splitTexturedMesh(const AimsTimeSurface< D, T > &texmesh)
Split a textured mesh into a mesh and a texture.
static void cutMesh(const std::vector< const AimsSurfaceTriangle * > &insurf, const Point4df &plane, std::vector< carto::rc_ptr< AimsSurfaceTriangle > > &cut, AimsSurfaceTriangle &planemesh, bool checkplane=true)
static bool checkMeshIntersect(const AimsSurfaceTriangle &, const AimsSurfaceTriangle &)
Checks if two meshes intersect.
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 carto::rc_ptr< AimsTimeSurface< D, T > > joinTexturedMesh(const AimsTimeSurface< D, Void > &mesh, const TimeTexture< T > &texture)
Join a mesh and a texture into a textured mesh.
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,...
static std::vector< std::set< uint > > surfaceNeighbours(const AimsSurface< D, T > &surf)
static void rasterizeLine(const Point3df &p0, const Point3df &direction, float lmax, T &volume, int value)
T should be carto::Volume<int16_t> or BucketMap<Void>::Bucket.
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 float meshArea(const AimsSurfaceTriangle &surf)
static float meshVolume(const AimsSurfaceTriangle &surf)
static void cutMesh(const AimsSurfaceTriangle &insurf, const Point4df &plane, AimsSurfaceTriangle &cut, AimsTimeSurface< 2, Void > &borderline)
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.
static std::vector< std::set< uint > > surfaceNeighbours2ndOrder(const AimsTimeSurface< D, T > &surf)
static AimsSurface< 2, Void > * meshTextureBoundary(const AimsSurface< 3, Void > &mesh, const Texture< T > &tex, T region)
Extracts the boundary of region of value <region> of the input texture, on the mesh.
static float meshArea(const AimsSurface< 3, Void > &surf)
The class for EcatSino data write operation.
aims::AffineTransformation3d Motion
Definition spmR.h:52
AIMSDATA_API AimsTimeSurface< 3, Void > AimsSurfaceTriangle
Definition surface.h:595
AimsVector< float, 3 > Point3df
AimsVector< float, 4 > Point4df