Pointer-based runtime polymorphism.
16 std::vector<std::shared_ptr<rtp::Root>> vec;
18 vec.push_back( std::make_shared<Circle>(
Circle() ) );
19 vec.push_back( std::make_shared<Segment>(
Segment() ) );
20 vec.push_back( std::make_shared<FRect>(
FRect() ) );
21 vec.push_back( std::make_shared<Line2d>(
Line2d() ) );
22 vec.push_back( std::make_shared<Point2d>(
Point2d() ) );
23 vec.push_back( std::make_shared<Ellipse>(
Ellipse() ) );
24 vec.push_back( std::make_shared<CPolyline>(
cpol ) );
25 vec.push_back( std::make_shared<OPolyline>( opol ) );
29 std::cout <<
getString(e->type()) <<
": " << *e
30 <<
"\n -area = " << e->area()
31 <<
"\n -size = " << e->size();
33 std::cout <<
"\n -length = " << e->length();
35 std::cout <<
"\n -length = infinite";
41 auto pl1 = std::dynamic_pointer_cast<
CPolyline>( e );
42 std::cout <<
"pl1 is closed=" << pl1->isClosed() <<
'\n';
OPolyline_< HOMOG2D_INUMTYPE > OPolyline
Definition: homog2d.hpp:12399
FRect_< HOMOG2D_INUMTYPE > FRect
Default rectangle type.
Definition: homog2d.hpp:12395
Segment_< HOMOG2D_INUMTYPE > Segment
Default segment type.
Definition: homog2d.hpp:12388
Circle_< HOMOG2D_INUMTYPE > Circle
Default circle type.
Definition: homog2d.hpp:12392
Line2d_< HOMOG2D_INUMTYPE > Line2d
Default line type, uses double as numerical type.
Definition: homog2d.hpp:12376
Ellipse_< HOMOG2D_INUMTYPE > Ellipse
Default ellipse type.
Definition: homog2d.hpp:12402
CPolyline_< HOMOG2D_INUMTYPE > CPolyline
Default polyline type.
Definition: homog2d.hpp:12398
Point2d_< HOMOG2D_INUMTYPE > Point2d
Default point type, uses double as numerical type.
Definition: homog2d.hpp:12379
img::Image< img::SvgImage > im(300, 400)
CPolyline cpol
Definition: homog2d_test.cpp:4030
const char * getString(PtStyle t)
Definition: homog2d.hpp:496