summaryrefslogtreecommitdiff
path: root/src/MAT/MAT_Node.cxx
blob: 1a665527231d06438201a88987c9613ed60cdb4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
// File:	MAT_Node.cxx
// Created:	Thu May  6 18:34:58 1993
// Author:	Yves FRICAUD
//		<yfr@phylox>

#include <MAT_Node.ixx>
#include <MAT_BasicElt.hxx>
#include <MAT_Arc.hxx>
#include <Precision.hxx>

//=============================================================================
//function : 
//Purpose  :
//=============================================================================
MAT_Node::MAT_Node(const Standard_Integer     GeomIndex, 
		   const Handle(MAT_Arc)&     LinkedArc, 
		   const Standard_Real        Distance)
     : geomIndex(GeomIndex),
       distance(Distance)
{
  aLinkedArc = LinkedArc.operator->();
}

//=============================================================================
//function : GeomIndex 
//Purpose  :
//=============================================================================
Standard_Integer  MAT_Node::GeomIndex() const
{
  return geomIndex;
}

//=============================================================================
//function : Index
//Purpose  :
//=============================================================================
Standard_Integer  MAT_Node::Index() const
{
  return nodeIndex;
}

//=============================================================================
//function : LinkedArcs
//Purpose  :
//=============================================================================
void MAT_Node::LinkedArcs(MAT_SequenceOfArc& S) const
{
  S.Clear();
  Handle(MAT_Node) Me = this;
  Handle(MAT_Arc)  LA((MAT_Arc*)aLinkedArc);

  S.Append(LA);

  if (LA->HasNeighbour(Me, MAT_Left)) {
    Handle(MAT_Arc)  CA = LA->Neighbour(Me, MAT_Left);
    while (CA != LA) {
      S.Append(CA);
      CA = CA->Neighbour(Me, MAT_Left);
    }
  }
}

//=============================================================================
//function : NearElts 
//Purpose  :
//=============================================================================
void MAT_Node::NearElts(MAT_SequenceOfBasicElt& S) const
{
  S.Clear();

  Handle(MAT_Node) Me = this;
  Handle(MAT_Arc)  LA((MAT_Arc*)aLinkedArc);

  S.Append(LA->FirstElement());
  S.Append(LA->SecondElement());

  if (LA->HasNeighbour(Me, MAT_Left)) {

    Handle(MAT_Arc)  CA = LA->Neighbour(Me, MAT_Left);
    Standard_Boolean Pair = Standard_False;
    
    //---------------------------------------------------------
    // Recuperation des deux elements separes pour un arc sur
    // deux.
    //---------------------------------------------------------
    
    while (CA != LA) {
      if (Pair) {
	S.Append(CA->FirstElement());
	S.Append(CA->SecondElement());
      }
      else {
	Pair = Standard_True;
      }
      CA = CA->Neighbour(Me, MAT_Left);
    }
  }
}
  
//=============================================================================
//function : Distance
//Purpose  :
//=============================================================================
Standard_Real  MAT_Node::Distance() const
{
  return distance;
}


//=============================================================================
//function : PendingNode
//Purpose  :
//=============================================================================
Standard_Boolean  MAT_Node::PendingNode() const
{
  Handle(MAT_Node) Me = this;
  return (!((MAT_Arc*)aLinkedArc)->HasNeighbour(Me,MAT_Left));
}

//=============================================================================
//function : NodeOnFig
//Purpose  :
//=============================================================================
Standard_Boolean  MAT_Node::OnBasicElt() const
{
  return (Distance() == 0.0);
}

//=============================================================================
//function : NodeInfinite
//Purpose  :
//=============================================================================
Standard_Boolean  MAT_Node::Infinite() const
{
  return (Distance() == Precision::Infinite());
}

//=============================================================================
//function : SetLinkedArcs
//Purpose  :
//=============================================================================
void MAT_Node::SetLinkedArc (const Handle(MAT_Arc)& LinkedArc)
{
  aLinkedArc = LinkedArc.operator->();
}

//=============================================================================
//function : SetIndex
//Purpose  :
//=============================================================================
void MAT_Node::SetIndex (const Standard_Integer anIndex)
{
  nodeIndex = anIndex;
}