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