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.

106 lines
3.7 KiB

11 years ago
11 years ago
11 years ago
  1. /*
  2. * KiRouter - a push-and-(sometimes-)shove PCB router
  3. *
  4. * Copyright (C) 2013-2015 CERN
  5. * Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.txt for contributors.
  6. * Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
  7. *
  8. * This program is free software: you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation, either version 3 of the License, or (at your
  11. * option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along
  19. * with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. #ifndef __PNS_TOPOLOGY_H
  22. #define __PNS_TOPOLOGY_H
  23. #include <vector>
  24. #include <set>
  25. #include "pns_itemset.h"
  26. namespace PNS {
  27. class NODE;
  28. class SEGMENT;
  29. class JOINT;
  30. class ITEM;
  31. class SOLID;
  32. class DIFF_PAIR;
  33. class TOPOLOGY
  34. {
  35. public:
  36. typedef std::set<const JOINT*> JOINT_SET;
  37. TOPOLOGY( NODE* aNode ):
  38. m_world( aNode ) {};
  39. ~TOPOLOGY() {};
  40. bool SimplifyLine( LINE *aLine );
  41. ITEM* NearestUnconnectedItem( const JOINT* aStart, int* aAnchor = nullptr,
  42. int aKindMask = ITEM::ANY_T );
  43. bool NearestUnconnectedAnchorPoint( const LINE* aTrack, VECTOR2I& aPoint, LAYER_RANGE& aLayers,
  44. ITEM*& aItem );
  45. bool LeadingRatLine( const LINE* aTrack, SHAPE_LINE_CHAIN& aRatLine );
  46. const JOINT_SET ConnectedJoints( const JOINT* aStart );
  47. const ITEM_SET ConnectedItems( const JOINT* aStart, int aKindMask = ITEM::ANY_T );
  48. const ITEM_SET ConnectedItems( ITEM* aStart, int aKindMask = ITEM::ANY_T );
  49. int64_t ShortestConnectionLength( ITEM* aFrom, ITEM* aTo );
  50. /**
  51. * Assemble a trivial path between two joints given a starting item.
  52. *
  53. * @param aStart is the item to assemble from.
  54. * @param aTerminalJoints will be filled with the start and end points of the assembled path.
  55. * @param aFollowLockedSegments if true will assemble a path including locked segments
  56. * @return a set of items in the path.
  57. */
  58. const ITEM_SET AssembleTrivialPath( ITEM* aStart,
  59. std::pair<const JOINT*, const JOINT*>* aTerminalJoints = nullptr,
  60. bool aFollowLockedSegments = false );
  61. /**
  62. * Like AssembleTrivialPath, but follows the track length algorithm, which discards segments
  63. * that are fully inside pads, and truncates segments that cross into a pad (adding a straight-
  64. * line segment from the intersection to the pad anchor).
  65. *
  66. * @note When changing this, sync with BOARD::GetTrackLength()
  67. *
  68. * @param aStart is the item to assemble a path from.
  69. * @param aStartPad will be filled with the starting pad of the path, if found.
  70. * @param aEndPad will be filled with the ending pad of the path, if found.
  71. * @return an item set containing all the items in the path.
  72. */
  73. const ITEM_SET AssembleTuningPath( ITEM* aStart, SOLID** aStartPad = nullptr,
  74. SOLID** aEndPad = nullptr );
  75. const DIFF_PAIR AssembleDiffPair( SEGMENT* aStart );
  76. bool AssembleDiffPair( ITEM* aStart, DIFF_PAIR& aPair );
  77. const std::set<ITEM*> AssembleCluster( ITEM* aStart, int aLayer );
  78. private:
  79. const int DP_PARALLELITY_THRESHOLD = 5;
  80. bool followTrivialPath( LINE* aLine, bool aLeft, ITEM_SET& aSet, std::set<ITEM*>& aVisited,
  81. const JOINT** aTerminalJoint = nullptr );
  82. NODE *m_world;
  83. };
  84. }
  85. #endif