2010-09-20 16:21:47 +00:00
|
|
|
/**
|
2011-09-30 18:15:37 +00:00
|
|
|
* @file drc_clearance_test_functions.cpp
|
2010-09-20 16:21:47 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2011-09-30 18:15:37 +00:00
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
2010-09-20 16:21:47 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 2004-2007 Jean-Pierre Charras, jean-pierre.charras@gipsa-lab.inpg.fr
|
|
|
|
* Copyright (C) 2007 Dick Hollenbeck, dick@softplc.com
|
2011-09-30 18:15:37 +00:00
|
|
|
* Copyright (C) 2007 KiCad Developers, see change_log.txt for contributors.
|
2010-09-20 16:21:47 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/****************************/
|
|
|
|
/* DRC control */
|
|
|
|
/****************************/
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <wxPcbStruct.h>
|
|
|
|
#include <trigo.h>
|
2010-09-20 16:21:47 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <pcbnew.h>
|
|
|
|
#include <protos.h>
|
|
|
|
#include <drc_stuff.h>
|
2010-09-20 16:21:47 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_module.h>
|
|
|
|
#include <class_track.h>
|
|
|
|
#include <class_zone.h>
|
|
|
|
#include <class_marker_pcb.h>
|
2012-07-30 07:40:25 +00:00
|
|
|
#include <math_for_graphics.h>
|
2012-07-31 17:51:58 +00:00
|
|
|
#include <polygon_test_point_inside.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
|
|
|
|
2010-09-20 16:21:47 +00:00
|
|
|
/* compare 2 trapezoids (can be rectangle) and return true if distance > aDist
|
|
|
|
* i.e if for each edge of the first polygon distance from each edge of the other polygon
|
|
|
|
* is >= aDist
|
|
|
|
*/
|
|
|
|
bool trapezoid2trapezoidDRC( wxPoint aTref[4], wxPoint aTcompare[4], int aDist )
|
|
|
|
{
|
|
|
|
/* Test if one polygon is contained in the other and thus the polygon overlap.
|
|
|
|
* This case is not covered by the following check if one polygond is
|
|
|
|
* completely contained in the other (because edges don't intersect)!
|
|
|
|
*/
|
|
|
|
if( TestPointInsidePolygon( aTref, 4, aTcompare[0] ) )
|
|
|
|
return false;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-09-20 16:21:47 +00:00
|
|
|
if( TestPointInsidePolygon( aTcompare, 4, aTref[0] ) )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
int ii, jj, kk, ll;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-09-20 16:21:47 +00:00
|
|
|
for( ii = 0, jj = 3; ii<4; jj = ii, ii++ ) // for all edges in aTref
|
|
|
|
{
|
|
|
|
for( kk = 0, ll = 3; kk < 4; ll = kk, kk++ ) // for all edges in aTcompare
|
|
|
|
{
|
|
|
|
double d;
|
|
|
|
int intersect = TestForIntersectionOfStraightLineSegments( aTref[ii].x,
|
|
|
|
aTref[ii].y,
|
|
|
|
aTref[jj].x,
|
|
|
|
aTref[jj].y,
|
|
|
|
aTcompare[kk].x,
|
|
|
|
aTcompare[kk].y,
|
|
|
|
aTcompare[ll].x,
|
|
|
|
aTcompare[ll].y,
|
|
|
|
NULL, NULL, &d );
|
|
|
|
if( intersect || (d< aDist) )
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* compare a trapezoids (can be rectangle) and a segment and return true if distance > aDist
|
|
|
|
*/
|
|
|
|
bool trapezoid2segmentDRC( wxPoint aTref[4], wxPoint aSegStart, wxPoint aSegEnd, int aDist )
|
|
|
|
{
|
|
|
|
/* Test if the segment is contained in the polygon.
|
|
|
|
* This case is not covered by the following check if the segment is
|
|
|
|
* completely contained in the polygon (because edges don't intersect)!
|
|
|
|
*/
|
|
|
|
if( TestPointInsidePolygon( aTref, 4, aSegStart ) )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
int ii, jj;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-09-20 16:21:47 +00:00
|
|
|
for( ii = 0, jj = 3; ii < 4; jj = ii, ii++ ) // for all edges in aTref
|
|
|
|
{
|
|
|
|
double d;
|
|
|
|
int intersect = TestForIntersectionOfStraightLineSegments( aTref[ii].x,
|
|
|
|
aTref[ii].y,
|
|
|
|
aTref[jj].x,
|
|
|
|
aTref[jj].y,
|
|
|
|
aSegStart.x,
|
|
|
|
aSegStart.y,
|
|
|
|
aSegEnd.x,
|
|
|
|
aSegEnd.y,
|
|
|
|
NULL, NULL, &d );
|
|
|
|
if( intersect || (d< aDist) )
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* compare a trapezoid to a point and return true if distance > aDist
|
|
|
|
* do not use this function for horizontal or vertical rectangles
|
|
|
|
* because there is a faster an easier way to compare the distance
|
|
|
|
*/
|
|
|
|
bool trapezoid2pointDRC( wxPoint aTref[4], wxPoint aPcompare, int aDist )
|
|
|
|
{
|
|
|
|
/* Test if aPcompare point is contained in the polygon.
|
|
|
|
* This case is not covered by the following check if this point is inside the polygon
|
|
|
|
*/
|
|
|
|
if( TestPointInsidePolygon( aTref, 4, aPcompare ) )
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-01-26 17:49:48 +00:00
|
|
|
// Test distance between aPcompare and each segment of the polygon:
|
|
|
|
for( int ii = 0, jj = 3; ii < 4; jj = ii, ii++ ) // for all edge in polygon
|
2010-09-20 16:21:47 +00:00
|
|
|
{
|
2013-01-26 17:49:48 +00:00
|
|
|
if( TestSegmentHit( aTref[ii], aTref[jj], aPcompare, aDist ) )
|
2010-09-20 16:21:47 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool testPads )
|
|
|
|
{
|
|
|
|
TRACK* track;
|
|
|
|
wxPoint delta; // lenght on X and Y axis of segments
|
|
|
|
int layerMask;
|
|
|
|
int net_code_ref;
|
|
|
|
wxPoint shape_pos;
|
|
|
|
|
|
|
|
NETCLASS* netclass = aRefSeg->GetNetClass();
|
|
|
|
|
|
|
|
/* In order to make some calculations more easier or faster,
|
|
|
|
* pads and tracks coordinates will be made relative to the reference segment origin
|
|
|
|
*/
|
2013-01-13 00:04:00 +00:00
|
|
|
wxPoint origin = aRefSeg->GetStart(); // origin will be the origin of other coordinates
|
2010-09-20 16:21:47 +00:00
|
|
|
|
2013-01-13 00:04:00 +00:00
|
|
|
m_segmEnd = delta = aRefSeg->GetEnd() - origin;
|
2010-09-20 16:21:47 +00:00
|
|
|
m_segmAngle = 0;
|
|
|
|
|
|
|
|
layerMask = aRefSeg->ReturnMaskLayer();
|
|
|
|
net_code_ref = aRefSeg->GetNet();
|
|
|
|
|
|
|
|
// Phase 0 : Test vias
|
2011-10-01 19:24:27 +00:00
|
|
|
if( aRefSeg->Type() == PCB_VIA_T )
|
2010-09-20 16:21:47 +00:00
|
|
|
{
|
|
|
|
// test if the via size is smaller than minimum
|
2011-12-14 04:29:25 +00:00
|
|
|
if( aRefSeg->GetShape() == VIA_MICROVIA )
|
2010-09-20 16:21:47 +00:00
|
|
|
{
|
2013-01-13 00:04:00 +00:00
|
|
|
if( aRefSeg->GetWidth() < netclass->GetuViaMinDiameter() )
|
2010-09-20 16:21:47 +00:00
|
|
|
{
|
|
|
|
m_currentMarker = fillMarker( aRefSeg, NULL,
|
|
|
|
DRCE_TOO_SMALL_MICROVIA, m_currentMarker );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-01-13 00:04:00 +00:00
|
|
|
if( aRefSeg->GetWidth() < netclass->GetViaMinDiameter() )
|
2010-09-20 16:21:47 +00:00
|
|
|
{
|
|
|
|
m_currentMarker = fillMarker( aRefSeg, NULL,
|
|
|
|
DRCE_TOO_SMALL_VIA, m_currentMarker );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// test if via's hole is bigger than its diameter
|
|
|
|
// This test is necessary since the via hole size and width can be modified
|
|
|
|
// and a default via hole can be bigger than some vias sizes
|
2013-01-13 00:04:00 +00:00
|
|
|
if( aRefSeg->GetDrillValue() > aRefSeg->GetWidth() )
|
2010-09-20 16:21:47 +00:00
|
|
|
{
|
|
|
|
m_currentMarker = fillMarker( aRefSeg, NULL,
|
|
|
|
DRCE_VIA_HOLE_BIGGER, m_currentMarker );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// For microvias: test if they are blind vias and only between 2 layers
|
|
|
|
// because they are used for very small drill size and are drill by laser
|
|
|
|
// and **only one layer** can be drilled
|
2011-12-14 04:29:25 +00:00
|
|
|
if( aRefSeg->GetShape() == VIA_MICROVIA )
|
2010-09-20 16:21:47 +00:00
|
|
|
{
|
|
|
|
int layer1, layer2;
|
|
|
|
bool err = true;
|
|
|
|
|
|
|
|
( (SEGVIA*) aRefSeg )->ReturnLayerPair( &layer1, &layer2 );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
|
|
|
if( layer1 > layer2 )
|
2010-09-20 16:21:47 +00:00
|
|
|
EXCHG( layer1, layer2 );
|
|
|
|
|
|
|
|
// test:
|
|
|
|
if( layer1 == LAYER_N_BACK && layer2 == LAYER_N_2 )
|
|
|
|
err = false;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
if( layer1 == (m_pcb->GetDesignSettings().GetCopperLayerCount() - 2 )
|
2010-09-20 16:21:47 +00:00
|
|
|
&& layer2 == LAYER_N_FRONT )
|
|
|
|
err = false;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-09-20 16:21:47 +00:00
|
|
|
if( err )
|
|
|
|
{
|
|
|
|
m_currentMarker = fillMarker( aRefSeg, NULL,
|
|
|
|
DRCE_MICRO_VIA_INCORRECT_LAYER_PAIR, m_currentMarker );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else // This is a track segment
|
|
|
|
{
|
2013-01-13 00:04:00 +00:00
|
|
|
if( aRefSeg->GetWidth() < netclass->GetTrackMinWidth() )
|
2010-09-20 16:21:47 +00:00
|
|
|
{
|
|
|
|
m_currentMarker = fillMarker( aRefSeg, NULL,
|
|
|
|
DRCE_TOO_SMALL_TRACK_WIDTH, m_currentMarker );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// for a non horizontal or vertical segment Compute the segment angle
|
|
|
|
// in tenths of degrees and its length
|
|
|
|
if( delta.x || delta.y )
|
|
|
|
{
|
|
|
|
// Compute the segment angle in 0,1 degrees
|
|
|
|
m_segmAngle = ArcTangente( delta.y, delta.x );
|
|
|
|
|
|
|
|
// Compute the segment length: we build an equivalent rotated segment,
|
|
|
|
// this segment is horizontal, therefore dx = length
|
|
|
|
RotatePoint( &delta, m_segmAngle ); // delta.x = length, delta.y = 0
|
|
|
|
}
|
|
|
|
|
|
|
|
m_segmLength = delta.x;
|
|
|
|
|
|
|
|
/******************************************/
|
|
|
|
/* Phase 1 : test DRC track to pads : */
|
|
|
|
/******************************************/
|
|
|
|
|
2010-10-28 13:02:07 +00:00
|
|
|
/* Use a dummy pad to test DRC tracks versus holes, for pads not on all copper layers
|
|
|
|
* but having a hole
|
|
|
|
* This dummy pad has the size and shape of the hole
|
|
|
|
* to test tracks to pad hole DRC, using checkClearanceSegmToPad test function.
|
|
|
|
* Therefore, this dummy pad is a circle or an oval.
|
|
|
|
* A pad must have a parent because some functions expect a non null parent
|
|
|
|
* to find the parent board, and some other data
|
|
|
|
*/
|
|
|
|
MODULE dummymodule( m_pcb ); // Creates a dummy parent
|
|
|
|
D_PAD dummypad( &dummymodule );
|
2012-02-19 04:02:19 +00:00
|
|
|
|
|
|
|
dummypad.SetLayerMask( ALL_CU_LAYERS ); // Ensure the hole is on all layers
|
2010-09-20 16:21:47 +00:00
|
|
|
|
|
|
|
// Compute the min distance to pads
|
|
|
|
if( testPads )
|
|
|
|
{
|
2011-12-10 05:33:24 +00:00
|
|
|
for( unsigned ii = 0; ii<m_pcb->GetPadCount(); ++ii )
|
2010-09-20 16:21:47 +00:00
|
|
|
{
|
2011-12-10 05:33:24 +00:00
|
|
|
D_PAD* pad = m_pcb->GetPad( ii );
|
2010-09-20 16:21:47 +00:00
|
|
|
|
|
|
|
/* No problem if pads are on an other layer,
|
|
|
|
* But if a drill hole exists (a pad on a single layer can have a hole!)
|
|
|
|
* we must test the hole
|
|
|
|
*/
|
2012-02-19 04:02:19 +00:00
|
|
|
if( (pad->GetLayerMask() & layerMask ) == 0 )
|
2010-09-20 16:21:47 +00:00
|
|
|
{
|
2011-09-07 19:41:04 +00:00
|
|
|
/* We must test the pad hole. In order to use the function
|
|
|
|
* checkClearanceSegmToPad(),a pseudo pad is used, with a shape and a
|
|
|
|
* size like the hole
|
2010-09-20 16:21:47 +00:00
|
|
|
*/
|
2012-02-19 04:02:19 +00:00
|
|
|
if( pad->GetDrillSize().x == 0 )
|
2010-09-20 16:21:47 +00:00
|
|
|
continue;
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
dummypad.SetSize( pad->GetDrillSize() );
|
2010-09-20 16:21:47 +00:00
|
|
|
dummypad.SetPosition( pad->GetPosition() );
|
2012-02-19 04:02:19 +00:00
|
|
|
dummypad.SetShape( pad->GetDrillShape() );
|
|
|
|
dummypad.SetOrientation( pad->GetOrientation() );
|
|
|
|
|
2010-09-20 16:21:47 +00:00
|
|
|
m_padToTestPos = dummypad.GetPosition() - origin;
|
|
|
|
|
2013-01-13 00:04:00 +00:00
|
|
|
if( !checkClearanceSegmToPad( &dummypad, aRefSeg->GetWidth(),
|
2011-09-07 19:41:04 +00:00
|
|
|
netclass->GetClearance() ) )
|
2010-09-20 16:21:47 +00:00
|
|
|
{
|
|
|
|
m_currentMarker = fillMarker( aRefSeg, pad,
|
|
|
|
DRCE_TRACK_NEAR_THROUGH_HOLE, m_currentMarker );
|
|
|
|
return false;
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-09-20 16:21:47 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// The pad must be in a net (i.e pt_pad->GetNet() != 0 )
|
|
|
|
// but no problem if the pad netcode is the current netcode (same net)
|
2010-09-20 16:21:47 +00:00
|
|
|
if( pad->GetNet() // the pad must be connected
|
|
|
|
&& net_code_ref == pad->GetNet() ) // the pad net is the same as current net -> Ok
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// DRC for the pad
|
|
|
|
shape_pos = pad->ReturnShapePos();
|
|
|
|
m_padToTestPos = shape_pos - origin;
|
|
|
|
|
2013-01-13 00:04:00 +00:00
|
|
|
if( !checkClearanceSegmToPad( pad, aRefSeg->GetWidth(), aRefSeg->GetClearance( pad ) ) )
|
2010-09-20 16:21:47 +00:00
|
|
|
{
|
|
|
|
m_currentMarker = fillMarker( aRefSeg, pad,
|
|
|
|
DRCE_TRACK_NEAR_PAD, m_currentMarker );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************/
|
|
|
|
/* Phase 2: test DRC with other track segments */
|
|
|
|
/***********************************************/
|
|
|
|
|
|
|
|
// At this point the reference segment is the X axis
|
|
|
|
|
|
|
|
// Test the reference segment with other track segments
|
2011-11-10 08:21:11 +00:00
|
|
|
wxPoint segStartPoint;
|
|
|
|
wxPoint segEndPoint;
|
|
|
|
for( track = aStart; track; track = track->Next() )
|
2010-09-20 16:21:47 +00:00
|
|
|
{
|
|
|
|
// No problem if segments have the same net code:
|
|
|
|
if( net_code_ref == track->GetNet() )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// No problem if segment are on different layers :
|
|
|
|
if( ( layerMask & track->ReturnMaskLayer() ) == 0 )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// the minimum distance = clearance plus half the reference track
|
|
|
|
// width plus half the other track's width
|
|
|
|
int w_dist = aRefSeg->GetClearance( track );
|
2013-01-13 00:04:00 +00:00
|
|
|
w_dist += (aRefSeg->GetWidth() + track->GetWidth()) / 2;
|
2010-09-20 16:21:47 +00:00
|
|
|
|
|
|
|
// If the reference segment is a via, we test it here
|
2011-10-01 19:24:27 +00:00
|
|
|
if( aRefSeg->Type() == PCB_VIA_T )
|
2010-09-20 16:21:47 +00:00
|
|
|
{
|
|
|
|
int angle = 0; // angle du segment a tester;
|
|
|
|
|
2013-01-13 00:04:00 +00:00
|
|
|
delta = track->GetEnd() - track->GetStart();
|
|
|
|
segStartPoint = aRefSeg->GetStart() - track->GetStart();
|
2010-09-20 16:21:47 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
if( track->Type() == PCB_VIA_T )
|
2010-09-20 16:21:47 +00:00
|
|
|
{
|
|
|
|
// Test distance between two vias, i.e. two circles, trivial case
|
|
|
|
if( (int) hypot( segStartPoint.x, segStartPoint.y ) < w_dist )
|
|
|
|
{
|
|
|
|
m_currentMarker = fillMarker( aRefSeg, track,
|
|
|
|
DRCE_VIA_NEAR_VIA, m_currentMarker );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else // test via to segment
|
|
|
|
{
|
|
|
|
// Compute l'angle
|
|
|
|
angle = ArcTangente( delta.y, delta.x );
|
|
|
|
|
|
|
|
// Compute new coordinates ( the segment become horizontal)
|
|
|
|
RotatePoint( &delta, angle );
|
|
|
|
RotatePoint( &segStartPoint, angle );
|
|
|
|
|
|
|
|
if( !checkMarginToCircle( segStartPoint, w_dist, delta.x ) )
|
|
|
|
{
|
|
|
|
m_currentMarker = fillMarker( track, aRefSeg,
|
|
|
|
DRCE_VIA_NEAR_TRACK, m_currentMarker );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-09-20 16:21:47 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We compute segStartPoint, segEndPoint = starting and ending point coordinates for
|
|
|
|
* the segment to test in the new axis : the new X axis is the
|
|
|
|
* reference segment. We must translate and rotate the segment to test
|
|
|
|
*/
|
2013-01-13 00:04:00 +00:00
|
|
|
segStartPoint = track->GetStart() - origin;
|
|
|
|
segEndPoint = track->GetEnd() - origin;
|
2010-09-20 16:21:47 +00:00
|
|
|
RotatePoint( &segStartPoint, m_segmAngle );
|
|
|
|
RotatePoint( &segEndPoint, m_segmAngle );
|
2011-10-01 19:24:27 +00:00
|
|
|
if( track->Type() == PCB_VIA_T )
|
2010-09-20 16:21:47 +00:00
|
|
|
{
|
|
|
|
if( checkMarginToCircle( segStartPoint, w_dist, m_segmLength ) )
|
|
|
|
continue;
|
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
m_currentMarker = fillMarker( aRefSeg, track,
|
|
|
|
DRCE_TRACK_NEAR_VIA, m_currentMarker );
|
2010-09-20 16:21:47 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We have changed axis:
|
|
|
|
* the reference segment is Horizontal.
|
|
|
|
* 3 cases : the segment to test can be parallel, perpendicular or have an other direction
|
|
|
|
*/
|
|
|
|
if( segStartPoint.y == segEndPoint.y ) // parallel segments
|
|
|
|
{
|
|
|
|
if( abs( segStartPoint.y ) >= w_dist )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// Ensure segStartPoint.x <= segEndPoint.x
|
|
|
|
if( segStartPoint.x > segEndPoint.x )
|
|
|
|
EXCHG( segStartPoint.x, segEndPoint.x );
|
|
|
|
|
|
|
|
if( segStartPoint.x > (-w_dist) && segStartPoint.x < (m_segmLength + w_dist) ) /* possible error drc */
|
|
|
|
{
|
|
|
|
// Fine test : we consider the rounded shape of each end of the track segment:
|
|
|
|
if( segStartPoint.x >= 0 && segStartPoint.x <= m_segmLength )
|
|
|
|
{
|
|
|
|
m_currentMarker = fillMarker( aRefSeg, track,
|
|
|
|
DRCE_TRACK_ENDS1, m_currentMarker );
|
|
|
|
return false;
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-09-20 16:21:47 +00:00
|
|
|
if( !checkMarginToCircle( segStartPoint, w_dist, m_segmLength ) )
|
|
|
|
{
|
|
|
|
m_currentMarker = fillMarker( aRefSeg, track,
|
|
|
|
DRCE_TRACK_ENDS2, m_currentMarker );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-09-20 16:21:47 +00:00
|
|
|
if( segEndPoint.x > (-w_dist) && segEndPoint.x < (m_segmLength + w_dist) )
|
|
|
|
{
|
|
|
|
/* Fine test : we consider the rounded shape of the ends */
|
|
|
|
if( segEndPoint.x >= 0 && segEndPoint.x <= m_segmLength )
|
|
|
|
{
|
|
|
|
m_currentMarker = fillMarker( aRefSeg, track,
|
|
|
|
DRCE_TRACK_ENDS3, m_currentMarker );
|
|
|
|
return false;
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-09-20 16:21:47 +00:00
|
|
|
if( !checkMarginToCircle( segEndPoint, w_dist, m_segmLength ) )
|
|
|
|
{
|
|
|
|
m_currentMarker = fillMarker( aRefSeg, track,
|
|
|
|
DRCE_TRACK_ENDS4, m_currentMarker );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( segStartPoint.x <=0 && segEndPoint.x >= 0 )
|
|
|
|
{
|
|
|
|
m_currentMarker = fillMarker( aRefSeg, track,
|
|
|
|
DRCE_TRACK_UNKNOWN1, m_currentMarker );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( segStartPoint.x == segEndPoint.x ) // perpendicular segments
|
|
|
|
{
|
|
|
|
if( ( segStartPoint.x <= (-w_dist) ) || ( segStartPoint.x >= (m_segmLength + w_dist) ) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// Test if segments are crossing
|
|
|
|
if( segStartPoint.y > segEndPoint.y )
|
|
|
|
EXCHG( segStartPoint.y, segEndPoint.y );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-09-20 16:21:47 +00:00
|
|
|
if( (segStartPoint.y < 0) && (segEndPoint.y > 0) )
|
|
|
|
{
|
|
|
|
m_currentMarker = fillMarker( aRefSeg, track,
|
|
|
|
DRCE_TRACKS_CROSSING, m_currentMarker );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// At this point the drc error is due to an end near a reference segm end
|
|
|
|
if( !checkMarginToCircle( segStartPoint, w_dist, m_segmLength ) )
|
|
|
|
{
|
|
|
|
m_currentMarker = fillMarker( aRefSeg, track,
|
|
|
|
DRCE_ENDS_PROBLEM1, m_currentMarker );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if( !checkMarginToCircle( segEndPoint, w_dist, m_segmLength ) )
|
|
|
|
{
|
|
|
|
m_currentMarker = fillMarker( aRefSeg, track,
|
|
|
|
DRCE_ENDS_PROBLEM2, m_currentMarker );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else // segments quelconques entre eux
|
|
|
|
{
|
|
|
|
// calcul de la "surface de securite du segment de reference
|
|
|
|
// First rought 'and fast) test : the track segment is like a rectangle
|
|
|
|
|
|
|
|
m_xcliplo = m_ycliplo = -w_dist;
|
|
|
|
m_xcliphi = m_segmLength + w_dist;
|
|
|
|
m_ycliphi = w_dist;
|
|
|
|
|
|
|
|
// A fine test is needed because a serment is not exactly a
|
|
|
|
// rectangle, it has rounded ends
|
|
|
|
if( !checkLine( segStartPoint, segEndPoint ) )
|
|
|
|
{
|
|
|
|
/* 2eme passe : the track has rounded ends.
|
|
|
|
* we must a fine test for each rounded end and the
|
|
|
|
* rectangular zone
|
|
|
|
*/
|
|
|
|
|
|
|
|
m_xcliplo = 0;
|
|
|
|
m_xcliphi = m_segmLength;
|
|
|
|
|
|
|
|
if( !checkLine( segStartPoint, segEndPoint ) )
|
|
|
|
{
|
|
|
|
m_currentMarker = fillMarker( aRefSeg, track,
|
|
|
|
DRCE_ENDS_PROBLEM3, m_currentMarker );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else // The drc error is due to the starting or the ending point of the reference segment
|
|
|
|
{
|
|
|
|
// Test the starting and the ending point
|
2013-01-13 00:04:00 +00:00
|
|
|
segStartPoint = track->GetStart();
|
|
|
|
segEndPoint = track->GetEnd();
|
2010-09-20 16:21:47 +00:00
|
|
|
delta = segEndPoint - segStartPoint;
|
|
|
|
|
|
|
|
/* Compute the segment orientation (angle) en 0,1 degre */
|
|
|
|
int angle = ArcTangente( delta.y, delta.x );
|
|
|
|
|
|
|
|
// Compute the segment lenght: delta.x = lenght after rotation
|
|
|
|
RotatePoint( &delta, angle );
|
|
|
|
|
|
|
|
/* Comute the reference segment coordinates relatives to a
|
|
|
|
* X axis = current tested segment
|
|
|
|
*/
|
2013-01-13 00:04:00 +00:00
|
|
|
wxPoint relStartPos = aRefSeg->GetStart() - segStartPoint;
|
|
|
|
wxPoint relEndPos = aRefSeg->GetEnd() - segStartPoint;
|
2010-09-20 16:21:47 +00:00
|
|
|
|
|
|
|
RotatePoint( &relStartPos, angle );
|
|
|
|
RotatePoint( &relEndPos, angle );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-09-20 16:21:47 +00:00
|
|
|
if( !checkMarginToCircle( relStartPos, w_dist, delta.x ) )
|
|
|
|
{
|
|
|
|
m_currentMarker = fillMarker( aRefSeg, track,
|
|
|
|
DRCE_ENDS_PROBLEM4, m_currentMarker );
|
|
|
|
return false;
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-09-20 16:21:47 +00:00
|
|
|
if( !checkMarginToCircle( relEndPos, w_dist, delta.x ) )
|
|
|
|
{
|
|
|
|
m_currentMarker = fillMarker( aRefSeg, track,
|
|
|
|
DRCE_ENDS_PROBLEM5, m_currentMarker );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* test DRC between 2 pads.
|
|
|
|
* this function can be also used to test DRC between a pas and a hole,
|
|
|
|
* because a hole is like a round pad.
|
|
|
|
*/
|
|
|
|
bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad )
|
|
|
|
{
|
|
|
|
int dist;
|
|
|
|
|
|
|
|
int pad_angle;
|
|
|
|
|
|
|
|
// Get the clerance between the 2 pads. this is the min distance between aRefPad and aPad
|
|
|
|
int dist_min = aRefPad->GetClearance( aPad );
|
|
|
|
|
|
|
|
// relativePadPos is the aPad shape position relative to the aRefPad shape position
|
|
|
|
wxPoint relativePadPos = aPad->ReturnShapePos() - aRefPad->ReturnShapePos();
|
|
|
|
|
|
|
|
dist = (int) hypot( relativePadPos.x, relativePadPos.y );
|
|
|
|
|
|
|
|
// Quick test: Clearance is OK if the bounding circles are further away than "dist_min"
|
2012-02-19 04:02:19 +00:00
|
|
|
if( (dist - aRefPad->GetBoundingRadius() - aPad->GetBoundingRadius()) >= dist_min )
|
2010-09-20 16:21:47 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
/* Here, pads are near and DRC depend on the pad shapes
|
|
|
|
* We must compare distance using a fine shape analysis
|
|
|
|
* Because a circle or oval shape is the easier shape to test, try to have
|
|
|
|
* aRefPad shape type = PAD_CIRCLE or PAD_OVAL.
|
|
|
|
* if aRefPad = TRAP. and aPad = RECT, also swap pads
|
|
|
|
* Swap aRefPad and aPad if needed
|
|
|
|
*/
|
|
|
|
bool swap_pads;
|
|
|
|
swap_pads = false;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2013-01-26 17:49:48 +00:00
|
|
|
// swap pads to make comparisons easier
|
|
|
|
// priority is aRefPad = ROUND then OVAL then RECT then other
|
|
|
|
if( aRefPad->GetShape() != aPad->GetShape() && aRefPad->GetShape() != PAD_CIRCLE )
|
|
|
|
{
|
|
|
|
// pad ref shape is here oval, rect or trapezoid
|
|
|
|
switch( aPad->GetShape() )
|
|
|
|
{
|
|
|
|
case PAD_CIRCLE:
|
|
|
|
swap_pads = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PAD_OVAL:
|
|
|
|
swap_pads = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PAD_RECT:
|
|
|
|
if( aRefPad->GetShape() != PAD_OVAL )
|
|
|
|
swap_pads = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-09-20 16:21:47 +00:00
|
|
|
|
|
|
|
if( swap_pads )
|
|
|
|
{
|
|
|
|
EXCHG( aRefPad, aPad );
|
|
|
|
relativePadPos = -relativePadPos;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Because pad exchange, aRefPad shape is PAD_CIRCLE or PAD_OVAL,
|
|
|
|
* if one of the 2 pads was a PAD_CIRCLE or PAD_OVAL.
|
|
|
|
* Therefore, if aRefPad is a PAD_RECT or a PAD_TRAPEZOID,
|
|
|
|
* aPad is also a PAD_RECT or a PAD_TRAPEZOID
|
|
|
|
*/
|
|
|
|
bool diag = true;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
switch( aRefPad->GetShape() )
|
2010-09-20 16:21:47 +00:00
|
|
|
{
|
|
|
|
case PAD_CIRCLE:
|
|
|
|
|
|
|
|
/* One can use checkClearanceSegmToPad to test clearance
|
2012-02-19 04:02:19 +00:00
|
|
|
* aRefPad is like a track segment with a null length and a witdth = GetSize().x
|
2010-09-20 16:21:47 +00:00
|
|
|
*/
|
|
|
|
m_segmLength = 0;
|
|
|
|
m_segmAngle = 0;
|
|
|
|
|
|
|
|
m_segmEnd.x = m_segmEnd.y = 0;
|
|
|
|
|
|
|
|
m_padToTestPos = relativePadPos;
|
2012-02-19 04:02:19 +00:00
|
|
|
diag = checkClearanceSegmToPad( aPad, aRefPad->GetSize().x, dist_min );
|
2010-09-20 16:21:47 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PAD_RECT:
|
|
|
|
// pad_angle = pad orient relative to the aRefPad orient
|
2012-02-19 04:02:19 +00:00
|
|
|
pad_angle = aRefPad->GetOrientation() + aPad->GetOrientation();
|
2010-09-20 16:21:47 +00:00
|
|
|
NORMALIZE_ANGLE_POS( pad_angle );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
if( aPad->GetShape() == PAD_RECT )
|
2010-09-20 16:21:47 +00:00
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
wxSize size = aPad->GetSize();
|
2010-09-20 16:21:47 +00:00
|
|
|
|
|
|
|
// The trivial case is if both rects are rotated by multiple of 90 deg
|
|
|
|
// Most of time this is the case, and the test is fast
|
2012-02-19 04:02:19 +00:00
|
|
|
if( ( (aRefPad->GetOrientation() == 0) || (aRefPad->GetOrientation() == 900)
|
|
|
|
|| (aRefPad->GetOrientation() == 1800) || (aRefPad->GetOrientation() == 2700) )
|
|
|
|
&& ( (aPad->GetOrientation() == 0) || (aPad->GetOrientation() == 900) || (aPad->GetOrientation() == 1800)
|
|
|
|
|| (aPad->GetOrientation() == 2700) ) )
|
2010-09-20 16:21:47 +00:00
|
|
|
{
|
|
|
|
if( (pad_angle == 900) || (pad_angle == 2700) )
|
|
|
|
{
|
|
|
|
EXCHG( size.x, size.y );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test DRC:
|
|
|
|
diag = false;
|
2012-02-19 04:02:19 +00:00
|
|
|
RotatePoint( &relativePadPos, aRefPad->GetOrientation() );
|
2012-09-22 11:19:37 +00:00
|
|
|
relativePadPos.x = std::abs( relativePadPos.x );
|
|
|
|
relativePadPos.y = std::abs( relativePadPos.y );
|
2010-09-20 16:21:47 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
if( ( relativePadPos.x - ( (size.x + aRefPad->GetSize().x) / 2 ) ) >= dist_min )
|
2010-09-20 16:21:47 +00:00
|
|
|
diag = true;
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
if( ( relativePadPos.y - ( (size.y + aRefPad->GetSize().y) / 2 ) ) >= dist_min )
|
2010-09-20 16:21:47 +00:00
|
|
|
diag = true;
|
|
|
|
}
|
|
|
|
else // at least one pad has any other orient. Test is more tricky
|
|
|
|
{ // Use the trapezoid2trapezoidDRC which also compare 2 rectangles with any orientation
|
|
|
|
wxPoint polyref[4]; // Shape of aRefPad
|
|
|
|
wxPoint polycompare[4]; // Shape of aPad
|
2012-02-19 04:02:19 +00:00
|
|
|
aRefPad->BuildPadPolygon( polyref, wxSize( 0, 0 ), aRefPad->GetOrientation() );
|
|
|
|
aPad->BuildPadPolygon( polycompare, wxSize( 0, 0 ), aPad->GetOrientation() );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-09-20 16:21:47 +00:00
|
|
|
// Move aPad shape to relativePadPos
|
|
|
|
for( int ii = 0; ii < 4; ii++ )
|
|
|
|
polycompare[ii] += relativePadPos;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-09-20 16:21:47 +00:00
|
|
|
// And now test polygons:
|
|
|
|
if( !trapezoid2trapezoidDRC( polyref, polycompare, dist_min ) )
|
|
|
|
diag = false;
|
|
|
|
}
|
|
|
|
}
|
2012-02-19 04:02:19 +00:00
|
|
|
else if( aPad->GetShape() == PAD_TRAPEZOID )
|
2010-09-20 16:21:47 +00:00
|
|
|
{
|
|
|
|
wxPoint polyref[4]; // Shape of aRefPad
|
|
|
|
wxPoint polycompare[4]; // Shape of aPad
|
2012-02-19 04:02:19 +00:00
|
|
|
aRefPad->BuildPadPolygon( polyref, wxSize( 0, 0 ), aRefPad->GetOrientation() );
|
|
|
|
aPad->BuildPadPolygon( polycompare, wxSize( 0, 0 ), aPad->GetOrientation() );
|
2010-09-20 16:21:47 +00:00
|
|
|
|
|
|
|
// Move aPad shape to relativePadPos
|
|
|
|
for( int ii = 0; ii < 4; ii++ )
|
|
|
|
polycompare[ii] += relativePadPos;
|
|
|
|
|
|
|
|
// And now test polygons:
|
|
|
|
if( !trapezoid2trapezoidDRC( polyref, polycompare, dist_min ) )
|
|
|
|
diag = false;
|
|
|
|
}
|
2012-02-16 06:17:01 +00:00
|
|
|
else
|
2010-09-20 16:21:47 +00:00
|
|
|
{
|
2012-02-16 06:17:01 +00:00
|
|
|
// Should not occur, because aPad and aRefPad are swapped
|
|
|
|
// to have only aPad shape RECT or TRAP and aRefPad shape TRAP or RECT.
|
2013-01-26 17:49:48 +00:00
|
|
|
wxLogDebug( wxT( "DRC::checkClearancePadToPad: unexpected pad ref RECT @ %d, %d to pad shape %d @ %d, %d"),
|
|
|
|
aRefPad->GetPosition().x, aRefPad->GetPosition().y,
|
|
|
|
aPad->GetShape(), aPad->GetPosition().x, aPad->GetPosition().y );
|
2010-09-20 16:21:47 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PAD_OVAL: /* an oval pad is like a track segment */
|
|
|
|
{
|
|
|
|
/* Create a track segment with same dimensions as the oval aRefPad
|
|
|
|
* and use checkClearanceSegmToPad function to test aPad to aRefPad clearance
|
|
|
|
*/
|
|
|
|
int segm_width;
|
2012-02-19 04:02:19 +00:00
|
|
|
m_segmAngle = aRefPad->GetOrientation(); // Segment orient.
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
if( aRefPad->GetSize().y < aRefPad->GetSize().x ) // Build an horizontal equiv segment
|
2010-09-20 16:21:47 +00:00
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
segm_width = aRefPad->GetSize().y;
|
|
|
|
m_segmLength = aRefPad->GetSize().x - aRefPad->GetSize().y;
|
2010-09-20 16:21:47 +00:00
|
|
|
}
|
|
|
|
else // Vertical oval: build an horizontal equiv segment and rotate 90.0 deg
|
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
segm_width = aRefPad->GetSize().x;
|
|
|
|
m_segmLength = aRefPad->GetSize().y - aRefPad->GetSize().x;
|
2010-09-20 16:21:47 +00:00
|
|
|
m_segmAngle += 900;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* the start point must be 0,0 and currently relativePadPos
|
|
|
|
* is relative the center of pad coordinate */
|
|
|
|
wxPoint segstart;
|
|
|
|
segstart.x = -m_segmLength / 2; // Start point coordinate of the horizontal equivalent segment
|
|
|
|
|
2011-05-12 11:06:32 +00:00
|
|
|
RotatePoint( &segstart, m_segmAngle ); // actual start point coordinate of the equivalent segment
|
|
|
|
// Calculate segment end position relative to the segment origin
|
|
|
|
m_segmEnd.x = -2 * segstart.x;
|
|
|
|
m_segmEnd.y = -2 * segstart.y;
|
|
|
|
|
|
|
|
// Recalculate the equivalent segment angle in 0,1 degrees
|
|
|
|
// to prepare a call to checkClearanceSegmToPad()
|
|
|
|
m_segmAngle = ArcTangente( m_segmEnd.y, m_segmEnd.x );
|
2010-09-20 16:21:47 +00:00
|
|
|
|
|
|
|
// move pad position relative to the segment origin
|
|
|
|
m_padToTestPos = relativePadPos - segstart;
|
|
|
|
|
2011-05-12 11:06:32 +00:00
|
|
|
// Use segment to pad check to test the second pad:
|
2010-09-20 16:21:47 +00:00
|
|
|
diag = checkClearanceSegmToPad( aPad, segm_width, dist_min );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case PAD_TRAPEZOID:
|
|
|
|
|
|
|
|
// at this point, aPad is also a trapezoid, because all other shapes
|
|
|
|
// have priority, and are already tested
|
2012-02-19 04:02:19 +00:00
|
|
|
wxASSERT( aPad->GetShape() == PAD_TRAPEZOID );
|
2010-09-20 16:21:47 +00:00
|
|
|
{
|
|
|
|
wxPoint polyref[4]; // Shape of aRefPad
|
|
|
|
wxPoint polycompare[4]; // Shape of aPad
|
2012-02-19 04:02:19 +00:00
|
|
|
aRefPad->BuildPadPolygon( polyref, wxSize( 0, 0 ), aRefPad->GetOrientation() );
|
|
|
|
aPad->BuildPadPolygon( polycompare, wxSize( 0, 0 ), aPad->GetOrientation() );
|
2010-09-20 16:21:47 +00:00
|
|
|
|
|
|
|
// Move aPad shape to relativePadPos
|
|
|
|
for( int ii = 0; ii < 4; ii++ )
|
|
|
|
polycompare[ii] += relativePadPos;
|
|
|
|
|
|
|
|
// And now test polygons:
|
|
|
|
if( !trapezoid2trapezoidDRC( polyref, polycompare, dist_min ) )
|
|
|
|
diag = false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2013-01-26 17:49:48 +00:00
|
|
|
wxLogDebug( wxT( "DRC::checkClearancePadToPad: unexpected pad shape" ) );
|
2010-09-20 16:21:47 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return diag;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* test if distance between a segment is > aMinDist
|
|
|
|
* segment start point is assumed in (0,0) and segment start point in m_segmEnd
|
2011-05-12 11:06:32 +00:00
|
|
|
* and its orientation is m_segmAngle (m_segmAngle must be already initialized)
|
2010-09-20 16:21:47 +00:00
|
|
|
* and have aSegmentWidth.
|
|
|
|
*/
|
|
|
|
bool DRC::checkClearanceSegmToPad( const D_PAD* aPad, int aSegmentWidth, int aMinDist )
|
|
|
|
{
|
|
|
|
wxSize padHalfsize; // half the dimension of the pad
|
|
|
|
int orient;
|
|
|
|
wxPoint startPoint, endPoint;
|
|
|
|
int seuil;
|
|
|
|
int deltay;
|
|
|
|
|
|
|
|
int segmHalfWidth = aSegmentWidth / 2;
|
|
|
|
|
|
|
|
seuil = segmHalfWidth + aMinDist;
|
2012-02-19 04:02:19 +00:00
|
|
|
padHalfsize.x = aPad->GetSize().x >> 1;
|
|
|
|
padHalfsize.y = aPad->GetSize().y >> 1;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
if( aPad->GetShape() == PAD_TRAPEZOID ) // The size is bigger, due to GetDelta() extra size
|
2010-09-20 16:21:47 +00:00
|
|
|
{
|
2012-09-22 11:19:37 +00:00
|
|
|
padHalfsize.x += std::abs(aPad->GetDelta().y) / 2; // Remember: GetDelta().y is the GetSize().x change
|
|
|
|
padHalfsize.y += std::abs(aPad->GetDelta().x) / 2; // Remember: GetDelta().x is the GetSize().y change
|
2010-09-20 16:21:47 +00:00
|
|
|
}
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
if( aPad->GetShape() == PAD_CIRCLE )
|
2010-09-20 16:21:47 +00:00
|
|
|
{
|
|
|
|
/* Easy case: just test the distance between segment and pad centre
|
|
|
|
* calculate pad coordinates in the X,Y axis with X axis = segment to test
|
|
|
|
*/
|
|
|
|
RotatePoint( &m_padToTestPos, m_segmAngle );
|
|
|
|
return checkMarginToCircle( m_padToTestPos, seuil + padHalfsize.x, m_segmLength );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* calculate the bounding box of the pad, including the clearance and the segment width
|
|
|
|
* if the line from 0 to m_segmEnd does not intersect this bounding box,
|
|
|
|
* the clearance is always OK
|
|
|
|
* But if intersect, a better analysis of the pad shape must be done.
|
|
|
|
*/
|
|
|
|
m_xcliplo = m_padToTestPos.x - seuil - padHalfsize.x;
|
|
|
|
m_ycliplo = m_padToTestPos.y - seuil - padHalfsize.y;
|
|
|
|
m_xcliphi = m_padToTestPos.x + seuil + padHalfsize.x;
|
|
|
|
m_ycliphi = m_padToTestPos.y + seuil + padHalfsize.y;
|
|
|
|
|
|
|
|
startPoint.x = startPoint.y = 0;
|
|
|
|
endPoint = m_segmEnd;
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
orient = aPad->GetOrientation();
|
2010-09-20 16:21:47 +00:00
|
|
|
|
|
|
|
RotatePoint( &startPoint, m_padToTestPos, -orient );
|
|
|
|
RotatePoint( &endPoint, m_padToTestPos, -orient );
|
|
|
|
|
|
|
|
if( checkLine( startPoint, endPoint ) )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
/* segment intersects the bounding box. But there is not always a DRC error.
|
|
|
|
* A fine analysis of the pad shape must be done.
|
|
|
|
*/
|
2012-02-19 04:02:19 +00:00
|
|
|
switch( aPad->GetShape() )
|
2010-09-20 16:21:47 +00:00
|
|
|
{
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
|
|
|
|
case PAD_OVAL:
|
|
|
|
|
|
|
|
/* an oval is a complex shape, but is a rectangle and 2 circles
|
|
|
|
* these 3 basic shapes are more easy to test.
|
|
|
|
*/
|
|
|
|
/* We use a vertical oval shape. for horizontal ovals, swap x and y size and rotate the shape*/
|
|
|
|
if( padHalfsize.x > padHalfsize.y )
|
|
|
|
{
|
|
|
|
EXCHG( padHalfsize.x, padHalfsize.y );
|
|
|
|
orient += 900;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-09-20 16:21:47 +00:00
|
|
|
if( orient >= 3600 )
|
|
|
|
orient -= 3600;
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-09-20 16:21:47 +00:00
|
|
|
deltay = padHalfsize.y - padHalfsize.x;
|
|
|
|
|
2011-05-12 11:06:32 +00:00
|
|
|
// here: padHalfsize.x = radius, delta = dist centre cercles a centre pad
|
2010-09-20 16:21:47 +00:00
|
|
|
|
|
|
|
// Test the rectangle area between the two circles
|
|
|
|
m_xcliplo = m_padToTestPos.x - seuil - padHalfsize.x;
|
|
|
|
m_ycliplo = m_padToTestPos.y - segmHalfWidth - deltay;
|
|
|
|
m_xcliphi = m_padToTestPos.x + seuil + padHalfsize.x;
|
|
|
|
m_ycliphi = m_padToTestPos.y + segmHalfWidth + deltay;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-09-20 16:21:47 +00:00
|
|
|
if( !checkLine( startPoint, endPoint ) )
|
2011-05-12 11:06:32 +00:00
|
|
|
{
|
2010-09-20 16:21:47 +00:00
|
|
|
return false;
|
2011-05-12 11:06:32 +00:00
|
|
|
}
|
2010-09-20 16:21:47 +00:00
|
|
|
|
|
|
|
// test the first circle
|
2011-05-12 11:06:32 +00:00
|
|
|
startPoint.x = m_padToTestPos.x; // startPoint = centre of the upper circle of the oval shape
|
2010-09-20 16:21:47 +00:00
|
|
|
startPoint.y = m_padToTestPos.y + deltay;
|
|
|
|
|
|
|
|
// Calculate the actual position of the circle, given the pad orientation:
|
|
|
|
RotatePoint( &startPoint, m_padToTestPos, orient );
|
|
|
|
|
|
|
|
// Calculate the actual position of the circle in the new X,Y axis:
|
|
|
|
RotatePoint( &startPoint, m_segmAngle );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-09-20 16:21:47 +00:00
|
|
|
if( !checkMarginToCircle( startPoint, padHalfsize.x + seuil, m_segmLength ) )
|
2011-05-12 11:06:32 +00:00
|
|
|
{
|
2010-09-20 16:21:47 +00:00
|
|
|
return false;
|
2011-05-12 11:06:32 +00:00
|
|
|
}
|
2010-09-20 16:21:47 +00:00
|
|
|
|
|
|
|
// test the second circle
|
2011-05-12 11:06:32 +00:00
|
|
|
startPoint.x = m_padToTestPos.x; // startPoint = centre of the lower circle of the oval shape
|
2010-09-20 16:21:47 +00:00
|
|
|
startPoint.y = m_padToTestPos.y - deltay;
|
|
|
|
RotatePoint( &startPoint, m_padToTestPos, orient );
|
|
|
|
RotatePoint( &startPoint, m_segmAngle );
|
|
|
|
|
|
|
|
if( !checkMarginToCircle( startPoint, padHalfsize.x + seuil, m_segmLength ) )
|
2011-05-12 11:06:32 +00:00
|
|
|
{
|
2010-09-20 16:21:47 +00:00
|
|
|
return false;
|
2011-05-12 11:06:32 +00:00
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-09-20 16:21:47 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PAD_RECT: /* 2 rectangle + 4 1/4 cercles a tester */
|
|
|
|
/* Test du rectangle dimx + seuil, dimy */
|
|
|
|
m_xcliplo = m_padToTestPos.x - padHalfsize.x - seuil;
|
|
|
|
m_ycliplo = m_padToTestPos.y - padHalfsize.y;
|
|
|
|
m_xcliphi = m_padToTestPos.x + padHalfsize.x + seuil;
|
|
|
|
m_ycliphi = m_padToTestPos.y + padHalfsize.y;
|
|
|
|
|
|
|
|
if( !checkLine( startPoint, endPoint ) )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/* Test du rectangle dimx , dimy + seuil */
|
|
|
|
m_xcliplo = m_padToTestPos.x - padHalfsize.x;
|
|
|
|
m_ycliplo = m_padToTestPos.y - padHalfsize.y - seuil;
|
|
|
|
m_xcliphi = m_padToTestPos.x + padHalfsize.x;
|
|
|
|
m_ycliphi = m_padToTestPos.y + padHalfsize.y + seuil;
|
|
|
|
|
|
|
|
if( !checkLine( startPoint, endPoint ) )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/* test des 4 cercles ( surface d'solation autour des sommets */
|
|
|
|
/* test du coin sup. gauche du pad */
|
|
|
|
startPoint.x = m_padToTestPos.x - padHalfsize.x;
|
|
|
|
startPoint.y = m_padToTestPos.y - padHalfsize.y;
|
|
|
|
RotatePoint( &startPoint, m_padToTestPos, orient );
|
|
|
|
RotatePoint( &startPoint, m_segmAngle );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-09-20 16:21:47 +00:00
|
|
|
if( !checkMarginToCircle( startPoint, seuil, m_segmLength ) )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/* test du coin sup. droit du pad */
|
|
|
|
startPoint.x = m_padToTestPos.x + padHalfsize.x;
|
|
|
|
startPoint.y = m_padToTestPos.y - padHalfsize.y;
|
|
|
|
RotatePoint( &startPoint, m_padToTestPos, orient );
|
|
|
|
RotatePoint( &startPoint, m_segmAngle );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-09-20 16:21:47 +00:00
|
|
|
if( !checkMarginToCircle( startPoint, seuil, m_segmLength ) )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/* test du coin inf. gauche du pad */
|
|
|
|
startPoint.x = m_padToTestPos.x - padHalfsize.x;
|
|
|
|
startPoint.y = m_padToTestPos.y + padHalfsize.y;
|
|
|
|
RotatePoint( &startPoint, m_padToTestPos, orient );
|
|
|
|
RotatePoint( &startPoint, m_segmAngle );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-09-20 16:21:47 +00:00
|
|
|
if( !checkMarginToCircle( startPoint, seuil, m_segmLength ) )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/* test du coin inf. droit du pad */
|
|
|
|
startPoint.x = m_padToTestPos.x + padHalfsize.x;
|
|
|
|
startPoint.y = m_padToTestPos.y + padHalfsize.y;
|
|
|
|
RotatePoint( &startPoint, m_padToTestPos, orient );
|
|
|
|
RotatePoint( &startPoint, m_segmAngle );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-09-20 16:21:47 +00:00
|
|
|
if( !checkMarginToCircle( startPoint, seuil, m_segmLength ) )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PAD_TRAPEZOID:
|
|
|
|
{
|
|
|
|
wxPoint poly[4];
|
|
|
|
aPad->BuildPadPolygon( poly, wxSize( 0, 0 ), orient );
|
|
|
|
|
|
|
|
// Move shape to m_padToTestPos
|
|
|
|
for( int ii = 0; ii < 4; ii++ )
|
|
|
|
{
|
|
|
|
poly[ii] += m_padToTestPos;
|
|
|
|
RotatePoint( &poly[ii], m_segmAngle );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !trapezoid2segmentDRC( poly, wxPoint( 0, 0 ), wxPoint(m_segmLength,0), seuil ) )
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper function checkMarginToCircle
|
|
|
|
* Check the distance between a circle (round pad, via or round end of track)
|
|
|
|
* and a segment. the segment is expected starting at 0,0, and on the X axis
|
|
|
|
* return true if distance >= aRadius
|
|
|
|
*/
|
|
|
|
bool DRC::checkMarginToCircle( wxPoint aCentre, int aRadius, int aLength )
|
|
|
|
{
|
|
|
|
if( abs( aCentre.y ) > aRadius ) // trivial case
|
|
|
|
return true;
|
|
|
|
|
2011-05-12 11:06:32 +00:00
|
|
|
// Here, distance between aCentre and X axis is < aRadius
|
2010-09-20 16:21:47 +00:00
|
|
|
if( (aCentre.x >= -aRadius ) && ( aCentre.x <= (aLength + aRadius) ) )
|
|
|
|
{
|
|
|
|
if( (aCentre.x >= 0) && (aCentre.x <= aLength) )
|
|
|
|
return false; // aCentre is between the starting point and the ending point of the segm
|
|
|
|
|
|
|
|
if( aCentre.x > aLength ) // aCentre is after the ending point
|
|
|
|
aCentre.x -= aLength; // move aCentre to the starting point of the segment
|
|
|
|
|
|
|
|
if( hypot( aCentre.x, aCentre.y ) < aRadius )
|
|
|
|
// distance between aCentre and the starting point or the ending point is < aRadius
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Helper function used in checkLine::
|
|
|
|
static inline int USCALE( unsigned arg, unsigned num, unsigned den )
|
|
|
|
{
|
|
|
|
int ii;
|
|
|
|
|
|
|
|
ii = (int) ( ( (double) arg * num ) / den );
|
|
|
|
return ii;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Helper function checkLine
|
|
|
|
* Test if a line intersects a bounding box (a rectangle)
|
|
|
|
* The rectangle is defined by m_xcliplo, m_ycliplo and m_xcliphi, m_ycliphi
|
|
|
|
* return true if the line from aSegStart to aSegEnd is outside the bounding box
|
|
|
|
*/
|
|
|
|
bool DRC::checkLine( wxPoint aSegStart, wxPoint aSegEnd )
|
|
|
|
{
|
|
|
|
#define WHEN_OUTSIDE return true
|
|
|
|
#define WHEN_INSIDE
|
|
|
|
int temp;
|
|
|
|
|
|
|
|
if( aSegStart.x > aSegEnd.x )
|
|
|
|
EXCHG( aSegStart, aSegEnd );
|
|
|
|
|
|
|
|
if( (aSegEnd.x < m_xcliplo) || (aSegStart.x > m_xcliphi) )
|
|
|
|
{
|
|
|
|
WHEN_OUTSIDE;
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-09-20 16:21:47 +00:00
|
|
|
if( aSegStart.y < aSegEnd.y )
|
|
|
|
{
|
|
|
|
if( (aSegEnd.y < m_ycliplo) || (aSegStart.y > m_ycliphi) )
|
|
|
|
{
|
|
|
|
WHEN_OUTSIDE;
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-09-20 16:21:47 +00:00
|
|
|
if( aSegStart.y < m_ycliplo )
|
|
|
|
{
|
2011-09-07 19:41:04 +00:00
|
|
|
temp = USCALE( (aSegEnd.x - aSegStart.x), (m_ycliplo - aSegStart.y),
|
|
|
|
(aSegEnd.y - aSegStart.y) );
|
|
|
|
|
2010-09-20 16:21:47 +00:00
|
|
|
if( (aSegStart.x += temp) > m_xcliphi )
|
|
|
|
{
|
|
|
|
WHEN_OUTSIDE;
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-09-20 16:21:47 +00:00
|
|
|
aSegStart.y = m_ycliplo;
|
|
|
|
WHEN_INSIDE;
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-09-20 16:21:47 +00:00
|
|
|
if( aSegEnd.y > m_ycliphi )
|
|
|
|
{
|
2011-09-07 19:41:04 +00:00
|
|
|
temp = USCALE( (aSegEnd.x - aSegStart.x), (aSegEnd.y - m_ycliphi),
|
|
|
|
(aSegEnd.y - aSegStart.y) );
|
|
|
|
|
2010-09-20 16:21:47 +00:00
|
|
|
if( (aSegEnd.x -= temp) < m_xcliplo )
|
|
|
|
{
|
|
|
|
WHEN_OUTSIDE;
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-09-20 16:21:47 +00:00
|
|
|
aSegEnd.y = m_ycliphi;
|
|
|
|
WHEN_INSIDE;
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-09-20 16:21:47 +00:00
|
|
|
if( aSegStart.x < m_xcliplo )
|
|
|
|
{
|
2011-09-07 19:41:04 +00:00
|
|
|
temp = USCALE( (aSegEnd.y - aSegStart.y), (m_xcliplo - aSegStart.x),
|
|
|
|
(aSegEnd.x - aSegStart.x) );
|
2010-09-20 16:21:47 +00:00
|
|
|
aSegStart.y += temp;
|
|
|
|
aSegStart.x = m_xcliplo;
|
|
|
|
WHEN_INSIDE;
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-09-20 16:21:47 +00:00
|
|
|
if( aSegEnd.x > m_xcliphi )
|
|
|
|
{
|
2011-09-07 19:41:04 +00:00
|
|
|
temp = USCALE( (aSegEnd.y - aSegStart.y), (aSegEnd.x - m_xcliphi),
|
|
|
|
(aSegEnd.x - aSegStart.x) );
|
2010-09-20 16:21:47 +00:00
|
|
|
aSegEnd.y -= temp;
|
|
|
|
aSegEnd.x = m_xcliphi;
|
|
|
|
WHEN_INSIDE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( (aSegStart.y < m_ycliplo) || (aSegEnd.y > m_ycliphi) )
|
|
|
|
{
|
|
|
|
WHEN_OUTSIDE;
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-09-20 16:21:47 +00:00
|
|
|
if( aSegStart.y > m_ycliphi )
|
|
|
|
{
|
2011-09-07 19:41:04 +00:00
|
|
|
temp = USCALE( (aSegEnd.x - aSegStart.x), (aSegStart.y - m_ycliphi),
|
|
|
|
(aSegStart.y - aSegEnd.y) );
|
|
|
|
|
2010-09-20 16:21:47 +00:00
|
|
|
if( (aSegStart.x += temp) > m_xcliphi )
|
|
|
|
{
|
|
|
|
WHEN_OUTSIDE;
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-09-20 16:21:47 +00:00
|
|
|
aSegStart.y = m_ycliphi;
|
|
|
|
WHEN_INSIDE;
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-09-20 16:21:47 +00:00
|
|
|
if( aSegEnd.y < m_ycliplo )
|
|
|
|
{
|
2011-09-07 19:41:04 +00:00
|
|
|
temp = USCALE( (aSegEnd.x - aSegStart.x), (m_ycliplo - aSegEnd.y),
|
|
|
|
(aSegStart.y - aSegEnd.y) );
|
|
|
|
|
2010-09-20 16:21:47 +00:00
|
|
|
if( (aSegEnd.x -= temp) < m_xcliplo )
|
|
|
|
{
|
|
|
|
WHEN_OUTSIDE;
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-09-20 16:21:47 +00:00
|
|
|
aSegEnd.y = m_ycliplo;
|
|
|
|
WHEN_INSIDE;
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-09-20 16:21:47 +00:00
|
|
|
if( aSegStart.x < m_xcliplo )
|
|
|
|
{
|
2011-09-07 19:41:04 +00:00
|
|
|
temp = USCALE( (aSegStart.y - aSegEnd.y), (m_xcliplo - aSegStart.x),
|
|
|
|
(aSegEnd.x - aSegStart.x) );
|
2010-09-20 16:21:47 +00:00
|
|
|
aSegStart.y -= temp;
|
|
|
|
aSegStart.x = m_xcliplo;
|
|
|
|
WHEN_INSIDE;
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-09-20 16:21:47 +00:00
|
|
|
if( aSegEnd.x > m_xcliphi )
|
|
|
|
{
|
2011-09-07 19:41:04 +00:00
|
|
|
temp = USCALE( (aSegStart.y - aSegEnd.y), (aSegEnd.x - m_xcliphi),
|
|
|
|
(aSegEnd.x - aSegStart.x) );
|
2010-09-20 16:21:47 +00:00
|
|
|
aSegEnd.y += temp;
|
|
|
|
aSegEnd.x = m_xcliphi;
|
|
|
|
WHEN_INSIDE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( ( (aSegEnd.x + aSegStart.x) / 2 <= m_xcliphi )
|
|
|
|
&& ( (aSegEnd.x + aSegStart.x) / 2 >= m_xcliplo ) \
|
|
|
|
&& ( (aSegEnd.y + aSegStart.y) / 2 <= m_ycliphi )
|
|
|
|
&& ( (aSegEnd.y + aSegStart.y) / 2 >= m_ycliplo ) )
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
2011-09-07 19:41:04 +00:00
|
|
|
{
|
2010-09-20 16:21:47 +00:00
|
|
|
return true;
|
2011-09-07 19:41:04 +00:00
|
|
|
}
|
2010-09-20 16:21:47 +00:00
|
|
|
}
|