25 #include <layers_id_colors_and_visibility.h>
27 #include <unordered_set>
29 #include <boost/range/adaptor/map.hpp>
32 #include <geometry/shape_index.h>
49 typedef std::list<ITEM*> NET_ITEMS_LIST;
51 typedef std::unordered_set<ITEM*> ITEM_SET;
90 template<
class Visitor>
91 int Query(
const ITEM* aItem,
int aMinDistance, Visitor& aVisitor );
106 template<
class Visitor>
107 int Query(
const SHAPE* aShape,
int aMinDistance, Visitor& aVisitor );
130 return m_allItems.find( aItem ) != m_allItems.end();
138 int Size()
const {
return m_allItems.size(); }
140 ITEM_SET::iterator begin() {
return m_allItems.begin(); }
141 ITEM_SET::iterator end() {
return m_allItems.end(); }
144 static const int MaxSubIndices = 128;
145 static const int SI_Multilayer = 2;
146 static const int SI_SegDiagonal = 0;
147 static const int SI_SegStraight = 1;
148 static const int SI_Traces = 3;
149 static const int SI_PadsTop = 0;
150 static const int SI_PadsBottom = 1;
152 template <
class Visitor>
153 int querySingle(
int index,
const SHAPE* aShape,
int aMinDistance, Visitor& aVisitor );
155 ITEM_SHAPE_INDEX* getSubindex(
const ITEM* aItem );
157 ITEM_SHAPE_INDEX* m_subIndices[MaxSubIndices];
158 std::map<int, NET_ITEMS_LIST> m_netMap;
163 template<
class Visitor>
164 int INDEX::querySingle(
int index,
const SHAPE* aShape,
int aMinDistance, Visitor& aVisitor )
166 if( !m_subIndices[index] )
169 return m_subIndices[index]->
Query( aShape, aMinDistance, aVisitor,
false );
172 template<
class Visitor>
178 total += querySingle( SI_Multilayer, shape, aMinDistance, aVisitor );
182 if( layers.IsMultilayer() )
184 total += querySingle( SI_PadsTop, shape, aMinDistance, aVisitor );
185 total += querySingle( SI_PadsBottom, shape, aMinDistance, aVisitor );
187 for(
int i = layers.Start(); i <= layers.End(); ++i )
188 total += querySingle( SI_Traces + 2 * i + SI_SegStraight, shape, aMinDistance, aVisitor );
192 int l = layers.Start();
195 total += querySingle( SI_PadsTop, shape, aMinDistance, aVisitor );
197 total += querySingle( SI_PadsBottom, shape, aMinDistance, aVisitor );
199 total += querySingle( SI_Traces + 2 * l + SI_SegStraight, shape, aMinDistance, aVisitor );
205 template<
class Visitor>
210 for(
int i = 0; i < MaxSubIndices; i++ )
211 total += querySingle( i, aShape, aMinDistance, aVisitor );