DGtal  1.5.beta
exampleDSLSubsegment.cpp
Go to the documentation of this file.
1 
39 #include <iostream>
40 #include "ConfigExamples.h"
41 #include "DGtal/helpers/StdDefs.h"
42 #include "DGtal/base/Common.h"
44 
45 #include <map>
46 #include "DGtal/geometry/curves/DSLSubsegment.h"
47 #include "DGtal/kernel/CPointPredicate.h"
48 #include "DGtal/arithmetic/IntegerComputer.h"
49 
50 
51 
52 using namespace std;
53 using namespace DGtal;
54 
56 
57 int main( )
58 {
59  trace.beginBlock ( "Example exampleDSLSubsegment" );
60 
61 
62  typedef DGtal::int32_t Integer;
63  typedef long double Number;
64 
65  // Define the DSLSubsegment: the first template parameter specifies
66  // the type of integer used for computations, the second one is the
67  // type of the input DSL characteristics (Integer in this case).
68  typedef DGtal::DSLSubsegment<Integer,Integer> DSLSubseg;
69 
70  typedef DSLSubseg::Point Point;
71 
72  // Define the two endpoints of the subsegment
73  Point A(1,5);
74  Point B(6,9);
75 
76  // Compute the minimal characteristics of the subsegment [AB] of the
77  // 8-connected DSL of characteristics (2,3,15). The algorithm using
78  // the Farey fan is used in this case. If the string is set to
79  // "localCH", the algorithm using local convex hull is used: the
80  // result is the same but the computation time is a bit longer.
81  DSLSubseg D1(2,3,15,A,B,"farey");
82 
83  // Display the result
84  std::cout << "a=" << D1.getA() << " b=" << D1.getB() << " mu=" << D1.getMu() << std::endl;
85 
86  // Define a DSL subsegment with floating-point input
87  // characteristics.
88  typedef DGtal::DSLSubsegment<Integer,Number> DSLSubsegD;
89 
90  // Same as before, except that the last parameter is the precision used for
91  // floating-point geometric predicates. The algorithm used is an
92  // adaptation of the Farey fan algorithm for floating-point input data.
93  DSLSubsegD D2(0.6666,5,A,B,0.00005);
94 
95  // Display the result
96  std::cout << "a=" << D2.getA() << " b=" << D2.getB() << " mu=" << D2.getMu() << std::endl;
97 
98 
99 
100  trace.endBlock();
101  return 0;
102 }
103 // //
Aim: Given a Digital Straight line and two endpoints A and B on this line, compute the minimal charac...
Definition: DSLSubsegment.h:76
void beginBlock(const std::string &keyword="")
double endBlock()
int main()
DGtal is the top-level namespace which contains all DGtal functions and types.
Trace trace
Definition: Common.h:153
boost::int32_t int32_t
signed 32-bit integer.
Definition: BasicTypes.h:72
MyPointD Point
Definition: testClone2.cpp:383