7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-21 00:21:25 +00:00

Dogbone: correct small mouth warning

It has to fit the cutter diameter, not the radius!

Also you can use SHAPE_ARC as a generic arc object.
This commit is contained in:
John Beard 2024-09-20 10:16:23 +01:00
parent 2a333475cd
commit 671ecdf13c
5 changed files with 26 additions and 26 deletions

View File

@ -23,12 +23,12 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __CHAMFER_H
#define __CHAMFER_H
#pragma once
#include <optional>
#include <geometry/seg.h>
#include <geometry/shape_arc.h>
/**
* Parameters that define a simple chamfer operation.
@ -60,11 +60,7 @@ std::optional<CHAMFER_RESULT> ComputeChamferPoints( const SEG& aSegA, const SEG&
struct DOGBONE_RESULT
{
// For lack of a generic ARC class, we can just use the points
// that define the arc
VECTOR2I m_arc_start;
VECTOR2I m_arc_mid;
VECTOR2I m_arc_end;
SHAPE_ARC m_arc;
// The updated original segments
// These can be empty if the dogbone "consumed" the original segments
@ -90,6 +86,3 @@ struct DOGBONE_RESULT
*/
std::optional<DOGBONE_RESULT> ComputeDogbone( const SEG& aSegA, const SEG& aSegB,
int aDogboneRadius );
#endif

View File

@ -55,6 +55,11 @@ namespace KIGEOM
*/
SEG NormalisedSeg( const SEG& aSeg );
/**
* Get the end point of the segment that is _not_ the given point.
*/
const VECTOR2I& GetOtherEnd( const SEG& aSeg, const VECTOR2I& aPoint );
/**
* Decompose a BOX2 into four segments.
*

View File

@ -24,6 +24,8 @@
#include "geometry/corner_operations.h"
#include <geometry/circle.h>
#include <geometry/shape_arc.h>
#include <geometry/shape_utils.h>
namespace
{
@ -46,14 +48,6 @@ std::optional<VECTOR2I> GetSharedEndpoint( const SEG& aSegA, const SEG& aSegB )
return std::nullopt;
}
/**
* Get the end point of the segment that is _not_ the given point.
*/
VECTOR2I GetOtherPoint( const SEG& aSeg, const VECTOR2I& aPoint )
{
return ( aSeg.A == aPoint ) ? aSeg.B : aSeg.A;
}
/**
* Get the bisector of two segments that join at a corner.
@ -121,8 +115,8 @@ std::optional<CHAMFER_RESULT> ComputeChamferPoints( const SEG& aSegA, const SEG&
}
// These are the other existing line points (the ones that are not the intersection)
const VECTOR2I a_end_pt = GetOtherPoint( aSegA, *corner );
const VECTOR2I b_end_pt = GetOtherPoint( aSegB, *corner );
const VECTOR2I& a_end_pt = KIGEOM::GetOtherEnd( aSegA, *corner );
const VECTOR2I& b_end_pt = KIGEOM::GetOtherEnd( aSegB, *corner );
// Now, construct segment of the set-back lengths, that begins
// at the intersection point and is parallel to each line segments
@ -199,10 +193,10 @@ std::optional<DOGBONE_RESULT> ComputeDogbone( const SEG& aSegA, const SEG& aSegB
return std::nullopt;
}
const int mouth_width = SEG( *ptOnSegA, *ptOnSegB ).Length();
SHAPE_ARC arc( *ptOnSegA, *corner, *ptOnSegB, 0 );
const VECTOR2I aOtherPtA = GetOtherPoint( aSegA, *corner );
const VECTOR2I aOtherPtB = GetOtherPoint( aSegB, *corner );
const VECTOR2I& aOtherPtA = KIGEOM::GetOtherEnd( aSegA, *corner );
const VECTOR2I& aOtherPtB = KIGEOM::GetOtherEnd( aSegB, *corner );
// See if we need to update the original segments
// or if the dogbone consumed them
@ -213,7 +207,9 @@ std::optional<DOGBONE_RESULT> ComputeDogbone( const SEG& aSegA, const SEG& aSegB
if( aOtherPtB != *ptOnSegB )
new_b = SEG{ aOtherPtB, *ptOnSegB };
const bool small_arc_mouth = arc.GetCentralAngle() > ANGLE_270;
return DOGBONE_RESULT{
*ptOnSegA, *corner, *ptOnSegB, new_a, new_b, mouth_width < aDogboneRadius,
arc, new_a, new_b, small_arc_mouth,
};
}

View File

@ -39,6 +39,12 @@ SEG KIGEOM::NormalisedSeg( const SEG& aSeg )
}
const VECTOR2I& KIGEOM::GetOtherEnd( const SEG& aSeg, const VECTOR2I& aPoint )
{
return ( aSeg.A == aPoint ) ? aSeg.B : aSeg.A;
}
std::array<SEG, 4> KIGEOM::BoxToSegs( const BOX2I& aBox )
{
const std::array<VECTOR2I, 4> corners = {

View File

@ -333,8 +333,8 @@ void DOGBONE_CORNER_ROUTINE::ProcessLinePair( PCB_SHAPE& aLineA, PCB_SHAPE& aLin
auto tArc = std::make_unique<PCB_SHAPE>( GetBoard(), SHAPE_T::ARC );
tArc->SetArcGeometry( dogbone_result->m_arc_start, dogbone_result->m_arc_mid,
dogbone_result->m_arc_end );
tArc->SetArcGeometry( dogbone_result->m_arc.GetP0(), dogbone_result->m_arc.GetArcMid(),
dogbone_result->m_arc.GetP1() );
// Copy properties from one of the source lines
tArc->SetWidth( aLineA.GetWidth() );