homog2d library
|
Polyline, will be instanciated either as OPolyline_ (open polyline) or CPolyline_. More...
#include <homog2d.hpp>
Public Types | |
using | FType = FPT |
using | SType = std::conditional< std::is_same_v< PLT, typ::IsClosed >, typ::T_CPol, typ::T_OPol > |
Public Member Functions | |
void | draw (img::Image< img::SvgImage > &, img::DrawParams dp=img::DrawParams()) const |
Draw Polyline (SVG implementation) More... | |
void | draw (img::Image< cv::Mat > &, img::DrawParams dp=img::DrawParams()) const |
Draw PolylineBase (Opencv implementation) More... | |
std::vector< Line2d_< HOMOG2D_INUMTYPE > > | getBisectorLines () const |
template<typename T > | |
PolylineBase< typ::IsClosed, FPT > | getOffsetPoly (T value, OffsetPolyParams p=OffsetPolyParams{}) const |
Return an "offsetted" closed polyline, requires simple polygon (CPolyline AND no crossings) as input. More... | |
template<typename T , typename std::enable_if< trait::IsShape< T >::value, T >::type * = nullptr> | |
detail::IntersectM< FPT > | intersects (const T &other) const |
Polyline intersection with Line, Segment, FRect, Circle. More... | |
template<typename T , typename std::enable_if<(trait::HasArea< T >::value &&!trait::PolIsClosed< T >::value), T >::type * = nullptr> | |
bool | isInside (const T &prim) const |
Polyline isInside other primitive. More... | |
template<typename T , typename std::enable_if< trait::PolIsClosed< T >::value, T >::type * = nullptr> | |
bool | isInside (const T &cpol) const |
Polyline isInside other CPolyline. More... | |
Type | type () const |
Constructors | |
PolylineBase ()=default | |
Default constructor. More... | |
template<typename FPT2 > | |
PolylineBase (const FRect_< FPT2 > &rect) | |
Constructor from FRect. Enabled for "closed" type, disabled for "open" type. More... | |
template<typename FPT2 > | |
PolylineBase (const Segment_< FPT2 > &seg) | |
template<typename T , typename std::enable_if< trait::IsContainer< T >::value, T >::type * = nullptr> | |
PolylineBase (const T &vec) | |
Constructor from a vector of points. More... | |
template<typename FPT2 , typename T > | |
PolylineBase (FPT2 rad, T n) | |
Constructor that builds a regular convex polygon of n points at a distance rad , centered at (0,0). More... | |
template<typename FPT2 > | |
constexpr | PolylineBase (const CPolyline_< FPT2 > &other) |
Copy-Constructor from Closed Polyline. More... | |
template<typename FPT2 > | |
PolylineBase (const OPolyline_< FPT2 > &other) | |
Copy-Constructor from Open Polyline. More... | |
template<typename BPT , bool CLKW, bool CLOSED> | |
PolylineBase (const boost::geometry::model::polygon< BPT, CLKW, CLOSED > &bgpol) | |
Constructor from a boost geometry polygon, see misc/test_files/bg_test_1.cpp. More... | |
Attributes access | |
size_t | size () const |
Returns the number of points. More... | |
constexpr bool | isClosed () const |
HOMOG2D_INUMTYPE | length () const |
Returns length of Polyline. More... | |
HOMOG2D_INUMTYPE | area () const |
Returns area of polygon (computed only if necessary) More... | |
bool | isSimple () const |
Returns true if object is a polygon (closed, and no segment crossing) More... | |
auto | getBB () const |
Returns Bounding Box of Polyline. More... | |
LPBase< typ::IsPoint, HOMOG2D_INUMTYPE > | centroid () const |
Compute centroid of polygon. More... | |
size_t | nbSegs () const |
Returns the number of segments. If "closed",. More... | |
Point2d_< FPT > | getExtremePoint (CardDir) const |
Get Top-most / Bottom-most / Left-most / Right-most point. More... | |
Point2d_< FPT > | getTmPoint () const |
Return Top-most point of Polyline. More... | |
Point2d_< FPT > | getBmPoint () const |
Return Bottom-most point of Polyline. More... | |
Point2d_< FPT > | getLmPoint () const |
Return Left-most point of Polyline. More... | |
Point2d_< FPT > | getRmPoint () const |
Return Right-most point of Polyline. More... | |
bool | isConvex () const |
Returns true if polygon is convex. More... | |
Modifiers (non-const member functions) | |
void | clear () |
Clear all (does not change the "open/close" status). More... | |
template<typename FPT2 > | |
void | rotate (Rotate, const Point2d_< FPT2 > &) |
Rotates the polyline by either 90°, 180°, 270° (-90°) at point refpt . More... | |
void | rotate (Rotate) |
Rotates the polyline by either 90°, 180°, 270° (-90°) at point (0,0) More... | |
void | minimize () |
Miminize the PolylineBase: remove all points that lie in the middle of two segments with same angle. More... | |
template<typename TX , typename TY > | |
void | translate (TX dx, TY dy) |
Translate Polyline using dx , dy . More... | |
template<typename T1 , typename T2 > | |
void | translate (const std::pair< T1, T2 > &ppt) |
Translate Polyline, using a pair of numerical values. More... | |
template<typename TX , typename TY > | |
void | moveTo (TX x, TY y) |
Move Polyline to new origin. More... | |
template<typename T1 > | |
void | moveTo (const Point2d_< T1 > &new_org) |
Move Polyline to new origin, given by new_org . More... | |
template<typename CONT , typename std::enable_if< trait::IsContainer< CONT >::value, CONT >::type * = nullptr> | |
void | set (const CONT &vec) |
Set from vector/array/list of points (discards previous points) More... | |
template<typename FPT1 , typename FPT2 , typename FPT3 > | |
void | setParallelogram (const Point2d_< FPT1 > &pt1, const Point2d_< FPT2 > &pt2, const Point2d_< FPT3 > &pt3) |
Build a parallelogram (4 points) from 3 points. More... | |
template<typename FPT2 > | |
void | set (const FRect_< FPT2 > &rect) |
Set from FRect. More... | |
template<typename FPT2 , typename T > | |
std::pair< HOMOG2D_INUMTYPE, HOMOG2D_INUMTYPE > | set (FPT2 rad, T n) |
Build RCP (Regular Convex Polygon), and return distance between consecutive points. More... | |
Operators | |
template<typename PLT2 , typename FPT2 > | |
bool | operator== (const PolylineBase< PLT2, FPT2 > &other) const |
template<typename PLT2 , typename FPT2 > | |
bool | operator!= (const PolylineBase< PLT2, FPT2 > &other) const |
![]() | |
std::pair< int, int > | dsize () const |
Get data size expressed as number of bits for, respectively, mantissa and exponent. More... | |
Dtype | dtype () const |
Get numerical data type as a Dtype value, can be stringified with h2d::getString(Dtype) More... | |
template<typename T > | |
constexpr bool | isInside (const Common< T > &) const |
This function is a fallback for all sub-classes that do not provide such a method. More... | |
size_t | size () const |
![]() | |
virtual | ~Root () |
Friends | |
template<typename T1 , typename T2 > | |
std::ostream & | h2d::base::operator<< (std::ostream &, const h2d::base::PolylineBase< T1, T2 > &) |
template<typename T1 > | |
class | h2d::Ellipse_ |
template<typename FPT1 , typename FPT2 > | |
CPolyline_< FPT1 > | h2d::operator* (const h2d::Homogr_< FPT2 > &, const h2d::FRect_< FPT1 > &) |
template<typename FPT1 , typename FPT2 , typename PLT2 > | |
auto | h2d::operator* (const Homogr_< FPT2 > &, const base::PolylineBase< PLT2, FPT1 > &) -> base::PolylineBase< PLT2, FPT1 > |
template<typename T1 , typename T2 > | |
class | PolylineBase |
Data access | |
std::vector< Point2d_< FPT > > & | getPts () |
Returns the points (reference) More... | |
const std::vector< Point2d_< FPT > > & | getPts () const |
Returns the points (const reference) More... | |
std::vector< OSegment_< FPT > > | getOSegs () const |
Returns (as a copy) the oriented segments of the polyline. More... | |
std::vector< Segment_< FPT > > | getSegs () const |
Returns (as a copy) the segments of the polyline. More... | |
Point2d_< FPT > | getPoint (size_t idx) const |
Returns one point of the polyline. More... | |
OSegment_< FPT > | getOSegment (size_t idx) const |
Returns one oriented segment of the polyline. More... | |
Segment_< FPT > | getSegment (size_t idx) const |
Returns one segment of the polyline. More... | |
CPolyline_< FPT > | convexHull () const |
Return convex hull (member function implementation) More... | |
Polyline, will be instanciated either as OPolyline_ (open polyline) or CPolyline_.
template args:
using h2d::base::PolylineBase< PLT, FPT >::FType = FPT |
using h2d::base::PolylineBase< PLT, FPT >::SType = std::conditional<std::is_same_v<PLT,typ::IsClosed>,typ::T_CPol,typ::T_OPol> |
|
default |
Default constructor.
|
inline |
Constructor from FRect. Enabled for "closed" type, disabled for "open" type.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Constructor from a boost geometry polygon, see misc/test_files/bg_test_1.cpp.
Requirements: the Boost polygon must have 2-cartesian coordinates points, either bg::model::point
or bg::model::d2::point_xy
but the underlying numerical type is free.
bgpol | Boost Point Type (either bg::model::point or bg::model::d2::point_xy ) this one is ignored here true: closed, false: open input boost geometry polygon |
|
virtual |
Returns area of polygon (computed only if necessary)
Implements h2d::rtp::Root.
Point2d_< HOMOG2D_INUMTYPE > h2d::base::base::PolylineBase::centroid | ( | ) | const |
Compute centroid of polygon.
ref: https://en.wikipedia.org/wiki/Centroid#Of_a_polygon
|
inline |
Clear all (does not change the "open/close" status).
CPolyline_< FPT > h2d::base::PolylineBase< CT, FPT >::convexHull | ( | ) | const |
Return convex hull (member function implementation)
|
virtual |
Draw Polyline (SVG implementation)
Implements h2d::rtp::Root.
|
virtual |
Draw PolylineBase (Opencv implementation)
Implements h2d::rtp::Root.
|
inline |
Returns Bounding Box of Polyline.
|
inline |
Point2d_< FPT > h2d::base::PolylineBase< PLT, FPT >::getBmPoint | ( | ) | const |
Return Bottom-most point of Polyline.
Point2d_< FPT > h2d::base::PolylineBase< PLT, FPT >::getExtremePoint | ( | CardDir | dir | ) | const |
Get Top-most / Bottom-most / Left-most / Right-most point.
Point2d_< FPT > h2d::base::PolylineBase< PLT, FPT >::getLmPoint | ( | ) | const |
Return Left-most point of Polyline.
PolylineBase< typ::IsClosed, FPT > h2d::base::PolylineBase< PLT, FPT >::getOffsetPoly | ( | T | dist, |
OffsetPolyParams | params = OffsetPolyParams{} |
||
) | const |
Return an "offsetted" closed polyline, requires simple polygon (CPolyline AND no crossings) as input.
On failure (for whatever reason), will return an empty CPolyline
|
inline |
|
inline |
Returns (as a copy) the oriented segments of the polyline.
|
inline |
Returns one point of the polyline.
|
inline |
Returns the points (reference)
|
inline |
Point2d_< FPT > h2d::base::PolylineBase< PLT, FPT >::getRmPoint | ( | ) | const |
Return Right-most point of Polyline.
|
inline |
|
inline |
Returns (as a copy) the segments of the polyline.
Point2d_< FPT > h2d::base::PolylineBase< PLT, FPT >::getTmPoint | ( | ) | const |
Return Top-most point of Polyline.
|
inline |
Polyline intersection with Line, Segment, FRect, Circle.
|
inline |
bool h2d::base::PolylineBase< PLT, FPT >::isConvex | ( | ) | const |
Returns true if polygon is convex.
This implies that:
|
inline |
Polyline isInside other primitive.
Sfinae should resolve for T=Circle,FRect,Ellipse but not for CPolyline
|
inline |
Polyline isInside other CPolyline.
Sfinae should resolve ONLY for CPolyline
bool h2d::base::PolylineBase< PLT, FPT >::isSimple | ( | ) | const |
Returns true if object is a polygon (closed, and no segment crossing)
|
virtual |
Returns length of Polyline.
Implements h2d::rtp::Root.
|
inline |
Miminize the PolylineBase: remove all points that lie in the middle of two segments with same angle.
For example, if we have the following points ("Open" polyline): (0,0)-(1,0)-(2,0)
This will be replaced by: (0,0)–(2,0)
|
inline |
Move Polyline to new origin.
|
inline |
Move Polyline to new origin, given by new_org
.
|
inline |
Returns the number of segments. If "closed",.
the last segment (going from last to first point) is counted
|
inline |
|
inline |
void h2d::base::PolylineBase< PLT, FPT >::rotate | ( | Rotate | rot, |
const Point2d_< FPT2 > & | refpt | ||
) |
Rotates the polyline by either 90°, 180°, 270° (-90°) at point refpt
.
For an arbitrary angle alpha
(rad.), you can write:
void h2d::base::PolylineBase< PLT, FPT >::rotate | ( | Rotate | rot | ) |
Rotates the polyline by either 90°, 180°, 270° (-90°) at point (0,0)
For an arbitrary angle alpha
(rad.), you can write:
|
inline |
Set from vector/array/list of points (discards previous points)
|
inline |
std::pair< HOMOG2D_INUMTYPE, HOMOG2D_INUMTYPE > h2d::base::PolylineBase< PLT, FPT >::set | ( | FPT2 | rad, |
T | ni | ||
) |
Build RCP (Regular Convex Polygon), and return distance between consecutive points.
Build a Regular Convex Polygon of radius rad
with n
points, centered at (0,0)
rad | Radius |
ni | Nb of points |
void h2d::base::PolylineBase< PLT, FPT >::setParallelogram | ( | const Point2d_< FPT1 > & | pt1, |
const Point2d_< FPT2 > & | pt2, | ||
const Point2d_< FPT3 > & | pt3 | ||
) |
|
inlinevirtual |
Returns the number of points.
Implements h2d::rtp::Root.
|
inline |
Translate Polyline using dx
, dy
.
|
inline |
Translate Polyline, using a pair of numerical values.
|
inlinevirtual |
Implements h2d::rtp::Root.
|
friend |
|
friend |
|
friend |
|
friend |