homog2d library
Functions
rtp_v.hpp File Reference
This graph shows which files directly or indirectly include this file:

Functions

template<typename IM >
void do_vrtp (const std::vector< h2d::Point2d > &vecpts, IM &im)
 Variant-based runtime polymorphism function. More...
 

Function Documentation

◆ do_vrtp()

template<typename IM >
void do_vrtp ( const std::vector< h2d::Point2d > &  vecpts,
IM &  im 
)

Variant-based runtime polymorphism function.

Variant-based polymorphism

ONLY TO BE USED WITH THE ASSOCIATED PROGRAMS homog2d_test_rtp_*.cpp

12 {
13  CPolyline cpol( vecpts );
14  OPolyline opol( vecpts );
15 
16  std::vector<CommonType> vec;
17 
18  vec.push_back( Circle() );
19  vec.push_back( Segment() );
20  vec.push_back( FRect() );
21  vec.push_back( Line2d() );
22  vec.push_back( Point2d() );
23  vec.push_back( Ellipse() );
24  vec.push_back( cpol );
25  vec.push_back( opol );
26 
27  fct::DrawFunct vde( im );
28  auto h = Homogr().addTranslation(3,3).addScale(15);
29  for( auto& e: vec )
30  {
31  std::cout << getString(type(e))
32  << "\n -area=" << area(e)
33  << "\n -size=" << size(e);
34  if( type(e) != Type::Line2d )
35  std::cout << "\n -length=" << length(e);
36  else
37  {
39  std::cout << "\n -length=N/A (li=" << li << ')';
40  }
41 
42  std::cout << "\n- data type=" << getString(dtype(e)) << '\n';
43 
44  e = transform( h, e );
45  std::visit( vde, e ); // then draw
46  }
47 }
Homogr_< HOMOG2D_INUMTYPE > Homogr
Default homography (3x3 matrix) type, uses double as numerical type.
Definition: homog2d.hpp:12382
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
HOMOG2D_INUMTYPE length(const T &elem)
Returns length of element or variant (free function)
Definition: homog2d.hpp:10223
Type type(const T &elem)
Free function. Returns the type of object or variant.
Definition: homog2d.hpp:10190
VariantUnwrapper(const std::variant< Ts... > &) -> VariantUnwrapper< Ts... >
Fix for the above VariantUnwrapper for C++17.
Line2d li
Definition: homog2d_test.cpp:4035
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
Dtype dtype(const T &elem)
Returns the underlying data type of object or variant.
Definition: homog2d.hpp:10208
HOMOG2D_INUMTYPE size(const T &elem)
Returns size of element or variant (free function)
Definition: homog2d.hpp:10253
img::Image< img::SvgImage > im(300, 400)
CPolyline cpol
Definition: homog2d_test.cpp:4030
CommonType_< FPT > transform(const Homogr_< FPT > &h, const T &elem)
Apply homography to primitive.
Definition: homog2d.hpp:10378
HOMOG2D_INUMTYPE area(const T &elem)
Returns area of element or variant (free function)
Definition: homog2d.hpp:10238
const char * getString(PtStyle t)
Definition: homog2d.hpp:496
Here is the call graph for this function:
Here is the caller graph for this function: