1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
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
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.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
16 Standard_Boolean Blend_CSWalking::Recadre(Blend_FuncInv& FuncInv,
17 const Standard_Boolean OnFirst,
18 const math_Vector& sol,
20 Standard_Integer& Indexsol,
21 Standard_Boolean& IsVtx,
25 Standard_Integer nbarc;
26 Standard_Boolean ok,yamin;
27 Standard_Real dist,distmin,prm,pmin;
29 math_Vector toler(1,4),infb(1,4),supb(1,4),valsol(1,4);
31 Handle(TheTopolTool) Iter;
34 yamin = Standard_False;
38 pt2d.SetCoord(sol(1),sol(2));
42 pt2d.SetCoord(sol(3),sol(4));
46 while (Iter->More()) {
49 ok = TheBlendTool::Project(pt2d,surf1,Iter->Value(),prm,dist);
52 ok = TheBlendTool::Project(pt2d,surf2,Iter->Value(),prm,dist);
56 yamin = Standard_True;
65 IsVtx = Standard_False;
67 return Standard_False;
72 while (nbarc < Indexsol) {
77 TheArc thearc = Iter->Value();
78 Handle(Adaptor2d_HCurve2d) thecur;
80 thecur = TheBlendTool::CurveOnSurf(thearc,surf1);
83 thecur = TheBlendTool::CurveOnSurf(thearc,surf2);
86 FuncInv.Set(OnFirst,thecur);
88 FuncInv.GetTolerance(toler,tolesp);
89 FuncInv.GetBounds(infb,supb);
102 math_FunctionSetRoot rsnld(FuncInv,toler,30);
103 rsnld.Perform(FuncInv,solrst,infb,supb);
107 if (!rsnld.IsDone()) {
109 std::cout << "RSNLD not done "<< std::endl << std::endl;
111 return Standard_False;
114 // On doit verifier la valeur de la fonction
117 if (FuncInv.IsSolution(solrst,tolesp)) {
120 // situ = TheTopolTool::Classify(surf2,gp_Pnt2d(solrst(3),solrst(4)),
121 // Max(toler(3),toler(4)));
125 // situ = TheTopolTool::Classify(surf1,gp_Pnt2d(solrst(3),solrst(4)),
126 // Max(toler(3),toler(4)));
130 situ = domain2->Classify(gp_Pnt2d(solrst(3),solrst(4)),
131 Min(toler(3),toler(4)));
135 situ = domain1->Classify(gp_Pnt2d(solrst(3),solrst(4)),
136 Min(toler(3),toler(4)));
140 if ((situ != TopAbs_IN) && (situ != TopAbs_ON)) {
141 return Standard_False;
144 Iter->Initialize(thearc);
145 Iter->InitVertexIterator();
146 IsVtx = !Iter->MoreVertex();
148 Vtx = Iter->Vertex();
149 if (Abs(TheBlendTool::Parameter(Vtx,thearc)-solrst(1)) <=
150 TheBlendTool::Tolerance(Vtx,thearc)) {
151 IsVtx = Standard_True;
155 IsVtx = !Iter->MoreVertex();
158 if (!Iter->MoreVertex()) {
159 IsVtx = Standard_False;
162 return Standard_True;
165 return Standard_False;
171 void Blend_CSWalking::Transition(const TheArc& A,
172 const Standard_Real Param,
173 IntSurf_Transition& TLine,
174 IntSurf_Transition& TArc)
181 gp_Vec d1u,d1v,normale,tgrst;
183 TheArcTool::D1(A,Param,p2d,dp2d);
184 TheSurfaceTool::D1(surf,p2d.X(),p2d.Y(),pbid,d1u,d1v);
186 tgrst.SetLinearForm(dp2d.X(),d1u,dp2d.Y(),d1v);
187 normale = d1u.Crossed(d1v);
189 IntSurf::MakeTransition(previousP.TangentOnS(),tgrst,normale,TLine,TArc);
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)
201 IntSurf_Transition Tline,Tarc;
202 Standard_Real prm,U,V;
203 Standard_Integer nbarc;
204 Handle(TheTopolTool) Iter;
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);
216 while (nbarc < Index) {
220 Transition(Iter->Value(),Param,Tline,Tarc);
221 Extrem.AddArc(Iter->Value(),Param,Tline,Tarc);
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);
243 Transition(arc,Param,Tline,Tarc);
244 Extrem.AddArc(arc,Param,Tline,Tarc);