0032969: Coding - get rid of unused headers [IMeshData to PLib]
[occt.git] / src / IntSurf / IntSurf_PntOn2S.cxx
1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 //
4 // This file is part of Open CASCADE Technology software library.
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
11 //
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
14
15
16 #include <IntSurf_PntOn2S.hxx>
17
18 IntSurf_PntOn2S::IntSurf_PntOn2S ()
19   : pt(0,0,0),u1(0),v1(0),u2(0),v2(0)
20 {}
21
22 void IntSurf_PntOn2S::SetValue (const gp_Pnt& Pt,
23                                 const Standard_Boolean OnFirst,
24                                 const Standard_Real U,
25                                 const Standard_Real V) {
26
27   pt = Pt;
28   if (OnFirst) {
29     u1 = U;
30     v1 = V;
31   }
32   else {
33     u2 = U;
34     v2 = V;
35   }
36 }
37
38
39 void IntSurf_PntOn2S::SetValue (const Standard_Boolean OnFirst,
40                                 const Standard_Real U,
41                                 const Standard_Real V) {
42
43   if (OnFirst) {
44     u1 = U;
45     v1 = V;
46   }
47   else {
48     u2 = U;
49     v2 = V;
50   }
51 }
52
53 gp_Pnt2d IntSurf_PntOn2S::ValueOnSurface(const Standard_Boolean OnFirst) const
54 {
55   gp_Pnt2d PointOnSurf;
56   if (OnFirst)
57     PointOnSurf.SetCoord(u1,v1);
58   else
59     PointOnSurf.SetCoord(u2,v2);
60   return PointOnSurf;
61 }
62
63 void IntSurf_PntOn2S::ParametersOnSurface(const Standard_Boolean OnFirst,
64                                           Standard_Real& U,
65                                           Standard_Real& V) const
66 {
67   if (OnFirst) {
68     U = u1;
69     V = v1;
70   }
71   else {
72     U = u2;
73     V = v2;
74   }
75 }
76
77 Standard_Boolean IntSurf_PntOn2S::IsSame( const IntSurf_PntOn2S& theOterPoint,
78                                           const Standard_Real theTol3D,
79                                           const Standard_Real theTol2D) const
80 {
81   if(pt.SquareDistance(theOterPoint.Value()) > theTol3D*theTol3D)
82     return Standard_False;
83
84   if(theTol2D < 0.0)
85   {//We need not compare 2D-coordinates of the points
86     return Standard_True;
87   }
88
89   Standard_Real aU1 = 0.0, aV1 = 0.0, aU2 = 0.0, aV2 = 0.0;
90   theOterPoint.Parameters(aU1, aV1, aU2, aV2);
91
92   gp_Pnt2d aP1(u1, v1), aP2(aU1, aV1);
93
94   if(!aP1.IsEqual(aP2, theTol2D))
95     return Standard_False;
96
97   aP1.SetCoord(u2, v2);
98   aP2.SetCoord(aU2, aV2);
99
100   if(!aP1.IsEqual(aP2, theTol2D))
101     return Standard_False;
102
103   return Standard_True;
104 }