homog2d library
Functions | Variables
showcase7c.cpp File Reference

shows Segment isInside() FRect , Circle, CPolyline More...

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

Functions

template<typename T >
void draw_intersect (const Segment &seg, const T &p)
 
int main (int, const char **)
 

Variables

img::Image< img::SvgImageim (380, 160)
 

Detailed Description

shows Segment isInside() FRect , Circle, CPolyline

Function Documentation

◆ draw_intersect()

template<typename T >
void draw_intersect ( const Segment seg,
const T &  p 
)
15 {
16  auto inter = seg.intersects(p);
17  if( inter() )
18  for( const auto& pt: inter.get() )
19  pt.draw( im, img::DrawParams().setPointStyle( img::PtStyle::Dot ) );
20 }
void draw(img::Image< img::SvgImage > &im, img::DrawParams dp=img::DrawParams()) const
SVG draw function.
Definition: homog2d.hpp:4414
Draw parameters, independent of back-end library.
Definition: homog2d.hpp:514
detail::Intersect< detail::Inters_1, FPT > intersects(const SegVec< SV2, FPT2 > &) const
Segment/Segment intersection.
Definition: homog2d.hpp:8205
DrawParams & setPointStyle(PtStyle ps)
Definition: homog2d.hpp:585
std::array< FPT, 3 > get() const
Definition: homog2d.hpp:4203
img::Image< img::SvgImage > im(380, 160)
Point2d pt
Definition: homog2d_test.cpp:4034
Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int  ,
const char **   
)
23 {
24  auto n = 35; // nb images
25  FRect rect(35,30,110,90);
26  Circle cir( 160,60, 30 );
27 
28  std::vector<Point2d> vpts{
29  { 0, 0 },
30  { 140,30 },
31  { 80,110},
32  { 60,50 },
33  { 20,80 }
34  };
35  CPolyline pol( vpts );
36  pol.translate( 220, 20 );
37 
38  auto col = img::DrawParams().setColor(50,250,20);
39  auto col_outside = img::DrawParams().setColor(50,20,200);
40  auto col_inside = img::DrawParams().setColor(200,20,20).setThickness(2);
41 
42  Point2d pt1( 20,55 );
43  Point2d pt2( 32,38 );
44  for( int i=0; i<n; i++ )
45  {
46  im.clear();
47  Segment seg(pt1,pt2);
48 
49  auto cols = col_outside;
50  if( seg.isInside( rect ) || seg.isInside( cir ) || seg.isInside( pol ) )
51  cols = col_inside;
52 
53  rect.draw( im, col );
54  cir.draw( im, col );
55  pol.draw( im, col );
56  seg.draw( im, cols );
57 
61 
62  translate( pt1, 10, 0);
63  translate( pt2, 8, 2) ;
64  std::ostringstream oss;
65  oss << "showcase7c_" << std::setfill('0') << std::setw(2) <<i << ".svg";
66  im.write( oss.str() );
67  }
68 }
A circle.
Definition: homog2d.hpp:378
void draw(img::Image< cv::Mat > &, img::DrawParams dp=img::DrawParams()) const
Draw FRect (Opencv implementation)
Definition: homog2d.hpp:11845
bool isInside(const Circle_< FPT2 > &shape) const
Segment is inside Circle.
Definition: homog2d.hpp:5145
Segment seg
Definition: homog2d_test.cpp:4033
CPolyline pol(5, 5u)
FRect rect
Definition: homog2d_test.cpp:4038
DrawParams & setThickness(uint8_t t)
Definition: homog2d.hpp:600
void translate(TX dx, TY dy)
Translate Polyline using dx, dy.
Definition: homog2d.hpp:6411
void draw(img::Image< cv::Mat > &, img::DrawParams dp=img::DrawParams()) const
Definition: homog2d.hpp:11868
Draw parameters, independent of back-end library.
Definition: homog2d.hpp:514
void draw(img::Image< cv::Mat > &, img::DrawParams=img::DrawParams()) const
Draw Circle (Opencv implementation)
Definition: homog2d.hpp:11907
A Flat Rectangle, modeled by its two opposite points.
Definition: homog2d.hpp:379
void draw_intersect(const Segment &seg, const T &p)
Definition: showcase7c.cpp:14
A line segment, oriented (OSegment_) or not (Segment_). Holds the two points.
Definition: homog2d.hpp:366
DrawParams & setColor(uint8_t r, uint8_t g, uint8_t b)
Definition: homog2d.hpp:605
void translate(T &prim, FP1 dx, FP2 dy)
Translate primitive prim (free function)
Definition: homog2d.hpp:11015
void draw(img::Image< img::SvgImage > &, img::DrawParams dp=img::DrawParams()) const
Draw Polyline (SVG implementation)
Definition: homog2d.hpp:12302
img::Image< img::SvgImage > im(380, 160)
Polyline, will be instanciated either as OPolyline_ (open polyline) or CPolyline_.
Definition: homog2d.hpp:364
Circle cir
Definition: homog2d_test.cpp:4036
Base class, will be instanciated as Point2d_ or Line2d_.
Definition: homog2d.hpp:365
Here is the call graph for this function:

Variable Documentation

◆ im

img::Image<img::SvgImage> im(380, 160)