From 8c22f8df31ccbba29dd15011562232885c5571a3 Mon Sep 17 00:00:00 2001 From: Roberto Fernandez Bautista Date: Mon, 26 Feb 2024 19:06:53 +0100 Subject: [PATCH] SHAPE_LINE_CHAIN: Fix/unify constructors --- .../include/geometry/shape_line_chain.h | 20 ++--------------- libs/kimath/src/geometry/shape_line_chain.cpp | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/libs/kimath/include/geometry/shape_line_chain.h b/libs/kimath/include/geometry/shape_line_chain.h index 19c129762b..ed0a353b3d 100644 --- a/libs/kimath/include/geometry/shape_line_chain.h +++ b/libs/kimath/include/geometry/shape_line_chain.h @@ -173,25 +173,9 @@ public: SHAPE_LINE_CHAIN( const std::vector& aV ); - SHAPE_LINE_CHAIN( const std::vector& aV, bool aClosed = false ) : - SHAPE_LINE_CHAIN_BASE( SH_LINE_CHAIN ), - m_closed( aClosed ), - m_width( 0 ) - { - m_points = aV; - m_shapes = std::vector>( aV.size(), SHAPES_ARE_PT ); - } + SHAPE_LINE_CHAIN( const std::vector& aV, bool aClosed = false ); - SHAPE_LINE_CHAIN( const SHAPE_ARC& aArc, bool aClosed = false ) : - SHAPE_LINE_CHAIN_BASE( SH_LINE_CHAIN ), - m_closed( aClosed ), - m_width( 0 ) - { - m_points = aArc.ConvertToPolyline().CPoints(); - m_arcs.emplace_back( aArc ); - m_arcs.back().SetWidth( 0 ); - m_shapes = std::vector>( m_points.size(), { 0, SHAPE_IS_PT } ); - } + SHAPE_LINE_CHAIN( const SHAPE_ARC& aArc, bool aClosed = false ); SHAPE_LINE_CHAIN( const ClipperLib::Path& aPath, const std::vector& aZValueBuffer, diff --git a/libs/kimath/src/geometry/shape_line_chain.cpp b/libs/kimath/src/geometry/shape_line_chain.cpp index b2d267f1a2..f92b25fb73 100644 --- a/libs/kimath/src/geometry/shape_line_chain.cpp +++ b/libs/kimath/src/geometry/shape_line_chain.cpp @@ -45,6 +45,7 @@ class SHAPE; const ssize_t SHAPE_LINE_CHAIN::SHAPE_IS_PT = -1; const std::pair SHAPE_LINE_CHAIN::SHAPES_ARE_PT = { SHAPE_IS_PT, SHAPE_IS_PT }; + SHAPE_LINE_CHAIN::SHAPE_LINE_CHAIN( const std::vector& aV) : SHAPE_LINE_CHAIN_BASE( SH_LINE_CHAIN ), m_closed( false ), m_width( 0 ) { @@ -55,6 +56,27 @@ SHAPE_LINE_CHAIN::SHAPE_LINE_CHAIN( const std::vector& aV) } +SHAPE_LINE_CHAIN::SHAPE_LINE_CHAIN( const std::vector& aV, bool aClosed ) : + SHAPE_LINE_CHAIN_BASE( SH_LINE_CHAIN ), + m_closed( false ), + m_width( 0 ) +{ + m_points = aV; + m_shapes = std::vector>( aV.size(), SHAPES_ARE_PT ); + SetClosed( aClosed ); +} + + +SHAPE_LINE_CHAIN::SHAPE_LINE_CHAIN( const SHAPE_ARC& aArc, bool aClosed ) : + SHAPE_LINE_CHAIN_BASE( SH_LINE_CHAIN ), + m_closed( false ), + m_width( aArc.GetWidth() ) +{ + Append( aArc ); + SetClosed( aClosed ); +} + + SHAPE_LINE_CHAIN::SHAPE_LINE_CHAIN( const ClipperLib::Path& aPath, const std::vector& aZValueBuffer, const std::vector& aArcBuffer ) :