From 3b9d593be943e871441f662402eab11b7089cff2 Mon Sep 17 00:00:00 2001 From: "S. Kramm" Date: Sun, 21 Apr 2024 20:52:21 +0200 Subject: [PATCH] minor --- docs/homog2d_manual.md | 1 + homog2d.hpp | 63 ++++++++++++++++++++++++++---------------- 2 files changed, 40 insertions(+), 24 deletions(-) diff --git a/docs/homog2d_manual.md b/docs/homog2d_manual.md index 317b643..d98d355 100644 --- a/docs/homog2d_manual.md +++ b/docs/homog2d_manual.md @@ -2402,6 +2402,7 @@ for( auto& e: vec ) << "\n"; } ``` +(warning, the `length()` function will throw here if a `Line2d` in in the vector) To draw these on an `img::Image`, you can do this: ```C++ diff --git a/homog2d.hpp b/homog2d.hpp index 8ae8ed0..e0217e5 100644 --- a/homog2d.hpp +++ b/homog2d.hpp @@ -9477,7 +9477,8 @@ Can be printed with `getString()` \sa CommonType_ */ template -Type type( const T& elem ) +Type +type( const T& elem ) { if constexpr( trait::IsVariant::value ) return std::visit( fct::TypeFunct{}, elem ); @@ -9490,7 +9491,8 @@ Type type( const T& elem ) Can be printed with `getString()` */ template -Dtype dtype( const T& elem ) +Dtype +dtype( const T& elem ) { if constexpr( trait::IsVariant::value ) return std::visit( fct::DTypeFunct{}, elem ); @@ -9499,7 +9501,8 @@ Dtype dtype( const T& elem ) } template -HOMOG2D_INUMTYPE length( const T& elem ) +HOMOG2D_INUMTYPE +length( const T& elem ) { if constexpr( trait::IsVariant::value ) return std::visit( fct::LengthFunct{}, elem ); @@ -9508,7 +9511,8 @@ HOMOG2D_INUMTYPE length( const T& elem ) } template -HOMOG2D_INUMTYPE area( const T& elem ) +HOMOG2D_INUMTYPE +area( const T& elem ) { if constexpr( trait::IsVariant::value ) return std::visit( fct::AreaFunct{}, elem ); @@ -9521,7 +9525,8 @@ HOMOG2D_INUMTYPE area( const T& elem ) \warning The floating-point type of the returned object (variant) will be the one of the homography \c h, NOT the one of the input element. */ template -CommonType_ transform( const Homogr_& h, const T& elem ) +CommonType_ +transform( const Homogr_& h, const T& elem ) { if constexpr( trait::IsVariant::value ) return std::visit( fct::TransformFunct(h), elem ); @@ -9970,7 +9975,8 @@ getClosestPoints( ); namespace priv { -/// used in getClosestPoints() + +/// Used in getClosestPoints() template class ClosestPoints { @@ -10071,7 +10077,8 @@ getPts( const Segment_& seg ) /// Returns Segment supporting line (free function) /// \sa Segment_::getLine() template -Line2d_ getLine( const Segment_& seg ) +Line2d_ +getLine( const Segment_& seg ) { return seg.getLine(); } @@ -10079,7 +10086,8 @@ Line2d_ getLine( const Segment_& seg ) /// Returns Extended Segment (free function) /// \sa Segment_::geExtended() template -Segment_ getExtended( const Segment_& seg ) +Segment_ +getExtended( const Segment_& seg ) { return seg.getExtended(); } @@ -10111,7 +10119,6 @@ getOrthogPts( const Segment_& seg ) return seg.getOrthogPts(); } - //------------------------------------------------------------------ /// Free function, returns segment between two circle centers (or ellipse) template @@ -10301,14 +10308,16 @@ getPts( const FRect_& rect ) /// Free function template -HOMOG2D_INUMTYPE height( const FRect_& rect ) +HOMOG2D_INUMTYPE +height( const FRect_& rect ) { return rect.height(); } /// Free function template -HOMOG2D_INUMTYPE width( const FRect_& rect ) +HOMOG2D_INUMTYPE +width( const FRect_& rect ) { return rect.width(); } @@ -10332,7 +10341,8 @@ getDiagonals( const FRect_& rect ) /// Returns centroid of Polyline (free function) /// \sa PolylineBase::centroid() template -base::LPBase centroid( const base::PolylineBase& pl ) +base::LPBase +centroid( const base::PolylineBase& pl ) { return pl.centroid(); } @@ -10376,7 +10386,8 @@ center( const Circle_& cir ) /// Get data size expressed as number of bits for, respectively, mantissa and exponent /// \sa detail::Common::dsize() template -std::pair dsize( const T& t ) +std::pair +dsize( const T& t ) { return t.dsize(); } @@ -10438,7 +10449,8 @@ getCenter(const T& other ) Calls the member function. Type checking is done there. */ template -void translate( T& prim, FP1 dx, FP2 dy ) +void +translate( T& prim, FP1 dx, FP2 dy ) { prim.translate( dx, dy ); } @@ -10448,7 +10460,8 @@ void translate( T& prim, FP1 dx, FP2 dy ) Calls the member function. Type checking is done there. */ template -void translate( T& prim, const std::pair& ppt ) +void +translate( T& prim, const std::pair& ppt ) { prim.translate( ppt.first, ppt.second ); } @@ -10457,11 +10470,12 @@ void translate( T& prim, const std::pair& ppt ) /** Calls the member function. Type checking is done there. */ - template - void moveTo( T& prim, const Point2d_& pt ) - { - prim.moveTo( pt ); - } +template +void +moveTo( T& prim, const Point2d_& pt ) +{ + prim.moveTo( pt ); +} /// Move primitive to other location (free function) /** @@ -10542,7 +10556,7 @@ findFarthestPoint( const Point2d_& pt, const T& cont ) //------------------------------------------------------------------ /// Returns index of point in container \c cont that is the farthest to \c pt template -std::pair +auto findNearestFarthestPoint( const Point2d_& pt, const T& cont ) { if( cont.empty() ) @@ -10590,7 +10604,6 @@ void draw( img::Image& img, const Prim& prim, const img::DrawParams& dp=img:: /// Free function, draws text \c str at position \c pt template -inline void drawText( img::Image& im, std::string str, Point2d_ pt, img::DrawParams dp=img::DrawParams() ) { @@ -10637,7 +10650,8 @@ template< T >::type* = nullptr > -void draw( img::Image& img, const T& cont, const img::DrawParams& dp=img::DrawParams() ) +void +draw( img::Image& img, const T& cont, const img::DrawParams& dp=img::DrawParams() ) { size_t c=0; for( const auto& elem: cont ) @@ -10656,7 +10670,8 @@ template< T >::type* = nullptr > -void draw( img::Image& img, const T& cont, std::function& func ) +void +draw( img::Image& img, const T& cont, std::function& func ) { size_t c=0; for( const auto& elem: cont )