KiCad PCB EDA Suite
Loading...
Searching...
No Matches
arc_tangent_seed.cpp File Reference
#include <tool/arc_tangent_seed.h>
#include <array>
#include <span>
#include <bezier_curves.h>
#include <eda_shape.h>
#include <geometry/shape_arc.h>
#include <geometry/shape_line_chain.h>
#include <geometry/shape_poly_set.h>

Go to the source code of this file.

Functions

static std::optional< VECTOR2D > normalized (const VECTOR2D &aVec)
 
static const VECTOR2I * nearestEnd (const VECTOR2I &aFirst, const VECTOR2I &aLast, const VECTOR2I &aPoint, std::optional< int > aTolerance=std::nullopt)
 
static std::optional< VECTOR2D > tangentAtEndpoint (const EDA_SHAPE &aShape, const VECTOR2I &aPoint)
 
std::optional< ARC_TANGENT_SEED > ArcTangentSeedNear (const EDA_SHAPE &aShape, const VECTOR2I &aNear)
 Seed the next tangent arc from whichever endpoint of aShape lies nearest aNear.
 
static std::optional< ARC_TANGENT_SEED > polylineSeedAt (std::span< const VECTOR2I > aVertices, bool aClosed, const VECTOR2I &aPoint, int aTolerance)
 
std::optional< ARC_TANGENT_SEED > ArcTangentSeedAt (const SEG &aSegment, const VECTOR2I &aPoint, int aTolerance)
 Tangent seed for a point on or near a segment, arc or Bezier shape.
 
std::optional< ARC_TANGENT_SEED > ArcTangentSeedAt (const EDA_SHAPE &aShape, const VECTOR2I &aPoint, int aTolerance)
 Tangent seed for a point on or near a segment, arc or Bezier shape.
 

Function Documentation

◆ ArcTangentSeedAt() [1/2]

std::optional< ARC_TANGENT_SEED > ArcTangentSeedAt ( const EDA_SHAPE & aShape,
const VECTOR2I & aPoint,
int aTolerance )

Tangent seed for a point on or near a segment, arc or Bezier shape.

A point within aTolerance of an endpoint gives the outward direction at that endpoint, and the seed starts at the endpoint itself. Any other point within aTolerance of the shape gives the tangent axis at the nearest point of the shape, and the seed starts there.

Parameters
aToleranceis the largest distance in IU between aPoint and the shape.
Returns
std::nullopt for other shape types or when the point is not close enough.

Definition at line 163 of file arc_tangent_seed.cpp.

References ARC, ArcTangentSeedAt(), BEZIER, SHAPE_POLY_SET::CHole(), BOX2< Vec >::Contains(), SHAPE_POLY_SET::COutline(), end, EDA_SHAPE::GetArcMid(), EDA_SHAPE::GetBezierC1(), EDA_SHAPE::GetBezierC2(), SHAPE_ARC::GetCenter(), EDA_SHAPE::GetEnd(), BEZIER_POLY::GetPoly(), EDA_SHAPE::GetPolyShape(), EDA_SHAPE::GetShape(), EDA_SHAPE::GetStart(), SHAPE_POLY_SET::HoleCount(), BOX2< Vec >::Inflate(), BOX2< Vec >::Merge(), nearestEnd(), SHAPE_ARC::NearestPoint(), normalized(), SHAPE_POLY_SET::OutlineCount(), POLY, polylineSeedAt(), radius, SEGMENT, and tangentAtEndpoint().

◆ ArcTangentSeedAt() [2/2]

std::optional< ARC_TANGENT_SEED > ArcTangentSeedAt ( const SEG & aSegment,
const VECTOR2I & aPoint,
int aTolerance )

Tangent seed for a point on or near a segment, arc or Bezier shape.

A point within aTolerance of an endpoint gives the outward direction at that endpoint, and the seed starts at the endpoint itself. Any other point within aTolerance of the shape gives the tangent axis at the nearest point of the shape, and the seed starts there.

Parameters
aToleranceis the largest distance in IU between aPoint and the shape.
Returns
std::nullopt for other shape types or when the point is not close enough.

Definition at line 155 of file arc_tangent_seed.cpp.

References SEG::A, SEG::B, and polylineSeedAt().

Referenced by ArcTangentSeedAt(), DRAWING_TOOL::drawManagedShape(), and EE_GRAPHIC_TOOL::drawManagedShape().

◆ ArcTangentSeedNear()

std::optional< ARC_TANGENT_SEED > ArcTangentSeedNear ( const EDA_SHAPE & aShape,
const VECTOR2I & aNear )

Seed the next tangent arc from whichever endpoint of aShape lies nearest aNear.

Used to chain arcs, where aNear is the last point the user clicked on the previous arc.

Definition at line 93 of file arc_tangent_seed.cpp.

References EDA_SHAPE::GetEnd(), EDA_SHAPE::GetStart(), nearestEnd(), and tangentAtEndpoint().

Referenced by DRAWING_TOOL::DrawArc(), and EE_GRAPHIC_TOOL::DrawArc().

◆ nearestEnd()

static const VECTOR2I * nearestEnd ( const VECTOR2I & aFirst,
const VECTOR2I & aLast,
const VECTOR2I & aPoint,
std::optional< int > aTolerance = std::nullopt )
static

Definition at line 44 of file arc_tangent_seed.cpp.

Referenced by ArcTangentSeedAt(), ArcTangentSeedNear(), and polylineSeedAt().

◆ normalized()

◆ polylineSeedAt()

static std::optional< ARC_TANGENT_SEED > polylineSeedAt ( std::span< const VECTOR2I > aVertices,
bool aClosed,
const VECTOR2I & aPoint,
int aTolerance )
static

Definition at line 107 of file arc_tangent_seed.cpp.

References SEG::Distance(), end, nearestEnd(), and normalized().

Referenced by ArcTangentSeedAt(), and ArcTangentSeedAt().

◆ tangentAtEndpoint()

static std::optional< VECTOR2D > tangentAtEndpoint ( const EDA_SHAPE & aShape,
const VECTOR2I & aPoint )
static