b311480e |
1 | // Copyright (c) 1995-1999 Matra Datavision |
2 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
3 | // |
4 | // The content of this file is subject to the Open CASCADE Technology Public |
5 | // License Version 6.5 (the "License"). You may not use the content of this file |
6 | // except in compliance with the License. Please obtain a copy of the License |
7 | // at http://www.opencascade.org and read it completely before using this file. |
8 | // |
9 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
10 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
11 | // |
12 | // The Original Code and all software distributed under the License is |
13 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
14 | // Initial Developer hereby disclaims all such warranties, including without |
15 | // limitation, any warranties of merchantability, fitness for a particular |
16 | // purpose or non-infringement. Please see the License for the specific terms |
17 | // and conditions governing the rights and limitations under the License. |
18 | |
7fd59977 |
19 | #include <gp_Pnt.hxx> |
20 | #include <gp_Vec.hxx> |
21 | #include <gp_Pnt2d.hxx> |
22 | #include <gp_Vec2d.hxx> |
23 | |
24 | #ifndef DEB |
25 | #define No_Standard_RangeError |
26 | #define No_Standard_OutOfRange |
27 | #endif |
28 | |
29 | |
30 | #define SURFACE1 (*((ThePSurface *)(surface1))) |
31 | #define SURFACE2 (*((ThePSurface *)(surface2))) |
32 | #define CURVE (*((TheCurveOnSurf *)(curve))) |
33 | |
34 | IntImp_ZerCOnSSParFunc::IntImp_ZerCOnSSParFunc(const ThePSurface& S1, |
35 | const TheCurveOnSurf& C, |
36 | const ThePSurface& S2) |
37 | { |
38 | surface1 = (Standard_Address)(&S1); |
39 | surface2 = (Standard_Address)(&S2); |
40 | curve = (Standard_Address)(&C); |
41 | } |
42 | |
43 | Standard_Integer IntImp_ZerCOnSSParFunc::NbVariables()const { return 3;} |
44 | |
45 | Standard_Integer IntImp_ZerCOnSSParFunc::NbEquations()const { return 3;} |
46 | |
47 | Standard_Boolean IntImp_ZerCOnSSParFunc::Value(const math_Vector& X, |
48 | math_Vector& F){ |
49 | |
50 | gp_Pnt Psurf(ThePSurfaceTool::Value(SURFACE1,X(1),X(2))); |
51 | gp_Pnt2d p2d(TheCurveTool::Value(CURVE,X(3))); |
52 | gp_Pnt Pcurv(ThePSurfaceTool::Value(SURFACE2,p2d.X(),p2d.Y())); |
53 | |
54 | F(1) = Psurf.X()-Pcurv.X(); |
55 | F(2) = Psurf.Y()-Pcurv.Y(); |
56 | F(3) = Psurf.Z()-Pcurv.Z(); |
57 | f = F(1)*F(1)+ F(2)*F(2)+ F(3)*F(3); |
58 | p = gp_Pnt((Psurf.XYZ()+Pcurv.XYZ())/2.); |
59 | return Standard_True; |
60 | } |
61 | |
62 | Standard_Boolean IntImp_ZerCOnSSParFunc::Derivatives ( const math_Vector& X, |
63 | math_Matrix& D) { |
64 | gp_Pnt Psurf,Pcurv; |
65 | gp_Vec D1u,D1v,D1w; |
66 | gp_Pnt2d p2d; |
67 | gp_Vec2d d2d; |
68 | gp_Vec d1u,d1v; |
69 | |
70 | ThePSurfaceTool::D1(SURFACE1,X(1),X(2),Psurf,D1u,D1v); |
71 | TheCurveTool::D1(CURVE,X(3),p2d,d2d); |
72 | ThePSurfaceTool::D1(SURFACE2,p2d.X(),p2d.Y(),Pcurv,d1u,d1v); |
73 | D1w.SetLinearForm(d2d.X(),d1u,d2d.Y(),d1v); |
74 | |
75 | D(1,1) = D1u.X(); |
76 | D(1,2) = D1v.X(); |
77 | D(1,3) = -D1w.X(); |
78 | D(2,1) = D1u.Y(); |
79 | D(2,2) = D1v.Y(); |
80 | D(2,3) = -D1w.Y(); |
81 | D(3,1) = D1u.Z(); |
82 | D(3,2) = D1v.Z(); |
83 | D(3,3) = -D1w.Z(); |
84 | return Standard_True; |
85 | } |
86 | |
87 | Standard_Boolean IntImp_ZerCOnSSParFunc::Values( const math_Vector& X, |
88 | math_Vector& F, |
89 | math_Matrix& D) { |
90 | gp_Pnt Psurf,Pcurv; |
91 | gp_Vec D1u,D1v,D1w; |
92 | |
93 | gp_Pnt2d p2d; |
94 | gp_Vec2d d2d; |
95 | gp_Vec d1u,d1v; |
96 | |
97 | ThePSurfaceTool::D1(SURFACE1,X(1),X(2),Psurf,D1u,D1v); |
98 | TheCurveTool::D1(CURVE,X(3),p2d,d2d); |
99 | ThePSurfaceTool::D1(SURFACE2,p2d.X(),p2d.Y(),Pcurv,d1u,d1v); |
100 | D1w.SetLinearForm(d2d.X(),d1u,d2d.Y(),d1v); |
101 | |
102 | D(1,1) = D1u.X(); |
103 | D(1,2) = D1v.X(); |
104 | D(1,3) = -D1w.X(); |
105 | D(2,1) = D1u.Y(); |
106 | D(2,2) = D1v.Y(); |
107 | D(2,3) = -D1w.Y(); |
108 | D(3,1) = D1u.Z(); |
109 | D(3,2) = D1v.Z(); |
110 | D(3,3) = -D1w.Z(); |
111 | F(1) = Psurf.X()-Pcurv.X(); |
112 | F(2) = Psurf.Y()-Pcurv.Y(); |
113 | F(3) = Psurf.Z()-Pcurv.Z(); |
114 | f = F(1)*F(1)+ F(2)*F(2)+ F(3)*F(3); |
115 | p = gp_Pnt((Psurf.XYZ()+Pcurv.XYZ())/2.); |
116 | return Standard_True; |
117 | } |
118 | |
119 | const gp_Pnt& IntImp_ZerCOnSSParFunc::Point() const { return p;} |
120 | |
121 | Standard_Real IntImp_ZerCOnSSParFunc::Root() const { return f;} |
122 | |
123 | const ThePSurface& IntImp_ZerCOnSSParFunc::AuxillarSurface() const { |
124 | return SURFACE1;} |
125 | |
126 | const TheCurveOnSurf& IntImp_ZerCOnSSParFunc::AuxillarCurve() const { |
127 | return CURVE;} |
128 | |
129 | #undef SURFACE1 |
130 | #undef SURFACE2 |
131 | #undef CURVE |