DGtal  1.5.beta
viewer3D-7-planes.cpp File Reference
#include <cstdlib>
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/io/viewers/Viewer3D.h"
#include "DGtal/geometry/surfaces/COBANaivePlaneComputer.h"
Include dependency graph for viewer3D-7-planes.cpp:

Go to the source code of this file.

Functions

template<typename Viewer3D , typename Domain , typename Predicate >
void displayPredicate (Viewer3D &viewer, const Domain &domain, const Predicate &pred)
 
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
Jacques-Olivier Lachaud (jacqu.nosp@m.es-o.nosp@m.livie.nosp@m.r.la.nosp@m.chaud.nosp@m.@uni.nosp@m.v-sav.nosp@m.oie..nosp@m.fr ) Laboratory of Mathematics (CNRS, UMR 5127), University of Savoie, France
Date
2012/03/05

Functions for testing class COBANaivePlaneComputer.

This file is part of the DGtal library.

Definition in file viewer3D-7-planes.cpp.

Function Documentation

◆ displayPredicate()

template<typename Viewer3D , typename Domain , typename Predicate >
void displayPredicate ( Viewer3D viewer,
const Domain domain,
const Predicate &  pred 
)
Examples
io/viewers/viewer3D-7-planes.cpp, io/viewers/viewer3D-7-stdplane.cpp, io/viewers/viewer3D-7bis-planes.cpp, and io/viewers/viewer3D-7bis-stdplane.cpp.

Definition at line 64 of file viewer3D-7-planes.cpp.

66 {
67  for ( typename Domain::ConstIterator itB = domain.begin(), itE = domain.end();
68  itB != itE; ++itB )
69  {
70  if ( pred( *itB ) )
71  viewer << *itB;
72  }
73 }
Iterator for HyperRectDomain.
const ConstIterator & end() const
const ConstIterator & begin() const
Domain domain

References DGtal::HyperRectDomain< TSpace >::begin(), domain, and DGtal::HyperRectDomain< TSpace >::end().

Referenced by main().

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 75 of file viewer3D-7-planes.cpp.

