homog2d library
Macros | Functions
bg_test_1.cpp File Reference

test of importing a polygon from Boost Geometry More...

#include "../../homog2d.hpp"
Include dependency graph for bg_test_1.cpp:

Macros

#define HOMOG2D_USE_BOOSTGEOM
 
#define HOMOG2D_USE_OPENCV
 

Functions

int main ()
 

Detailed Description

test of importing a polygon from Boost Geometry

Note
20230216: preliminar feature, will be expanded

run with $ make test-bg

Macro Definition Documentation

◆ HOMOG2D_USE_BOOSTGEOM

#define HOMOG2D_USE_BOOSTGEOM

◆ HOMOG2D_USE_OPENCV

#define HOMOG2D_USE_OPENCV

Function Documentation

◆ main()

int main ( )
15 {
16  namespace bg = boost::geometry;
17  std::cout << "Boost version:" << BOOST_VERSION << '\n';
18  std::cout << "Boost lib version:" << BOOST_LIB_VERSION << '\n';
19 // two types of boost points
20  using point_t1 = bg::model::point<double, 2, bg::cs::cartesian>;
21  using point_t2 = bg::model::d2::point_xy<double>;
22 
23 // build two boost geometry polygons, one open, one closed
24  using cpolygon_t1 = bg::model::polygon<point_t1,true,true>;
25  using opolygon_t1 = bg::model::polygon<point_t1,true,false>;
26 
27  cpolygon_t1 cpoly1{{ {0.0, 0.0}, {0.0, 5.0}, {5.0, 5.0}, {5.0, 0.0}, {0.0, 0.0} }};
28  opolygon_t1 opoly1{{ {0.0, 0.0}, {0.0, 5.0}, {5.0, 5.0}, {5.0, 0.0} }};
29 
30 // importing the polygons
31  h2d::CPolyline p1a( cpoly1 );
32  h2d::OPolyline p1b( opoly1 );
33  std::cout << "p1a=" << p1a << "p1b=" << p1b << '\n';
34 
35  using cpolygon_t2 = bg::model::polygon<point_t2,true,true>;
36  using opolygon_t2 = bg::model::polygon<point_t2,true,false>;
37 
38  cpolygon_t2 cpoly2{{ {0.0, 0.0}, {0.0, 5.0}, {5.0, 5.0}, {5.0, 0.0}, {0.0, 0.0} }};
39  opolygon_t2 opoly2{{ {0.0, 0.0}, {0.0, 5.0}, {5.0, 5.0}, {5.0, 0.0} }};
40 
41  h2d::CPolyline p2a( cpoly2 );
42  h2d::OPolyline p2b( opoly2 );
43  std::cout << "p2a=" << p2a << "p2b=" << p2b << '\n';
44 
45  point_t1 ptb1(3,4);
46  point_t2 ptb2(8,9);
47  h2d::Point2d p1(ptb1);
48  h2d::Point2d p2(ptb2);
49  std::cout << "p1=" << p1 << " p2=" << p2 << '\n';
50 
51  p1.set(ptb2);
52  p2.set(ptb1);
53  std::cout << "p1=" << p1 << " p2=" << p2 << '\n';
54 
55  p1 = ptb2;
56  p2 = ptb1;
57 
58 // convert to bg type
59  point_t1 bpt1a = p1.getPt<point_t1>();
60  point_t1 bpt1b = h2d::getPt<point_t1>(p2);
61 }
Polyline, will be instanciated either as OPolyline_ (open polyline) or CPolyline_.
Definition: homog2d.hpp:364
Base class, will be instanciated as Point2d_ or Line2d_.
Definition: homog2d.hpp:365
Here is the call graph for this function: