7fd59977 |
1 | // File: MAT_Node.cxx |
2 | // Created: Thu May 6 18:34:58 1993 |
3 | // Author: Yves FRICAUD |
4 | // <yfr@phylox> |
5 | |
6 | #include <MAT_Node.ixx> |
7 | #include <MAT_BasicElt.hxx> |
8 | #include <MAT_Arc.hxx> |
9 | #include <Precision.hxx> |
10 | |
11 | //============================================================================= |
12 | //function : |
13 | //Purpose : |
14 | //============================================================================= |
15 | MAT_Node::MAT_Node(const Standard_Integer GeomIndex, |
16 | const Handle(MAT_Arc)& LinkedArc, |
17 | const Standard_Real Distance) |
18 | : geomIndex(GeomIndex), |
19 | distance(Distance) |
20 | { |
21 | aLinkedArc = LinkedArc.operator->(); |
22 | } |
23 | |
24 | //============================================================================= |
25 | //function : GeomIndex |
26 | //Purpose : |
27 | //============================================================================= |
28 | Standard_Integer MAT_Node::GeomIndex() const |
29 | { |
30 | return geomIndex; |
31 | } |
32 | |
33 | //============================================================================= |
34 | //function : Index |
35 | //Purpose : |
36 | //============================================================================= |
37 | Standard_Integer MAT_Node::Index() const |
38 | { |
39 | return nodeIndex; |
40 | } |
41 | |
42 | //============================================================================= |
43 | //function : LinkedArcs |
44 | //Purpose : |
45 | //============================================================================= |
46 | void MAT_Node::LinkedArcs(MAT_SequenceOfArc& S) const |
47 | { |
48 | S.Clear(); |
49 | Handle(MAT_Node) Me = this; |
50 | Handle(MAT_Arc) LA((MAT_Arc*)aLinkedArc); |
51 | |
52 | S.Append(LA); |
53 | |
54 | if (LA->HasNeighbour(Me, MAT_Left)) { |
55 | Handle(MAT_Arc) CA = LA->Neighbour(Me, MAT_Left); |
56 | while (CA != LA) { |
57 | S.Append(CA); |
58 | CA = CA->Neighbour(Me, MAT_Left); |
59 | } |
60 | } |
61 | } |
62 | |
63 | //============================================================================= |
64 | //function : NearElts |
65 | //Purpose : |
66 | //============================================================================= |
67 | void MAT_Node::NearElts(MAT_SequenceOfBasicElt& S) const |
68 | { |
69 | S.Clear(); |
70 | |
71 | Handle(MAT_Node) Me = this; |
72 | Handle(MAT_Arc) LA((MAT_Arc*)aLinkedArc); |
73 | |
74 | S.Append(LA->FirstElement()); |
75 | S.Append(LA->SecondElement()); |
76 | |
77 | if (LA->HasNeighbour(Me, MAT_Left)) { |
78 | |
79 | Handle(MAT_Arc) CA = LA->Neighbour(Me, MAT_Left); |
80 | Standard_Boolean Pair = Standard_False; |
81 | |
82 | //--------------------------------------------------------- |
83 | // Recuperation des deux elements separes pour un arc sur |
84 | // deux. |
85 | //--------------------------------------------------------- |
86 | |
87 | while (CA != LA) { |
88 | if (Pair) { |
89 | S.Append(CA->FirstElement()); |
90 | S.Append(CA->SecondElement()); |
91 | } |
92 | else { |
93 | Pair = Standard_True; |
94 | } |
95 | CA = CA->Neighbour(Me, MAT_Left); |
96 | } |
97 | } |
98 | } |
99 | |
100 | //============================================================================= |
101 | //function : Distance |
102 | //Purpose : |
103 | //============================================================================= |
104 | Standard_Real MAT_Node::Distance() const |
105 | { |
106 | return distance; |
107 | } |
108 | |
109 | |
110 | //============================================================================= |
111 | //function : PendingNode |
112 | //Purpose : |
113 | //============================================================================= |
114 | Standard_Boolean MAT_Node::PendingNode() const |
115 | { |
116 | Handle(MAT_Node) Me = this; |
117 | return (!((MAT_Arc*)aLinkedArc)->HasNeighbour(Me,MAT_Left)); |
118 | } |
119 | |
120 | //============================================================================= |
121 | //function : NodeOnFig |
122 | //Purpose : |
123 | //============================================================================= |
124 | Standard_Boolean MAT_Node::OnBasicElt() const |
125 | { |
126 | return (Distance() == 0.0); |
127 | } |
128 | |
129 | //============================================================================= |
130 | //function : NodeInfinite |
131 | //Purpose : |
132 | //============================================================================= |
133 | Standard_Boolean MAT_Node::Infinite() const |
134 | { |
135 | return (Distance() == Precision::Infinite()); |
136 | } |
137 | |
138 | //============================================================================= |
139 | //function : SetLinkedArcs |
140 | //Purpose : |
141 | //============================================================================= |
142 | void MAT_Node::SetLinkedArc (const Handle(MAT_Arc)& LinkedArc) |
143 | { |
144 | aLinkedArc = LinkedArc.operator->(); |
145 | } |
146 | |
147 | //============================================================================= |
148 | //function : SetIndex |
149 | //Purpose : |
150 | //============================================================================= |
151 | void MAT_Node::SetIndex (const Standard_Integer anIndex) |
152 | { |
153 | nodeIndex = anIndex; |
154 | } |
155 | |
156 | |
157 | |
158 | |