7fd59977 |
1 | // File: IntPolyh_Point.cxx |
2 | // Created: Mon Mar 8 09:32:00 1999 |
3 | // Author: Fabrice SERVANT |
4 | // <fst@cleox.paris1.matra-dtv.fr> |
5 | |
6 | |
7 | #include <IntPolyh_Point.ixx> |
8 | |
9 | #include <stdio.h> |
10 | |
11 | |
12 | IntPolyh_Point::IntPolyh_Point() : x(0),y(0),z(0),u(0),v(0),POC(1) { |
13 | } |
14 | |
15 | IntPolyh_Point::IntPolyh_Point(const Standard_Real _x, |
16 | const Standard_Real _y, |
17 | const Standard_Real _z, |
18 | const Standard_Real _u, |
19 | const Standard_Real _v):POC(1) { |
20 | x=_x; y=_y; z=_z; u=_u; v=_v; |
21 | } |
22 | |
23 | Standard_Real IntPolyh_Point::X() const { return(x); } |
24 | Standard_Real IntPolyh_Point::Y() const { return(y); } |
25 | Standard_Real IntPolyh_Point::Z() const { return(z); } |
26 | Standard_Real IntPolyh_Point::U() const { return(u); } |
27 | Standard_Real IntPolyh_Point::V() const { return(v); } |
28 | Standard_Integer IntPolyh_Point::PartOfCommon() const {return(POC);} |
29 | |
30 | |
31 | void IntPolyh_Point::Set(const Standard_Real _x,const Standard_Real _y, const Standard_Real _z, |
32 | const Standard_Real _u, const Standard_Real _v, const Standard_Integer II) { |
33 | x=_x; y=_y; z=_z; u=_u; v=_v; POC=II;} |
34 | |
35 | void IntPolyh_Point::Equal(const IntPolyh_Point &Pt) { |
36 | x = Pt.x; |
37 | y = Pt.y; |
38 | z = Pt.z; |
39 | u = Pt.u; |
40 | v = Pt.v; |
41 | } |
42 | |
43 | void IntPolyh_Point::SetX(const Standard_Real _x) { x=_x; } |
44 | void IntPolyh_Point::SetY(const Standard_Real _y) { y=_y; } |
45 | void IntPolyh_Point::SetZ(const Standard_Real _z) { z=_z; } |
46 | void IntPolyh_Point::SetU(const Standard_Real _u) { u=_u; } |
47 | void IntPolyh_Point::SetV(const Standard_Real _v) { v=_v; } |
48 | void IntPolyh_Point::SetPartOfCommon(const Standard_Integer ii) { POC=ii; } |
49 | |
50 | void IntPolyh_Point::Middle(const Handle(Adaptor3d_HSurface)& MySurface, |
51 | const IntPolyh_Point & Point1, |
52 | const IntPolyh_Point & Point2){ |
53 | u = (Point1.U()+Point2.U())*0.5; |
54 | v = (Point1.V()+Point2.V())*0.5; |
55 | |
56 | gp_Pnt PtXYZ = (MySurface)->Value(u, v); |
57 | |
58 | x=PtXYZ.X(); |
59 | y=PtXYZ.Y(); |
60 | z=PtXYZ.Z(); |
61 | } |
62 | |
63 | |
64 | IntPolyh_Point IntPolyh_Point::Add(const IntPolyh_Point &P1)const{ |
65 | IntPolyh_Point res; |
66 | res.SetX(x+P1.X()); |
67 | res.SetY(y+P1.Y()); |
68 | res.SetZ(z+P1.Z()); |
69 | res.SetU(u+P1.U()); |
70 | res.SetV(v+P1.V()); |
71 | return(res); |
72 | } |
73 | |
74 | IntPolyh_Point IntPolyh_Point::Sub(const IntPolyh_Point &P1)const{ |
75 | IntPolyh_Point res; |
76 | res.SetX(x-P1.X()); |
77 | res.SetY(y-P1.Y()); |
78 | res.SetZ(z-P1.Z()); |
79 | res.SetU(u-P1.U()); |
80 | res.SetV(v-P1.V()); |
81 | return(res); |
82 | } |
83 | |
84 | IntPolyh_Point IntPolyh_Point::Divide(const Standard_Real RR)const{ |
85 | IntPolyh_Point res; |
86 | if (Abs(RR)>10.0e-20) { |
87 | res.SetX(x/RR); |
88 | res.SetY(y/RR); |
89 | res.SetZ(z/RR); |
90 | res.SetU(u/RR); |
91 | res.SetV(v/RR); |
92 | } |
93 | else { |
94 | printf("Division par zero RR=%f\n",RR); |
95 | //Dump(); |
96 | } |
97 | return(res); |
98 | } |
99 | |
100 | IntPolyh_Point IntPolyh_Point::Multiplication(const Standard_Real RR)const{ |
101 | IntPolyh_Point res; |
102 | res.SetX(x*RR); |
103 | res.SetY(y*RR); |
104 | res.SetZ(z*RR); |
105 | res.SetU(u*RR); |
106 | res.SetV(v*RR); |
107 | return(res); |
108 | } |
109 | |
110 | Standard_Real IntPolyh_Point::SquareModulus()const{ |
111 | Standard_Real res=x*x+y*y+z*z; |
112 | return(res); |
113 | } |
114 | |
115 | Standard_Real IntPolyh_Point::SquareDistance(const IntPolyh_Point &P2)const{ |
116 | Standard_Real res=(x-P2.x)*(x-P2.x)+(y-P2.y)*(y-P2.y)+(z-P2.z)*(z-P2.z); |
117 | return(res); |
118 | } |
119 | |
120 | //inline |
121 | Standard_Real IntPolyh_Point::Dot(const IntPolyh_Point &b ) const{ |
122 | Standard_Real t=x*b.x+y*b.y+z*b.z; |
123 | return(t); |
124 | } |
125 | |
126 | //inline |
127 | void IntPolyh_Point::Cross(const IntPolyh_Point &a,const IntPolyh_Point &b){ |
128 | x=a.y*b.z-a.z*b.y; |
129 | y=a.z*b.x-a.x*b.z; |
130 | z=a.x*b.y-a.y*b.x; |
131 | //u=? |
132 | //v=? |
133 | } |
134 | |
135 | void IntPolyh_Point::Dump() const{ |
136 | printf("\nPoint : x=%+8.3eg y=%+8.3eg z=%+8.3eg u=%+8.3eg v=%+8.3eg\n",x,y,z,u,v); |
137 | } |
138 | |
139 | void IntPolyh_Point::Dump(const Standard_Integer i) const{ |
140 | printf("\nPoint(%3d) : x=%+8.3eg y=%+8.3eg z=%+8.3eg u=%+8.3eg v=%+8.3eg poc=%3d\n",i,x,y,z,u,v,POC); |
141 | } |
142 | |
143 | |
144 | |
145 | |
146 | |
147 | |
148 | |