Commit | Line | Data |
---|---|---|
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 | |
0797d9d3 | 15 | #ifndef OCCT_DEBUG |
7fd59977 | 16 | #define No_Standard_RangeError |
17 | #define No_Standard_OutOfRange | |
18 | #endif | |
19 | ||
20 | ||
21 | #include <StdFail_NotDone.hxx> | |
22 | #include <Standard_DomainError.hxx> | |
23 | #include <IntImp_ComputeTangence.hxx> | |
24 | #include <math_FunctionSetRoot.hxx> | |
25 | #include <Precision.hxx> | |
26 | ||
27 | IntImp_IntCS::IntImp_IntCS(const Standard_Real U, | |
28 | const Standard_Real V, | |
29 | const Standard_Real W, | |
30 | const TheFunction& F, | |
31 | const Standard_Real TolTangency, | |
32 | const Standard_Real MarginCoef) : | |
33 | done(Standard_True), | |
34 | empty(Standard_True), | |
35 | myFunction(F), | |
d533dafb | 36 | w(0.0), |
37 | u(0.0), | |
38 | v(0.0), | |
7fd59977 | 39 | tol(TolTangency*TolTangency) |
40 | { | |
41 | if(tol<1e-13) { tol=1e-13; } | |
42 | math_FunctionSetRoot Rsnld(myFunction); | |
43 | Standard_Real u0,u1,v0,v1,w0,w1; | |
44 | const ThePSurface& S = myFunction.AuxillarSurface(); | |
45 | const TheCurve& C = myFunction.AuxillarCurve(); | |
46 | ||
47 | w0 = TheCurveTool::FirstParameter(C); | |
48 | w1 = TheCurveTool::LastParameter(C); | |
49 | ||
50 | u0 = ThePSurfaceTool::FirstUParameter(S); | |
51 | v0 = ThePSurfaceTool::FirstVParameter(S); | |
52 | u1 = ThePSurfaceTool::LastUParameter(S); | |
53 | v1 = ThePSurfaceTool::LastVParameter(S); | |
54 | ||
55 | if (MarginCoef > 0.) { | |
56 | if (!Precision::IsInfinite(u0) && !Precision::IsInfinite(u1)) { | |
57 | Standard_Real marg = (u1-u0)*MarginCoef; | |
58 | if (u0 > u1) marg = -marg; | |
59 | u0 -= marg; u1 += marg; | |
60 | } | |
61 | if (!Precision::IsInfinite(v0) && !Precision::IsInfinite(v1)) { | |
62 | Standard_Real marg = (v1-v0)*MarginCoef; | |
63 | if (v0 > v1) marg = -marg; | |
64 | v0 -= marg; v1 += marg; | |
65 | } | |
66 | } | |
67 | ||
68 | Perform(U,V,W,Rsnld,u0,u1,v0,v1,w0,w1); | |
69 | } | |
70 | ||
71 | IntImp_IntCS::IntImp_IntCS(const TheFunction& F, | |
72 | const Standard_Real TolTangency) : | |
73 | done(Standard_True), | |
74 | empty(Standard_True), | |
75 | myFunction(F), | |
76 | tol(TolTangency*TolTangency) | |
77 | { | |
78 | } | |
79 | ||
80 | void IntImp_IntCS::Perform(const Standard_Real U, | |
81 | const Standard_Real V, | |
82 | const Standard_Real W, | |
83 | math_FunctionSetRoot& Rsnld, | |
84 | const Standard_Real u0, | |
85 | const Standard_Real u1, | |
86 | const Standard_Real v0, | |
87 | const Standard_Real v1, | |
88 | const Standard_Real w0, | |
89 | const Standard_Real w1) { | |
90 | done = Standard_True; | |
41194117 K |
91 | Standard_Real BornInfBuf[3], BornSupBuf[3], ToleranceBuf[3], UVapBuf[3]; |
92 | math_Vector BornInf (BornInfBuf, 1, 3), BornSup (BornSupBuf, 1, 3), Tolerance (ToleranceBuf, 1, 3), UVap (UVapBuf, 1, 3); | |
7fd59977 | 93 | UVap(1) = U; |
94 | UVap(2) = V; | |
95 | UVap(3) = W; | |
96 | const ThePSurface& S = myFunction.AuxillarSurface(); | |
97 | const TheCurve& C = myFunction.AuxillarCurve(); | |
98 | ||
99 | BornInf(1) = u0; BornInf(2) = v0; | |
100 | BornSup(1) = u1; BornSup(2) = v1; | |
101 | ||
102 | BornInf(3) = w0; BornSup(3) = w1; | |
103 | ||
104 | Tolerance(1) = ThePSurfaceTool::UResolution(S,Precision::Confusion()); | |
105 | Tolerance(2) = ThePSurfaceTool::VResolution(S,Precision::Confusion()); | |
106 | Tolerance(3) = TheCurveTool::Resolution(C,Precision::Confusion()); | |
107 | Rsnld.SetTolerance(Tolerance); | |
108 | Standard_Integer autretentative=0; | |
109 | done=Standard_False; | |
110 | do { | |
111 | if(autretentative==1) { | |
112 | UVap(3)=w0; | |
113 | } | |
114 | else if(autretentative==2) { | |
115 | UVap(3)=w1; | |
116 | } | |
117 | autretentative++; | |
118 | Rsnld.Perform(myFunction,UVap,BornInf,BornSup); | |
119 | if (Rsnld.IsDone()) { | |
120 | Standard_Real AbsmyFunctionRoot = Abs(myFunction.Root()); | |
121 | if (AbsmyFunctionRoot <= tol) { | |
122 | Rsnld.Root(UVap); | |
123 | u = UVap(1); | |
124 | v = UVap(2); | |
125 | w = UVap(3); | |
126 | empty = Standard_False; | |
127 | done=Standard_True; | |
128 | } | |
129 | } | |
130 | } | |
131 | while(done==Standard_False && autretentative<3); | |
132 | } | |
133 | ||
134 | Standard_Boolean IntImp_IntCS::IsDone() const { return done;} | |
135 | ||
136 | Standard_Boolean IntImp_IntCS::IsEmpty()const { | |
9775fa61 | 137 | if (!done) throw StdFail_NotDone(); |
7fd59977 | 138 | return empty; |
139 | } | |
140 | ||
141 | const gp_Pnt& IntImp_IntCS::Point() const | |
142 | { | |
9775fa61 | 143 | if (!done) throw StdFail_NotDone(); |
144 | if (empty) throw Standard_DomainError(); | |
7fd59977 | 145 | return myFunction.Point(); |
146 | } | |
147 | ||
148 | void IntImp_IntCS::ParameterOnSurface(Standard_Real& U, | |
149 | Standard_Real& V) const | |
150 | { | |
9775fa61 | 151 | if (!done) throw StdFail_NotDone(); |
152 | if (empty) throw Standard_DomainError(); | |
7fd59977 | 153 | U=u; |
154 | V=v; | |
155 | } | |
156 | Standard_Real IntImp_IntCS::ParameterOnCurve() const | |
157 | { | |
9775fa61 | 158 | if (!done) throw StdFail_NotDone(); |
159 | if (empty) throw Standard_DomainError(); | |
7fd59977 | 160 | return w; |
161 | } | |
162 | ||
163 | TheFunction& IntImp_IntCS::Function() {return myFunction;} |