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.

123 lines
2.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. #ifndef __PNS_VIA_H
  21. #define __PNS_VIA_H
  22. #include <geometry/shape_line_chain.h>
  23. #include <geometry/shape_circle.h>
  24. #include "pns_item.h"
  25. class PNS_NODE;
  26. class PNS_VIA : public PNS_ITEM
  27. {
  28. public:
  29. PNS_VIA() :
  30. PNS_ITEM( VIA ) {};
  31. PNS_VIA( const VECTOR2I& aPos, const PNS_LAYERSET& aLayers, int aDiameter, int aNet = -1 ) :
  32. PNS_ITEM( VIA )
  33. {
  34. SetNet( aNet );
  35. SetLayers( aLayers );
  36. m_pos = aPos;
  37. m_diameter = aDiameter;
  38. m_shape = SHAPE_CIRCLE( aPos, aDiameter / 2 );
  39. };
  40. PNS_VIA( const PNS_VIA& b ) : PNS_ITEM( VIA )
  41. {
  42. SetNet( b.GetNet() );
  43. SetLayers( b.GetLayers() );
  44. m_pos = b.m_pos;
  45. m_diameter = b.m_diameter;
  46. m_shape = SHAPE_CIRCLE( m_pos, m_diameter / 2 );
  47. }
  48. const VECTOR2I& GetPos() const
  49. {
  50. return m_pos;
  51. }
  52. void SetPos( const VECTOR2I& aPos )
  53. {
  54. m_pos = aPos;
  55. m_shape.SetCenter( aPos );
  56. }
  57. int GetDiameter() const
  58. {
  59. return m_diameter;
  60. }
  61. void SetDiameter( int aDiameter )
  62. {
  63. m_diameter = aDiameter;
  64. m_shape.SetRadius( m_diameter / 2 );
  65. }
  66. int GetDrill() const
  67. {
  68. return m_drill;
  69. }
  70. void SetDrill( int aDrill )
  71. {
  72. m_drill = aDrill;
  73. }
  74. bool PushoutForce( PNS_NODE* aNode,
  75. const VECTOR2I& aDirection,
  76. VECTOR2I& aForce,
  77. bool aSolidsOnly = true,
  78. int aMaxIterations = 10 );
  79. const SHAPE* GetShape() const
  80. {
  81. return &m_shape;
  82. }
  83. PNS_VIA* Clone() const
  84. {
  85. PNS_VIA* v = new PNS_VIA();
  86. v->SetNet( GetNet() );
  87. v->SetLayers( GetLayers() );
  88. v->m_pos = m_pos;
  89. v->m_diameter = m_diameter;
  90. v->m_shape = SHAPE_CIRCLE( m_pos, m_diameter / 2 );
  91. return v;
  92. }
  93. const SHAPE_LINE_CHAIN Hull( int aClearance = 0, int aWalkaroundThickness = 0 ) const;
  94. private:
  95. int m_diameter;
  96. int m_drill;
  97. VECTOR2I m_pos;
  98. SHAPE_CIRCLE m_shape;
  99. };
  100. #endif