You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
1.8 KiB

  1. /*
  2. * KiRouter - a push-and-(sometimes-)shove PCB router
  3. *
  4. * Copyright (C) 2013 CERN
  5. * Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
  6. *
  7. * This program is free software: you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation, either version 3 of the License, or (at your
  10. * option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License along
  18. * with this program. If not, see <http://www.gnu.or/licenses/>.
  19. */
  20. #include <boost/foreach.hpp>
  21. #include "pns_itemset.h"
  22. PNS_ITEMSET::PNS_ITEMSET()
  23. {
  24. }
  25. PNS_ITEMSET::~PNS_ITEMSET()
  26. {
  27. }
  28. PNS_ITEMSET& PNS_ITEMSET::FilterLayers( int aStart, int aEnd )
  29. {
  30. ItemVector newItems;
  31. PNS_LAYERSET l;
  32. if( aEnd < 0 )
  33. l = PNS_LAYERSET( aStart );
  34. else
  35. l = PNS_LAYERSET( aStart, aEnd );
  36. BOOST_FOREACH( PNS_ITEM * item, m_items )
  37. if( item->GetLayers().Overlaps( l ) )
  38. newItems.push_back( item );
  39. m_items = newItems;
  40. return *this;
  41. }
  42. PNS_ITEMSET& PNS_ITEMSET::FilterKinds( int aKindMask )
  43. {
  44. ItemVector newItems;
  45. BOOST_FOREACH( PNS_ITEM * item, m_items )
  46. if( item->GetKind() & aKindMask )
  47. newItems.push_back( item );
  48. m_items = newItems;
  49. return *this;
  50. }
  51. PNS_ITEMSET& PNS_ITEMSET::FilterNet( int aNet )
  52. {
  53. ItemVector newItems;
  54. BOOST_FOREACH( PNS_ITEM * item, m_items )
  55. if( item->GetNet() == aNet )
  56. newItems.push_back( item );
  57. m_items = newItems;
  58. return *this;
  59. }