Skip to content

Commit

Permalink
fix assertion message
Browse files Browse the repository at this point in the history
Type() is not printed in assert messages. Introduce TypeName() instead.
  • Loading branch information
Moritz Meier committed Sep 15, 2023
1 parent 0ce0e68 commit 83c71c5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 22 deletions.
5 changes: 5 additions & 0 deletions 3rd_party/router/kimath/include/geometry/shape.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
44 changes: 22 additions & 22 deletions 3rd_party/router/kimath/src/geometry/shape_collisions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 );

Expand All @@ -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 );

Expand All @@ -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 );

Expand All @@ -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 );

Expand All @@ -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 );

Expand All @@ -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;
Expand Down Expand Up @@ -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 );

Expand All @@ -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;
Expand Down Expand Up @@ -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() );

Expand Down

0 comments on commit 83c71c5

Please sign in to comment.