86 const double areaRatioThreshold = 1.3;
89 const double areaRatioEpsilon = 0.25;
92 const double minAreaCutoffDistanceFactor = 6;
95 const int lockDistanceFactor = 30;
98 const int unlockDistanceFactor = 10;
113 double refLength =
SEG( p0, aP ).
Length();
122 double areaS = straight.
Area();
129 PNS_DBG( dbg, AddShape, &diag,
YELLOW, 100000, wxT(
"mt-diag" ) );
131 double areaDiag = diag.
Area();
132 double ratio = areaS / ( areaDiag + 1.0 );
138 PNS_DBG( dbg, Message,
"Posture: Unlocked and reset" );
155 if( trail.
Area() > areaCutoff )
159 PNS_DBG( dbg, Message, wxString::Format(
"Posture: rl %.0f thr %d tol %d as %.3f area OK %d forced %d\n", refLength, (
int)(unlockDistanceFactor *
m_tolerance),
m_tolerance, ratio, areaOk?1:0,
m_forced?1:0 ) );
168 if( !
m_forced && areaOk && ratio > areaRatioThreshold + areaRatioEpsilon )
169 newDirection = diagDirection;
170 else if( !
m_forced && areaOk && ratio < ( 1.0 / areaRatioThreshold ) - areaRatioEpsilon )
171 newDirection = straightDirection;
177 PNS_DBG( dbg, Message, wxString::Format(
"Posture: direction update %s => %s",
187 wxString::Format( wxT(
"Posture: checking direction %s against last seg %s" ),
194 PNS_DBG( dbg, Message, wxString::Format( wxT(
"Posture: forcing straight => %s" ),
195 straightDirection.
Format() ) );
204 PNS_DBG( dbg, Message, wxString::Format( wxT(
"Posture: forcing diagonal => %s" ),
205 diagDirection.
Format() ) );
217 PNS_DBG( dbg, Message, wxString::Format( wxT(
"Posture: correcting half full => %s" ),
229 PNS_DBG( dbg, Message, wxString::Format( wxT(
"Posture: correcting right => %s" ),
245 PNS_DBG( dbg, Message, wxString::Format( wxT(
"Posture: correcting obtuse => %s" ),
262 PNS_DBG( dbg, Message,
"Posture: solution locked" );
Represent route directions & corner angles in a 45-degree metric.
AngleType Angle(const DIRECTION_45 &aOther) const
Return the type of angle between directions (this) and aOther.
bool IsDiagonal() const
Returns true if the direction is diagonal (e.g.
const DIRECTION_45 Right() const
Return the direction on the right side of this (i.e.
const std::string Format() const
Format the direction in a human readable word.
void AddTrailPoint(const VECTOR2I &aP)
DIRECTION_45 m_lastSegDirection
DIRECTION_45 GetPosture(const VECTOR2I &aP)
VECTOR2I GetTrailLeadVector() const
virtual DEBUG_DECORATOR * GetDebugDecorator()=0
ROUTER_IFACE * GetInterface() const
static ROUTER * GetInstance()
ecoord SquaredDistance(const SEG &aSeg) const
VECTOR2I::extended_type ecoord
int Length() const
Return the length (this).
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
const SHAPE_LINE_CHAIN Reverse() const
Reverse point order in the line chain.
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
void Simplify(int aMaxError=0)
Simplify the line chain by removing colinear adjacent segments and duplicate vertices.
int PointCount() const
Return the number of points (vertices) in this line chain.
void Clear()
Remove all points from the line chain.
const SHAPE_LINE_CHAIN Slice(int aStartIndex, int aEndIndex=-1) const
Return a subset of this line chain containing the [start_index, end_index] range of points.
double Area(bool aAbsolute=true) const
Return the area of this chain.
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
int SegmentCount() const
Return the number of segments in this line chain.
const SEG CSegment(int aIndex) const
Return a constant copy of the aIndex segment in the line chain.
Push and Shove diff pair dimensions (gap) settings dialog.
#define PNS_DBG(dbg, method,...)
VECTOR2< int32_t > VECTOR2I