KiCad PCB EDA Suite
Loading...
Searching...
No Matches
IDF_SEGMENT Class Reference

A segment as used in IDFv3 outlines. More...

#include <idf_common.h>

Public Member Functions

 IDF_SEGMENT ()
 Initialize the internal variables.
 
 IDF_SEGMENT (const IDF_POINT &aStartPoint, const IDF_POINT &aEndPoint)
 Create a straight segment.
 
 IDF_SEGMENT (const IDF_POINT &aStartPoint, const IDF_POINT &aEndPoint, double aAngle, bool aFromKicad)
 Create a straight segment, arc, or circle depending on the angle.
 
bool MatchesStart (const IDF_POINT &aPoint, double aRadius=1e-3)
 Return true if the given coordinate is within a radius 'rad' of the start point.
 
bool MatchesEnd (const IDF_POINT &aPoint, double aRadius=1e-3)
 Return true if the given coordinate is within a radius 'rad' of the end point.
 
bool IsCircle ()
 
double GetMinX ()
 
void SwapEnds ()
 Swap the start and end points and alters internal variables as necessary for arcs.
 

Public Attributes

IDF_POINT startPoint
 starting point coordinates in mm
 
IDF_POINT endPoint
 end point coordinates in mm
 
IDF_POINT center
 center of an arc or circle; internally calculated and not to be set by the user.
 
double angle
 included angle (degrees) according to IDFv3 specification
 
double offsetAngle
 angle between center and start of arc; internally calculated
 
double radius
 radius of the arc or circle; internally calculated
 

Private Member Functions

void CalcCenterAndRadius ()
 

Detailed Description

A segment as used in IDFv3 outlines.

It may be any of an arc, line segment, or circle

Definition at line 467 of file idf_common.h.

Constructor & Destructor Documentation

◆ IDF_SEGMENT() [1/3]

IDF_SEGMENT::IDF_SEGMENT ( )

Initialize the internal variables.

Definition at line 993 of file idf_common.cpp.

References angle, offsetAngle, and radius.

◆ IDF_SEGMENT() [2/3]

IDF_SEGMENT::IDF_SEGMENT ( const IDF_POINT & aStartPoint,
const IDF_POINT & aEndPoint )

Create a straight segment.

Definition at line 1001 of file idf_common.cpp.

References angle, endPoint, offsetAngle, radius, and startPoint.

◆ IDF_SEGMENT() [3/3]

IDF_SEGMENT::IDF_SEGMENT ( const IDF_POINT & aStartPoint,
const IDF_POINT & aEndPoint,
double aAngle,
bool aFromKicad )

Create a straight segment, arc, or circle depending on the angle.

Parameters
aStartPointis the start point (center if using KiCad convention, otherwise IDF convention)
aEndPointis the end point (start of arc if using KiCad convention, otherwise IDF convention)
aAngleis the included angle; the KiCad convention is equivalent to the IDF convention
fromKicadset to true if we need to convert from KiCad to IDF convention.

Definition at line 1011 of file idf_common.cpp.

References std::abs(), angle, IDF3::CalcAngleDeg(), CalcCenterAndRadius(), IDF_POINT::CalcDistance(), center, endPoint, M_PI, MIN_ANG, offsetAngle, radius, and startPoint.

Member Function Documentation

◆ CalcCenterAndRadius()

void IDF_SEGMENT::CalcCenterAndRadius ( )
private

◆ GetMinX()

double IDF_SEGMENT::GetMinX ( )
Returns
the minimum X coordinate of this segment.

Definition at line 1125 of file idf_common.cpp.

References angle, center, endPoint, IsCircle(), offsetAngle, radius, and startPoint.

◆ IsCircle()

bool IDF_SEGMENT::IsCircle ( )
Returns
true if this segment is a circle.

Definition at line 1114 of file idf_common.cpp.

References std::abs(), angle, and MIN_ANG.

Referenced by addSegment(), GetMinX(), IDF3::GetOutline(), IDF_OUTLINE::push(), BOARD_OUTLINE::readOutlines(), SwapEnds(), and BOARD_OUTLINE::writeOutline().

◆ MatchesEnd()

bool IDF_SEGMENT::MatchesEnd ( const IDF_POINT & aPoint,
double aRadius = 1e-3 )

Return true if the given coordinate is within a radius 'rad' of the end point.

Parameters
aPointare the coordinates (mm) of the point being compared.
aRadiusis the radius (mm) within which the points are considered the same.
Returns
true if the given point matches the end point of this segment.

Definition at line 1067 of file idf_common.cpp.

References endPoint.

◆ MatchesStart()

bool IDF_SEGMENT::MatchesStart ( const IDF_POINT & aPoint,
double aRadius = 1e-3 )

Return true if the given coordinate is within a radius 'rad' of the start point.

Parameters
aPointare the coordinates of the point (mm) being compared.
aRadiusis the radius (mm) within which the points are considered the same.
Returns
true if the given point matches the start point of this segment.

Definition at line 1061 of file idf_common.cpp.

References startPoint.

Referenced by IDF3::GetOutline(), and IDF_OUTLINE::push().

◆ SwapEnds()

void IDF_SEGMENT::SwapEnds ( )

Swap the start and end points and alters internal variables as necessary for arcs.

Definition at line 1161 of file idf_common.cpp.

References angle, IDF3::CalcAngleDeg(), center, endPoint, IsCircle(), MIN_ANG, offsetAngle, and startPoint.

Member Data Documentation

◆ angle

double IDF_SEGMENT::angle

included angle (degrees) according to IDFv3 specification

Definition at line 541 of file idf_common.h.

Referenced by addSegment(), CalcCenterAndRadius(), GetMinX(), IDF3::GetOutline(), IDF_SEGMENT(), IDF_SEGMENT(), IDF_SEGMENT(), IsCircle(), SwapEnds(), and BOARD_OUTLINE::writeOutline().

◆ center

IDF_POINT IDF_SEGMENT::center

center of an arc or circle; internally calculated and not to be set by the user.

Definition at line 540 of file idf_common.h.

Referenced by addSegment(), CalcCenterAndRadius(), GetMinX(), IDF_SEGMENT(), and SwapEnds().

◆ endPoint

IDF_POINT IDF_SEGMENT::endPoint

◆ offsetAngle

double IDF_SEGMENT::offsetAngle

angle between center and start of arc; internally calculated

Definition at line 542 of file idf_common.h.

Referenced by addSegment(), CalcCenterAndRadius(), GetMinX(), IDF_SEGMENT(), IDF_SEGMENT(), IDF_SEGMENT(), and SwapEnds().

◆ radius

double IDF_SEGMENT::radius

radius of the arc or circle; internally calculated

Definition at line 543 of file idf_common.h.

Referenced by addSegment(), CalcCenterAndRadius(), GetMinX(), IDF_SEGMENT(), IDF_SEGMENT(), and IDF_SEGMENT().

◆ startPoint


The documentation for this class was generated from the following files: