DGtal 1.3.0
Loading...
Searching...
No Matches
testImplicitShape.cpp
Go to the documentation of this file.
1
31#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
42using namespace std;
43using namespace DGtal;
44
46// Functions for testing class ImplicitShape.
48
53{
54 trace.beginBlock ( "Testing implicit shaper ..." );
55 Z2i::Point a(0,0);
56 Z2i::Point b(64,64);
57 Z2i::Point c(32,32);
58
59 Board2D board;
60
63
66 board << set;
67 board.saveSVG("implicitball.svg");
68
69 set.clear();
70 board.clear();
73 board << set;
74 board.saveSVG("implicitcube.svg");
75
76
77 set.clear();
78 board.clear();
81 board << set;
82 board.saveSVG("implicitlosange.svg");
83
84 set.clear();
85 board.clear();
88 board << set;
89 board.saveSVG("implicitrounded-1.svg");
90
91
92 set.clear();
93 board.clear();
96 board << set;
97 board.saveSVG("implicitrounded-2.5.svg");
98
99
100 return true;
101}
107{
108 trace.beginBlock ( "Testing implicit shaper in 3D..." );
109 Z3i::Point a(0,0);
110 Z3i::Point b(64,64,64);
111 Z3i::Point c(32,32,32);
112
113 Z3i::Domain domain(a,b);
114
116
117 Image image(domain);
119
122
123 for(Z3i::DigitalSet::ConstIterator it=set.begin(), itend=set.end();
124 it != itend;
125 ++it)
126 {
127 image.setValue((*it), 128);
128 }
129
130 VolWriter<Image>::exportVol("implicitrounded.vol",image);
131
132 return true;
133}
134
136// Standard services - public :
137
138int main( int argc, char** argv )
139{
140 trace.beginBlock ( "Testing class ImplicitShape" );
141 trace.info() << "Args:";
142 for ( int i = 0; i < argc; ++i )
143 trace.info() << " " << argv[ i ];
144 trace.info() << endl;
145
146 bool res = testImplicitShape() && testImplicitShape3D(); // && ... other tests
147 trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
148 trace.endBlock();
149 return res ? 0 : 1;
150}
151// //
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition: Board2D.h:71
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
Container::const_iterator ConstIterator
ConstIterator type of the container;.
Aim: implements association bewteen points lying in a digital domain and values.
Definition: Image.h:70
Aim: model of CEuclideanOrientedShape and CEuclideanBoundedShape concepts to create a ball in nD....
Definition: ImplicitBall.h:65
Aim: model of CEuclideanOrientedShape and CEuclideanBoundedShape concepts to create an hypercube in n...
Aim: model of CEuclideanOrientedShape and CEuclideanBoundedShape concepts to create a ball for the L_...
Aim: model of CEuclideanOrientedShape and CEuclideanBoundedShape concepts to create a rounded hypercu...
static void euclideanShaper(TDigitalSet &aSet, const TShapeFunctor &aFunctor, const double h=1.0)
void beginBlock(const std::string &keyword="")
std::ostream & emphase()
std::ostream & info()
double endBlock()
void clear(const DGtal::Color &color=DGtal::Color::None)
Definition: Board.cpp:152
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:1012
DGtal is the top-level namespace which contains all DGtal functions and types.
Trace trace
Definition: Common.h:154
STL namespace.
static bool exportVol(const std::string &filename, const Image &aImage, const bool compressed=true, const Functor &aFunctor=Functor())
int main()
Definition: testBits.cpp:56
bool testImplicitShape()
bool testImplicitShape3D()
Domain domain