DGtal 1.3.0
Loading...
Searching...
No Matches
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"

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 183 of file testBoard3D.cpp.

184{
185 trace.beginBlock ( "Testing class Board3D" );
186 trace.info() << "Args:";
187 for ( int i = 0; i < argc; ++i )
188 trace.info() << " " << argv[ i ];
189 trace.info() << endl;
190
191bool res = testBoard3D() && testQuadNorm()
193 && testShapes(); // && ... other tests
194 trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
195 trace.endBlock();
196 return res ? 0 : 1;
197}
void beginBlock(const std::string &keyword="")
std::ostream & emphase()
std::ostream & info()
double endBlock()
Trace trace
Definition: Common.h:154
bool testNormaliation()
bool testShapes()
bool testBoard3D()
Definition: testBoard3D.cpp:49
bool testQuadNorm()
Definition: testBoard3D.cpp:88

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

◆ testBoard3D()

bool testBoard3D ( )

Example of a test. To be completed.

Definition at line 49 of file testBoard3D.cpp.

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

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

Referenced by main().

◆ testNormaliation()

bool testNormaliation ( )

Definition at line 131 of file testBoard3D.cpp.

132{
133 trace.beginBlock ( "Testing normalization ..." );
134
135 Point p1( 0, 0, 0 );
136 Point p2( 0, 10 , 0);
137 Point p3( 10, 10, 0);
138 Point p4(10, 0, 100 );
139 Point p5( 20, 0 , 0);
140 Point p6( 20, 10, 0);
141
142 KSpace k;
143
144 k.init(Point(2,2,2), Point(4,4,4), true);
145
146 Board3D<Space,KSpace> board(k);
147
148 board << p1<<p2<<p3<<p4;
149
150 board.saveOBJ("dgtalBoard3D-norm.obj", true);
151 board.saveOBJ("dgtalBoard3D-wonorm.obj");
152
153 trace.endBlock();
154
155 return true;
156}
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
Space::Point Point
Definition: StdDefs.h:168

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

Referenced by main().

◆ testQuadNorm()

bool testQuadNorm ( )

Definition at line 88 of file testBoard3D.cpp.

89{
90 unsigned int nbok = 0;
91 unsigned int nb = 0;
92 trace.beginBlock ( "Testing Board3D Quads ..." );
93
94
95
96 Point p1( 0, 0, 0 );
97 Point p2( 0, 1 , 0);
98 Point p3( 1, 1, 0);
99 Point p4(1, 0, 0 );
100 Point p5( 2, 0 , 0);
101 Point p6( 2, 1, 0);
102 RealVector n(1,1,1);
103 RealVector n2(0,1,1);
104
105 KSpace k;
106
107 k.init(Point(2,2,2), Point(4,4,4), true);
108
109 Board3D<Space,KSpace> board(k);
110 board << CustomColors3D(Color(0, 255,0),Color(0, 255, 0));
111 board.addQuadWithNormal(p1,p2,p3,p4, n.getNormalized(), true);
112 board << CustomColors3D(Color(0, 0, 255),Color(0, 0, 255));
113 board.addQuadWithNormal(p4,p5,p6,p3, n2.getNormalized(), true);
114
115 Cell surfel = k.uCell( Point( 4,5,5) );
116 Display3DFactory<Space,KSpace>::drawUnorientedSurfelWithNormal( board, surfel, n2.getNormalized());
117
118 board.saveOBJ("dgtalBoard3D.quad.obj");
119
120
121 nbok += true ? 1 : 0;
122 nb++;
123 trace.info() << "(" << nbok << "/" << nb << ") "
124 << "true == true" << std::endl;
125 trace.endBlock();
126
127 return nbok == nb;
128}
Cell uCell(const PreCell &c) const
From an unsigned cell, returns an unsigned cell lying into this Khalismky space.
static void drawUnorientedSurfelWithNormal(Display &display, const typename KSpace::Cell &anObject, const RealVector &aNormal, const bool enableDoubleFace=false)

References DGtal::Display3D< Space, KSpace >::addQuadWithNormal(), DGtal::Trace::beginBlock(), DGtal::Display3DFactory< TSpace, TKSpace >::drawUnorientedSurfelWithNormal(), 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().

◆ testShapes()

bool testShapes ( )

Definition at line 159 of file testBoard3D.cpp.

160{
161 trace.beginBlock ( "Testing shapes ..." );
162
163 RealPoint p1( 0, 0, 0 );
164 RealPoint p2(10, 10, 0);
165
167
169 board.addLine(p1,p2, 0.5);
170
171 board.saveOBJ("dgtalBoard3D-line.obj");
172
173 trace.endBlock();
174
175 return true;
176}
static const Color Red
Definition: Color.h:416
virtual void setLineColor(DGtal::Color aColor)
void addLine(const RealPoint &p1, const RealPoint &p2, const double width=0.03)

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

Referenced by main().