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. |
b311480e |
14 | |
7fd59977 |
15 | /* |
16 | Standard_Boolean Blend_CSWalking::Recadre(Blend_FuncInv& FuncInv, |
17 | const Standard_Boolean OnFirst, |
18 | const math_Vector& sol, |
19 | math_Vector& solrst, |
20 | Standard_Integer& Indexsol, |
21 | Standard_Boolean& IsVtx, |
22 | TheVertex& Vtx) |
23 | |
24 | { |
25 | Standard_Integer nbarc; |
26 | Standard_Boolean ok,yamin; |
27 | Standard_Real dist,distmin,prm,pmin; |
28 | gp_Pnt2d pt2d; |
29 | math_Vector toler(1,4),infb(1,4),supb(1,4),valsol(1,4); |
30 | |
31 | Handle(TheTopolTool) Iter; |
32 | TopAbs_State situ; |
33 | |
34 | yamin = Standard_False; |
35 | nbarc = 0; |
36 | distmin = RealLast(); |
37 | if (OnFirst) { |
38 | pt2d.SetCoord(sol(1),sol(2)); |
39 | Iter = domain1; |
40 | } |
41 | else { |
42 | pt2d.SetCoord(sol(3),sol(4)); |
43 | Iter = domain2; |
44 | } |
45 | Iter->Init(); |
46 | while (Iter->More()) { |
47 | nbarc++; |
48 | if (OnFirst) { |
49 | ok = TheBlendTool::Project(pt2d,surf1,Iter->Value(),prm,dist); |
50 | } |
51 | else { |
52 | ok = TheBlendTool::Project(pt2d,surf2,Iter->Value(),prm,dist); |
53 | } |
54 | if (ok) { |
55 | if (dist<distmin) { |
56 | yamin = Standard_True; |
57 | distmin = dist; |
58 | pmin = prm; |
59 | Indexsol = nbarc; |
60 | } |
61 | } |
62 | Iter->Next(); |
63 | } |
64 | |
65 | IsVtx = Standard_False; |
66 | if (!yamin) { |
67 | return Standard_False; |
68 | } |
69 | |
70 | Iter->Init(); |
71 | nbarc = 1; |
72 | while (nbarc < Indexsol) { |
73 | nbarc++; |
74 | Iter->Next(); |
75 | } |
76 | |
77 | TheArc thearc = Iter->Value(); |
78 | Handle(Adaptor2d_HCurve2d) thecur; |
79 | if (OnFirst) { |
80 | thecur = TheBlendTool::CurveOnSurf(thearc,surf1); |
81 | } |
82 | else { |
83 | thecur = TheBlendTool::CurveOnSurf(thearc,surf2); |
84 | } |
85 | |
86 | FuncInv.Set(OnFirst,thecur); |
87 | |
88 | FuncInv.GetTolerance(toler,tolesp); |
89 | FuncInv.GetBounds(infb,supb); |
90 | solrst(1) = pmin; |
91 | solrst(2) = param; |
92 | |
93 | if (OnFirst) { |
94 | solrst(3) = sol(3); |
95 | solrst(4) = sol(4); |
96 | } |
97 | else { |
98 | solrst(3) = sol(1); |
99 | solrst(4) = sol(2); |
100 | } |
101 | |
102 | math_FunctionSetRoot rsnld(FuncInv,toler,30); |
103 | rsnld.Perform(FuncInv,solrst,infb,supb); |
104 | |
105 | |
106 | |
107 | if (!rsnld.IsDone()) { |
0797d9d3 |
108 | #ifdef OCCT_DEBUG |
04232180 |
109 | std::cout << "RSNLD not done "<< std::endl << std::endl; |
aefdc31b |
110 | #endif |
7fd59977 |
111 | return Standard_False; |
112 | } |
113 | |
114 | // On doit verifier la valeur de la fonction |
115 | rsnld.Root(solrst); |
116 | |
117 | if (FuncInv.IsSolution(solrst,tolesp)) { |
118 | |
119 | // if (OnFirst) { |
120 | // situ = TheTopolTool::Classify(surf2,gp_Pnt2d(solrst(3),solrst(4)), |
121 | // Max(toler(3),toler(4))); |
122 | // |
123 | // } |
124 | // else { |
125 | // situ = TheTopolTool::Classify(surf1,gp_Pnt2d(solrst(3),solrst(4)), |
126 | // Max(toler(3),toler(4))); |
127 | // } |
128 | |
129 | if (OnFirst) { |
130 | situ = domain2->Classify(gp_Pnt2d(solrst(3),solrst(4)), |
131 | Min(toler(3),toler(4))); |
132 | |
133 | } |
134 | else { |
135 | situ = domain1->Classify(gp_Pnt2d(solrst(3),solrst(4)), |
136 | Min(toler(3),toler(4))); |
137 | } |
138 | |
139 | |
140 | if ((situ != TopAbs_IN) && (situ != TopAbs_ON)) { |
141 | return Standard_False; |
142 | } |
143 | |
144 | Iter->Initialize(thearc); |
145 | Iter->InitVertexIterator(); |
146 | IsVtx = !Iter->MoreVertex(); |
147 | while (!IsVtx) { |
148 | Vtx = Iter->Vertex(); |
149 | if (Abs(TheBlendTool::Parameter(Vtx,thearc)-solrst(1)) <= |
150 | TheBlendTool::Tolerance(Vtx,thearc)) { |
151 | IsVtx = Standard_True; |
152 | } |
153 | else { |
154 | Iter->NextVertex(); |
155 | IsVtx = !Iter->MoreVertex(); |
156 | } |
157 | } |
158 | if (!Iter->MoreVertex()) { |
159 | IsVtx = Standard_False; |
160 | } |
161 | |
162 | return Standard_True; |
163 | } |
164 | |
165 | return Standard_False; |
166 | } |
167 | |
168 | */ |
169 | |
170 | |
171 | void Blend_CSWalking::Transition(const TheArc& A, |
172 | const Standard_Real Param, |
173 | IntSurf_Transition& TLine, |
174 | IntSurf_Transition& TArc) |
175 | { |
176 | |
177 | gp_Pnt2d p2d; |
178 | gp_Vec2d dp2d; |
179 | |
180 | gp_Pnt pbid; |
181 | gp_Vec d1u,d1v,normale,tgrst; |
182 | |
183 | TheArcTool::D1(A,Param,p2d,dp2d); |
184 | TheSurfaceTool::D1(surf,p2d.X(),p2d.Y(),pbid,d1u,d1v); |
185 | |
186 | tgrst.SetLinearForm(dp2d.X(),d1u,dp2d.Y(),d1v); |
187 | normale = d1u.Crossed(d1v); |
188 | |
189 | IntSurf::MakeTransition(previousP.TangentOnS(),tgrst,normale,TLine,TArc); |
190 | |
191 | } |
192 | |
193 | |
194 | void Blend_CSWalking::MakeExtremity(TheExtremity& Extrem, |
195 | const Standard_Integer Index, |
196 | const Standard_Real Param, |
197 | const Standard_Boolean IsVtx, |
198 | const TheVertex& Vtx) |
199 | { |
200 | |
201 | IntSurf_Transition Tline,Tarc; |
202 | Standard_Real prm,U,V; |
203 | Standard_Integer nbarc; |
204 | Handle(TheTopolTool) Iter; |
205 | |
206 | // Extrem.SetValue(previousP.PointOnS(),sol(1),sol(2),tolesp); |
207 | previousP.ParametersOnS(U,V); |
208 | Extrem.SetValue(previousP.PointOnS(),U,V,previousP.Parameter(),tolesp); |
209 | Iter = domain; |
210 | |
211 | |
212 | Iter->Init(); |
213 | nbarc = 1; |
214 | |
215 | if (!IsVtx) { |
216 | while (nbarc < Index) { |
217 | nbarc++; |
218 | Iter->Next(); |
219 | } |
220 | Transition(Iter->Value(),Param,Tline,Tarc); |
221 | Extrem.AddArc(Iter->Value(),Param,Tline,Tarc); |
222 | } |
223 | |
224 | else { |
225 | |
226 | Extrem.SetVertex(Vtx); |
227 | while (Iter->More()) { |
228 | TheArc arc = Iter->Value(); |
229 | if (nbarc != Index) { |
230 | Iter->Initialize(arc); |
231 | Iter->InitVertexIterator(); |
232 | while (Iter->MoreVertex()) { |
233 | // if (TheTopolTool::Identical(Vtx,Iter.Vertex())) { |
234 | if (Iter->Identical(Vtx,Iter->Vertex())) { |
235 | prm = TheBlendTool::Parameter(Vtx,arc); |
236 | Transition(arc,prm,Tline,Tarc); |
237 | Extrem.AddArc(arc,prm,Tline,Tarc); |
238 | } |
239 | Iter->NextVertex(); |
240 | } |
241 | } |
242 | else { |
243 | Transition(arc,Param,Tline,Tarc); |
244 | Extrem.AddArc(arc,Param,Tline,Tarc); |
245 | } |
246 | nbarc++; |
247 | Iter->Next(); |
248 | } |
249 | } |
250 | } |