Improve clarity.

This commit is contained in:
Jeff Young 2020-12-30 20:27:20 +00:00
parent 0e3c9de684
commit 5d8e6020d1
2 changed files with 22 additions and 22 deletions

View File

@ -301,13 +301,13 @@ int NODE::QueryColliding( const ITEM* aItem, NODE::OBSTACLES& aObstacles, int aK
}
NODE::OPT_OBSTACLE NODE::NearestObstacle( const LINE* aItem, int aKindMask,
NODE::OPT_OBSTACLE NODE::NearestObstacle( const LINE* aLine, int aKindMask,
const std::set<ITEM*>* aRestrictedSet )
{
OBSTACLES obs_list;
bool found_isects = false;
const SHAPE_LINE_CHAIN& line = aItem->CLine();
const SHAPE_LINE_CHAIN& line = aLine->CLine();
obs_list.reserve( 100 );
@ -315,18 +315,16 @@ NODE::OPT_OBSTACLE NODE::NearestObstacle( const LINE* aItem, int aKindMask,
for( int i = 0; i < line.SegmentCount(); i++ )
{
const SEGMENT s( *aItem, line.CSegment( i ) );
const SEGMENT s( *aLine, line.CSegment( i ) );
n += QueryColliding( &s, obs_list, aKindMask );
}
if( aItem->EndsWithVia() )
n += QueryColliding( &aItem->Via(), obs_list, aKindMask );
if( aLine->EndsWithVia() )
n += QueryColliding( &aLine->Via(), obs_list, aKindMask );
if( !n )
return OPT_OBSTACLE();
LINE& aLine = (LINE&) *aItem;
OBSTACLE nearest;
nearest.m_item = NULL;
nearest.m_distFirst = INT_MAX;
@ -341,22 +339,22 @@ NODE::OPT_OBSTACLE NODE::NearestObstacle( const LINE* aItem, int aKindMask,
std::vector<SHAPE_LINE_CHAIN::INTERSECTION> isect_list;
int clearance = GetClearance( obs.m_item, &aLine );
int clearance = GetClearance( obs.m_item, aLine );
SHAPE_LINE_CHAIN hull = obs.m_item->Hull( clearance, aItem->Width(), aItem->Layer() );
SHAPE_LINE_CHAIN obsHull = obs.m_item->Hull( clearance, aLine->Width(), aLine->Layer() );
if( aLine.EndsWithVia() )
if( aLine->EndsWithVia() )
{
clearance = GetClearance( obs.m_item, &aLine.Via() );
clearance = GetClearance( obs.m_item, &aLine->Via() );
SHAPE_LINE_CHAIN viaHull = aLine.Via().Hull( clearance, aItem->Width() );
SHAPE_LINE_CHAIN viaHull = aLine->Via().Hull( clearance, aLine->Width() );
viaHull.Intersect( hull, isect_list );
viaHull.Intersect( obsHull, isect_list );
for( const SHAPE_LINE_CHAIN::INTERSECTION& isect : isect_list )
{
int dist = aLine.CLine().Length() +
( isect.p - aLine.Via().Pos() ).EuclideanNorm();
int dist = aLine->CLine().Length() +
( isect.p - aLine->Via().Pos() ).EuclideanNorm();
if( dist < nearest.m_distFirst )
{
@ -364,7 +362,7 @@ NODE::OPT_OBSTACLE NODE::NearestObstacle( const LINE* aItem, int aKindMask,
nearest.m_distFirst = dist;
nearest.m_ipFirst = isect.p;
nearest.m_item = obs.m_item;
nearest.m_hull = hull;
nearest.m_hull = obsHull;
}
if( dist > dist_max )
@ -377,11 +375,11 @@ NODE::OPT_OBSTACLE NODE::NearestObstacle( const LINE* aItem, int aKindMask,
isect_list.clear();
hull.Intersect( aLine.CLine(), isect_list );
obsHull.Intersect( aLine->CLine(), isect_list );
for( const SHAPE_LINE_CHAIN::INTERSECTION& isect : isect_list )
{
int dist = aLine.CLine().PathLength( isect.p );
int dist = aLine->CLine().PathLength( isect.p );
if( dist < nearest.m_distFirst )
{
@ -389,7 +387,7 @@ NODE::OPT_OBSTACLE NODE::NearestObstacle( const LINE* aItem, int aKindMask,
nearest.m_distFirst = dist;
nearest.m_ipFirst = isect.p;
nearest.m_item = obs.m_item;
nearest.m_hull = hull;
nearest.m_hull = obsHull;
}
if( dist > dist_max )

View File

@ -62,7 +62,9 @@ enum class CONSTRAINT_TYPE
CT_LENGTH = 3,
CT_WIDTH = 4,
CT_VIA_DIAMETER = 5,
CT_VIA_HOLE = 6
CT_VIA_HOLE = 6,
CT_HOLE_CLEARANCE = 7,
CT_EDGE_CLEARANCE = 8
};
struct CONSTRAINT
@ -243,11 +245,11 @@ public:
*
* Follows the line in search of an obstacle that is nearest to the starting to the line's starting
* point.
* @param aItem the item to find collisions with
* @param aLine the item to find collisions with
* @param aKindMask mask of obstacle types to take into account
* @return the obstacle, if found, otherwise empty.
*/
OPT_OBSTACLE NearestObstacle( const LINE* aItem,
OPT_OBSTACLE NearestObstacle( const LINE* aLine,
int aKindMask = ITEM::ANY_T,
const std::set<ITEM*>* aRestrictedSet = NULL );