DGtal  1.5.beta
exampleInHalfPlane.cpp
Go to the documentation of this file.
1 
39 #include <iostream>
40 #include "DGtal/base/Common.h"
41 
42 #include "DGtal/kernel/SpaceND.h"
43 #include "DGtal/kernel/domains/HyperRectDomain.h"
44 
45 #include "DGtal/geometry/tools/determinant/Simple2x2DetComputer.h"
46 #include "DGtal/geometry/tools/determinant/SimpleIncremental2x2DetComputer.h"
47 #include "DGtal/geometry/tools/determinant/AvnaimEtAl2x2DetSignComputer.h"
48 #include "DGtal/geometry/tools/determinant/Filtered2x2DetComputer.h"
49 #include "DGtal/geometry/tools/determinant/InHalfPlaneBy2x2DetComputer.h"
51 #include "DGtal/geometry/tools/determinant/PredicateFromOrientationFunctor2.h"
52 #include "DGtal/geometry/tools/determinant/InHalfPlaneBySimple3x3Matrix.h"
55 
56 using namespace std;
57 using namespace DGtal;
58 
60 
61 bool
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 }
110 
111 void
113 {
114  {
116  //for coordinates of 30 (not zero) bits
120  Functor *a = new Functor();
121  BOOST_VERIFY(a);
122  delete a;
123  }
124 
125  {
127  //for coordinates of 52 (not zero) bits
129  typedef AvnaimEtAl2x2DetSignComputer<double> DetComputer;
130  typedef Filtered2x2DetComputer<DetComputer> FDetComputer;
133  Functor *a = new Functor();
134  BOOST_VERIFY(a);
135  delete a;
136  //NB. using double as coordinate type is slightly faster than using DGtal::int64_t
137  //typedef PointVector<2, double> Point;
138  }
139 
140  {
142  //for coordinates of 62 (not zero) bits
147  Functor *a= new Functor();
148  BOOST_VERIFY( a);
149  delete a;
150  }
151 
152  {
154  //for coordinates of 62 (not zero) bits
155  //if long double is implemented as the 80-bit extended precision type
157  typedef AvnaimEtAl2x2DetSignComputer<long double> DetComputer;
158  typedef Filtered2x2DetComputer<DetComputer> FDetComputer;
160  Functor *a = new Functor();
161  BOOST_VERIFY(a == a);
163  delete a;
164  }
165 
166 #ifdef WITH_BIGINTEGER
167  {
169  //for arbitrary coordinates
171  typedef Simple2x2DetComputer<DGtal::BigInteger> DetComputer;
173  Functor *a= new Functor();
174  BOOST_VERIFY( a);
176  delete a;
177  }
178 #endif
179 
180 }
181 
182 int main( int argc, char** argv )
183 {
184  trace.beginBlock ( "Example exampleInHalfPlane" );
185  trace.info() << "Args:";
186  for ( int i = 0; i < argc; ++i )
187  trace.info() << " " << argv[ i ];
188  trace.info() << endl;
189 
190  basicUsage();
191  advice();
192 
193  trace.endBlock();
194  return 0;
195 }
196 // //
Aim: Class that provides a way of computing the sign of the determinant of a 2x2 matrix from its four...
Aim: Class that provides a way of computing the sign of the determinant of a 2x2 matrix from its four...
Aim: Parallelepidec region of a digital space, model of a 'CDomain'.
Aim: Class that implements an orientation functor, ie. it provides a way to compute the orientation o...
Aim: Class that implements an orientation functor, ie. it provides a way to compute the orientation o...
Aim: Small adapter to models of COrientationFunctor2. It is a model of concepts::CPointPredicate....
void init(const Point &aPoint1, const Point &aPoint2)
Aim: Small class useful to compute the determinant of a 2x2 matrix from its four coefficients,...
void beginBlock(const std::string &keyword="")
std::ostream & info()
double endBlock()
bool basicUsage()
int main(int argc, char **argv)
void advice()
DGtal is the top-level namespace which contains all DGtal functions and types.
Trace trace
Definition: Common.h:153
MyPointD Point
Definition: testClone2.cpp:383
InHalfPlaneBySimple3x3Matrix< Point, double > Functor
Domain domain
HyperRectDomain< Space > Domain