summaryrefslogtreecommitdiff
path: root/src/MAT2d/MAT2d_Connexion.cxx
blob: 0616ca4a7832fcd2fe4f9a29ccc4344bfd6bedd7 (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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
// File:	MAT2d_Connexion.cxx
// Created:	Mon Oct 11 10:42:18 1993
// Author:	Yves FRICAUD
//		<yfr@phylox>

#include <MAT2d_Connexion.ixx>
#include <gp_Pnt2d.hxx>
#include <gp_Vec2d.hxx>



//=============================================================================
//function :
//purpose  :
//=============================================================================
MAT2d_Connexion::MAT2d_Connexion()
{
}

//=============================================================================
//function :
//purpose  :
//=============================================================================
MAT2d_Connexion::MAT2d_Connexion(const Standard_Integer LineA, 
				 const Standard_Integer LineB, 
				 const Standard_Integer ItemA, 
				 const Standard_Integer ItemB, 
				 const Standard_Real    Distance, 
				 const Standard_Real    ParameterOnA, 
				 const Standard_Real    ParameterOnB, 
				 const gp_Pnt2d&        PointA, 
				 const gp_Pnt2d&        PointB):
       lineA(LineA), lineB(LineB),itemA(ItemA),itemB(ItemB), 
       distance(Distance),
       parameterOnA(ParameterOnA),parameterOnB(ParameterOnB),
       pointA(PointA),pointB(PointB)
{
}

//=============================================================================
//function : IndexFirstLine
//purpose  :
//=============================================================================
Standard_Integer MAT2d_Connexion::IndexFirstLine() const
{
  return lineA;
}

//=============================================================================
//function : IndexSecondLine
//purpose  :
//=============================================================================
Standard_Integer  MAT2d_Connexion::IndexSecondLine() const 
{
  return lineB;
}

//=============================================================================
//function : IndexItemOnFirst
//purpose  :
//=============================================================================
Standard_Integer  MAT2d_Connexion::IndexItemOnFirst()const 
{
  return itemA;
}

//=============================================================================
//function : IndexItemOnSecond
// purpose :
//=============================================================================
Standard_Integer  MAT2d_Connexion::IndexItemOnSecond() const
{
  return itemB;
}

//=============================================================================
//function : ParameterOnFirst
//purpose  :
//=============================================================================
Standard_Real  MAT2d_Connexion::ParameterOnFirst() const
{
  return parameterOnA;
}

//=============================================================================
//function : ParameterOnSecond
// purpose :
//=============================================================================
Standard_Real  MAT2d_Connexion::ParameterOnSecond() const
{
  return parameterOnB;
}

//=============================================================================
//function : PointOnFirst
//purpose  :
//=============================================================================
gp_Pnt2d  MAT2d_Connexion::PointOnFirst() const
{
  return pointA;
}

//=============================================================================
//function : PointOnSecond
//purpose  :
//=============================================================================
gp_Pnt2d  MAT2d_Connexion::PointOnSecond() const 
{
  return pointB;
}

//=============================================================================
//function : Distance
//purpose  :
//=============================================================================
Standard_Real  MAT2d_Connexion::Distance() const
{
  return distance;
}

//=============================================================================
//function : IndexFirstLine
//purpose  :
//=============================================================================
void  MAT2d_Connexion::IndexFirstLine(const Standard_Integer anIndex)
{
  lineA = anIndex;
}

//=============================================================================
//function : IndexSecondLine
//purpose  :
//=============================================================================
void  MAT2d_Connexion::IndexSecondLine(const Standard_Integer anIndex)
{
  lineB = anIndex;
}

//=============================================================================
//function : IndexItemOnFirst
//purpose  :
//=============================================================================
void  MAT2d_Connexion::IndexItemOnFirst(const Standard_Integer anIndex)
{
  itemA = anIndex;
}

//=============================================================================
//function : IndexItemOnSecond
//purpose  :
//=============================================================================
void  MAT2d_Connexion::IndexItemOnSecond(const Standard_Integer anIndex)
{
  itemB = anIndex;
}

//=============================================================================
//function : ParameterOnFirst
//purpose  :
//=============================================================================
void  MAT2d_Connexion::ParameterOnFirst(const Standard_Real aParameter)
{
  parameterOnA = aParameter;
}

//=============================================================================
//function : ParameterOnSecond
//purpose  :
//=============================================================================
void  MAT2d_Connexion::ParameterOnSecond(const Standard_Real aParameter)
{
  parameterOnB = aParameter;
}

//=============================================================================
//function : PointOnFirst
//purpose  :
//=============================================================================
void  MAT2d_Connexion::PointOnFirst(const gp_Pnt2d& aPoint)
{
  pointA = aPoint;
}

//=============================================================================
//function : PointOnSecond
//purpose  :
//=============================================================================
void  MAT2d_Connexion::PointOnSecond(const gp_Pnt2d& aPoint)
{
  pointB = aPoint;
}

//=============================================================================
//function : Distance
//purpose  :
//=============================================================================
void  MAT2d_Connexion::Distance(const Standard_Real d)
{
  distance = d;
}

//=============================================================================
//function : Reverse
//purpose  :
//=============================================================================
Handle(MAT2d_Connexion) MAT2d_Connexion::Reverse() const
{
  return new MAT2d_Connexion(lineB,lineA,itemB,itemA,distance,
			     parameterOnB,parameterOnA,pointB,pointA);
}

//=============================================================================
//function : IsAfter
//purpose  :
//=============================================================================
Standard_Boolean MAT2d_Connexion::IsAfter(const Handle(MAT2d_Connexion)& C2,
					  const Standard_Real    Sense) const
{
  if (lineA != C2->IndexFirstLine()) {
    return Standard_False;
  }
  
  if (itemA > C2->IndexItemOnFirst()) {
    return Standard_True;
  }
  else if (itemA == C2->IndexItemOnFirst()){
    if ( parameterOnA > C2->ParameterOnFirst()) {
      return Standard_True;
    }
    else if ( parameterOnA == C2->ParameterOnFirst()) {
      gp_Vec2d Vect1(C2->PointOnFirst(),C2->PointOnSecond());
      gp_Vec2d Vect2(pointA,pointB);
      if ((Vect1^Vect2)*Sense > 0) {
	return Standard_True;
      }
    }
  }
  return Standard_False;
}

static void Indent(const Standard_Integer Offset) {
  if (Offset > 0) {
    for (Standard_Integer i = 0; i <Offset; i++) {cout <<" ";}
  }
}

//=============================================================================
//function : Dump
//purpose  :
//=============================================================================
void MAT2d_Connexion::Dump (const Standard_Integer ,
			    const Standard_Integer Offset) const
{
  Standard_Integer MyOffset = Offset;
  Indent (Offset);
  cout<<"MAT2d_Connexion :"<<endl;
  MyOffset++;
  Indent (MyOffset);
  cout <<"IndexFirstLine    :"<<lineA<<endl;
  Indent (MyOffset);
  cout <<"IndexSecondLine   :"<<lineB<<endl;
  Indent (MyOffset);
  cout <<"IndexItemOnFirst  :"<<itemA<<endl;
  Indent (MyOffset);
  cout <<"IndexItemOnSecond :"<<itemB<<endl;
  Indent (MyOffset);
  cout <<"ParameterOnFirst  :"<<parameterOnA<<endl;
  Indent (MyOffset);
  cout <<"ParameterOnSecond :"<<parameterOnB<<endl;
  Indent (MyOffset);
  cout <<"PointOnFirst      :"<<endl;
  cout <<"  X = "<<pointA.X()<<endl;
  cout <<"  Y = "<<pointA.Y()<<endl;
  Indent (MyOffset);
  cout <<"PointOnSecond     :"<<endl;
  cout <<"  X = "<<pointB.X()<<endl;
  cout <<"  Y = "<<pointB.Y()<<endl;
  Indent (MyOffset);
  cout <<"Distance          :"<<distance<<endl;
}