DGtal  0.9.3
testImplicitShape.cpp
Go to the documentation of this file.
1 
30 #include <iostream>
32 #include "DGtal/base/Common.h"
33 #include "DGtal/helpers/StdDefs.h"
34 #include "DGtal/shapes/Shapes.h"
35 #include "DGtal/shapes/ShapeFactory.h"
36 #include "DGtal/io/boards/Board2D.h"
37 #include "DGtal/io/colormaps/GrayscaleColorMap.h"
38 #include "DGtal/io/writers/VolWriter.h"
39 #include "DGtal/images/ImageContainerBySTLVector.h"
41 
42 using namespace std;
43 using namespace DGtal;
44 
46 // Functions for testing class ImplicitShape.
48 
53 {
54  unsigned int nbok = 0;
55  unsigned int nb = 0;
56 
57  trace.beginBlock ( "Testing implicit shaper ..." );
58  Z2i::Point a(0,0);
59  Z2i::Point b(64,64);
60  Z2i::Point c(32,32);
61 
62  Board2D board;
63 
64  Z2i::Domain domain(a,b);
66 
68  ImplicitBall<Z2i::Space>( c, 10));
69  board << set;
70  board.saveSVG("implicitball.svg");
71 
72  set.clear();
73  board.clear();
74  Shapes<Z2i::Domain>::euclideanShaper( set,
76  board << set;
77  board.saveSVG("implicitcube.svg");
78 
79 
80  set.clear();
81  board.clear();
82  Shapes<Z2i::Domain>::euclideanShaper( set,
84  board << set;
85  board.saveSVG("implicitlosange.svg");
86 
87  set.clear();
88  board.clear();
89  Shapes<Z2i::Domain>::euclideanShaper( set,
91  board << set;
92  board.saveSVG("implicitrounded-1.svg");
93 
94 
95  set.clear();
96  board.clear();
97  Shapes<Z2i::Domain>::euclideanShaper( set,
99  board << set;
100  board.saveSVG("implicitrounded-2.5.svg");
101 
102 
103  nbok += true ? 1 : 0;
104  nb++;
105  trace.info() << "(" << nbok << "/" << nb << ") "
106  << "true == true" << std::endl;
107  trace.endBlock();
108 
109  return nbok == nb;
110 }
116 {
117  unsigned int nbok = 0;
118  unsigned int nb = 0;
119 
120  trace.beginBlock ( "Testing implicit shaper in 3D..." );
121  Z3i::Point a(0,0);
122  Z3i::Point b(64,64,64);
123  Z3i::Point c(32,32,32);
124 
125  Z3i::Domain domain(a,b);
126 
128 
129  Image image(domain);
130  Z3i::DigitalSet set(domain);
131 
134 
135  for(Z3i::DigitalSet::ConstIterator it=set.begin(), itend=set.end();
136  it != itend;
137  ++it)
138  {
139  image.setValue((*it), 128);
140  }
141 
142  VolWriter<Image>::exportVol("implicitrounded.vol",image);
143 
144  nbok += true ? 1 : 0;
145  nb++;
146  trace.info() << "(" << nbok << "/" << nb << ") "
147  << "true == true" << std::endl;
148  trace.endBlock();
149 
150  return nbok == nb;
151 }
152 
154 // Standard services - public :
155 
156 int main( int argc, char** argv )
157 {
158  trace.beginBlock ( "Testing class ImplicitShape" );
159  trace.info() << "Args:";
160  for ( int i = 0; i < argc; ++i )
161  trace.info() << " " << argv[ i ];
162  trace.info() << endl;
163 
164  bool res = testImplicitShape() && testImplicitShape3D(); // && ... other tests
165  trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
166  trace.endBlock();
167  return res ? 0 : 1;
168 }
169 // //
void beginBlock(const std::string &keyword="")
Aim: model of CEuclideanOrientedShape and CEuclideanBoundedShape concepts to create a rounded hypercu...
const Domain domain(Point(1, 2), Point(6, 5))
Trace trace
Definition: Common.h:137
int main(int argc, char **argv)
bool testImplicitShape3D()
Aim: Export a 3D Image using the Vol formats.
Definition: VolWriter.h:68
STL namespace.
double endBlock()
void setValue(const Point &aPoint, const Value &aValue)
Definition: Image.h:247
Aim: model of CEuclideanOrientedShape and CEuclideanBoundedShape concepts to create a ball for the L_...
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:1012
std::ostream & emphase()
void clear(const DGtal::Color &color=DGtal::Color::None)
Definition: Board.cpp:152
Aim: model of CEuclideanOrientedShape and CEuclideanBoundedShape concepts to create a ball in nD...
Definition: ImplicitBall.h:64
Aim: model of CEuclideanOrientedShape and CEuclideanBoundedShape concepts to create an hypercube in n...
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
std::ostream & info()
ImageContainerBySTLVector< Domain, Value > Image
bool testImplicitShape()
Aim: A utility class for constructing different shapes (balls, diamonds, and others).
Container::const_iterator ConstIterator
ConstIterator type of the container;.
Image image(domain)
Aim: This class specializes a &#39;Board&#39; class so as to display DGtal objects more naturally (with <<)...
Definition: Board2D.h:70