b311480e |
1 | // Copyright (c) 1995-1999 Matra Datavision |
973c2be1 |
2 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
3 | // |
973c2be1 |
4 | // This file is part of Open CASCADE Technology software library. |
b311480e |
5 | // |
d5f74e42 |
6 | // This library is free software; you can redistribute it and/or modify it under |
7 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
8 | // by the Free Software Foundation, with special exception defined in the file |
9 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
10 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
11 | // |
973c2be1 |
12 | // Alternatively, this file may be used under the terms of Open CASCADE |
13 | // commercial license or contractual agreement. |
7fd59977 |
14 | |
15 | #define EpsAng 1.e-8 |
16 | #define EpsAng2 1.e-16 |
17 | #define Tolpetit 1.e-16 |
18 | |
0797d9d3 |
19 | #ifndef OCCT_DEBUG |
7fd59977 |
20 | #define No_Standard_RangeError |
21 | #define No_Standard_OutOfRange |
22 | #endif |
23 | |
24 | #define SURF (*((ThePSurface *)(surf))) |
25 | #define FUNC (*((TheISurface *)(func))) |
26 | |
27 | |
28 | IntImp_ZerImpFunc::IntImp_ZerImpFunc() : |
29 | computed(Standard_False), |
30 | derived(Standard_False) |
31 | { |
32 | } |
33 | |
34 | IntImp_ZerImpFunc::IntImp_ZerImpFunc(const ThePSurface& PS , |
35 | const TheISurface& IS) : |
36 | computed(Standard_False), |
37 | derived(Standard_False) |
38 | { |
39 | surf = (Standard_Address)(&PS); |
40 | func = (Standard_Address)(&IS); |
41 | } |
42 | |
43 | IntImp_ZerImpFunc::IntImp_ZerImpFunc(const TheISurface& IS) : |
44 | computed(Standard_False), |
45 | derived(Standard_False) |
46 | { |
47 | func = (Standard_Address)(&IS); |
48 | } |
49 | |
50 | Standard_Integer IntImp_ZerImpFunc::NbVariables() const |
51 | { |
52 | return 2; |
53 | } |
54 | |
55 | Standard_Integer IntImp_ZerImpFunc::NbEquations() const |
56 | { |
57 | return 1; |
58 | } |
59 | |
60 | Standard_Boolean IntImp_ZerImpFunc::Value(const math_Vector& X, |
61 | math_Vector& F) |
62 | { |
63 | u = X(1); |
64 | v = X(2); |
65 | pntsol = ThePSurfaceTool::Value(SURF, u, v); |
66 | valf = TheISurfaceTool::Value(FUNC, pntsol.X(), pntsol.Y(), pntsol.Z()); |
67 | F(1) = valf; |
68 | computed = Standard_False; |
69 | derived = Standard_False; |
70 | return Standard_True; |
71 | } |
72 | |
73 | Standard_Boolean IntImp_ZerImpFunc::Derivatives(const math_Vector& X, |
74 | math_Matrix& D) |
75 | { |
76 | u = X(1); |
77 | v = X(2); |
78 | ThePSurfaceTool::D1(SURF, u, v, pntsol, d1u, d1v); |
79 | TheISurfaceTool::Gradient(FUNC, pntsol.X(), pntsol.Y(), pntsol.Z(),gradient); |
80 | D(1,1) = d1u.Dot(gradient); |
81 | D(1,2) = d1v.Dot(gradient); |
82 | computed = Standard_False; |
83 | derived = Standard_True; |
84 | return Standard_True; |
85 | } |
86 | |
87 | Standard_Boolean IntImp_ZerImpFunc::Values(const math_Vector& X, |
88 | math_Vector& F, |
89 | math_Matrix& D) |
90 | { |
91 | u = X(1); |
92 | v = X(2); |
93 | ThePSurfaceTool::D1(SURF, u, v, pntsol, d1u, d1v); |
94 | TheISurfaceTool::ValueAndGradient(FUNC, pntsol.X(), pntsol.Y(), pntsol.Z(), |
95 | valf, gradient); |
96 | F(1) = valf; |
97 | D(1,1) = d1u.Dot(gradient); |
98 | D(1,2) = d1v.Dot(gradient); |
99 | computed = Standard_False; |
100 | derived = Standard_True; |
101 | return Standard_True; |
102 | } |
103 | |
104 | Standard_Boolean IntImp_ZerImpFunc::IsTangent() |
105 | { |
106 | if (!computed) { |
107 | computed = Standard_True; |
108 | if(!derived) { |
109 | ThePSurfaceTool::D1(SURF, u, v, pntsol, d1u, d1v); |
110 | derived = Standard_True; |
111 | } |
112 | |
113 | tgdu = gradient.Dot(d1v); |
114 | tgdv = -gradient.Dot(d1u); |
115 | Standard_Real N2grad = gradient.SquareMagnitude(); |
116 | Standard_Real N2grad_EpsAng2 = N2grad * EpsAng2; |
117 | Standard_Real N2d1u = d1u.SquareMagnitude(); |
118 | Standard_Real N2d1v = d1v.SquareMagnitude(); |
119 | tangent =(tgdu * tgdu <= N2grad_EpsAng2 * N2d1v) && |
120 | (tgdv * tgdv <= N2grad_EpsAng2 * N2d1u); |
121 | if(!tangent) { |
122 | d3d.SetLinearForm(tgdu,d1u,tgdv,d1v); |
123 | d2d = gp_Dir2d(tgdu, tgdv); |
124 | if (d3d.Magnitude() <= Tolpetit) { // jag |
b92f3572 |
125 | tangent = Standard_True; |
7fd59977 |
126 | } |
127 | } |
128 | } |
129 | return tangent; |
130 | } |
131 | |
132 | #undef EpsAng |
133 | #undef EpsAng2 |
134 | #undef Tolpetit |
135 | #undef FUNC |
136 | #undef SURF |