DGtal  0.9.3
Functions
testBoard3D.cpp File Reference
#include <iostream>
#include "DGtal/base/Common.h"
#include "ConfigTest.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/io/boards/Board3D.h"
Include dependency graph for testBoard3D.cpp:

Go to the source code of this file.

Functions

bool testBoard3D ()
 
bool testQuadNorm ()
 
bool testNormaliation ()
 
bool testShapes ()
 
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 Systemes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
Date
2014/04/12

Functions for testing class Board3D.

This file is part of the DGtal library.

Definition in file testBoard3D.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 192 of file testBoard3D.cpp.

References DGtal::Trace::beginBlock(), DGtal::Trace::emphase(), DGtal::Trace::endBlock(), DGtal::Trace::info(), testBoard3D(), testNormaliation(), testQuadNorm(), testShapes(), and DGtal::trace.

193 {
194  trace.beginBlock ( "Testing class Board3D" );
195  trace.info() << "Args:";
196  for ( int i = 0; i < argc; ++i )
197  trace.info() << " " << argv[ i ];
198  trace.info() << endl;
199 
200 bool res = testBoard3D() && testQuadNorm()
201  && testNormaliation()
202  && testShapes(); // && ... other tests
203  trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
204  trace.endBlock();
205  return res ? 0 : 1;
206 }
void beginBlock(const std::string &keyword="")
bool testShapes()
Trace trace
Definition: Common.h:137
double endBlock()
bool testNormaliation()
std::ostream & emphase()
std::ostream & info()
bool testQuadNorm()
Definition: testBoard3D.cpp:97
bool testBoard3D()
Definition: testBoard3D.cpp:49

◆ testBoard3D()

bool testBoard3D ( )

Example of a test. To be completed.

Definition at line 49 of file testBoard3D.cpp.

References DGtal::Trace::beginBlock(), DGtal::HyperRectDomain< TSpace >::className(), domain(), DGtal::Trace::endBlock(), DGtal::Trace::info(), DGtal::DigitalSetByAssociativeContainer< TDomain, TContainer >::insertNew(), DGtal::Board3D< Space, KSpace >::saveOBJ(), and DGtal::trace.

Referenced by main().

50 {
51  unsigned int nbok = 0;
52  unsigned int nb = 0;
53  trace.beginBlock ( "Testing Board3D ..." );
54 
55 
56 
57  Point p1( -3, -2, 0 );
58  Point p2( 7, 3 , 6);
59  Point p3( -1, -1, -1);
60  Point p4(-1, -1, 0 );
61  Point p5( 5, 2 , 4);
62  Point p6(-3, -6, 0 );
63  Point p7( 5, 2 , 3);
64 
65  Domain domain(p6, p7);
66  DigitalSet shape_set( domain );
67  shape_set.insertNew(p6);
68  shape_set.insertNew(p7);
69 
70  Board3D<> board;
71  board << SetMode3D(domain.className(), "Paving");
72  board << p1 << p2 << p3;
73  board << shape_set;
74  board.saveOBJ("dgtalBoard3D-1-points.obj");
75 
76  trace.info()<<" Second"<<std::endl;
77  Board3D<> board2;
78  board2 << SetMode3D(domain.className(), "Paving");
79  board2 << CustomColors3D(Color(250, 0,0),Color(250, 0,0));
80  board2 << p1 ;
81  board2 << CustomColors3D(Color(0, 255,0),Color(0, 255,0));
82  board2 << p2 << p3;
83  board2 << CustomColors3D(Color(0, 0,255),Color(0, 0,255));
84  board2 << p6;
85 
86  board2.saveOBJ("dgtalBoard3D-1bis-points.obj");
87 
88  nbok += true ? 1 : 0;
89  nb++;
90  trace.info() << "(" << nbok << "/" << nb << ") "
91  << "true == true" << std::endl;
92  trace.endBlock();
93 
94  return nbok == nb;
95 }
void beginBlock(const std::string &keyword="")
const Domain domain(Point(1, 2), Point(6, 5))
Trace trace
Definition: Common.h:137
void saveOBJ(const std::string &filename, const bool isNormalized=false)
double endBlock()
The class Board3D is a type of Display3D which export the figures in the format OBJ/MTL when calling ...
Definition: Board3D.h:81
std::string className() const
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
std::ostream & info()
Structure representing an RGB triple with alpha component.
Definition: Color.h:66
Modifier class in a Display3D stream. Useful to choose your own mode for a given class. Realizes the concept CDrawableWithDisplay3D.

◆ testNormaliation()

bool testNormaliation ( )

Definition at line 140 of file testBoard3D.cpp.

References DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), DGtal::KhalimskySpaceND< dim, TInteger >::init(), DGtal::Board3D< Space, KSpace >::saveOBJ(), and DGtal::trace.

Referenced by main().

