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