76 {
77  using namespace Z3i;
78 
79  QApplication application(argc,argv);
80  trace.beginBlock ( "Testing class COBANaivePlaneComputer" );
81 
82  unsigned int nbok = 0;
83  unsigned int nb = 0;
84 
85  typedef COBANaivePlaneComputer<Z3, BigInteger> PlaneComputer;
86  typedef PlaneComputer::Primitive Primitive;
87  PlaneComputer plane;
88 
89  plane.init( 2, 100, 1, 1 );
90  Point pt0( 0, 0, 0 );
91  bool pt0_inside = plane.extend( pt0 );
92  trace.info() << "(" << nbok << "/" << nb << ") Plane=" << plane
93  << std::endl;
94  Point pt1( 8, 1, 3 );
95  bool pt1_inside = plane.extend( pt1 );
96  ++nb, nbok += pt1_inside == true ? 1 : 0;
97  trace.info() << "(" << nbok << "/" << nb << ") add " << pt1
98  << " Plane=" << plane << std::endl;
99  Point pt2( 2, 7, 1 );
100  bool pt2_inside = plane.extend( pt2 );
101  ++nb, nbok += pt2_inside == true ? 1 : 0;
102  trace.info() << "(" << nbok << "/" << nb << ") add " << pt2
103  << " Plane=" << plane << std::endl;
104 
105  Point pt3( 0, 5, 12 );
106  bool pt3_inside = plane.extend( pt3 );
107  ++nb, nbok += pt3_inside == false ? 1 : 0;
108  trace.info() << "(" << nbok << "/" << nb << ") add " << pt3
109  << " Plane=" << plane << std::endl;
110 
111  Point pt4( -5, -5, 10 );
112  bool pt4_inside = plane.extend( pt4 );
113  ++nb, nbok += pt4_inside == false ? 1 : 0;
114  trace.info() << "(" << nbok << "/" << nb << ") add " << pt4
115  << " Plane=" << plane << std::endl;
116 
117  Point pt5 = pt0 + pt1 + pt2 + Point( 0, 0, 1 );
118  bool pt5_inside = plane.extend( pt5 );
119  ++nb, nbok += pt5_inside == true ? 1 : 0;
120  trace.info() << "(" << nbok << "/" << nb << ") add " << pt5
121  << " Plane=" << plane << std::endl;
122 
123  Point pt6 = Point( 1, 0, 1 );
124  bool pt6_inside = plane.extend( pt6 );
125  ++nb, nbok += pt6_inside == true ? 1 : 0;
126  trace.info() << "(" << nbok << "/" << nb << ") add " << pt5
127  << " Plane=" << plane << std::endl;
128 
129  Primitive strip = plane.primitive();
130  trace.info() << "strip=" << strip
131  << " axis=" << strip.mainAxis()
132  << " axiswidth=" << strip.axisWidth()
133  << " diag=" << strip.mainDiagonal()
134  << " diagwidth=" << strip.diagonalWidth()
135  << std::endl;
136  ++nb, nbok += strip.axisWidth() < 1.0 ? 1 : 0;
137  trace.info() << "(" << nbok << "/" << nb << ") axiswidth < 1 "
138  << std::endl;
139  ++nb, nbok += strip.diagonalWidth() < sqrt(3.0) ? 1 : 0;
140  trace.info() << "(" << nbok << "/" << nb << ") axiswidth < sqrt(3) "
141  << std::endl;
142  trace.emphase() << ( nbok == nb ? "Passed." : "Error." ) << endl;
143  trace.endBlock();
144 
145  typedef Viewer3D<> MyViewer;
146  MyViewer viewer;
147  viewer.show();
148  Color red( 255, 0, 0 );
149  Color green( 0, 255, 0 );
150  Color grey( 200, 200, 200 );
151  Domain domain( Point( -5, -5, -5 ), Point( 12, 12, 12 ) );
152  viewer << ( pt0_inside ? CustomColors3D( green, green ) : CustomColors3D( red, red ) ) << pt0;
153  viewer << ( pt1_inside ? CustomColors3D( green, green ) : CustomColors3D( red, red ) ) << pt1;
154  viewer << ( pt2_inside ? CustomColors3D( green, green ) : CustomColors3D( red, red ) ) << pt2;
155  viewer << ( pt3_inside ? CustomColors3D( green, green ) : CustomColors3D( red, red ) ) << pt3;
156  viewer << ( pt4_inside ? CustomColors3D( green, green ) : CustomColors3D( red, red ) ) << pt4;
157  viewer << ( pt5_inside ? CustomColors3D( green, green ) : CustomColors3D( red, red ) ) << pt5;
158  viewer << ( pt6_inside ? CustomColors3D( green, green ) : CustomColors3D( red, red ) ) << pt6;
159  viewer << CustomColors3D( grey, grey );
160  displayPredicate( viewer, domain, strip );
161 
162  viewer << MyViewer::updateDisplay;
163 
164 
165  return application.exec();
166 }
Aim: A class that contains the COBA algorithm (Emilie Charrier, Lilian Buzer, DGCI2008) for recognizi...
void init(Dimension axis, InternalInteger diameter, InternalInteger widthNumerator=NumberTraits< InternalInteger >::ONE, InternalInteger widthDenominator=NumberTraits< InternalInteger >::ONE)
Structure representing an RGB triple with alpha component.
Definition: Color.h:68
void beginBlock(const std::string &keyword="")
std::ostream & emphase()
std::ostream & info()
double endBlock()
virtual void show()
Overload QWidget method in order to add a call to updateList() method (to ensure that the lists are w...
Trace trace
Definition: Common.h:153
MyPointD Point
Definition: testClone2.cpp:383
void displayPredicate(Viewer3D &viewer, const Domain &domain, const Predicate &pred)

References DGtal::Trace::beginBlock(), displayPredicate(), domain, DGtal::Trace::emphase(), DGtal::Trace::endBlock(), DGtal::Trace::info(), DGtal::COBANaivePlaneComputer< TSpace, TInternalInteger >::init(), DGtal::Viewer3D< TSpace, TKSpace >::show(), and DGtal::trace.