From 83c71c50cf7d717e3f73801869791dde222597a8 Mon Sep 17 00:00:00 2001 From: Moritz Meier Date: Fri, 15 Sep 2023 20:31:00 +0200 Subject: [PATCH 1/2] fix assertion message Type() is not printed in assert messages. Introduce TypeName() instead. --- .../router/kimath/include/geometry/shape.h | 5 +++ .../kimath/src/geometry/shape_collisions.cpp | 44 +++++++++---------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/3rd_party/router/kimath/include/geometry/shape.h b/3rd_party/router/kimath/include/geometry/shape.h index e62555f75..cd301c5cd 100644 --- a/3rd_party/router/kimath/include/geometry/shape.h +++ b/3rd_party/router/kimath/include/geometry/shape.h @@ -96,6 +96,11 @@ class SHAPE_BASE return m_type; } + wxString TypeName() const + { + return SHAPE_TYPE_asString( m_type ); + } + virtual bool HasIndexableSubshapes() const { return false; diff --git a/3rd_party/router/kimath/src/geometry/shape_collisions.cpp b/3rd_party/router/kimath/src/geometry/shape_collisions.cpp index 5f1c3caf3..e3b555197 100644 --- a/3rd_party/router/kimath/src/geometry/shape_collisions.cpp +++ b/3rd_party/router/kimath/src/geometry/shape_collisions.cpp @@ -290,8 +290,8 @@ static inline bool Collide( const SHAPE_LINE_CHAIN_BASE& aA, const SHAPE_LINE_CH int aClearance, int* aActual, VECTOR2I* aLocation, VECTOR2I* aMTV ) { wxASSERT_MSG( !aMTV, wxString::Format( wxT( "MTV not implemented for %s : %s collisions" ), - aA.Type(), - aB.Type() ) ); + aA.TypeName(), + aB.TypeName() ) ); int closest_dist = INT_MAX; VECTOR2I nearest; @@ -372,8 +372,8 @@ static inline bool Collide( const SHAPE_RECT& aA, const SHAPE_LINE_CHAIN_BASE& a int* aActual, VECTOR2I* aLocation, VECTOR2I* aMTV ) { wxASSERT_MSG( !aMTV, wxString::Format( wxT( "MTV not implemented for %s : %s collisions" ), - aA.Type(), - aB.Type() ) ); + aA.TypeName(), + aB.TypeName() ) ); int closest_dist = INT_MAX; VECTOR2I nearest; @@ -429,8 +429,8 @@ static inline bool Collide( const SHAPE_RECT& aA, const SHAPE_SEGMENT& aB, int a int* aActual, VECTOR2I* aLocation, VECTOR2I* aMTV ) { wxASSERT_MSG( !aMTV, wxString::Format( wxT( "MTV not implemented for %s : %s collisions" ), - aA.Type(), - aB.Type() ) ); + aA.TypeName(), + aB.TypeName() ) ); bool rv = aA.Collide( aB.GetSeg(), aClearance + aB.GetWidth() / 2, aActual, aLocation ); @@ -445,8 +445,8 @@ static inline bool Collide( const SHAPE_SEGMENT& aA, const SHAPE_SEGMENT& aB, in int* aActual, VECTOR2I* aLocation, VECTOR2I* aMTV ) { wxASSERT_MSG( !aMTV, wxString::Format( wxT( "MTV not implemented for %s : %s collisions" ), - aA.Type(), - aB.Type() ) ); + aA.TypeName(), + aB.TypeName() ) ); bool rv = aA.Collide( aB.GetSeg(), aClearance + aB.GetWidth() / 2, aActual, aLocation ); @@ -461,8 +461,8 @@ static inline bool Collide( const SHAPE_LINE_CHAIN_BASE& aA, const SHAPE_SEGMENT int aClearance, int* aActual, VECTOR2I* aLocation, VECTOR2I* aMTV ) { wxASSERT_MSG( !aMTV, wxString::Format( wxT( "MTV not implemented for %s : %s collisions" ), - aA.Type(), - aB.Type() ) ); + aA.TypeName(), + aB.TypeName() ) ); bool rv = aA.Collide( aB.GetSeg(), aClearance + aB.GetWidth() / 2, aActual, aLocation ); @@ -484,8 +484,8 @@ static inline bool Collide( const SHAPE_ARC& aA, const SHAPE_RECT& aB, int aClea int* aActual, VECTOR2I* aLocation, VECTOR2I* aMTV ) { wxASSERT_MSG( !aMTV, wxString::Format( wxT( "MTV not implemented for %s : %s collisions" ), - aA.Type(), - aB.Type() ) ); + aA.TypeName(), + aB.TypeName() ) ); const SHAPE_LINE_CHAIN lc( aA ); @@ -502,8 +502,8 @@ static inline bool Collide( const SHAPE_ARC& aA, const SHAPE_CIRCLE& aB, int aCl int* aActual, VECTOR2I* aLocation, VECTOR2I* aMTV ) { wxASSERT_MSG( !aMTV, wxString::Format( wxT( "MTV not implemented for %s : %s collisions" ), - aA.Type(), - aB.Type() ) ); + aA.TypeName(), + aB.TypeName() ) ); const SHAPE_LINE_CHAIN lc( aA ); @@ -520,8 +520,8 @@ static inline bool Collide( const SHAPE_ARC& aA, const SHAPE_LINE_CHAIN& aB, int int* aActual, VECTOR2I* aLocation, VECTOR2I* aMTV ) { wxASSERT_MSG( !aMTV, wxString::Format( wxT( "MTV not implemented for %s : %s collisions" ), - aA.Type(), - aB.Type() ) ); + aA.TypeName(), + aB.TypeName() ) ); int closest_dist = INT_MAX; VECTOR2I nearest; @@ -592,8 +592,8 @@ static inline bool Collide( const SHAPE_ARC& aA, const SHAPE_SEGMENT& aB, int aC int* aActual, VECTOR2I* aLocation, VECTOR2I* aMTV ) { wxASSERT_MSG( !aMTV, wxString::Format( wxT( "MTV not implemented for %s : %s collisions" ), - aA.Type(), - aB.Type() ) ); + aA.TypeName(), + aB.TypeName() ) ); const SHAPE_LINE_CHAIN lc( aA ); @@ -610,8 +610,8 @@ static inline bool Collide( const SHAPE_ARC& aA, const SHAPE_LINE_CHAIN_BASE& aB int* aActual, VECTOR2I* aLocation, VECTOR2I* aMTV ) { wxASSERT_MSG( !aMTV, wxString::Format( wxT( "MTV not implemented for %s : %s collisions" ), - aA.Type(), - aB.Type() ) ); + aA.TypeName(), + aB.TypeName() ) ); int closest_dist = INT_MAX; VECTOR2I nearest; @@ -667,8 +667,8 @@ static inline bool Collide( const SHAPE_ARC& aA, const SHAPE_ARC& aB, int aClear int* aActual, VECTOR2I* aLocation, VECTOR2I* aMTV ) { wxASSERT_MSG( !aMTV, wxString::Format( wxT( "MTV not implemented for %s : %s collisions" ), - aA.Type(), - aB.Type() ) ); + aA.TypeName(), + aB.TypeName() ) ); SEG mediatrix( aA.GetCenter(), aB.GetCenter() ); From eba98c1330ef5ddf860282b83e29e005ebc2370c Mon Sep 17 00:00:00 2001 From: Moritz Meier Date: Fri, 15 Sep 2023 20:33:41 +0200 Subject: [PATCH 2/2] fix crash in pns walkaround pns crashes when in walkaround mode and track collides with an arc. Fix ported from Kicad: https://gitlab.com/kicad/code/kicad/-/commit/df9cf0a0c39ed99527b0c04e3892e8dd7ed603e7 --- 3rd_party/router/kimath/src/geometry/shape_collisions.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/3rd_party/router/kimath/src/geometry/shape_collisions.cpp b/3rd_party/router/kimath/src/geometry/shape_collisions.cpp index e3b555197..8e3c91ffd 100644 --- a/3rd_party/router/kimath/src/geometry/shape_collisions.cpp +++ b/3rd_party/router/kimath/src/geometry/shape_collisions.cpp @@ -501,9 +501,10 @@ static inline bool Collide( const SHAPE_ARC& aA, const SHAPE_RECT& aB, int aClea static inline bool Collide( const SHAPE_ARC& aA, const SHAPE_CIRCLE& aB, int aClearance, int* aActual, VECTOR2I* aLocation, VECTOR2I* aMTV ) { - wxASSERT_MSG( !aMTV, wxString::Format( wxT( "MTV not implemented for %s : %s collisions" ), + // https://gitlab.com/kicad/code/kicad/-/commit/df9cf0a0c39ed99527b0c04e3892e8dd7ed603e7 + /* wxASSERT_MSG( !aMTV, wxString::Format( wxT( "MTV not implemented for %s : %s collisions" ), aA.TypeName(), - aB.TypeName() ) ); + aB.TypeName() ) ); */ const SHAPE_LINE_CHAIN lc( aA );