DGtal  0.9.3
Functions
exampleInHalfPlane.cpp File Reference
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/kernel/SpaceND.h"
#include "DGtal/kernel/domains/HyperRectDomain.h"
#include "DGtal/geometry/tools/determinant/Simple2x2DetComputer.h"
#include "DGtal/geometry/tools/determinant/SimpleIncremental2x2DetComputer.h"
#include "DGtal/geometry/tools/determinant/AvnaimEtAl2x2DetSignComputer.h"
#include "DGtal/geometry/tools/determinant/Filtered2x2DetComputer.h"
#include "DGtal/geometry/tools/determinant/InHalfPlaneBy2x2DetComputer.h"
#include "DGtal/geometry/tools/determinant/PredicateFromOrientationFunctor2.h"
#include "DGtal/geometry/tools/determinant/InHalfPlaneBySimple3x3Matrix.h"
Include dependency graph for exampleInHalfPlane.cpp:

Go to the source code of this file.

Functions

bool basicUsage ()
 
void advice ()
 
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
Tristan Roussillon (trist.nosp@m.an.r.nosp@m.oussi.nosp@m.llon.nosp@m.@liri.nosp@m.s.cn.nosp@m.rs.fr ) Laboratoire d'InfoRmatique en Image et Systèmes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
Date
2013/11/28

An example file named exampleInHalfPlane.

This file is part of the DGtal library.

Definition in file exampleInHalfPlane.cpp.

Function Documentation

◆ advice()

void advice ( )

[FunctorDefinition30]

[FunctorDefinition30]

[FunctorDefinition52]

[FunctorDefinition52]

[FunctorDefinition62]

[FunctorDefinition62]

[FunctorDefinition62bis]

[FunctorDefinition62bis]

Examples:
geometry/tools/determinant/exampleInHalfPlane.cpp.

Definition at line 112 of file exampleInHalfPlane.cpp.

Referenced by main().

113 {
114  {
116  //for coordinates of 30 (not zero) bits
120  Functor *a = new Functor();
121  BOOST_VERIFY(a);
122  }
123 
124  {
126  //for coordinates of 52 (not zero) bits
128  typedef AvnaimEtAl2x2DetSignComputer<double> DetComputer;
129  typedef Filtered2x2DetComputer<DetComputer> FDetComputer;
132  Functor *a = new Functor();
133  BOOST_VERIFY(a);
134  //NB. using double as coordinate type is slightly faster than using DGtal::int64_t
135  //typedef PointVector<2, double> Point;
136  }
137 
138  {
140  //for coordinates of 62 (not zero) bits
145  Functor *a= new Functor();
146  BOOST_VERIFY( a);
147  }
148 
149  {
151  //for coordinates of 62 (not zero) bits
152  //if long double is implemented as the 80-bit extended precision type
154  typedef AvnaimEtAl2x2DetSignComputer<long double> DetComputer;
155  typedef Filtered2x2DetComputer<DetComputer> FDetComputer;
157  Functor *a = new Functor();
158  BOOST_VERIFY(a == a);
160  }
161 
162 #ifdef WITH_BIGINTEGER
163  {
165  //for arbitrary coordinates
167  typedef Simple2x2DetComputer<DGtal::BigInteger> DetComputer;
169  Functor *a= new Functor();
170  BOOST_VERIFY( a);
172  }
173 #endif
174 
175 }
InHalfPlaneBySimple3x3Matrix< Point, double > Functor
Aim: Class that provides a way of computing the sign of the determinant of a 2x2 matrix from its four...
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:141
Aim: Small class useful to compute the determinant of a 2x2 matrix from its four coefficients, ie. .
Aim: Class that implements an orientation functor, ie. it provides a way to compute the orientation o...
MyPointD Point
Definition: testClone2.cpp:383
Aim: Class that provides a way of computing the sign of the determinant of a 2x2 matrix from its four...
Aim: Class that implements an orientation functor, ie. it provides a way to compute the orientation o...

◆ basicUsage()

bool basicUsage ( )

[DomainDefinition]

[DomainDefinition]

[ProblemStatement]

[ProblemStatement]

[FunctorDefinition]

[FunctorDefinition]

[PredicateDefinition]

[PredicateDefinition]

[FunctorInitialization]

[FunctorInitialization]

[PredicateUsage]

[PredicateUsage]

Definition at line 62 of file exampleInHalfPlane.cpp.

References domain(), and DGtal::PredicateFromOrientationFunctor2< TOrientationFunctor, acceptNeg, acceptZero >::init().

Referenced by main().

63 {
65  //domain definition
66  typedef SpaceND< 2, DGtal::int16_t > DigitalSpace;
68  typedef Domain::Point Point;
69  Domain domain( Point(-32767,-32767), Point(32767,32767) );
71 
73  Point P, Q, R;
74  P = Point(0,0);
75  Q = Point(5,2);
76  R = Point(2,1);
77  //problem: are P, Q, R counter-clockwise oriented ?
79 
81  //orientation functor
82  typedef InHalfPlaneBySimple3x3Matrix<Point, DGtal::int32_t> OrientationFunctor;
83  OrientationFunctor orientationFunctor;
85 
87  //geometric predicate
89  pointPredicate( orientationFunctor );
91 
93  //initialization
94  pointPredicate.init( P, Q );
95  //which is equivalent to
96  //orientationFunctor.init( P, Q );
97  //because the predicate stores a pointer to the functor
99 
100  bool isCCW;
102  //decision
103  isCCW = pointPredicate( R );
104  //which is equivalent to the following shortcut:
105  //isCCW = pointPredicate( P, Q, R );
107 
108  return isCCW;
109 }
HyperRectDomain< Space > Domain
const Domain domain(Point(1, 2), Point(6, 5))
Aim: SpaceND is a utility class that defines the fundamental structure of a Digital Space in ND...
Definition: SpaceND.h:95
Aim: Parallelepidec region of a digital space, model of a &#39;CDomain&#39;.
Aim: Small adapter to models of COrientationFunctor2. It is a model of concepts::CPointPredicate. It is also a ternary predicate on points, useful for basic geometric tasks such as convex hull computation.
MyPointD Point
Definition: testClone2.cpp:383
Aim: Class that implements an orientation functor, ie. it provides a way to compute the orientation o...

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 177 of file exampleInHalfPlane.cpp.

References advice(), basicUsage(), DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), DGtal::Trace::info(), and DGtal::trace.

178 {
179  trace.beginBlock ( "Example exampleInHalfPlane" );
180  trace.info() << "Args:";
181  for ( int i = 0; i < argc; ++i )
182  trace.info() << " " << argv[ i ];
183  trace.info() << endl;
184 
185  basicUsage();
186  advice();
187 
188  trace.endBlock();
189  return 0;
190 }
void beginBlock(const std::string &keyword="")
Trace trace
Definition: Common.h:137
double endBlock()
void advice()
bool basicUsage()
std::ostream & info()