From dfdd2cfdbfb9fb585755eec4a593225a03832fcb Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Tue, 31 Jul 2012 19:51:58 +0200 Subject: [PATCH] Remove freepcb arc legacy code from PolyLine. --- pcbnew/class_pad.cpp | 1 + pcbnew/class_zone.cpp | 1 + pcbnew/drc_clearance_test_functions.cpp | 1 + ...ones_polygons_insulated_copper_islands.cpp | 1 + pcbnew/zones_polygons_test_connections.cpp | 2 +- pcbnew/zones_test_and_combine_areas.cpp | 17 +- polygon/PolyLine.cpp | 248 ++---------------- polygon/PolyLine.h | 13 +- polygon/math_for_graphics.cpp | 37 +-- polygon/math_for_graphics.h | 7 +- 10 files changed, 58 insertions(+), 270 deletions(-) diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp index 5b338ebeca..9b79c76976 100644 --- a/pcbnew/class_pad.cpp +++ b/pcbnew/class_pad.cpp @@ -44,6 +44,7 @@ #include #include +#include int D_PAD::m_PadSketchModePenSize = 0; // Pen size used to draw pads in sketch mode diff --git a/pcbnew/class_zone.cpp b/pcbnew/class_zone.cpp index c97dfc0b4e..53024e5ea4 100644 --- a/pcbnew/class_zone.cpp +++ b/pcbnew/class_zone.cpp @@ -47,6 +47,7 @@ #include #include #include +#include ZONE_CONTAINER::ZONE_CONTAINER( BOARD* aBoard ) : diff --git a/pcbnew/drc_clearance_test_functions.cpp b/pcbnew/drc_clearance_test_functions.cpp index 5caa5e0d10..8ebea8231c 100644 --- a/pcbnew/drc_clearance_test_functions.cpp +++ b/pcbnew/drc_clearance_test_functions.cpp @@ -45,6 +45,7 @@ #include #include #include +#include /* compare 2 trapezoids (can be rectangle) and return true if distance > aDist diff --git a/pcbnew/zones_polygons_insulated_copper_islands.cpp b/pcbnew/zones_polygons_insulated_copper_islands.cpp index d0a0d09970..07b2c026f5 100644 --- a/pcbnew/zones_polygons_insulated_copper_islands.cpp +++ b/pcbnew/zones_polygons_insulated_copper_islands.cpp @@ -35,6 +35,7 @@ #include #include +#include /** diff --git a/pcbnew/zones_polygons_test_connections.cpp b/pcbnew/zones_polygons_test_connections.cpp index 5ee92ff48e..66e1a481aa 100644 --- a/pcbnew/zones_polygons_test_connections.cpp +++ b/pcbnew/zones_polygons_test_connections.cpp @@ -28,7 +28,6 @@ #include // sort - #include #include #include @@ -40,6 +39,7 @@ #include #include +#include static bool CmpZoneSubnetValue( const BOARD_CONNECTED_ITEM* a, const BOARD_CONNECTED_ITEM* b ); void Merge_SubNets_Connected_By_CopperAreas( BOARD* aPcb, int aNetcode ); diff --git a/pcbnew/zones_test_and_combine_areas.cpp b/pcbnew/zones_test_and_combine_areas.cpp index 75755e7974..00cada3d40 100644 --- a/pcbnew/zones_test_and_combine_areas.cpp +++ b/pcbnew/zones_test_and_combine_areas.cpp @@ -43,6 +43,7 @@ #include #include +#define STRAIGHT 0 // To be remove after math_for_graphics code cleanup /** * Function AddArea @@ -386,8 +387,8 @@ bool BOARD::TestAreaIntersections( ZONE_CONTAINER* area_to_test ) yf2 = poly2->GetY( is2 ); } - int n_int = FindSegmentIntersections( xi1, yi1, xf1, yf1, CPolyLine::STRAIGHT, - xi2, yi2, xf2, yf2, CPolyLine::STRAIGHT ); + int n_int = FindSegmentIntersections( xi1, yi1, xf1, yf1, STRAIGHT, + xi2, yi2, xf2, yf2, STRAIGHT ); if( n_int ) return true; } @@ -497,8 +498,8 @@ int BOARD::TestAreaIntersection( ZONE_CONTAINER* area_ref, ZONE_CONTAINER* area_ yf2 = poly2->GetY( is2 ); } - int n_int = FindSegmentIntersections( xi1, yi1, xf1, yf1, CPolyLine::STRAIGHT, - xi2, yi2, xf2, yf2, CPolyLine::STRAIGHT ); + int n_int = FindSegmentIntersections( xi1, yi1, xf1, yf1, STRAIGHT, + xi2, yi2, xf2, yf2, STRAIGHT ); if( n_int ) { bInt = true; @@ -843,10 +844,10 @@ int BOARD::Test_Drc_Areas_Outlines_To_Areas_Outlines( ZONE_CONTAINER* aArea_To_E int x, y; int d = GetClearanceBetweenSegments( bx1, by1, bx2, by2, - CPolyLine::STRAIGHT, + STRAIGHT, 0, ax1, ay1, ax2, ay2, - CPolyLine::STRAIGHT, + STRAIGHT, 0, zone2zoneClearance, &x, &y ); @@ -986,9 +987,9 @@ bool DRC::doEdgeZoneDrc( ZONE_CONTAINER* aArea, int aCornerIndex ) } int x, y; // variables containing the intersecting point coordinates - int d = GetClearanceBetweenSegments( bx1, by1, bx2, by2, CPolyLine::STRAIGHT, + int d = GetClearanceBetweenSegments( bx1, by1, bx2, by2, STRAIGHT, 0, - ax1, ay1, ax2, ay2, CPolyLine::STRAIGHT, + ax1, ay1, ax2, ay2, STRAIGHT, 0, zone_clearance, &x, &y ); diff --git a/polygon/PolyLine.cpp b/polygon/PolyLine.cpp index 7956cce353..130cc00ef7 100644 --- a/polygon/PolyLine.cpp +++ b/polygon/PolyLine.cpp @@ -14,6 +14,10 @@ #include #include #include +#include + +enum m_SideStyle { STRAIGHT }; // side styles + CPolyLine::CPolyLine() { @@ -62,7 +66,6 @@ void armBoolEng( Bool_Engine* aBooleng, bool aConvertHoles = false ); */ int CPolyLine::NormalizeWithKbool( std::vector* aExtraPolyList ) { - std::vector arc_array; std::vector hole_array; // list of holes std::vector* hole; // used to store corners for a given hole CPolyLine* polyline; @@ -108,7 +111,6 @@ int CPolyLine::NormalizeWithKbool( std::vector* aExtraPolyList ) { // first external contour, replace this poly m_CornersList.clear(); - m_SideStyle.clear(); bool first = true; while( m_Kbool_Poly_Engine->PolygonHasMorePoints() ) @@ -257,8 +259,7 @@ int CPolyLine::AddPolygonsToBoolEng( Bool_Engine* aBooleng, GroupType aGroup ) /** * Function MakeKboolPoly * fill a kbool engine with a closed polyline contour - * approximates arcs with multiple straight-line segments - * combining intersecting contours if possible + * normalize self-intersecting contours * @return error: 0 if Ok, 1 if error */ int CPolyLine::MakeKboolPoly() @@ -269,20 +270,12 @@ int CPolyLine::MakeKboolPoly() m_Kbool_Poly_Engine = NULL; } - std::vector* arc_array = NULL; // Remove me - if( !GetClosed() ) return 1; // error - int n_arcs = 0; int polycount = GetContoursCount(); int last_contour = polycount - 1; - if( arc_array ) - arc_array->clear(); - - int iarc = 0; - for( int icont = 0; icont <= last_contour; icont++ ) { // Fill a kbool engine for this contour, @@ -309,8 +302,6 @@ int CPolyLine::MakeKboolPoly() } } - // first, calculate number of vertices in contour - int n_vertices = 0; int ic_st = GetContourStart( icont ); int ic_end = GetContourEnd( icont ); @@ -320,159 +311,12 @@ int CPolyLine::MakeKboolPoly() return 1; // error } - for( int ic = ic_st; ic<=ic_end; ic++ ) + // Enter this contour to booleng + for( int ic = ic_st; ic <= ic_end; ic++ ) { - int style = m_SideStyle[ic]; - - if( style == STRAIGHT ) - n_vertices++; - else - { - // style is ARC_CW or ARC_CCW - int n = CArc::ARC_STEPS; - n_vertices += n; - n_arcs++; - } - } - - // now enter this contour to booleng - int ivtx = 0; - - for( int ic = ic_st; ic<=ic_end; ic++ ) - { - int style = m_SideStyle[ic]; int x1 = m_CornersList[ic].x; int y1 = m_CornersList[ic].y; - int x2, y2; - - if( ic < ic_end ) - { - x2 = m_CornersList[ic + 1].x; - y2 = m_CornersList[ic + 1].y; - } - else - { - x2 = m_CornersList[ic_st].x; - y2 = m_CornersList[ic_st].y; - } - - if( style == STRAIGHT ) - { - booleng->AddPoint( x1, y1 ); - ivtx++; - } - else - { - // style is arc_cw or arc_ccw - int n; // number of steps for arcs - n = CArc::ARC_STEPS; - double xo, yo, theta1, theta2, a, b; - a = fabs( (double) (x1 - x2) ); - b = fabs( (double) (y1 - y2) ); - - if( style == CPolyLine::ARC_CW ) - { - // clockwise arc (ie.quadrant of ellipse) - if( x2 > x1 && y2 > y1 ) - { - // first quadrant, draw second quadrant of ellipse - xo = x2; - yo = y1; - theta1 = M_PI; - theta2 = M_PI / 2.0; - } - else if( x2 < x1 && y2 > y1 ) - { - // second quadrant, draw third quadrant of ellipse - xo = x1; - yo = y2; - theta1 = 3.0 * M_PI / 2.0; - theta2 = M_PI; - } - else if( x2 < x1 && y2 < y1 ) - { - // third quadrant, draw fourth quadrant of ellipse - xo = x2; - yo = y1; - theta1 = 2.0 * M_PI; - theta2 = 3.0 * M_PI / 2.0; - } - else - { - xo = x1; // fourth quadrant, draw first quadrant of ellipse - yo = y2; - theta1 = M_PI / 2.0; - theta2 = 0.0; - } - } - else - { - // counter-clockwise arc - if( x2 > x1 && y2 > y1 ) - { - xo = x1; // first quadrant, draw fourth quadrant of ellipse - yo = y2; - theta1 = 3.0 * M_PI / 2.0; - theta2 = 2.0 * M_PI; - } - else if( x2 < x1 && y2 > y1 ) - { - xo = x2; // second quadrant - yo = y1; - theta1 = 0.0; - theta2 = M_PI / 2.0; - } - else if( x2 < x1 && y2 < y1 ) - { - xo = x1; // third quadrant - yo = y2; - theta1 = M_PI / 2.0; - theta2 = M_PI; - } - else - { - xo = x2; // fourth quadrant - yo = y1; - theta1 = M_PI; - theta2 = 3.0 * M_PI / 2.0; - } - } - - // now write steps for arc - if( arc_array ) - { - CArc new_arc; - new_arc.style = style; - new_arc.n_steps = n; - new_arc.xi = x1; - new_arc.yi = y1; - new_arc.xf = x2; - new_arc.yf = y2; - arc_array->push_back( new_arc ); - iarc++; - } - - for( int is = 0; isAddPoint( x, y ); - ivtx++; - } - } - } - - if( n_vertices != ivtx ) - { - wxASSERT( 0 ); + booleng->AddPoint( x1, y1 ); } // close list added to the bool engine @@ -624,7 +468,6 @@ void CPolyLine::Start( int layer, int x, int y, int hatch ) poly_pt.end_contour = false; m_CornersList.push_back( poly_pt ); - m_SideStyle.push_back( 0 ); } @@ -636,12 +479,8 @@ void CPolyLine::AppendCorner( int x, int y ) CPolyPt poly_pt( x, y ); poly_pt.end_contour = false; - // add entries for new corner and side + // add entries for new corner m_CornersList.push_back( poly_pt ); - m_SideStyle.push_back( STRAIGHT ); - - if( m_CornersList.size() > 0 && !m_CornersList[m_CornersList.size() - 1].end_contour ) - m_SideStyle[m_CornersList.size() - 1] = STRAIGHT; } @@ -670,29 +509,24 @@ void CPolyLine::DeleteCorner( int ic ) { UnHatch(); int icont = GetContour( ic ); - int istart = GetContourStart( icont ); int iend = GetContourEnd( icont ); - bool bClosed = icont < GetContoursCount() - 1 || GetClosed(); + bool closed = icont < GetContoursCount() - 1 || GetClosed(); - if( !bClosed ) + if( !closed ) { // open contour, must be last contour m_CornersList.erase( m_CornersList.begin() + ic ); - - if( ic != istart ) - m_SideStyle.erase( m_SideStyle.begin() + ic - 1 ); } else { // closed contour m_CornersList.erase( m_CornersList.begin() + ic ); - m_SideStyle.erase( m_SideStyle.begin() + ic ); if( ic == iend ) m_CornersList[ic - 1].end_contour = true; } - if( bClosed && GetContourSize( icont ) < 3 ) + if( closed && GetContourSize( icont ) < 3 ) { // delete the entire contour RemoveContour( icont ); @@ -725,7 +559,6 @@ void CPolyLine::RemoveContour( int icont ) { // remove last contour m_CornersList.erase( m_CornersList.begin() + istart, m_CornersList.end() ); - m_SideStyle.erase( m_SideStyle.begin() + istart, m_SideStyle.end() ); } else { @@ -733,7 +566,6 @@ void CPolyLine::RemoveContour( int icont ) for( int ic = iend; ic>=istart; ic-- ) { m_CornersList.erase( m_CornersList.begin() + ic ); - m_SideStyle.erase( m_SideStyle.begin() + ic ); } } @@ -958,7 +790,6 @@ void CPolyLine::RemoveAllContours( void ) */ { m_CornersList.clear(); - m_SideStyle.clear(); } @@ -975,12 +806,10 @@ void CPolyLine::InsertCorner( int ic, int x, int y ) if( (unsigned) (ic) >= m_CornersList.size() ) { m_CornersList.push_back( CPolyPt( x, y ) ); - m_SideStyle.push_back( STRAIGHT ); } else { m_CornersList.insert( m_CornersList.begin() + ic + 1, CPolyPt( x, y ) ); - m_SideStyle.insert( m_SideStyle.begin() + ic + 1, STRAIGHT ); } if( (unsigned) (ic + 1) < m_CornersList.size() ) @@ -1166,41 +995,6 @@ int CPolyLine::GetContourSize( int icont ) } -void CPolyLine::SetSideStyle( int is, int style ) -{ - UnHatch(); - wxPoint p1, p2; - - if( is == (int) (m_CornersList.size() - 1) ) - { - p1.x = m_CornersList[m_CornersList.size() - 1].x; - p1.y = m_CornersList[m_CornersList.size() - 1].y; - p2.x = m_CornersList[0].x; - p2.y = m_CornersList[0].y; - } - else - { - p1.x = m_CornersList[is].x; - p1.y = m_CornersList[is].y; - p2.x = m_CornersList[is + 1].x; - p2.y = m_CornersList[is + 1].y; - } - - if( p1.x == p2.x || p1.y == p2.y ) - m_SideStyle[is] = STRAIGHT; - else - m_SideStyle[is] = style; - - Hatch(); -} - - -int CPolyLine::GetSideStyle( int is ) -{ - return m_SideStyle[is]; -} - - int CPolyLine::GetClosed() { if( m_CornersList.size() == 0 ) @@ -1318,7 +1112,7 @@ void CPolyLine::Hatch() m_CornersList[ic].x, m_CornersList[ic].y, m_CornersList[i_start_contour].x, m_CornersList[i_start_contour].y, - m_SideStyle[ic], + STRAIGHT, &x, &y, &x2, &y2 ); i_start_contour = ic + 1; } @@ -1327,7 +1121,7 @@ void CPolyLine::Hatch() ok = FindLineSegmentIntersection( a, slope, m_CornersList[ic].x, m_CornersList[ic].y, m_CornersList[ic + 1].x, m_CornersList[ic + 1].y, - m_SideStyle[ic], + STRAIGHT, &x, &y, &x2, &y2 ); } @@ -1443,8 +1237,6 @@ void CPolyLine::Copy( CPolyLine* src ) m_hatchPitch = src->m_hatchPitch; // copy corners, using vector copy m_CornersList = src->m_CornersList; - // copy side styles, using vector copy - m_SideStyle = src->m_SideStyle; } @@ -1595,10 +1387,9 @@ int CPolyLine::Distance( wxPoint aStart, wxPoint aEnd, int aWidth ) by2 = GetY( ic2 + 1 ); } - int bstyle = GetSideStyle( ic2 ); - int d = GetClearanceBetweenSegments( bx1, by1, bx2, by2, bstyle, 0, + int d = GetClearanceBetweenSegments( bx1, by1, bx2, by2, STRAIGHT, 0, aStart.x, aStart.y, aEnd.x, aEnd.y, - CPolyLine::STRAIGHT, aWidth, + STRAIGHT, aWidth, 1, // min clearance, should be > 0 NULL, NULL ); @@ -1654,12 +1445,9 @@ int CPolyLine::Distance( const wxPoint& aPoint ) by2 = GetY( ic2 + 1 ); } - // Here we expect only straight lines for vertices - // (no arcs, not yet supported in Pcbnew) int d = KiROUND( GetPointToLineSegmentDistance( aPoint.x, aPoint.y, bx1, by1, bx2, by2 ) ); - if( distance > d ) distance = d; @@ -1901,9 +1689,9 @@ bool CPolyLine::IsPolygonSelfIntersecting() int x2f = GetX( is2_next ); int y2f = GetY( is2_next ); int ret = FindSegmentIntersections( x1i, y1i, x1f, y1f, - CPolyLine::STRAIGHT, + STRAIGHT, x2i, y2i, x2f, y2f, - CPolyLine::STRAIGHT ); + STRAIGHT ); if( ret ) { // intersection between non-adjacent sides diff --git a/polygon/PolyLine.h b/polygon/PolyLine.h index 2a15368f42..984062700c 100644 --- a/polygon/PolyLine.h +++ b/polygon/PolyLine.h @@ -24,13 +24,13 @@ #include // inflection modes for DS_LINE and DS_LINE_VERTEX, used in math_for_graphics.cpp -enum { +/*enum { IM_NONE = 0, IM_90_45, IM_45_90, IM_90 }; - +*/ class CRect { @@ -58,6 +58,7 @@ public: } }; +/* class CArc { public: @@ -67,7 +68,7 @@ public: int n_steps; // number of straight-line segments in gpc_poly bool bFound; }; - +*/ class CPolyPt : public wxPoint { @@ -98,12 +99,9 @@ public: }; -#include - class CPolyLine { public: - enum m_SideStyle { STRAIGHT, ARC_CW, ARC_CCW }; // side styles enum HATCH_STYLE { NO_HATCH, DIAGONAL_FULL, DIAGONAL_EDGE }; // hatch styles // constructors/destructor @@ -197,7 +195,6 @@ public: int GetUtility( int ic ) { return m_CornersList[ic].m_utility; }; void SetUtility( int ic, int utility ) { m_CornersList[ic].m_utility = utility; }; - int GetSideStyle( int is ); int GetHatchPitch() { return m_hatchPitch; } static int GetDefaultHatchPitchMils() { return 20; } // default hatch pitch value in mils @@ -214,7 +211,6 @@ public: void SetX( int ic, int x ); void SetY( int ic, int y ); void SetEndContour( int ic, bool end_contour ); - void SetSideStyle( int is, int style ); void SetHatchStyle( enum HATCH_STYLE style ) { @@ -299,7 +295,6 @@ private: Bool_Engine* m_Kbool_Poly_Engine; // polygons set in kbool engine data public: std::vector m_CornersList; // array of points for corners - std::vector m_SideStyle; // array of styles for sides std::vector m_HatchLines; // hatch lines showing the polygon area }; diff --git a/polygon/math_for_graphics.cpp b/polygon/math_for_graphics.cpp index de9a802817..5f360dc252 100644 --- a/polygon/math_for_graphics.cpp +++ b/polygon/math_for_graphics.cpp @@ -34,12 +34,17 @@ double Distance( double x1, double y1, double x2, double y2 ) return d; } +static bool Quadratic( double a, double b, double c, double *x1, double *x2 ); +static bool FindLineEllipseIntersections( double a, double b, double c, double d, double *x1, double *x2 ); +static bool FindVerticalLineEllipseIntersections( double a, double b, double x, double *y1, double *y2 ); static int GetArcIntersections( EllipseKH * el1, EllipseKH * el2, double * x1=NULL, double * y1=NULL, double * x2=NULL, double * y2=NULL ); static bool InRange( double x, double xi, double xf ); +enum m_SideStyle { STRAIGHT, ARC_CW, ARC_CCW }; // side styles + /** @@ -112,7 +117,7 @@ int MakeEllipseFromArc( int xi, int yi, int xf, int yf, int style, EllipseKH* el // convert to clockwise arc int xxi, xxf, yyi, yyf; - if( style == CPolyLine::ARC_CCW ) + if( style == ARC_CCW ) { xxi = xf; xxf = xi; @@ -199,7 +204,7 @@ int FindSegmentIntersections( int xi, int yi, int xf, int yf, int style, || min( yi, yf ) > max( yi2, yf2 ) ) return 0; - if( style != CPolyLine::STRAIGHT && style2 != CPolyLine::STRAIGHT ) + if( style != STRAIGHT && style2 != STRAIGHT ) { // two identical arcs intersect if( style == style2 && xi == xi2 && yi == yi2 && xf == xf2 && yf == yf2 ) @@ -224,7 +229,7 @@ int FindSegmentIntersections( int xi, int yi, int xf, int yf, int style, } } - if( style == CPolyLine::STRAIGHT && style2 == CPolyLine::STRAIGHT ) + if( style == STRAIGHT && style2 == STRAIGHT ) { // both straight-line segments int x, y; @@ -246,7 +251,7 @@ int FindSegmentIntersections( int xi, int yi, int xf, int yf, int style, yr[0] = y; iret = 1; } - else if( style == CPolyLine::STRAIGHT ) + else if( style == STRAIGHT ) { // first segment is straight, second segment is an arc int ret; @@ -288,7 +293,7 @@ int FindSegmentIntersections( int xi, int yi, int xf, int yf, int style, } } } - else if( style2 == CPolyLine::STRAIGHT ) + else if( style2 == STRAIGHT ) { // first segment is an arc, second segment is straight int ret; @@ -381,7 +386,7 @@ int FindLineSegmentIntersection( double a, double b, int xi, int yi, int xf, int if( xf != xi ) { // non-vertical segment, get intersection - if( style == CPolyLine::STRAIGHT || yf == yi ) + if( style == STRAIGHT || yf == yi ) { // horizontal or oblique straight segment // put into form y = c + dx; @@ -436,13 +441,13 @@ int FindLineSegmentIntersection( double a, double b, int xi, int yi, int xf, int return 0; } } - else if( style == CPolyLine::ARC_CW || style == CPolyLine::ARC_CCW ) + else if( style == ARC_CW || style == ARC_CCW ) { // arc (quadrant of ellipse) // convert to clockwise arc int xxi, xxf, yyi, yyf; - if( style == CPolyLine::ARC_CCW ) + if( style == ARC_CCW ) { xxi = xf; xxf = xi; @@ -640,7 +645,7 @@ bool TestForIntersectionOfStraightLineSegments( int x1i, int y1i, int x1f, int y a = (double) y2i - b * x2i; double x1, y1, x2, y2; - int test = FindLineSegmentIntersection( a, b, x1i, y1i, x1f, y1f, CPolyLine::STRAIGHT, + int test = FindLineSegmentIntersection( a, b, x1i, y1i, x1f, y1f, STRAIGHT, &x1, &y1, &x2, &y2 ); if( test ) @@ -668,7 +673,7 @@ bool TestForIntersectionOfStraightLineSegments( int x1i, int y1i, int x1f, int y a = (double) y2i - b * x2i; double x1, y1, x2, y2; - int test = FindLineSegmentIntersection( a, b, x1i, y1i, x1f, y1f, CPolyLine::STRAIGHT, + int test = FindLineSegmentIntersection( a, b, x1i, y1i, x1f, y1f, STRAIGHT, &x1, &y1, &x2, &y2 ); if( test ) @@ -696,7 +701,7 @@ bool TestForIntersectionOfStraightLineSegments( int x1i, int y1i, int x1f, int y a = (double) y1i - b * x1i; double x1, y1, x2, y2; - int test = FindLineSegmentIntersection( a, b, x2i, y2i, x2f, y2f, CPolyLine::STRAIGHT, + int test = FindLineSegmentIntersection( a, b, x2i, y2i, x2f, y2f, STRAIGHT, &x1, &y1, &x2, &y2 ); if( test ) @@ -724,7 +729,7 @@ bool TestForIntersectionOfStraightLineSegments( int x1i, int y1i, int x1f, int y a = (double) y1i - b * x1i; double x1, y1, x2, y2; - int test = FindLineSegmentIntersection( a, b, x2i, y2i, x2f, y2f, CPolyLine::STRAIGHT, + int test = FindLineSegmentIntersection( a, b, x2i, y2i, x2f, y2f, STRAIGHT, &x1, &y1, &x2, &y2 ); if( test ) @@ -760,7 +765,7 @@ bool TestForIntersectionOfStraightLineSegments( int x1i, int y1i, int x1f, int y y2i, x2f, y2f, - CPolyLine::STRAIGHT, + STRAIGHT, &x1, &y1, &x2, @@ -904,7 +909,7 @@ int GetClearanceBetweenSegments( int x1i, int y1i, int x1f, int y1f, int style1, if( min( y2i, y2f ) - max( y1i, y1f ) > min_dist ) return max_cl+1; - if( style1 == CPolyLine::STRAIGHT && style1 == CPolyLine::STRAIGHT ) + if( style1 == STRAIGHT && style1 == STRAIGHT ) { // both segments are straight lines int xx, yy; @@ -948,7 +953,7 @@ int GetClearanceBetweenSegments( int x1i, int y1i, int x1f, int y1f, int style1, bool bArcs; int xi = 0, yi = 0, xf = 0, yf = 0; - if( style2 == CPolyLine::STRAIGHT ) + if( style2 == STRAIGHT ) { // style1 = arc, style2 = straight MakeEllipseFromArc( x1i, y1i, x1f, y1f, style1, &el1 ); @@ -958,7 +963,7 @@ int GetClearanceBetweenSegments( int x1i, int y1i, int x1f, int y1f, int style1, yf = y2f; bArcs = false; } - else if( style1 == CPolyLine::STRAIGHT ) + else if( style1 == STRAIGHT ) { // style2 = arc, style1 = straight xi = x1i; diff --git a/polygon/math_for_graphics.h b/polygon/math_for_graphics.h index a9b1cf2b68..86ef869874 100644 --- a/polygon/math_for_graphics.h +++ b/polygon/math_for_graphics.h @@ -1,9 +1,5 @@ // math stuff for graphics, from FreePCB - -// math stuff for graphics -bool Quadratic( double a, double b, double c, double *x1, double *x2 ); - /** * Function TestLineHit * test for hit on line segment i.e. a point within a given distance from segment @@ -16,11 +12,10 @@ bool TestLineHit( int xi, int yi, int xf, int yf, int x, int y, double dist ); int FindLineSegmentIntersection( double a, double b, int xi, int yi, int xf, int yf, int style, double * x1, double * y1, double * x2, double * y2, double * dist=NULL ); + int FindSegmentIntersections( int xi, int yi, int xf, int yf, int style, int xi2, int yi2, int xf2, int yf2, int style2, double x[]=NULL, double y[]=NULL ); -bool FindLineEllipseIntersections( double a, double b, double c, double d, double *x1, double *x2 ); -bool FindVerticalLineEllipseIntersections( double a, double b, double x, double *y1, double *y2 ); /** * Function TestForIntersectionOfStraightLineSegments