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