DGtal  1.1.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
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
DGtal::MeshVoxelizer::pointIsInsideVoxel
static bool pointIsInsideVoxel(const PointR3 &P, const PointZ3 &v)
DGtal::MeshVoxelizer::voxelize
void voxelize(DigitalSet &outputSet, const MeshPoint &a, const MeshPoint &b, const MeshPoint &c, const double scaleFactor=1.0)
DGtal::MeshVoxelizer::DigitalSet
TDigitalSet DigitalSet
Digital Set Type.
Definition: MeshVoxelizer.h:88
DGtal::MeshVoxelizer::IntersectionTarget
typename IntersectionTargetTrait< Space, Separation, 1 >::Type IntersectionTarget
Definition: MeshVoxelizer.h:104
DGtal::SpaceND::Point
PointVector< dim, Integer > Point
Points in DGtal::SpaceND.
Definition: SpaceND.h:110
DGtal::MeshVoxelizer::VectorR3
typename Space::RealPoint VectorR3
Definition: MeshVoxelizer.h:100
DGtal::MeshVoxelizer::voxelizeTriangle
void voxelizeTriangle(DigitalSet &outputSet, const PointR3 &A, const PointR3 &B, const PointR3 &C, const VectorR3 &n, const std::pair< PointZ3, PointZ3 > &bbox)
DGtal::MeshVoxelizer::BOOST_STATIC_ASSERT_MSG
BOOST_STATIC_ASSERT_MSG(DigitalSet::Space::dimension==3, "DigitalSet dimension must be 3")
DGtal::MeshVoxelizer::MeshVoxelizer
MeshVoxelizer()=default
DGtal::SpaceND
Definition: SpaceND.h:96
DGtal::MeshVoxelizer::Domain
typename DigitalSet::Domain Domain
Definition: MeshVoxelizer.h:98
DGtal::MeshVoxelizer::BOOST_STATIC_ASSERT_MSG
BOOST_STATIC_ASSERT_MSG(Separation==6||Separation==26, "Separation must be 6 or 26")
Separation Checking.
DGtal::MeshVoxelizer::MeshFace
std::vector< unsigned int > MeshFace
Definition: MeshVoxelizer.h:97
DGtal::Mesh
Aim: This class is defined to represent a surface mesh through a set of vertices and faces....
Definition: Mesh.h:92
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition: ClosedIntegerHalfPlane.h:49
Domain
HyperRectDomain< Space > Domain
Definition: testSimpleRandomAccessRangeFromPoint.cpp:44
DGtal::MeshVoxelizer::INSIDE
@ INSIDE
Definition: MeshVoxelizer.h:158
DGtal::MeshVoxelizer::PointR3
typename Space::RealPoint PointR3
Definition: MeshVoxelizer.h:99
DGtal::InHalfPlaneBySimple3x3Matrix
Aim: Class that implements an orientation functor, ie. it provides a way to compute the orientation o...
Definition: InHalfPlaneBySimple3x3Matrix.h:92
DGtal::MeshVoxelizer::OUTSIDE
@ OUTSIDE
Definition: MeshVoxelizer.h:158
DGtal::MeshVoxelizer::TriangleOrientation
TriangleOrientation
Enum type when deciding if a 2D point belongs to a 2D triangle.
Definition: MeshVoxelizer.h:158
DGtal::MeshVoxelizer::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((concepts::CDigitalSet< TDigitalSet >))
Concept Checking.
DGtal::MeshVoxelizer::ONVERTEX
@ ONVERTEX
Definition: MeshVoxelizer.h:158
DGtal::MeshVoxelizer::PointR2
typename Space2D::RealPoint PointR2
Definition: MeshVoxelizer.h:101
DGtal::MeshVoxelizer::voxelize
void voxelize(DigitalSet &outputSet, const Mesh< MeshPoint > &aMesh, const double scaleFactor=1.0)
DGtal::MeshVoxelizer::pointIsInside2DTriangle
static TriangleOrientation pointIsInside2DTriangle(const PointR2 &A, const PointR2 &B, const PointR2 &C, const PointR2 &p)
DGtal::SpaceND::RealPoint
PointVector< dim, double > RealPoint
Definition: SpaceND.h:117
DGtal::MeshVoxelizer::PointZ3
typename Space::Point PointZ3
Definition: MeshVoxelizer.h:102
DGtal::MeshVoxelizer::myIntersectionTarget
IntersectionTarget myIntersectionTarget
Intersection target.
Definition: MeshVoxelizer.h:218
DGtal::MeshVoxelizer::ONEDGE
@ ONEDGE
Definition: MeshVoxelizer.h:158
Space
SpaceND< 2 > Space
Definition: testSimpleRandomAccessRangeFromPoint.cpp:42
DGtal::MeshVoxelizer::Space
typename DigitalSet::Space Space
Definition: MeshVoxelizer.h:95
DGtal::IntersectionTargetTrait::IntersectionTarget
Internal intersection target structure.
Definition: IntersectionTarget.h:75
DGtal::concepts::CDigitalSet
Aim: Represents a set of points within the given domain. This set of points is modifiable by the user...
Definition: CDigitalSet.h:141
DGtal::MeshVoxelizer::distance
static double distance(const PointR3 &M, const VectorR3 &n, const PointZ3 &p)
DGtal::MeshVoxelizer
Aim: A class for computing the digitization of a triangle or a Mesh.
Definition: MeshVoxelizer.h:80