141 {
142  trace.beginBlock ( "Testing normalization ..." );
143 
144  Point p1( 0, 0, 0 );
145  Point p2( 0, 10 , 0);
146  Point p3( 10, 10, 0);
147  Point p4(10, 0, 100 );
148  Point p5( 20, 0 , 0);
149  Point p6( 20, 10, 0);
150 
151  KSpace k;
152 
153  k.init(Point(2,2,2), Point(4,4,4), true);
154 
155  Board3D<Space,KSpace> board(k);
156 
157  board << p1<<p2<<p3<<p4;
158 
159  board.saveOBJ("dgtalBoard3D-norm.obj", true);
160  board.saveOBJ("dgtalBoard3D-wonorm.obj");
161 
162  trace.endBlock();
163 
164  return true;
165 }
void beginBlock(const std::string &keyword="")
Trace trace
Definition: Common.h:137
double endBlock()
bool init(const Point &lower, const Point &upper, bool isClosed)
The class Board3D is a type of Display3D which export the figures in the format OBJ/MTL when calling ...
Definition: Board3D.h:81
MyPointD Point
Definition: testClone2.cpp:383
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex...

◆ testQuadNorm()

bool testQuadNorm ( )

Definition at line 97 of file testBoard3D.cpp.

References DGtal::Display3D< Space, KSpace >::addQuadWithNormal(), DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), DGtal::PointVector< dim, TEuclideanRing, TContainer >::getNormalized(), DGtal::Trace::info(), DGtal::KhalimskySpaceND< dim, TInteger >::init(), DGtal::Board3D< Space, KSpace >::saveOBJ(), DGtal::trace, and DGtal::KhalimskySpaceND< dim, TInteger >::uCell().

Referenced by main().

98 {
99  unsigned int nbok = 0;
100  unsigned int nb = 0;
101  trace.beginBlock ( "Testing Board3D Quads ..." );
102 
103 
104 
105  Point p1( 0, 0, 0 );
106  Point p2( 0, 1 , 0);
107  Point p3( 1, 1, 0);
108  Point p4(1, 0, 0 );
109  Point p5( 2, 0 , 0);
110  Point p6( 2, 1, 0);
111  RealVector n(1,1,1);
112  RealVector n2(0,1,1);
113 
114  KSpace k;
115 
116  k.init(Point(2,2,2), Point(4,4,4), true);
117 
118  Board3D<Space,KSpace> board(k);
119  board << CustomColors3D(Color(0, 255,0),Color(0, 255, 0));
120  board.addQuadWithNormal(p1,p2,p3,p4, n.getNormalized(), true);
121  board << CustomColors3D(Color(0, 0, 255),Color(0, 0, 255));
122  board.addQuadWithNormal(p4,p5,p6,p3, n2.getNormalized(), true);
123 
124  Cell surfel = k.uCell( Point( 4,5,5) );
125  Display3DFactory<Space,KSpace>::drawUnorientedSurfelWithNormal( board, surfel, n2.getNormalized());
126 
127  board.saveOBJ("dgtalBoard3D.quad.obj");
128 
129 
130  nbok += true ? 1 : 0;
131  nb++;
132  trace.info() << "(" << nbok << "/" << nb << ") "
133  << "true == true" << std::endl;
134  trace.endBlock();
135 
136  return nbok == nb;
137 }
void beginBlock(const std::string &keyword="")
Trace trace
Definition: Common.h:137
double endBlock()
Factory for GPL Display3D:
bool init(const Point &lower, const Point &upper, bool isClosed)
The class Board3D is a type of Display3D which export the figures in the format OBJ/MTL when calling ...
Definition: Board3D.h:81
Cell uCell(const PreCell &c) const
MyPointD Point
Definition: testClone2.cpp:383
std::ostream & info()
Structure representing an RGB triple with alpha component.
Definition: Color.h:66
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex...

◆ testShapes()

bool testShapes ( )

Definition at line 168 of file testBoard3D.cpp.

References DGtal::Display3D< Space, KSpace >::addLine(), DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), DGtal::Board3D< Space, KSpace >::saveOBJ(), DGtal::Display3D< Space, KSpace >::setLineColor(), and DGtal::trace.

Referenced by main().

169 {
170  trace.beginBlock ( "Testing shapes ..." );
171 
172  RealPoint p1( 0, 0, 0 );
173  RealPoint p2(10, 10, 0);
174 
175  Board3D<Space,KSpace> board;
176 
177  board.setLineColor(Color::Red);
178  board.addLine(p1,p2, 0.5);
179 
180  board.saveOBJ("dgtalBoard3D-line.obj");
181 
182  trace.endBlock();
183 
184  return true;
185 }
void beginBlock(const std::string &keyword="")
Trace trace
Definition: Common.h:137
void saveOBJ(const std::string &filename, const bool isNormalized=false)
double endBlock()
virtual void setLineColor(DGtal::Color aColor)
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:141
The class Board3D is a type of Display3D which export the figures in the format OBJ/MTL when calling ...
Definition: Board3D.h:81
void addLine(const RealPoint &p1, const RealPoint &p2, const double width=0.03)