From 8df299a6bca5c41f9cba60e5b9b7bdc21f4fd4b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20W=C5=82ostowski?= Date: Fri, 1 Dec 2017 16:53:58 +0100 Subject: [PATCH] pcbnew: Optimized zone filling algorithm: code cleanup --- CMakeLists.txt | 1 - common/gal/opengl/opengl_gal.cpp | 1 + common/geometry/shape_poly_set.cpp | 2 -- include/geometry/shape_poly_set.h | 6 +++- pcbnew/class_zone.h | 50 +++++++++++++++--------------- pcbnew/connectivity_algo.cpp | 4 +-- pcbnew/pcb_painter.cpp | 27 ---------------- 7 files changed, 33 insertions(+), 58 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 84e5bea757..c70a34237f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -478,7 +478,6 @@ include( CheckFindPackageResult ) find_package( OpenMP ) if( OPENMP_FOUND ) - message( "FOUND OPENMP" ) set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}" ) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}" ) add_definitions( -DUSE_OPENMP ) diff --git a/common/gal/opengl/opengl_gal.cpp b/common/gal/opengl/opengl_gal.cpp index 3952352727..29d15096b4 100644 --- a/common/gal/opengl/opengl_gal.cpp +++ b/common/gal/opengl/opengl_gal.cpp @@ -1513,6 +1513,7 @@ void OPENGL_GAL::drawStrokedSemiCircle( const VECTOR2D& aCenterPoint, double aRa Restore(); } + void OPENGL_GAL::drawPolygon( GLdouble* aPoints, int aPointCount ) { currentManager->Shader( SHADER_NONE ); diff --git a/common/geometry/shape_poly_set.cpp b/common/geometry/shape_poly_set.cpp index 086a360c40..a6ad767133 100644 --- a/common/geometry/shape_poly_set.cpp +++ b/common/geometry/shape_poly_set.cpp @@ -659,8 +659,6 @@ void SHAPE_POLY_SET::importTree( PolyTree* tree ) } -// Polygon fracturing code. Work in progress. - struct FractureEdge { FractureEdge( bool connected, SHAPE_LINE_CHAIN* owner, int index ) : diff --git a/include/geometry/shape_poly_set.h b/include/geometry/shape_poly_set.h index b849579c35..cec3491cb3 100644 --- a/include/geometry/shape_poly_set.h +++ b/include/geometry/shape_poly_set.h @@ -65,7 +65,9 @@ class SHAPE_POLY_SET : public SHAPE struct TRI { - TRI(){}; + TRI() + { + } int a, b, c; }; @@ -810,6 +812,8 @@ class SHAPE_POLY_SET : public SHAPE ///> For aFastMode meaning, see function booleanOp void Fracture( POLYGON_MODE aFastMode ); + ///> Converts a single outline slitted ("fractured") polygon into a set ouf outlines + ///> with holes. void Unfracture( POLYGON_MODE aFastMode ); ///> Returns true if the polygon set has any holes. diff --git a/pcbnew/class_zone.h b/pcbnew/class_zone.h index aabb4b631a..3688359c72 100644 --- a/pcbnew/class_zone.h +++ b/pcbnew/class_zone.h @@ -120,10 +120,10 @@ public: void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) override; - void SetLayerSet( LSET aLayerSet ); - - virtual LSET GetLayerSet() const override; - + void SetLayerSet( LSET aLayerSet ); + + virtual LSET GetLayerSet() const override; + /** * Function Draw * Draws the zone outline. @@ -180,22 +180,22 @@ public: * Function IsOnCopperLayer * @return true if this zone is on a copper layer, false if on a technical layer */ - bool IsOnCopperLayer() const; + bool IsOnCopperLayer() const; + + /** + * Function CommonLayerExist + * Test if this zone shares a common layer with the given layer set + */ + bool CommonLayerExists( const LSET aLayerSet ) const; + + virtual void SetLayer( PCB_LAYER_ID aLayer ) override; + + virtual PCB_LAYER_ID GetLayer() const override; + + virtual bool IsOnLayer( PCB_LAYER_ID ) const override; + + virtual void ViewGetLayers( int aLayers[], int& aCount ) const override; - /** - * Function CommonLayerExist - * Test if this zone shares a common layer with the given layer set - */ - bool CommonLayerExists( const LSET aLayerSet ) const; - - virtual void SetLayer( PCB_LAYER_ID aLayer ) override; - - virtual PCB_LAYER_ID GetLayer() const override; - - virtual bool IsOnLayer( PCB_LAYER_ID ) const override; - - virtual void ViewGetLayers( int aLayers[], int& aCount ) const override; - /// How to fill areas: 0 = use filled polygons, 1 => fill with segments. void SetFillMode( int aFillMode ) { m_FillMode = aFillMode; } int GetFillMode() const { return m_FillMode; } @@ -599,9 +599,9 @@ public: * returns a reference to the list of filled polygons. * @return Reference to the list of filled polygons. */ - - //TODO - This should be called for each layer on which the zone exists - + + //TODO - This should be called for each layer on which the zone exists + const SHAPE_POLY_SET& GetFilledPolysList() const { return m_FilledPolysList; @@ -735,6 +735,7 @@ public: const std::vector& GetHatchLines() const { return m_HatchLines; } + #if defined(DEBUG) virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); } #endif @@ -749,8 +750,8 @@ private: int m_cornerSmoothingType; unsigned int m_cornerRadius; - LSET m_layerSet; - + LSET m_layerSet; + /* Priority: when a zone outline is inside and other zone, if its priority is higher * the other zone priority, it will be created inside. * if priorities are equal, a DRC error is set @@ -815,7 +816,6 @@ private: HATCH_STYLE m_hatchStyle; // hatch style, see enum above int m_hatchPitch; // for DIAGONAL_EDGE, distance between 2 hatch lines std::vector m_HatchLines; // hatch lines - std::vector m_insulatedIslands; /** diff --git a/pcbnew/connectivity_algo.cpp b/pcbnew/connectivity_algo.cpp index e35b52f916..0280d235c3 100644 --- a/pcbnew/connectivity_algo.cpp +++ b/pcbnew/connectivity_algo.cpp @@ -293,11 +293,11 @@ bool CN_CONNECTIVITY_ALGO::Add( BOARD_ITEM* aItem ) return true; } + void CN_CONNECTIVITY_ALGO::searchConnections( bool aIncludeZones ) { std::mutex cnListLock; - //PROF_COUNTER cnt("search"); int totalDirtyCount = 0; if( m_lastSearchWithZones != aIncludeZones ) @@ -627,7 +627,6 @@ const CN_CONNECTIVITY_ALGO::CLUSTERS CN_CONNECTIVITY_ALGO::SearchClusters( CLUST CN_ITEM* head = nullptr; CLUSTERS clusters; - if( isDirty() ) searchConnections( includeZones ); @@ -837,6 +836,7 @@ void CN_CONNECTIVITY_ALGO::PropagateNets() propagateConnections(); } + void CN_CONNECTIVITY_ALGO::FindIsolatedCopperIslands( ZONE_CONTAINER* aZone, std::vector& aIslands ) { if( aZone->GetFilledPolysList().IsEmpty() ) diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index a299885935..7050b272cb 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -1144,33 +1144,6 @@ void PCB_PAINTER::draw( const ZONE_CONTAINER* aZone, int aLayer ) } m_gal->DrawPolygon( polySet ); - -#if 0 - for( int i = 0; i < polySet.OutlineCount(); i++ ) - { - const SHAPE_LINE_CHAIN& outline = polySet.COutline( i ); - // fixme: GAL drawing API that accepts SHAPEs directly (this fiddling with double<>int conversion - // is just a performance hog) - - for( int j = 0; j < outline.PointCount(); j++ ) - corners.push_back ( (VECTOR2D) outline.CPoint( j ) ); - - corners.push_back( (VECTOR2D) outline.CPoint( 0 ) ); - - if( displayMode == PCB_RENDER_SETTINGS::DZ_SHOW_FILLED ) - { - m_gal->DrawPolygon( corners ); - m_gal->DrawPolyline( corners ); - } - else if( displayMode == PCB_RENDER_SETTINGS::DZ_SHOW_OUTLINED ) - { - m_gal->DrawPolyline( corners ); - } - - - corners.clear(); - } -#endif } }