From 6a93777a51d35ac79d71b9980b2397669a88f841 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 8 Nov 2014 13:25:29 +0100 Subject: [PATCH 1/2] Polyline.h: remove useless class CRect. Use the more powerful EDA_RECT instead. Clean and remove duplicate code. --- include/base_struct.h | 176 +------------------- include/class_eda_rect.h | 207 ++++++++++++++++++++++++ pcbnew/class_zone.cpp | 13 +- pcbnew/zone_filling_algorithm.cpp | 2 +- pcbnew/zones_test_and_combine_areas.cpp | 16 +- polygon/PolyLine.cpp | 56 ++++--- polygon/PolyLine.h | 42 ++--- 7 files changed, 275 insertions(+), 237 deletions(-) create mode 100644 include/class_eda_rect.h diff --git a/include/base_struct.h b/include/base_struct.h index 335763ec05..8a5332df56 100644 --- a/include/base_struct.h +++ b/include/base_struct.h @@ -38,6 +38,7 @@ #include #include #include +#include #if defined(DEBUG) #include // needed for Show() @@ -113,181 +114,6 @@ public: }; -/** - * Class EDA_RECT - * handles the component boundary box. - * This class is similar to wxRect, but some wxRect functions are very curious, - * and are working only if dimensions are >= 0 (not always the case in KiCad) - * and also KiCad needs some specific method. - * so I prefer this more suitable class - */ -class EDA_RECT -{ -private: - wxPoint m_Pos; // Rectangle Origin - wxSize m_Size; // Rectangle Size - -public: - EDA_RECT() { }; - - EDA_RECT( const wxPoint& aPos, const wxSize& aSize ) : - m_Pos( aPos ), - m_Size( aSize ) - { } - - wxPoint Centre() const - { - return wxPoint( m_Pos.x + ( m_Size.x >> 1 ), - m_Pos.y + ( m_Size.y >> 1 ) ); - } - - /** - * Function Move - * moves the rectangle by the \a aMoveVector. - * @param aMoveVector A wxPoint that is the value to move this rectangle - */ - void Move( const wxPoint& aMoveVector ); - - /** - * Function Normalize - * ensures that the height ant width are positive. - */ - void Normalize(); - - /** - * Function Contains - * @param aPoint = the wxPoint to test - * @return true if aPoint is inside the boundary box. A point on a edge is seen as inside - */ - bool Contains( const wxPoint& aPoint ) const; - /** - * Function Contains - * @param x = the x coordinate of the point to test - * @param y = the x coordinate of the point to test - * @return true if point is inside the boundary box. A point on a edge is seen as inside - */ - bool Contains( int x, int y ) const { return Contains( wxPoint( x, y ) ); } - - /** - * Function Contains - * @param aRect = the EDA_RECT to test - * @return true if aRect is Contained. A common edge is seen as contained - */ - bool Contains( const EDA_RECT& aRect ) const; - - const wxSize& GetSize() const { return m_Size; } - int GetX() const { return m_Pos.x; } - int GetY() const { return m_Pos.y; } - - const wxPoint& GetOrigin() const { return m_Pos; } - const wxPoint& GetPosition() const { return m_Pos; } - const wxPoint GetEnd() const { return wxPoint( GetRight(), GetBottom() ); } - - int GetWidth() const { return m_Size.x; } - int GetHeight() const { return m_Size.y; } - int GetRight() const { return m_Pos.x + m_Size.x; } - int GetBottom() const { return m_Pos.y + m_Size.y; } - - void SetOrigin( const wxPoint& pos ) { m_Pos = pos; } - void SetOrigin( int x, int y ) { m_Pos.x = x; m_Pos.y = y; } - void SetSize( const wxSize& size ) { m_Size = size; } - void SetSize( int w, int h ) { m_Size.x = w; m_Size.y = h; } - void Offset( int dx, int dy ) { m_Pos.x += dx; m_Pos.y += dy; } - void Offset( const wxPoint& offset ) { m_Pos.x += offset.x; m_Pos.y += - offset.y; } - void SetX( int val ) { m_Pos.x = val; } - void SetY( int val ) { m_Pos.y = val; } - void SetWidth( int val ) { m_Size.x = val; } - void SetHeight( int val ) { m_Size.y = val; } - void SetEnd( int x, int y ) { SetEnd( wxPoint( x, y ) ); } - void SetEnd( const wxPoint& pos ) - { - m_Size.x = pos.x - m_Pos.x; m_Size.y = pos.y - m_Pos.y; - } - - /** - * Function Intersects - * tests for a common area between rectangles. - * - * @param aRect A rectangle to test intersection with. - * @return bool - true if the argument rectangle intersects this rectangle. - * (i.e. if the 2 rectangles have at least a common point) - */ - bool Intersects( const EDA_RECT& aRect ) const; - - /** - * Function Intersects - * tests for a common area between a segment and this rectangle. - * - * @param aPoint1 First point of the segment to test intersection with. - * @param aPoint2 Second point of the segment to test intersection with. - * @return bool - true if the argument segment intersects this rectangle. - * (i.e. if the segment and rectangle have at least a common point) - */ - bool Intersects( const wxPoint& aPoint1, const wxPoint& aPoint2 ) const; - - /** - * Function operator(wxRect) - * overloads the cast operator to return a wxRect - * wxRect does not accept negative values for size, so ensure the - * wxRect size is always >= 0 - */ - operator wxRect() const - { - EDA_RECT rect( m_Pos, m_Size ); - rect.Normalize(); - return wxRect( rect.m_Pos, rect.m_Size ); - } - - /** - * Function Inflate - * inflates the rectangle horizontally by \a dx and vertically by \a dy. If \a dx - * and/or \a dy is negative the rectangle is deflated. - */ - EDA_RECT& Inflate( wxCoord dx, wxCoord dy ); - - /** - * Function Inflate - * inflates the rectangle horizontally and vertically by \a aDelta. If \a aDelta - * is negative the rectangle is deflated. - */ - EDA_RECT& Inflate( int aDelta ); - - /** - * Function Merge - * modifies the position and size of the rectangle in order to contain \a aRect. It is - * mainly used to calculate bounding boxes. - * @param aRect The rectangle to merge with this rectangle. - */ - void Merge( const EDA_RECT& aRect ); - - /** - * Function Merge - * modifies the position and size of the rectangle in order to contain the given point. - * @param aPoint The point to merge with the rectangle. - */ - void Merge( const wxPoint& aPoint ); - - /** - * Function GetArea - * returns the area of the rectangle. - * @return The area of the rectangle. - */ - double GetArea() const; - - /** - * Function GetBoundingBoxRotated - * @return the bounding box of this, after rotation - * @param aAngle = the rotation angle in 0.1 deg. - * @param aRotCenter = the rotation point. - * useful to calculate bounding box of rotated items, when - * rotation if not k*90 degrees - */ - const EDA_RECT GetBoundingBoxRotated( wxPoint aRotCenter, double aAngle ); -}; - - - // These define are used for the .m_Flags and .m_UndoRedoStatus member of the // class EDA_ITEM #define IS_CHANGED (1 << 0) ///< Item was edited, and modified diff --git a/include/class_eda_rect.h b/include/class_eda_rect.h new file mode 100644 index 0000000000..f46d3eec90 --- /dev/null +++ b/include/class_eda_rect.h @@ -0,0 +1,207 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr + * Copyright (C) 2004-2014 KiCad Developers, see change_log.txt for contributors. + * + * 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 + */ + +/** + * @file class_eda_rect.h + */ + +#ifndef CLASS_EDA_RECT_H +#define CLASS_EDA_RECT_H + +/** + * Class EDA_RECT + * handles the component boundary box. + * This class is similar to wxRect, but some wxRect functions are very curious, + * and are working only if dimensions are >= 0 (not always the case in KiCad) + * and also KiCad needs some specific method. + * so I prefer this more suitable class + */ +class EDA_RECT +{ +private: + wxPoint m_Pos; // Rectangle Origin + wxSize m_Size; // Rectangle Size + +public: + EDA_RECT() { }; + + EDA_RECT( const wxPoint& aPos, const wxSize& aSize ) : + m_Pos( aPos ), + m_Size( aSize ) + { } + + wxPoint Centre() const + { + return wxPoint( m_Pos.x + ( m_Size.x >> 1 ), + m_Pos.y + ( m_Size.y >> 1 ) ); + } + + /** + * Function Move + * moves the rectangle by the \a aMoveVector. + * @param aMoveVector A wxPoint that is the value to move this rectangle + */ + void Move( const wxPoint& aMoveVector ); + + /** + * Function Normalize + * ensures that the height ant width are positive. + */ + void Normalize(); + + /** + * Function Contains + * @param aPoint = the wxPoint to test + * @return true if aPoint is inside the boundary box. A point on a edge is seen as inside + */ + bool Contains( const wxPoint& aPoint ) const; + /** + * Function Contains + * @param x = the x coordinate of the point to test + * @param y = the x coordinate of the point to test + * @return true if point is inside the boundary box. A point on a edge is seen as inside + */ + bool Contains( int x, int y ) const { return Contains( wxPoint( x, y ) ); } + + /** + * Function Contains + * @param aRect = the EDA_RECT to test + * @return true if aRect is Contained. A common edge is seen as contained + */ + bool Contains( const EDA_RECT& aRect ) const; + + const wxSize& GetSize() const { return m_Size; } + int GetX() const { return m_Pos.x; } + int GetY() const { return m_Pos.y; } + + const wxPoint& GetOrigin() const { return m_Pos; } + const wxPoint& GetPosition() const { return m_Pos; } + const wxPoint GetEnd() const { return wxPoint( m_Pos.x + m_Size.x, m_Pos.y + m_Size.y ); } + + int GetWidth() const { return m_Size.x; } + int GetHeight() const { return m_Size.y; } + int GetRight() const { return m_Pos.x + m_Size.x; } + int GetLeft() const { return m_Pos.x; } + int GetBottom() const { return m_Pos.y + m_Size.y; } // Y axis from top to bottom + + void SetOrigin( const wxPoint& pos ) { m_Pos = pos; } + void SetOrigin( int x, int y ) { m_Pos.x = x; m_Pos.y = y; } + void SetSize( const wxSize& size ) { m_Size = size; } + void SetSize( int w, int h ) { m_Size.x = w; m_Size.y = h; } + void Offset( int dx, int dy ) { m_Pos.x += dx; m_Pos.y += dy; } + void Offset( const wxPoint& offset ) { m_Pos.x += offset.x; m_Pos.y += + offset.y; } + void SetX( int val ) { m_Pos.x = val; } + void SetY( int val ) { m_Pos.y = val; } + void SetWidth( int val ) { m_Size.x = val; } + void SetHeight( int val ) { m_Size.y = val; } + void SetEnd( int x, int y ) { SetEnd( wxPoint( x, y ) ); } + void SetEnd( const wxPoint& pos ) + { + m_Size.x = pos.x - m_Pos.x; m_Size.y = pos.y - m_Pos.y; + } + + /** + * Function Intersects + * tests for a common area between rectangles. + * + * @param aRect A rectangle to test intersection with. + * @return bool - true if the argument rectangle intersects this rectangle. + * (i.e. if the 2 rectangles have at least a common point) + */ + bool Intersects( const EDA_RECT& aRect ) const; + + /** + * Function Intersects + * tests for a common area between a segment and this rectangle. + * + * @param aPoint1 First point of the segment to test intersection with. + * @param aPoint2 Second point of the segment to test intersection with. + * @return bool - true if the argument segment intersects this rectangle. + * (i.e. if the segment and rectangle have at least a common point) + */ + bool Intersects( const wxPoint& aPoint1, const wxPoint& aPoint2 ) const; + + /** + * Function operator(wxRect) + * overloads the cast operator to return a wxRect + * wxRect does not accept negative values for size, so ensure the + * wxRect size is always >= 0 + */ + operator wxRect() const + { + EDA_RECT rect( m_Pos, m_Size ); + rect.Normalize(); + return wxRect( rect.m_Pos, rect.m_Size ); + } + + /** + * Function Inflate + * inflates the rectangle horizontally by \a dx and vertically by \a dy. If \a dx + * and/or \a dy is negative the rectangle is deflated. + */ + EDA_RECT& Inflate( wxCoord dx, wxCoord dy ); + + /** + * Function Inflate + * inflates the rectangle horizontally and vertically by \a aDelta. If \a aDelta + * is negative the rectangle is deflated. + */ + EDA_RECT& Inflate( int aDelta ); + + /** + * Function Merge + * modifies the position and size of the rectangle in order to contain \a aRect. It is + * mainly used to calculate bounding boxes. + * @param aRect The rectangle to merge with this rectangle. + */ + void Merge( const EDA_RECT& aRect ); + + /** + * Function Merge + * modifies the position and size of the rectangle in order to contain the given point. + * @param aPoint The point to merge with the rectangle. + */ + void Merge( const wxPoint& aPoint ); + + /** + * Function GetArea + * returns the area of the rectangle. + * @return The area of the rectangle. + */ + double GetArea() const; + + /** + * Function GetBoundingBoxRotated + * @return the bounding box of this, after rotation + * @param aAngle = the rotation angle in 0.1 deg. + * @param aRotCenter = the rotation point. + * useful to calculate bounding box of rotated items, when + * rotation if not k*90 degrees + */ + const EDA_RECT GetBoundingBoxRotated( wxPoint aRotCenter, double aAngle ); +}; + + +#endif // CLASS_EDA_RECT_H diff --git a/pcbnew/class_zone.cpp b/pcbnew/class_zone.cpp index 95ba4c7f92..ed9c217cab 100644 --- a/pcbnew/class_zone.cpp +++ b/pcbnew/class_zone.cpp @@ -262,7 +262,7 @@ void ZONE_CONTAINER::DrawFilledArea( EDA_DRAW_PANEL* panel, const CPolyPt& corner = m_FilledPolysList.GetCorner( ic ); wxPoint coord( corner.x + offset.x, corner.y + offset.y ); CornersBuffer.push_back( coord ); - CornersTypeBuffer.push_back( (char) corner.m_utility ); + CornersTypeBuffer.push_back( (char) corner.m_flags ); // the last corner of a filled area is found: draw it if( (corner.end_contour) || (ic == imax) ) @@ -273,9 +273,9 @@ void ZONE_CONTAINER::DrawFilledArea( EDA_DRAW_PANEL* panel, * just draw filled polygons but with outlines thickness = m_ZoneMinThickness * So DO NOT use draw filled polygons with outlines having a thickness > 0 * Note: Extra segments ( added to joint holes with external outline) flagged by - * m_utility != 0 are not drawn + * m_flags != 0 are not drawn * Note not all polygon libraries provide a flag for these extra-segments, therefore - * the m_utility member can be always 0 + * the m_flags member can be always 0 */ { // Draw outlines: @@ -485,11 +485,8 @@ bool ZONE_CONTAINER::HitTest( const EDA_RECT& aRect, bool aContained, int aAccur { EDA_RECT arect = aRect; arect.Inflate( aAccuracy ); - CRect rect = m_Poly->GetBoundingBox(); - EDA_RECT bbox; - - bbox.SetOrigin( rect.left, rect.bottom ); - bbox.SetEnd( rect.right, rect.top ); + EDA_RECT bbox = m_Poly->GetBoundingBox(); + bbox.Normalize(); if( aContained ) return arect.Contains( bbox ); diff --git a/pcbnew/zone_filling_algorithm.cpp b/pcbnew/zone_filling_algorithm.cpp index aadcc66c2a..2c6f3654dd 100644 --- a/pcbnew/zone_filling_algorithm.cpp +++ b/pcbnew/zone_filling_algorithm.cpp @@ -175,7 +175,7 @@ int ZONE_CONTAINER::FillZoneAreasWithSegments() for( ics = istart, ice = iend; ics <= iend; ice = ics, ics++ ) { - if( m_FilledPolysList[ice].m_utility ) + if( m_FilledPolysList[ice].m_flags ) continue; int seg_startX = m_FilledPolysList[ics].x; diff --git a/pcbnew/zones_test_and_combine_areas.cpp b/pcbnew/zones_test_and_combine_areas.cpp index b35c1be122..4f2c61b7e4 100644 --- a/pcbnew/zones_test_and_combine_areas.cpp +++ b/pcbnew/zones_test_and_combine_areas.cpp @@ -93,7 +93,7 @@ bool BOARD::CombineAllAreasInNet( PICKED_ITEMS_LIST* aDeletedList, int aNetCode, bool modified = false; - //Loop through all combinations + // Loop through all combinations for( unsigned ia1 = 0; ia1 < m_ZoneDescriptorList.size() - 1; ia1++ ) { ZONE_CONTAINER* curr_area = m_ZoneDescriptorList[ia1]; @@ -102,7 +102,7 @@ bool BOARD::CombineAllAreasInNet( PICKED_ITEMS_LIST* aDeletedList, int aNetCode, continue; // legal polygon - CRect b1 = curr_area->Outline()->GetBoundingBox(); + EDA_RECT b1 = curr_area->Outline()->GetBoundingBox(); bool mod_ia1 = false; for( unsigned ia2 = m_ZoneDescriptorList.size() - 1; ia2 > ia1; ia2-- ) @@ -121,10 +121,9 @@ bool BOARD::CombineAllAreasInNet( PICKED_ITEMS_LIST* aDeletedList, int aNetCode, if( curr_area->GetLayer() != area2->GetLayer() ) continue; - CRect b2 = area2->Outline()->GetBoundingBox(); + EDA_RECT b2 = area2->Outline()->GetBoundingBox(); - if( !( b1.left > b2.right || b1.right < b2.left - || b1.bottom > b2.top || b1.top < b2.bottom ) ) + if( b1.Intersects( b2 ) ) { // check area2 against curr_area if( curr_area->GetLocalFlags() || area2->GetLocalFlags() @@ -194,11 +193,10 @@ bool BOARD::TestAreaIntersection( ZONE_CONTAINER* area_ref, ZONE_CONTAINER* area CPolyLine* poly2 = area_to_test->Outline(); // test bounding rects - CRect b1 = poly1->GetBoundingBox(); - CRect b2 = poly2->GetBoundingBox(); + EDA_RECT b1 = poly1->GetBoundingBox(); + EDA_RECT b2 = poly2->GetBoundingBox(); - if( b1.bottom > b2.top || b1.top < b2.bottom || - b1.left > b2.right || b1.right < b2.left ) + if( ! b1.Intersects( b2 ) ) return false; // now test for intersecting segments diff --git a/polygon/PolyLine.cpp b/polygon/PolyLine.cpp index 2a9d32ef4c..9c2e78d993 100644 --- a/polygon/PolyLine.cpp +++ b/polygon/PolyLine.cpp @@ -53,7 +53,7 @@ CPolyLine::CPolyLine() m_hatchStyle = NO_HATCH; m_hatchPitch = 0; m_layer = F_Cu; - m_utility = 0; + m_flags = 0; } CPolyLine::CPolyLine( const CPolyLine& aCPolyLine) @@ -599,7 +599,6 @@ void CPolyLine::InsertCorner( int ic, int x, int y ) // undraw polyline by removing all graphic elements from display list -// void CPolyLine::UnHatch() { m_HatchLines.clear(); @@ -612,42 +611,50 @@ int CPolyLine::GetEndContour( int ic ) } -CRect CPolyLine::GetBoundingBox() +EDA_RECT CPolyLine::GetBoundingBox() { - CRect r; - - r.left = r.bottom = INT_MAX; - r.right = r.top = INT_MIN; + int xmin = INT_MAX; + int ymin = INT_MAX; + int xmax = INT_MIN; + int ymax = INT_MIN; for( unsigned i = 0; i< m_CornersList.GetCornersCount(); i++ ) { - r.left = std::min( r.left, m_CornersList[i].x ); - r.right = std::max( r.right, m_CornersList[i].x ); - r.bottom = std::min( r.bottom, m_CornersList[i].y ); - r.top = std::max( r.top, m_CornersList[i].y ); + xmin = std::min( xmin, m_CornersList[i].x ); + xmax = std::max( xmax, m_CornersList[i].x ); + ymin = std::min( ymin, m_CornersList[i].y ); + ymax = std::max( ymax, m_CornersList[i].y ); } + EDA_RECT r; + r.SetOrigin( wxPoint( xmin, ymin ) ); + r.SetEnd( wxPoint( xmax, ymax ) ); + return r; } -CRect CPolyLine::GetBoundingBox( int icont ) +EDA_RECT CPolyLine::GetBoundingBox( int icont ) { - CRect r; - - r.left = r.bottom = INT_MAX; - r.right = r.top = INT_MIN; + int xmin = INT_MAX; + int ymin = INT_MAX; + int xmax = INT_MIN; + int ymax = INT_MIN; int istart = GetContourStart( icont ); int iend = GetContourEnd( icont ); for( int i = istart; i<=iend; i++ ) { - r.left = std::min( r.left, m_CornersList[i].x ); - r.right = std::max( r.right, m_CornersList[i].x ); - r.bottom = std::min( r.bottom, m_CornersList[i].y ); - r.top = std::max( r.top, m_CornersList[i].y ); + xmin = std::min( xmin, m_CornersList[i].x ); + xmax = std::max( xmax, m_CornersList[i].x ); + ymin = std::min( ymin, m_CornersList[i].y ); + ymax = std::max( ymax, m_CornersList[i].y ); } + EDA_RECT r; + r.SetOrigin( wxPoint( xmin, ymin ) ); + r.SetEnd( wxPoint( xmax, ymax ) ); + return r; } @@ -1469,7 +1476,7 @@ bool CPolyLine::IsPolygonSelfIntersecting() int n_cont = GetContoursCount(); // make bounding rect for each contour - std::vector cr; + std::vector cr; cr.reserve( n_cont ); for( int icont = 0; icont cr[icont2].right - || cr[icont].bottom > cr[icont2].top - || cr[icont2].left > cr[icont].right - || cr[icont2].bottom > cr[icont].top ) + if( !cr[icont].Intersects( cr[icont2] ) ) { // rectangles don't overlap, do nothing } diff --git a/polygon/PolyLine.h b/polygon/PolyLine.h index 4eacd2867e..9239bc274d 100644 --- a/polygon/PolyLine.h +++ b/polygon/PolyLine.h @@ -5,6 +5,8 @@ * (see http://www.freepcb.com/ ) * * Copyright (C) 2012-2014 Jean-Pierre Charras, jp.charras at wanadoo.fr + * Copyright (C) 2008-2013 SoftPLC Corporation, Dick Hollenbeck + * Copyright (C) 2008-2013 Wayne Stambaugh * Copyright (C) 2012-2014 KiCad Developers, see CHANGELOG.TXT for contributors. * * This program is free software; you can redistribute it and/or @@ -48,17 +50,11 @@ #include -#include -#include // for wxPoint definition -#include +#include // for wxPoint definition +#include // for LAYER_NUM definition +#include // for EDA_RECT definition #include -class CRect -{ -public: - int left, right, top, bottom; -}; - class CSegment { public: @@ -83,22 +79,22 @@ class CPolyPt : public wxPoint { public: CPolyPt( int aX = 0, int aY = 0, bool aEnd = false, int aUtility = 0 ) : - wxPoint( aX, aY ), end_contour( aEnd ), m_utility( aUtility ) + wxPoint( aX, aY ), end_contour( aEnd ), m_flags( aUtility ) {} // / Pure copy constructor is here to dis-ambiguate from the // / specialized CPolyPt( const wxPoint& ) constructor version below. CPolyPt( const CPolyPt& aPt ) : - wxPoint( aPt.x, aPt.y ), end_contour( aPt.end_contour ), m_utility( aPt.m_utility ) + wxPoint( aPt.x, aPt.y ), end_contour( aPt.end_contour ), m_flags( aPt.m_flags ) {} CPolyPt( const wxPoint& aPoint ) : - wxPoint( aPoint ), end_contour( false ), m_utility( 0 ) + wxPoint( aPoint ), end_contour( false ), m_flags( 0 ) {} bool end_contour; - int m_utility; + int m_flags; bool operator ==( const CPolyPt& cpt2 ) const { return (x == cpt2.x) && (y == cpt2.y) && (end_contour == cpt2.end_contour); } @@ -127,10 +123,10 @@ public: void SetX( int ic, int aValue ) { m_cornersList[ic].x = aValue; } int GetY( int ic ) const { return m_cornersList[ic].y; } void SetY( int ic, int aValue ) { m_cornersList[ic].y = aValue; } - int GetUtility( int ic ) const { return m_cornersList[ic].m_utility; } + int GetUtility( int ic ) const { return m_cornersList[ic].m_flags; } void SetFlag( int ic, int aFlag ) { - m_cornersList[ic].m_utility = aFlag; + m_cornersList[ic].m_flags = aFlag; } bool IsEndContour( int ic ) const @@ -327,8 +323,18 @@ public: void MoveOrigin( int x_off, int y_off ); // misc. functions - CRect GetBoundingBox(); - CRect GetBoundingBox( int icont ); + /** + * @return the full bounding box of polygons + */ + EDA_RECT GetBoundingBox(); + + /** + * @return the bounding box of a given polygon + * @param icont = the index of the polygon contour + * (0 = main contour, 1 ... n = other contours, usually holes) + */ + EDA_RECT GetBoundingBox( int icont ); + void Copy( const CPolyLine* src ); bool TestPointInside( int x, int y ); @@ -464,7 +470,7 @@ private: int m_hatchPitch; // for DIAGONAL_EDGE hatched outlines, basic distance between 2 hatch lines // and the len of eacvh segment // for DIAGONAL_FULL, the pitch is twice this value - int m_utility; // a flag used in some calculations + int m_flags; // a flag used in some calculations public: CPOLYGONS_LIST m_CornersList; // array of points for corners std::vector m_HatchLines; // hatch lines showing the polygon area From f877a1159eb1bbc59288361a5375ea64f4a3ce74 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 8 Nov 2014 14:30:39 +0100 Subject: [PATCH 2/2] Fix python scripting issue (EDA_RECT not mapped) --- scripting/kicad.i | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripting/kicad.i b/scripting/kicad.i index 6b2bb008b8..b4014b2419 100644 --- a/scripting/kicad.i +++ b/scripting/kicad.i @@ -60,6 +60,7 @@ #include #include #include + #include #include #include #include @@ -96,6 +97,7 @@ %include %include +%include %include %include %include