22 #ifndef __PNS_OPTIMIZER_H
23 #define __PNS_OPTIMIZER_H
25 #include <unordered_map>
28 #include <geometry/shape_index_list.h>
29 #include <geometry/shape_line_chain.h>
54 m_lengthCost( aB.m_lengthCost ),
55 m_cornerCost( aB.m_cornerCost )
64 void Add(
LINE& aLine );
65 void Remove(
LINE& aLine );
66 void Replace(
LINE& aOldLine,
LINE& aNewLine );
69 double aCornerTollerace )
const;
71 double GetLengthCost()
const {
return m_lengthCost; }
72 double GetCornerCost()
const {
return m_cornerCost; }
93 enum OptimizationEffort
95 MERGE_SEGMENTS = 0x01,
111 void SetWorld(
NODE* aNode ) { m_world = aNode; }
112 void CacheStaticItem(
ITEM* aItem );
113 void CacheRemove(
ITEM* aItem );
114 void ClearCache(
bool aStaticOnly =
false );
116 void SetCollisionMask(
int aMask )
118 m_collisionKindMask = aMask;
121 void SetEffortLevel(
int aEffort )
123 m_effortLevel = aEffort;
127 void SetRestrictArea(
const BOX2I& aArea )
129 m_restrictArea = aArea;
130 m_restrictAreaActive =
true;
134 static const int MaxCachedItems = 256;
136 typedef std::vector<SHAPE_LINE_CHAIN> BREAKOUT_LIST;
146 bool mergeObtuse(
LINE* aLine );
147 bool mergeFull(
LINE* aLine );
148 bool removeUglyCorners(
LINE* aLine );
149 bool runSmartPads(
LINE* aLine );
151 bool fanoutCleanup(
LINE * aLine );
152 bool mergeDpSegments(
DIFF_PAIR *aPair );
153 bool mergeDpStep(
DIFF_PAIR *aPair,
bool aTryP,
int step );
155 bool checkColliding(
ITEM* aItem,
bool aUpdateCache =
true );
158 void cacheAdd(
ITEM* aItem,
bool aIsStatic );
159 void removeCachedSegments(
LINE* aLine,
int aStartVertex = 0,
int aEndVertex = -1 );
161 BREAKOUT_LIST circleBreakouts(
int aWidth,
const SHAPE* aShape,
bool aPermitDiagonal )
const;
162 BREAKOUT_LIST rectBreakouts(
int aWidth,
const SHAPE* aShape,
bool aPermitDiagonal )
const;
163 BREAKOUT_LIST ovalBreakouts(
int aWidth,
const SHAPE* aShape,
bool aPermitDiagonal )
const;
164 BREAKOUT_LIST customBreakouts(
int aWidth,
const ITEM* aItem,
bool aPermitDiagonal )
const;
165 BREAKOUT_LIST computeBreakouts(
int aWidth,
const ITEM* aItem,
bool aPermitDiagonal )
const;
167 int smartPadsSingle(
LINE* aLine,
ITEM* aPad,
bool aEnd,
int aEndVertex );
169 ITEM* findPadOrVia(
int aLayer,
int aNet,
const VECTOR2I& aP )
const;
173 typedef std::unordered_map<ITEM*, CACHED_ITEM> CachedItemTags;
174 CachedItemTags m_cacheTags;
176 int m_collisionKindMask;
180 BOX2I m_restrictArea;
181 bool m_restrictAreaActive;