0022048: Visualization, AIS_InteractiveContext - single object selection should alway...
[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 <Adaptor3d_HSurface.hxx>
19#include <IntPolyh_Point.hxx>
7fd59977 20
42cf5bc1 21#include <stdio.h>
7fd59977 22
55ab6ed6
P
23//=======================================================================
24//function : Middle
25//purpose :
26//=======================================================================
7fd59977 27void IntPolyh_Point::Middle(const Handle(Adaptor3d_HSurface)& MySurface,
28 const IntPolyh_Point & Point1,
29 const IntPolyh_Point & Point2){
68b07699 30 myU = (Point1.U()+Point2.U())*0.5;
31 myV = (Point1.V()+Point2.V())*0.5;
7fd59977 32
68b07699 33 gp_Pnt PtXYZ = (MySurface)->Value(myU, myV);
7fd59977 34
68b07699 35 myX=PtXYZ.X();
36 myY=PtXYZ.Y();
37 myZ=PtXYZ.Z();
7fd59977 38}
55ab6ed6
P
39//=======================================================================
40//function : Add
41//purpose :
42//=======================================================================
43IntPolyh_Point IntPolyh_Point::Add(const IntPolyh_Point &P1)const
44{
7fd59977 45 IntPolyh_Point res;
55ab6ed6 46 //
68b07699 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());
55ab6ed6 52 return res;
7fd59977 53}
54
55ab6ed6
P
55//=======================================================================
56//function : Sub
57//purpose :
58//=======================================================================
59IntPolyh_Point IntPolyh_Point::Sub(const IntPolyh_Point &P1)const
60{
7fd59977 61 IntPolyh_Point res;
55ab6ed6 62 //
68b07699 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());
55ab6ed6 68 return res;
7fd59977 69}
55ab6ed6
P
70//=======================================================================
71//function : Divide
72//purpose :
73//=======================================================================
74IntPolyh_Point IntPolyh_Point::Divide(const Standard_Real RR)const
75{
7fd59977 76 IntPolyh_Point res;
55ab6ed6 77 //
7fd59977 78 if (Abs(RR)>10.0e-20) {
68b07699 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);
7fd59977 84 }
85 else {
86 printf("Division par zero RR=%f\n",RR);
7fd59977 87 }
55ab6ed6 88 return res;
7fd59977 89}
55ab6ed6
P
90//=======================================================================
91//function : Multiplication
92//purpose :
93//=======================================================================
94IntPolyh_Point IntPolyh_Point::Multiplication(const Standard_Real RR)const
95{
7fd59977 96 IntPolyh_Point res;
55ab6ed6 97 //
68b07699 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);
55ab6ed6 103 return res;
7fd59977 104}
55ab6ed6
P
105//=======================================================================
106//function : SquareModulus
107//purpose :
108//=======================================================================
109Standard_Real IntPolyh_Point::SquareModulus()const
110{
68b07699 111 Standard_Real res=myX*myX+myY*myY+myZ*myZ;
55ab6ed6 112 return res;
7fd59977 113}
114
55ab6ed6
P
115//=======================================================================
116//function : SquareDistance
117//purpose :
118//=======================================================================
119Standard_Real IntPolyh_Point::SquareDistance(const IntPolyh_Point &P2)const
120{
68b07699 121 Standard_Real res=(myX-P2.myX)*(myX-P2.myX)+(myY-P2.myY)*(myY-P2.myY)+(myZ-P2.myZ)*(myZ-P2.myZ);
55ab6ed6 122 return res;
7fd59977 123}
55ab6ed6
P
124//=======================================================================
125//function : Dot
126//purpose :
127//=======================================================================
128Standard_Real IntPolyh_Point::Dot(const IntPolyh_Point &b ) const
129{
68b07699 130 Standard_Real t=myX*b.myX+myY*b.myY+myZ*b.myZ;
55ab6ed6 131 return t;
7fd59977 132}
55ab6ed6
P
133//=======================================================================
134//function : Cross
135//purpose :
136//=======================================================================
7fd59977 137void IntPolyh_Point::Cross(const IntPolyh_Point &a,const IntPolyh_Point &b){
68b07699 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;
7fd59977 141}
55ab6ed6
P
142//=======================================================================
143//function : Dump
144//purpose :
145//=======================================================================
146void IntPolyh_Point::Dump() const
147{
68b07699 148 printf("\nPoint : x=%+8.3eg y=%+8.3eg z=%+8.3eg u=%+8.3eg v=%+8.3eg\n",myX,myY,myZ,myU,myV);
7fd59977 149}
55ab6ed6
P
150//=======================================================================
151//function : Dump
152//purpose :
153//=======================================================================
154void 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",
68b07699 157 i,myX,myY,myZ,myU,myV,myPOC);
55ab6ed6 158}