From 6c224156f5eedc19a599beafd12b56298d3be642 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Thu, 13 Aug 2020 19:54:08 -0700 Subject: [PATCH] Adding conversion from points to arcs Allows detection of arcs from segments in a SHAPE_LINE_CHAIN, converting them to SHAPE_ARCs in the chain --- libs/kimath/include/geometry/shape_line_chain.h | 7 +++++++ libs/kimath/src/geometry/shape_line_chain.cpp | 14 ++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/libs/kimath/include/geometry/shape_line_chain.h b/libs/kimath/include/geometry/shape_line_chain.h index dfe171689f..3a98aa82dc 100644 --- a/libs/kimath/include/geometry/shape_line_chain.h +++ b/libs/kimath/include/geometry/shape_line_chain.h @@ -609,6 +609,13 @@ public: */ SHAPE_LINE_CHAIN& Simplify( bool aRemoveColinear = true ); + /** + * Detects arcs in a chain and converts them from segments to true arcs by adding an arc + * and the associated references. The original segment points are not changed. + * @return reference to self + */ + SHAPE_LINE_CHAIN& DetectArcs(); + /** * Convert an arc to only a point chain by removing the arc and references. * diff --git a/libs/kimath/src/geometry/shape_line_chain.cpp b/libs/kimath/src/geometry/shape_line_chain.cpp index 3911985eba..546c388174 100644 --- a/libs/kimath/src/geometry/shape_line_chain.cpp +++ b/libs/kimath/src/geometry/shape_line_chain.cpp @@ -223,6 +223,20 @@ bool SHAPE_LINE_CHAIN_BASE::Collide( const SEG& aSeg, int aClearance, int* aActu } +SHAPE_LINE_CHAIN& SHAPE_LINE_CHAIN::DetectArcs() +{ + for( int ii = 0; ii < PointCount(); ++ii ) + { + if( ssize_t ind = ArcIndex( ii ) >= 0 ) + { + const SHAPE_ARC& arc = Arc( ind ); + } + } + + return *this; +} + + const SHAPE_LINE_CHAIN SHAPE_LINE_CHAIN::Reverse() const { SHAPE_LINE_CHAIN a( *this );