30#include "ConfigTest.h"
31#include "DGtalCatch.h"
32#include "DGtal/shapes/MeshVoxelizer.h"
33#include "DGtal/kernel/sets/CDigitalSet.h"
34#include "DGtal/kernel/domains/HyperRectDomain.h"
35#include "DGtal/io/readers/MeshReader.h"
36#include "DGtal/io/Display3D.h"
37#include "DGtal/io/readers/MeshReader.h"
38#include "DGtal/io/boards/Board3D.h"
44TEST_CASE(
"Basic voxelization test",
"[voxelization]")
57 using TriOr = MeshVoxelizer6::TriangleOrientation;
60 SECTION(
"Test distance point/plan 3D")
63 const PointR3 A(38.6908 , 14.5441 , -0.71205);
64 const PointR3 B(34.6171 , 13.5999 , 2.44455);
65 const PointR3 C(37.4205 , 2.44239 , 6.31301);
68 const PointZ3 v(35, 2, 5);
70 const VectorR3 e1 = A - B;
71 const VectorR3 e2 = A - C;
73 double distance = MeshVoxelizer6::distance(A, e1.crossProduct(e2), v);
80 SECTION(
"Test if 2D point is inside triangle 2D")
88 OrientationFunctor orientationFunctor;
93 if(! pointPredicate(A, B, C))
107 REQUIRE(MeshVoxelizer6::pointIsInside2DTriangle(A, B, C, v) == TriOr::OUTSIDE);
111 REQUIRE(MeshVoxelizer6::pointIsInside2DTriangle(A, B, C, v) == TriOr::INSIDE);
115 REQUIRE(MeshVoxelizer6::pointIsInside2DTriangle(A, B, C, v) == TriOr::ONEDGE);
119 REQUIRE(MeshVoxelizer6::pointIsInside2DTriangle(A, B, C, v) == TriOr::ONVERTEX);
124 C = { -16.3299, 0. };
126 REQUIRE(MeshVoxelizer6::pointIsInside2DTriangle(A, B, C, v) == TriOr::OUTSIDE);
129 A = { -0.891282, 9.91201 };
130 B = { -1.40823, 9.91261 };
131 C = { -1.36963, 9.37414 };
132 v = { -1.16961, 9.83039 };
133 REQUIRE(MeshVoxelizer6::pointIsInside2DTriangle(A, B, C, v) == TriOr::INSIDE);
137 SECTION(
"Test if 3D point is inside voxel")
140 PointR3 P(-0.89, 9.91, 0.86);
141 PointZ3 v(-1, 10, 1);
143 REQUIRE(MeshVoxelizer6::pointIsInsideVoxel(P, v) ==
true);
147 REQUIRE(MeshVoxelizer6::pointIsInsideVoxel(P, v) ==
true);
151 REQUIRE(MeshVoxelizer6::pointIsInsideVoxel(P, v) ==
false);
156 REQUIRE(MeshVoxelizer6::pointIsInsideVoxel(P, v) ==
false);
160 SECTION(
"26-sep voxelization of a single triangle")
164 MeshVoxelizer26 voxelizer;
166 voxelizer.voxelize(outputSet,
Point(5,0,0),
Point(0,5,0),
Point(0,0,5));
168 for(
auto p: outputSet)
170 board.
saveOBJ(
"triangle26-dig.obj");
176 SECTION(
"6-sep voxelization of a single triangle")
180 MeshVoxelizer6 voxelizer;
182 voxelizer.voxelize(outputSet,
Point(5,0,0),
Point(0,5,0),
Point(0,0,5));
184 for(
auto p: outputSet)
186 board.
saveOBJ(
"triangle6-dig.obj");
192 SECTION(
"6-sep voxelization of a OFF cube mesh")
199 MeshVoxelizer6 voxelizer;
203 voxelizer.voxelize(outputSet, inputMesh, 10.0 );
205 for(
auto p: outputSet)
214 SECTION(
"26-sep voxelization of a OFF cube mesh")
221 MeshVoxelizer26 voxelizer;
225 voxelizer.voxelize(outputSet, inputMesh, 10.0 );
227 for(
auto p: outputSet)
229 board.
saveOBJ(
"box26-dig.obj");
The class Board3D is a type of Display3D which export the figures in the format OBJ/MTL when calling ...
void saveOBJ(const std::string &filename, const bool isNormalized=false)
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
Aim: A container class for storing sets of digital points within some given domain.
Aim: Class that implements an orientation functor, ie. it provides a way to compute the orientation o...
Aim: A class for computing the digitization of a triangle or a Mesh.
Aim: This class is defined to represent a surface mesh through a set of vertices and faces....
Aim: Implements basic operations that will be used in Point and Vector classes.
Aim: Small adapter to models of COrientationFunctor2. It is a model of concepts::CPointPredicate....
DGtal is the top-level namespace which contains all DGtal functions and types.
static bool importOFFFile(const std::string &filename, DGtal::Mesh< TPoint > &aMesh, bool invertVertexOrder=false)
TEST_CASE("Basic voxelization test", "[voxelization]")
SECTION("Testing constant forward iterators")
REQUIRE(domain.isInside(aPoint))