0028966: Coding Rules - remove Adaptor2d_HCurve2d, Adaptor3d_HCurve and Adaptor3d_HSu...
[occt.git] / src / IntPolyh / IntPolyh_Point.cxx
1 // Created on: 1999-03-08
2 // Created by: Fabrice SERVANT
3 // Copyright (c) 1999-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 <Adaptor3d_Surface.hxx>
19 #include <IntPolyh_Point.hxx>
20
21 #include <stdio.h>
22
23 //=======================================================================
24 //function : Middle
25 //purpose  : 
26 //=======================================================================
27 void IntPolyh_Point::Middle(const Handle(Adaptor3d_Surface)& MySurface,
28                                       const IntPolyh_Point & Point1, 
29                                       const IntPolyh_Point & Point2){
30   myU = (Point1.U()+Point2.U())*0.5;
31   myV = (Point1.V()+Point2.V())*0.5;
32   
33   gp_Pnt PtXYZ = (MySurface)->Value(myU, myV);
34
35   myX=PtXYZ.X();
36   myY=PtXYZ.Y(); 
37   myZ=PtXYZ.Z();
38 }
39 //=======================================================================
40 //function : Add
41 //purpose  : 
42 //=======================================================================
43 IntPolyh_Point IntPolyh_Point::Add(const IntPolyh_Point &P1)const
44 {
45   IntPolyh_Point res;
46   //
47   res.SetX(myX+P1.X());
48   res.SetY(myY+P1.Y());
49   res.SetZ(myZ+P1.Z());
50   res.SetU(myU+P1.U());
51   res.SetV(myV+P1.V());
52   return res;
53 }  
54
55 //=======================================================================
56 //function : Sub
57 //purpose  : 
58 //=======================================================================
59 IntPolyh_Point IntPolyh_Point::Sub(const IntPolyh_Point &P1)const
60
61   IntPolyh_Point res;
62   //
63   res.SetX(myX-P1.X());
64   res.SetY(myY-P1.Y());
65   res.SetZ(myZ-P1.Z());
66   res.SetU(myU-P1.U());
67   res.SetV(myV-P1.V());
68   return res;
69
70 //=======================================================================
71 //function : Divide
72 //purpose  : 
73 //=======================================================================
74 IntPolyh_Point IntPolyh_Point::Divide(const Standard_Real RR)const
75
76   IntPolyh_Point res;
77   //
78   if (Abs(RR)>10.0e-20) {
79     res.SetX(myX/RR);
80     res.SetY(myY/RR);
81     res.SetZ(myZ/RR);
82     res.SetU(myU/RR);
83     res.SetV(myV/RR);
84   }
85   else { 
86    printf("Division par zero RR=%f\n",RR);
87   }
88   return res;
89 }
90 //=======================================================================
91 //function : Multiplication
92 //purpose  : 
93 //=======================================================================
94 IntPolyh_Point IntPolyh_Point::Multiplication(const Standard_Real RR)const
95
96   IntPolyh_Point res;
97   //
98   res.SetX(myX*RR);
99   res.SetY(myY*RR);
100   res.SetZ(myZ*RR);
101   res.SetU(myU*RR);
102   res.SetV(myV*RR);
103   return res;
104 }
105 //=======================================================================
106 //function : SquareModulus
107 //purpose  : 
108 //=======================================================================
109 Standard_Real IntPolyh_Point::SquareModulus()const
110 {
111   Standard_Real res=myX*myX+myY*myY+myZ*myZ;
112   return res;
113 }
114
115 //=======================================================================
116 //function : SquareDistance
117 //purpose  : 
118 //=======================================================================
119 Standard_Real IntPolyh_Point::SquareDistance(const IntPolyh_Point &P2)const
120 {
121   Standard_Real res=(myX-P2.myX)*(myX-P2.myX)+(myY-P2.myY)*(myY-P2.myY)+(myZ-P2.myZ)*(myZ-P2.myZ);
122   return res;
123 }
124 //=======================================================================
125 //function : Dot
126 //purpose  : 
127 //=======================================================================
128 Standard_Real IntPolyh_Point::Dot(const IntPolyh_Point &b ) const
129
130   Standard_Real t=myX*b.myX+myY*b.myY+myZ*b.myZ;
131   return t;
132 }
133 //=======================================================================
134 //function : Cross
135 //purpose  : 
136 //=======================================================================
137 void IntPolyh_Point::Cross(const IntPolyh_Point &a,const IntPolyh_Point &b){ 
138   myX=a.myY*b.myZ-a.myZ*b.myY;
139   myY=a.myZ*b.myX-a.myX*b.myZ;
140   myZ=a.myX*b.myY-a.myY*b.myX;
141 }
142 //=======================================================================
143 //function : Dump
144 //purpose  : 
145 //=======================================================================
146 void IntPolyh_Point::Dump() const
147
148   printf("\nPoint : x=%+8.3eg y=%+8.3eg z=%+8.3eg u=%+8.3eg v=%+8.3eg\n",myX,myY,myZ,myU,myV);
149 }
150 //=======================================================================
151 //function : Dump
152 //purpose  : 
153 //=======================================================================
154 void IntPolyh_Point::Dump(const Standard_Integer i) const
155
156   printf("\nPoint(%3d) : x=%+8.3eg y=%+8.3eg z=%+8.3eg u=%+8.3eg v=%+8.3eg poc=%3d\n",
157          i,myX,myY,myZ,myU,myV,myPOC);
158 }