DGtal  1.0.0
MeshVoxelizer.h
1 
17 #pragma once
18 
29 #if !defined MeshVoxelizer_h
30 
31 #define MeshVoxelizer_h
32 
34 // Inclusions
35 #include "DGtal/helpers/StdDefs.h"
36 #include "DGtal/base/ConstAlias.h"
37 #include "DGtal/shapes/Mesh.h"
38 #include "DGtal/shapes/IntersectionTarget.h"
39 #include "DGtal/kernel/SpaceND.h"
40 #include "DGtal/kernel/sets/CDigitalSet.h"
41 #include "DGtal/geometry/tools/determinant/PredicateFromOrientationFunctor2.h"
42 #include "DGtal/geometry/tools/determinant/InHalfPlaneBySimple3x3Matrix.h"
44 
45 namespace DGtal
46 {
47 
49 
78  template <typename TDigitalSet, int Separation = 6>
80  {
81 
82  public:
83 
86 
88  typedef TDigitalSet DigitalSet;
89  BOOST_STATIC_ASSERT_MSG( DigitalSet::Space::dimension == 3, "DigitalSet dimension must be 3");
90 
92  BOOST_STATIC_ASSERT_MSG( Separation == 6 || Separation == 26, "Separation must be 6 or 26");
93 
94  /****** Associated types *********************/
95  using Space = typename DigitalSet::Space;
97  using MeshFace = std::vector< unsigned int >;
98  using Domain = typename DigitalSet::Domain;
99  using PointR3 = typename Space::RealPoint;
100  using VectorR3 = typename Space::RealPoint;
101  using PointR2 = typename Space2D::RealPoint;
102  using PointZ3 = typename Space::Point;
105  /*********************************************/
106 
107  public:
108 
112  MeshVoxelizer() = default;
113 
114  // ----------------------- Standard services ------------------------------
131  template<typename MeshPoint>
132  void voxelize(DigitalSet &outputSet,
133  const Mesh<MeshPoint> &aMesh,
134  const double scaleFactor = 1.0);
135 
149  template<typename MeshPoint>
150  void voxelize(DigitalSet &outputSet,
151  const MeshPoint &a, const MeshPoint &b, const MeshPoint &c,
152  const double scaleFactor = 1.0);
153 
154 
155 
156  // ----------------------- Internal services ------------------------------
159 
168  static
169  double distance(const PointR3& M,
170  const VectorR3& n,
171  const PointZ3& p) ;
172 
181  static
183  const PointR2& B,
184  const PointR2& C,
185  const PointR2& p) ;
186 
193  static
194  bool pointIsInsideVoxel(const PointR3& P,
195  const PointZ3& v) ;
196 
206  void voxelizeTriangle(DigitalSet &outputSet,
207  const PointR3& A,
208  const PointR3& B,
209  const PointR3& C,
210  const VectorR3& n,
211  const std::pair<PointZ3, PointZ3>& bbox);
212 
213  // ----------------------- Members ------------------------------
214 
215  private:
216 
219  };
220 }
221 
223 // Includes inline functions.
224 #include "DGtal/shapes/MeshVoxelizer.ih"
225 
226 // //
228 
229 #endif // !defined MeshVoxelizer_h
BOOST_CONCEPT_ASSERT((concepts::CDigitalSet< TDigitalSet >))
Concept Checking.
Aim: A class for intersection target used for voxelization.
HyperRectDomain< Space > Domain
typename Space2D::RealPoint PointR2
typename Space::RealPoint PointR3
Definition: MeshVoxelizer.h:99
std::vector< unsigned int > MeshFace
Definition: MeshVoxelizer.h:97
IntersectionTarget myIntersectionTarget
Intersection target.
void voxelize(DigitalSet &outputSet, const Mesh< MeshPoint > &aMesh, const double scaleFactor=1.0)
typename Space::Point PointZ3
Aim: This class is defined to represent a surface mesh through a set of vertices and faces....
Definition: Mesh.h:91
PointVector< dim, double > RealPoint
Definition: SpaceND.h:117
static double distance(const PointR3 &M, const VectorR3 &n, const PointZ3 &p)
static TriangleOrientation pointIsInside2DTriangle(const PointR2 &A, const PointR2 &B, const PointR2 &C, const PointR2 &p)
typename IntersectionTargetTrait< Space, Separation, 1 >::Type IntersectionTarget
typename DigitalSet::Space Space
Definition: MeshVoxelizer.h:95
TDigitalSet DigitalSet
Digital Set Type.
Definition: MeshVoxelizer.h:88
DGtal is the top-level namespace which contains all DGtal functions and types.
BOOST_STATIC_ASSERT_MSG(DigitalSet::Space::dimension==3, "DigitalSet dimension must be 3")
typename Space::RealPoint VectorR3
static bool pointIsInsideVoxel(const PointR3 &P, const PointZ3 &v)
void voxelizeTriangle(DigitalSet &outputSet, const PointR3 &A, const PointR3 &B, const PointR3 &C, const VectorR3 &n, const std::pair< PointZ3, PointZ3 > &bbox)
typename DigitalSet::Domain Domain
Definition: MeshVoxelizer.h:98
PointVector< dim, Integer > Point
Points in DGtal::SpaceND.
Definition: SpaceND.h:110
Aim: A class for computing the digitization of a triangle or a Mesh.
Definition: MeshVoxelizer.h:79
Aim: Represents a set of points within the given domain. This set of points is modifiable by the user...
Definition: CDigitalSet.h:138
Aim: Class that implements an orientation functor, ie. it provides a way to compute the orientation o...
TriangleOrientation
Enum type when deciding if a 2D point belongs to a 2D triangle.