33 #include "DGtal/base/Common.h"
34 #include "DGtal/helpers/StdDefs.h"
35 #include "DGtal/shapes/GaussDigitizer.h"
38 #include "DGtal/shapes/DigitalShapesDecorator.h"
41 #include "DGtal/shapes/parametric/Ball2D.h"
46 using namespace DGtal;
55 bool testDigitalShapesDecorator()
57 unsigned int nbok = 0;
65 typedef ShapeA::Point Point;
69 ShapeA shapeA(-2.501, 0.0, 2.5013);
70 ShapeA shapeB(2, 0.0, 2.5013);
71 ShapeA shapeC(0.0, 0.0, 2.5);
73 MyGaussDigitizerA digShapeA;
74 digShapeA.attach( shapeA );
75 digShapeA.init( shapeA.getLowerBound(), shapeA.getUpperBound(), h );
77 MyGaussDigitizerA digShapeB;
78 digShapeB.attach( shapeB );
79 digShapeB.init( shapeB.getLowerBound(), shapeB.getUpperBound(), h );
81 MyGaussDigitizerA digShapeC;
82 digShapeC.attach( shapeC );
83 digShapeC.init( shapeC.getLowerBound(), shapeC.getUpperBound(), h );
87 CSG s_union ( digShapeA );
88 s_union.plus( digShapeB );
90 CSG s_intersec ( digShapeA );
91 s_intersec.plus( digShapeB );
92 s_intersec.intersection( digShapeC );
94 CSG s_minus ( digShapeA );
95 s_minus.minus( digShapeC );
98 nbok += (( s_union.orientation( Point( -12, 0 )) ==
INSIDE )
99 || ( s_union.orientation( Point( -12, 0 )) ==
ON ))? 0 : 1;
100 nbok += (( s_union.orientation( Point( 0, 0 )) ==
INSIDE )
101 || ( s_union.orientation( Point( 0, 0 )) ==
ON ))? 1 : 0;
102 nbok += (( s_union.orientation( Point( 10, 0 )) ==
INSIDE )
103 || ( s_union.orientation( Point( 10, 0 )) ==
ON ))? 0 : 1;
104 nbok += (( s_union.orientation( Point( 9, 0 )) ==
INSIDE )
105 || ( s_union.orientation( Point( 9, 0 )) ==
ON ))? 1 : 0;
106 nbok += (( s_union.orientation( Point( -10, 0 )) ==
INSIDE )
107 || ( s_union.orientation( Point( -10, 0 )) ==
ON ))? 1 : 0;
110 nbok += (( s_intersec.orientation( Point( -6, 0 )) ==
INSIDE )
111 || ( s_intersec.orientation( Point( -6, 0 )) ==
ON ))? 0 : 1;
112 nbok += (( s_intersec.orientation( Point( 4, 0 )) ==
INSIDE )
113 || ( s_intersec.orientation( Point( 4, 0 )) ==
ON ))? 1 : 0;
114 nbok += (( s_intersec.orientation( Point( 6, 0 )) ==
INSIDE )
115 || ( s_intersec.orientation( Point( 6, 0 )) ==
ON ))? 0 : 1;
116 nbok += (( s_intersec.orientation( Point( 0, 5 )) ==
INSIDE )
117 || ( s_intersec.orientation( Point( 0, 5 )) ==
ON ))? 0 : 1;
120 nbok += (( s_minus.orientation( Point( -9, 0 )) ==
INSIDE )
121 || ( s_minus.orientation( Point( -9, 0 )) ==
ON ))? 1 : 0;
122 nbok += (( s_minus.orientation( Point( -2, 0 )) ==
INSIDE )
123 || ( s_minus.orientation( Point( -2, 0 )) ==
ON ))? 0 : 1;
124 nbok += (( s_minus.orientation( Point( 0, 2 )) ==
INSIDE )
125 || ( s_minus.orientation( Point( 0, 2 )) ==
ON ))? 0 : 1;
126 nbok += (( s_minus.orientation( Point( -8, 0 )) ==
INSIDE )
127 || ( s_minus.orientation( Point( -8, 0 )) ==
ON ))? 1 : 0;
132 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
133 <<
"true == true" << std::endl;
141 int main(
int argc,
char** argv )
145 for (
int i = 0; i < argc; ++i )
149 bool res = testDigitalShapesDecorator();
150 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << std::endl;
void beginBlock(const std::string &keyword="")
Aim: Model of the concept StarShaped represents any circle in the plane.
Aim: A class for computing the Gauss digitization of some Euclidean shape, i.e. its intersection with...
Aim: Constructive Solid Geometry (CSG) between models of CDigitalBoundedShape and CDigitalOrientedSha...
DGtal is the top-level namespace which contains all DGtal functions and types.