Warnings on vc14 were eliminated
[occt.git] / src / MAT2d / MAT2d_Connexion.cxx
CommitLineData
b311480e 1// Created on: 1993-10-11
2// Created by: Yves FRICAUD
3// Copyright (c) 1993-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 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
973c2be1 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
42cf5bc1 17
7fd59977 18#include <gp_Pnt2d.hxx>
19#include <gp_Vec2d.hxx>
42cf5bc1 20#include <MAT2d_Connexion.hxx>
21#include <Standard_Type.hxx>
7fd59977 22
92efcf78 23IMPLEMENT_STANDARD_RTTIEXT(MAT2d_Connexion,MMgt_TShared)
24
7fd59977 25//=============================================================================
26//function :
27//purpose :
28//=============================================================================
29MAT2d_Connexion::MAT2d_Connexion()
30{
31}
32
33//=============================================================================
34//function :
35//purpose :
36//=============================================================================
37MAT2d_Connexion::MAT2d_Connexion(const Standard_Integer LineA,
38 const Standard_Integer LineB,
39 const Standard_Integer ItemA,
40 const Standard_Integer ItemB,
41 const Standard_Real Distance,
42 const Standard_Real ParameterOnA,
43 const Standard_Real ParameterOnB,
44 const gp_Pnt2d& PointA,
45 const gp_Pnt2d& PointB):
46 lineA(LineA), lineB(LineB),itemA(ItemA),itemB(ItemB),
47 distance(Distance),
48 parameterOnA(ParameterOnA),parameterOnB(ParameterOnB),
49 pointA(PointA),pointB(PointB)
50{
51}
52
53//=============================================================================
54//function : IndexFirstLine
55//purpose :
56//=============================================================================
57Standard_Integer MAT2d_Connexion::IndexFirstLine() const
58{
59 return lineA;
60}
61
62//=============================================================================
63//function : IndexSecondLine
64//purpose :
65//=============================================================================
66Standard_Integer MAT2d_Connexion::IndexSecondLine() const
67{
68 return lineB;
69}
70
71//=============================================================================
72//function : IndexItemOnFirst
73//purpose :
74//=============================================================================
75Standard_Integer MAT2d_Connexion::IndexItemOnFirst()const
76{
77 return itemA;
78}
79
80//=============================================================================
81//function : IndexItemOnSecond
82// purpose :
83//=============================================================================
84Standard_Integer MAT2d_Connexion::IndexItemOnSecond() const
85{
86 return itemB;
87}
88
89//=============================================================================
90//function : ParameterOnFirst
91//purpose :
92//=============================================================================
93Standard_Real MAT2d_Connexion::ParameterOnFirst() const
94{
95 return parameterOnA;
96}
97
98//=============================================================================
99//function : ParameterOnSecond
100// purpose :
101//=============================================================================
102Standard_Real MAT2d_Connexion::ParameterOnSecond() const
103{
104 return parameterOnB;
105}
106
107//=============================================================================
108//function : PointOnFirst
109//purpose :
110//=============================================================================
111gp_Pnt2d MAT2d_Connexion::PointOnFirst() const
112{
113 return pointA;
114}
115
116//=============================================================================
117//function : PointOnSecond
118//purpose :
119//=============================================================================
120gp_Pnt2d MAT2d_Connexion::PointOnSecond() const
121{
122 return pointB;
123}
124
125//=============================================================================
126//function : Distance
127//purpose :
128//=============================================================================
129Standard_Real MAT2d_Connexion::Distance() const
130{
131 return distance;
132}
133
134//=============================================================================
135//function : IndexFirstLine
136//purpose :
137//=============================================================================
138void MAT2d_Connexion::IndexFirstLine(const Standard_Integer anIndex)
139{
140 lineA = anIndex;
141}
142
143//=============================================================================
144//function : IndexSecondLine
145//purpose :
146//=============================================================================
147void MAT2d_Connexion::IndexSecondLine(const Standard_Integer anIndex)
148{
149 lineB = anIndex;
150}
151
152//=============================================================================
153//function : IndexItemOnFirst
154//purpose :
155//=============================================================================
156void MAT2d_Connexion::IndexItemOnFirst(const Standard_Integer anIndex)
157{
158 itemA = anIndex;
159}
160
161//=============================================================================
162//function : IndexItemOnSecond
163//purpose :
164//=============================================================================
165void MAT2d_Connexion::IndexItemOnSecond(const Standard_Integer anIndex)
166{
167 itemB = anIndex;
168}
169
170//=============================================================================
171//function : ParameterOnFirst
172//purpose :
173//=============================================================================
174void MAT2d_Connexion::ParameterOnFirst(const Standard_Real aParameter)
175{
176 parameterOnA = aParameter;
177}
178
179//=============================================================================
180//function : ParameterOnSecond
181//purpose :
182//=============================================================================
183void MAT2d_Connexion::ParameterOnSecond(const Standard_Real aParameter)
184{
185 parameterOnB = aParameter;
186}
187
188//=============================================================================
189//function : PointOnFirst
190//purpose :
191//=============================================================================
192void MAT2d_Connexion::PointOnFirst(const gp_Pnt2d& aPoint)
193{
194 pointA = aPoint;
195}
196
197//=============================================================================
198//function : PointOnSecond
199//purpose :
200//=============================================================================
201void MAT2d_Connexion::PointOnSecond(const gp_Pnt2d& aPoint)
202{
203 pointB = aPoint;
204}
205
206//=============================================================================
207//function : Distance
208//purpose :
209//=============================================================================
210void MAT2d_Connexion::Distance(const Standard_Real d)
211{
212 distance = d;
213}
214
215//=============================================================================
216//function : Reverse
217//purpose :
218//=============================================================================
219Handle(MAT2d_Connexion) MAT2d_Connexion::Reverse() const
220{
221 return new MAT2d_Connexion(lineB,lineA,itemB,itemA,distance,
222 parameterOnB,parameterOnA,pointB,pointA);
223}
224
225//=============================================================================
226//function : IsAfter
227//purpose :
228//=============================================================================
229Standard_Boolean MAT2d_Connexion::IsAfter(const Handle(MAT2d_Connexion)& C2,
230 const Standard_Real Sense) const
231{
232 if (lineA != C2->IndexFirstLine()) {
233 return Standard_False;
234 }
235
236 if (itemA > C2->IndexItemOnFirst()) {
237 return Standard_True;
238 }
239 else if (itemA == C2->IndexItemOnFirst()){
240 if ( parameterOnA > C2->ParameterOnFirst()) {
241 return Standard_True;
242 }
243 else if ( parameterOnA == C2->ParameterOnFirst()) {
244 gp_Vec2d Vect1(C2->PointOnFirst(),C2->PointOnSecond());
245 gp_Vec2d Vect2(pointA,pointB);
246 if ((Vect1^Vect2)*Sense > 0) {
247 return Standard_True;
248 }
249 }
250 }
251 return Standard_False;
252}
253
254static void Indent(const Standard_Integer Offset) {
255 if (Offset > 0) {
256 for (Standard_Integer i = 0; i <Offset; i++) {cout <<" ";}
257 }
258}
259
260//=============================================================================
261//function : Dump
262//purpose :
263//=============================================================================
264void MAT2d_Connexion::Dump (const Standard_Integer ,
265 const Standard_Integer Offset) const
266{
267 Standard_Integer MyOffset = Offset;
268 Indent (Offset);
269 cout<<"MAT2d_Connexion :"<<endl;
270 MyOffset++;
271 Indent (MyOffset);
272 cout <<"IndexFirstLine :"<<lineA<<endl;
273 Indent (MyOffset);
274 cout <<"IndexSecondLine :"<<lineB<<endl;
275 Indent (MyOffset);
276 cout <<"IndexItemOnFirst :"<<itemA<<endl;
277 Indent (MyOffset);
278 cout <<"IndexItemOnSecond :"<<itemB<<endl;
279 Indent (MyOffset);
280 cout <<"ParameterOnFirst :"<<parameterOnA<<endl;
281 Indent (MyOffset);
282 cout <<"ParameterOnSecond :"<<parameterOnB<<endl;
283 Indent (MyOffset);
284 cout <<"PointOnFirst :"<<endl;
285 cout <<" X = "<<pointA.X()<<endl;
286 cout <<" Y = "<<pointA.Y()<<endl;
287 Indent (MyOffset);
288 cout <<"PointOnSecond :"<<endl;
289 cout <<" X = "<<pointB.X()<<endl;
290 cout <<" Y = "<<pointB.Y()<<endl;
291 Indent (MyOffset);
292 cout <<"Distance :"<<distance<<endl;
293}