DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
geometry/curves/exampleDSLSubsegment.cpp
Example of
DSLSubsegment
.
#include <iostream>
#include "ConfigExamples.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/base/Common.h"
#include <map>
#include "DGtal/geometry/curves/DSLSubsegment.h"
#include "DGtal/kernel/CPointPredicate.h"
#include "DGtal/arithmetic/IntegerComputer.h"
using namespace
std
;
using namespace
DGtal
;
int
main
( )
{
trace
.
beginBlock
(
"Example exampleDSLSubsegment"
);
typedef
DGtal::int32_t
Integer
;
typedef
long
double
Number;
// Define the DSLSubsegment: the first template parameter specifies
// the type of integer used for computations, the second one is the
// type of the input DSL characteristics (Integer in this case).
typedef
DGtal::DSLSubsegment<Integer,Integer>
DSLSubseg;
typedef
DSLSubseg::Point
Point
;
// Define the two endpoints of the subsegment
Point
A
(1,5);
Point
B
(6,9);
// Compute the minimal characteristics of the subsegment [AB] of the
// 8-connected DSL of characteristics (2,3,15). The algorithm using
// the Farey fan is used in this case. If the string is set to
// "localCH", the algorithm using local convex hull is used: the
// result is the same but the computation time is a bit longer.
DSLSubseg D1(2,3,15,
A
,
B
,
"farey"
);
// Display the result
std::cout <<
"a="
<< D1.getA() <<
" b="
<< D1.getB() <<
" mu="
<< D1.getMu() << std::endl;
// Define a DSL subsegment with floating-point input
// characteristics.
typedef
DGtal::DSLSubsegment<Integer,Number>
DSLSubsegD;
// Same as before, except that the last parameter is the precision used for
// floating-point geometric predicates. The algorithm used is an
// adaptation of the Farey fan algorithm for floating-point input data.
DSLSubsegD D2(0.6666,5,
A
,
B
,0.00005);
// Display the result
std::cout <<
"a="
<< D2.getA() <<
" b="
<< D2.getB() <<
" mu="
<< D2.getMu() << std::endl;
trace
.
endBlock
();
return
0;
}
// //
B
Definition
testPartialTemplateSpecialization.cpp:63
B::B
B(const C &c)
Definition
testPartialTemplateSpecialization.cpp:73
DGtal::DSLSubsegment
Aim: Given a Digital Straight line and two endpoints A and B on this line, compute the minimal charac...
Definition
DSLSubsegment.h:76
DGtal::Trace::beginBlock
void beginBlock(const std::string &keyword="")
DGtal::Trace::endBlock
double endBlock()
Integer
Point::Coordinate Integer
Definition
examplePlaneProbingParallelepipedEstimator.cpp:44
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
DGtal::int32_t
std::int32_t int32_t
signed 32-bit integer.
Definition
BasicTypes.h:71
DGtal::trace
Trace trace
std
STL namespace.
A
Definition
testCountedConstPtrOrConstPtr.cpp:43
A::A
A(int _a)
Definition
testCountedConstPtrOrConstPtr.cpp:44
Point
MyPointD Point
Definition
testClone2.cpp:381
main
int main(int, char **)
Definition
testIntegerComputer.cpp:331
Generated on
for DGtal by
1.18.0