KiCad PCB EDA Suite
pns_item.cpp
Go to the documentation of this file.
1 /*
2  * KiRouter - a push-and-(sometimes-)shove PCB router
3  *
4  * Copyright (C) 2013-2014 CERN
5  * Copyright (C) 2016 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 
22 #include "pns_item.h"
23 #include "pns_line.h"
24 
25 namespace PNS {
26 
27 bool ITEM::collideSimple( const ITEM* aOther, int aClearance, bool aNeedMTV,
28  VECTOR2I& aMTV, bool aDifferentNetsOnly ) const
29 {
30  // same nets? no collision!
31  if( aDifferentNetsOnly && m_net == aOther->m_net )
32  return false;
33 
34  // check if we are not on completely different layers first
35  if( !m_layers.Overlaps( aOther->m_layers ) )
36  return false;
37 
38  return Shape()->Collide( aOther->Shape(), aClearance );
39 
40  // fixme: MTV
41 }
42 
43 
44 bool ITEM::Collide( const ITEM* aOther, int aClearance, bool aNeedMTV,
45  VECTOR2I& aMTV, bool aDifferentNetsOnly ) const
46 {
47  if( collideSimple( aOther, aClearance, aNeedMTV, aMTV, aDifferentNetsOnly ) )
48  return true;
49 
50  // special case for "head" line with a via attached at the end.
51  if( aOther->m_kind == LINE_T )
52  {
53  const LINE* line = static_cast<const LINE*>( aOther );
54 
55  if( line->EndsWithVia() )
56  return collideSimple( &line->Via(), aClearance - line->Width() / 2, aNeedMTV, aMTV, aDifferentNetsOnly );
57  }
58 
59  return false;
60 }
61 
62 
63 const std::string ITEM::KindStr() const
64 {
65  switch( m_kind )
66  {
67  case LINE_T:
68  return "line";
69 
70  case SEGMENT_T:
71  return "segment";
72 
73  case VIA_T:
74  return "via";
75 
76  case JOINT_T:
77  return "joint";
78 
79  case SOLID_T:
80  return "solid";
81 
82  default:
83  return "unknown";
84  }
85 }
86 
87 
89 {
90 }
91 
92 }
Class ITEM.
Definition: pns_item.h:53
const VIA & Via() const
Definition: pns_line.h:253
virtual ~ITEM()
Definition: pns_item.cpp:88
LAYER_RANGE m_layers
Definition: pns_item.h:350
virtual const SHAPE * Shape() const
Function Shape()
Definition: pns_item.h:296
int Width() const
Returns line width
Definition: pns_line.h:159
virtual bool Collide(const ITEM *aOther, int aClearance, bool aNeedMTV, VECTOR2I &aMTV, bool aDifferentNetsOnly=true) const
Function Collide()
Definition: pns_item.cpp:44
bool EndsWithVia() const
Definition: pns_line.h:248
bool Overlaps(const LAYER_RANGE &aOther) const
Definition: pns_layerset.h:68
int m_net
Definition: pns_item.h:353
virtual bool Collide(const VECTOR2I &aP, int aClearance=0) const
Function Collide()
Definition: shape.h:106
PnsKind m_kind
Definition: pns_item.h:346
bool collideSimple(const ITEM *aOther, int aClearance, bool aNeedMTV, VECTOR2I &aMTV, bool aDifferentNetsOnly) const
Definition: pns_item.cpp:27
Push and Shove diff pair dimensions (gap) settings dialog.
const std::string KindStr() const
Function KindStr()
Definition: pns_item.cpp:63