1 // Created on: 1993-05-06
2 // Created by: Yves FRICAUD
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16 
17 
18 #include <MAT_Arc.hxx>
19 #include <MAT_BasicElt.hxx>
20 #include <MAT_Node.hxx>
21 #include <Precision.hxx>
22 #include <Standard_Type.hxx>
23 
IMPLEMENT_STANDARD_RTTIEXT(MAT_Node,Standard_Transient)24 IMPLEMENT_STANDARD_RTTIEXT(MAT_Node,Standard_Transient)
25 
26 //=============================================================================
27 //function :
28 //Purpose  :
29 //=============================================================================
30 MAT_Node::MAT_Node(const Standard_Integer     GeomIndex,
31 		   const Handle(MAT_Arc)&     LinkedArc,
32 		   const Standard_Real        Distance)
33      : nodeIndex(0),
34        geomIndex(GeomIndex),
35        distance(Distance)
36 {
37   aLinkedArc = LinkedArc.get();
38 }
39 
40 //=============================================================================
41 //function : GeomIndex
42 //Purpose  :
43 //=============================================================================
GeomIndex() const44 Standard_Integer  MAT_Node::GeomIndex() const
45 {
46   return geomIndex;
47 }
48 
49 //=============================================================================
50 //function : Index
51 //Purpose  :
52 //=============================================================================
Index() const53 Standard_Integer  MAT_Node::Index() const
54 {
55   return nodeIndex;
56 }
57 
58 //=============================================================================
59 //function : LinkedArcs
60 //Purpose  :
61 //=============================================================================
LinkedArcs(MAT_SequenceOfArc & S) const62 void MAT_Node::LinkedArcs(MAT_SequenceOfArc& S) const
63 {
64   S.Clear();
65   Handle(MAT_Node) Me = this;
66   Handle(MAT_Arc)  LA((MAT_Arc*)aLinkedArc);
67 
68   S.Append(LA);
69 
70   if (LA->HasNeighbour(Me, MAT_Left)) {
71     Handle(MAT_Arc)  CA = LA->Neighbour(Me, MAT_Left);
72     while (CA != LA) {
73       S.Append(CA);
74       CA = CA->Neighbour(Me, MAT_Left);
75     }
76   }
77 }
78 
79 //=============================================================================
80 //function : NearElts
81 //Purpose  :
82 //=============================================================================
NearElts(MAT_SequenceOfBasicElt & S) const83 void MAT_Node::NearElts(MAT_SequenceOfBasicElt& S) const
84 {
85   S.Clear();
86 
87   Handle(MAT_Node) Me = this;
88   Handle(MAT_Arc)  LA((MAT_Arc*)aLinkedArc);
89 
90   S.Append(LA->FirstElement());
91   S.Append(LA->SecondElement());
92 
93   if (LA->HasNeighbour(Me, MAT_Left)) {
94 
95     Handle(MAT_Arc)  CA = LA->Neighbour(Me, MAT_Left);
96     Standard_Boolean Pair = Standard_False;
97 
98     //---------------------------------------------------------
99     // Recuperation des deux elements separes pour un arc sur
100     // deux.
101     //---------------------------------------------------------
102 
103     while (CA != LA) {
104       if (Pair) {
105 	S.Append(CA->FirstElement());
106 	S.Append(CA->SecondElement());
107       }
108       else {
109 	Pair = Standard_True;
110       }
111       CA = CA->Neighbour(Me, MAT_Left);
112     }
113   }
114 }
115 
116 //=============================================================================
117 //function : Distance
118 //Purpose  :
119 //=============================================================================
Distance() const120 Standard_Real  MAT_Node::Distance() const
121 {
122   return distance;
123 }
124 
125 
126 //=============================================================================
127 //function : PendingNode
128 //Purpose  :
129 //=============================================================================
PendingNode() const130 Standard_Boolean  MAT_Node::PendingNode() const
131 {
132   Handle(MAT_Node) Me = this;
133   return (!((MAT_Arc*)aLinkedArc)->HasNeighbour(Me,MAT_Left));
134 }
135 
136 //=============================================================================
137 //function : NodeOnFig
138 //Purpose  :
139 //=============================================================================
OnBasicElt() const140 Standard_Boolean  MAT_Node::OnBasicElt() const
141 {
142   return (Distance() == 0.0);
143 }
144 
145 //=============================================================================
146 //function : NodeInfinite
147 //Purpose  :
148 //=============================================================================
Infinite() const149 Standard_Boolean  MAT_Node::Infinite() const
150 {
151   return (Distance() == Precision::Infinite());
152 }
153 
154 //=============================================================================
155 //function : SetLinkedArcs
156 //Purpose  :
157 //=============================================================================
SetLinkedArc(const Handle (MAT_Arc)& LinkedArc)158 void MAT_Node::SetLinkedArc (const Handle(MAT_Arc)& LinkedArc)
159 {
160   aLinkedArc = LinkedArc.get();
161 }
162 
163 //=============================================================================
164 //function : SetIndex
165 //Purpose  :
166 //=============================================================================
SetIndex(const Standard_Integer anIndex)167 void MAT_Node::SetIndex (const Standard_Integer anIndex)
168 {
169   nodeIndex = anIndex;
170 }
171 
172 
173 
174 
175