DGtal  1.3.beta
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  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 
61  Z2i::Domain domain(a,b);
63 
65  ImplicitBall<Z2i::Space>( c, 10));
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);
118  Z3i::DigitalSet set(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 
138 int 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 // //
DGtal::ImplicitHyperCube
Aim: model of CEuclideanOrientedShape and CEuclideanBoundedShape concepts to create an hypercube in n...
Definition: ImplicitHyperCube.h:59
image
Image image(domain)
DGtal::HyperRectDomain< Space >
DGtal::Trace::endBlock
double endBlock()
DGtal::ImplicitRoundedHyperCube
Aim: model of CEuclideanOrientedShape and CEuclideanBoundedShape concepts to create a rounded hypercu...
Definition: ImplicitRoundedHyperCube.h:62
DGtal::DigitalSetByAssociativeContainer::begin
ConstIterator begin() const
DGtal::ImageContainerBySTLVector
Definition: ImageContainerBySTLVector.h:126
DGtal::Trace::emphase
std::ostream & emphase()
DGtal::trace
Trace trace
Definition: Common.h:154
DGtal::Trace::beginBlock
void beginBlock(const std::string &keyword="")
LibBoard::Board::clear
void clear(const DGtal::Color &color=DGtal::Color::None)
Definition: Board.cpp:152
DGtal::Trace::info
std::ostream & info()
DGtal::VolWriter
Aim: Export a 3D Image using the Vol formats.
Definition: VolWriter.h:68
main
int main(int argc, char **argv)
Definition: testImplicitShape.cpp:138
DGtal::ImplicitNorm1Ball
Aim: model of CEuclideanOrientedShape and CEuclideanBoundedShape concepts to create a ball for the L_...
Definition: ImplicitNorm1Ball.h:59
Image
ImageContainerBySTLVector< Domain, Value > Image
Definition: testSimpleRandomAccessRangeFromPoint.cpp:45
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
testImplicitShape3D
bool testImplicitShape3D()
Definition: testImplicitShape.cpp:106
testImplicitShape
bool testImplicitShape()
Definition: testImplicitShape.cpp:52
DGtal::ImplicitBall
Aim: model of CEuclideanOrientedShape and CEuclideanBoundedShape concepts to create a ball in nD....
Definition: ImplicitBall.h:64
LibBoard::Board::saveSVG
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:1012
DGtal::DigitalSetByAssociativeContainer::end
ConstIterator end() const
DGtal::Board2D
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition: Board2D.h:70
DGtal::Image
Aim: implements association bewteen points lying in a digital domain and values.
Definition: Image.h:69
DGtal::Shapes
Aim: A utility class for constructing different shapes (balls, diamonds, and others).
Definition: DGtal/shapes/Shapes.h:71
domain
Domain domain
Definition: testProjection.cpp:88
DGtal::PointVector< dim, Integer >
DGtal::DigitalSetByAssociativeContainer::ConstIterator
Container::const_iterator ConstIterator
ConstIterator type of the container;.
Definition: DigitalSetByAssociativeContainer.h:108
DGtal::DigitalSetByAssociativeContainer
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
Definition: DigitalSetByAssociativeContainer.h:89