DGtal  0.9.3
Functions
testImplicitShape.cpp File Reference
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/shapes/Shapes.h"
#include "DGtal/shapes/ShapeFactory.h"
#include "DGtal/io/boards/Board2D.h"
#include "DGtal/io/colormaps/GrayscaleColorMap.h"
#include "DGtal/io/writers/VolWriter.h"
#include "DGtal/images/ImageContainerBySTLVector.h"
Include dependency graph for testImplicitShape.cpp:

Go to the source code of this file.

Functions

bool testImplicitShape ()
 
bool testImplicitShape3D ()
 
int main (int argc, char **argv)
 

Detailed Description

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Author
David Coeurjolly (david.nosp@m..coe.nosp@m.urjol.nosp@m.ly@l.nosp@m.iris..nosp@m.cnrs.nosp@m..fr ) Laboratoire d'InfoRmatique en Image et Systèmes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
Date
2011/03/22

Functions for testing class ImplicitShape.

This file is part of the DGtal library.

Definition in file testImplicitShape.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 156 of file testImplicitShape.cpp.

References DGtal::Trace::beginBlock(), DGtal::Trace::emphase(), DGtal::Trace::endBlock(), DGtal::Trace::info(), testImplicitShape(), testImplicitShape3D(), and DGtal::trace.

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 }
void beginBlock(const std::string &keyword="")
Trace trace
Definition: Common.h:137
bool testImplicitShape3D()
double endBlock()
std::ostream & emphase()
std::ostream & info()
bool testImplicitShape()

◆ testImplicitShape()

bool testImplicitShape ( )

Example of a test. To be completed.

Definition at line 52 of file testImplicitShape.cpp.

References DGtal::Trace::beginBlock(), LibBoard::Board::clear(), domain(), DGtal::Trace::endBlock(), DGtal::Trace::info(), LibBoard::Board::saveSVG(), and DGtal::trace.

Referenced by main().

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();
76  board << set;
77  board.saveSVG("implicitcube.svg");
78 
79 
80  set.clear();
81  board.clear();
84  board << set;
85  board.saveSVG("implicitlosange.svg");
86 
87  set.clear();
88  board.clear();
91  board << set;
92  board.saveSVG("implicitrounded-1.svg");
93 
94 
95  set.clear();
96  board.clear();
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 }
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
double endBlock()
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
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...
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
std::ostream & info()
Aim: A utility class for constructing different shapes (balls, diamonds, and others).
Aim: This class specializes a &#39;Board&#39; class so as to display DGtal objects more naturally (with <<)...
Definition: Board2D.h:70

◆ testImplicitShape3D()

bool testImplicitShape3D ( )

Example of a test. To be completed.

Definition at line 115 of file testImplicitShape.cpp.

References DGtal::Trace::beginBlock(), domain(), DGtal::Trace::endBlock(), image(), DGtal::Trace::info(), DGtal::Image< TImageContainer >::setValue(), and DGtal::trace.

Referenced by main().

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 }
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
Aim: Export a 3D Image using the Vol formats.
Definition: VolWriter.h:68
double endBlock()
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
std::ostream & info()
ImageContainerBySTLVector< Domain, Value > Image
Aim: A utility class for constructing different shapes (balls, diamonds, and others).
Container::const_iterator ConstIterator
ConstIterator type of the container;.
Image image(domain)