DGtal  1.5.beta
Go to the documentation of this file.
1
31 #include <iostream>
32 #include "DGtal/base/Common.h"
33 #include "ConfigTest.h"
34 #include "DGtalCatch.h"
35 #include "DGtal/helpers/StdDefs.h"
36
38 #include <DGtal/shapes/GaussDigitizer.h>
39
41
42 using namespace std;
43 using namespace DGtal;
44 using namespace Z3i;
45
47 // Functions for testing class WindingNumbersShape.
49
51 {
53
54  SECTION("Checking concept")
55  {
56  BOOST_CONCEPT_ASSERT( (DGtal::concepts::CEuclideanOrientedShape<WNShape>) );
57  }
58
59  SECTION("Simple testof the API")
60  {
61  Eigen::MatrixXd points(4,3);
62  points << 0,0,0,
63  0,1,0,
64  1,0,0,
65  1,1,1;
66  Eigen::MatrixXd normals(4,3);
67  normals << 0,0,-1,
68  0,0,-1,
69  0,0,-1,
70  0,0,1;
71
72  WNShape wnshape(points,normals);
73
74  RealPoint p(-2.0,-2.0,-2.0);
75  DGtal::Orientation ori = wnshape.orientation(p);
76  REQUIRE( ori == DGtal::OUTSIDE);
77
78  p = RealPoint(2.0,2.0,2.0);
79  ori = wnshape.orientation(p);
80  REQUIRE( ori == DGtal::OUTSIDE);
81
82  RealPoint q= RealPoint(.2,.2,.2);
83  auto ori2 = wnshape.orientation(q);
84  REQUIRE( ori2 == DGtal::INSIDE);
85  }
86
87  SECTION("Tesing with the GaussDigitizer")
88  {
89  Eigen::MatrixXd points(4,3);
90  points << 0,0,0,
91  0,1,0,
92  1,0,0,
93  1,1,1;
94  Eigen::MatrixXd normals(4,3);
95  normals << 0,0,-1,
96  0,0,-1,
97  0,0,-1,
98  0,0,1;
99
100  WNShape wnshape(points,normals);
102  gauss.attach(wnshape);
103  gauss.init(Z3i::RealPoint(0,0,0),Z3i::RealPoint(1.5,1.5,1.5), 0.5);
104  auto cpt=0;
105  for(auto p: gauss.getDomain())
106  if (gauss.orientation(p) == DGtal::INSIDE)
107  ++cpt;
108  REQUIRE( cpt == 8);
109  }
110 };
111
Aim: A class for computing the Gauss digitization of some Euclidean shape, i.e. its intersection with...
Orientation orientation(const Point &p) const
void attach(ConstAlias< EuclideanShape > shape)
void init(const RealPoint &xLow, const RealPoint &xUp, typename RealVector::Component gridStep)
Domain getDomain() const
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:593
DGtal is the top-level namespace which contains all DGtal functions and types.
Orientation
Definition: Common.h:141
@ INSIDE
Definition: Common.h:141
@ OUTSIDE
Definition: Common.h:141
Aim: model of a CEuclideanOrientedShape from an implicit function from an oriented point cloud....
Aim: characterizes models of digital oriented shapes. For example, models should provide an orientati...
SECTION("Testing constant forward iterators")
REQUIRE(domain.isInside(aPoint))
PointVector< 3, double > RealPoint