Warning, /include/opencascade/Blend_CSWalking_4.gxx is written in an unsupported language. File is not indexed.
0001 // Copyright (c) 1995-1999 Matra Datavision
0002 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0003 //
0004 // This file is part of Open CASCADE Technology software library.
0005 //
0006 // This library is free software; you can redistribute it and/or modify it under
0007 // the terms of the GNU Lesser General Public License version 2.1 as published
0008 // by the Free Software Foundation, with special exception defined in the file
0009 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0010 // distribution for complete text of the license and disclaimer of any warranty.
0011 //
0012 // Alternatively, this file may be used under the terms of Open CASCADE
0013 // commercial license or contractual agreement.
0014
0015 void Blend_CSWalking::InternalPerform(Blend_CSFunction& Func,
0016 // Blend_CSFuncInv& FuncInv,
0017 math_Vector& sol,
0018 const Standard_Real Bound)
0019 {
0020
0021 Standard_Real stepw = pasmax;
0022 Standard_Real parprec = param;
0023
0024 Blend_Status State;
0025 TopAbs_State situ;
0026 Standard_Real w,U,V;
0027 Standard_Integer nbarc;
0028 Standard_Integer Index = 0;
0029 Standard_Boolean Isvtx = Standard_False;
0030 Standard_Integer Nbvar = Func.NbVariables();
0031 Standard_Boolean Arrive,recad,echecrecad;
0032 gp_Pnt2d p2d;
0033 // math_Vector tolerance(1,3),infbound(1,3),supbound(1,3),parinit(1,3);
0034 // math_Vector solrst(1,3);
0035 math_Vector tolerance(1,Nbvar),infbound(1,Nbvar),supbound(1,Nbvar),
0036 parinit(1,Nbvar);
0037 math_Vector solrst(1,Nbvar);
0038 TheVertex Vtx;
0039 TheExtremity Exts,Extc;
0040
0041 //IntSurf_Transition Tline,Tarc;
0042
0043 Func.GetTolerance(tolerance,tolpoint3d);
0044 Func.GetBounds(infbound,supbound);
0045
0046 math_FunctionSetRoot rsnld(Func,tolerance,30);
0047 parinit = sol;
0048
0049 param = parprec + sens*stepw;
0050 Arrive = (sens *(param - Bound) > 0.) ;
0051
0052 // if (Arrive) {
0053 // line->Clear();
0054 // }
0055
0056 while (!Arrive) {
0057
0058 Func.Set(param);
0059 rsnld.Perform(Func,parinit,infbound,supbound);
0060
0061 if (!rsnld.IsDone()) {
0062 State = Blend_StepTooLarge;
0063 }
0064 else {
0065 rsnld.Root(sol);
0066
0067 // situ1 = TheTopolTool::Classify(surf1,gp_Pnt2d(sol(1),sol(2)),
0068 // Max(tolerance(1),tolerance(2)));
0069 // situ2 = TheTopolTool::Classify(surf2,gp_Pnt2d(sol(3),sol(4)),
0070 // Max(tolerance(3),tolerance(4)));
0071 /*
0072 situ = domain->Classify(gp_Pnt2d(sol(1),sol(2)),
0073 Min(tolerance(1),tolerance(2)));
0074 */
0075 situ = domain->Classify(Func.Pnt2d(),
0076 Min(tolerance(1),tolerance(2)));
0077
0078 w = Bound;
0079 recad = Standard_False;
0080 echecrecad = Standard_False;
0081
0082 if (situ == TopAbs_OUT || situ == TopAbs_ON) {
0083 // pb inverse sur surf
0084 // recad = Recadre(FuncInv,sol,solrst,Index,Isvtx,Vtx);
0085 Isvtx = Standard_False; // en attendant Recadre
0086 if (recad) {
0087 w = solrst(2);
0088 }
0089 else {
0090 echecrecad = Standard_True;
0091 }
0092 }
0093 if (!echecrecad) {
0094 if (recad) {
0095
0096 // sol sur surf
0097 State = Blend_OnRst1;
0098 param = w;
0099 domain->Init();
0100 nbarc = 1;
0101 while (nbarc < Index) {
0102 nbarc++;
0103 domain->Next();
0104 }
0105 p2d = TheArcTool::Value(domain->Value(),solrst(1));
0106 sol(1) = p2d.X();
0107 sol(2) = p2d.Y();
0108 sol(3) = solrst(3);
0109 Func.Set(param);
0110 }
0111 else {
0112 State = Blend_OK;
0113 }
0114 State = TestArret(Func,sol,Standard_True,State);
0115 }
0116 else {
0117 // Echec recadrage. On sort avec PointsConfondus
0118 State = Blend_SamePoints;
0119 }
0120 }
0121
0122 switch (State) {
0123 case Blend_OK :
0124 {
0125 #ifdef OCCT_DEBUG
0126 if (Blend_GettraceDRAWSECT()){
0127 Drawsect(surf,curv,param,Func);
0128 }
0129 #endif
0130
0131 // Mettre a jour la ligne.
0132 if (sens>0.) {
0133 line->Append(previousP);
0134 }
0135 else {
0136 line->Prepend(previousP);
0137 }
0138 parinit = sol;
0139 parprec = param;
0140
0141 if (param == Bound) {
0142 Arrive = Standard_True;
0143 /*
0144 Exts.SetValue(previousP.PointOnS(),sol(1),sol(2),tolesp);
0145 Extc.SetValue(previousP.PointOnC(),sol(3),tolesp);
0146 */
0147 previousP.ParametersOnS(U,V);
0148 Exts.SetValue(previousP.PointOnS(),U,V,
0149 previousP.Parameter(),tolpoint3d);
0150 Extc.SetValue(previousP.PointOnC(),previousP.ParameterOnC(),
0151 previousP.Parameter(),tolpoint3d);
0152 // Indiquer que fin sur Bound.
0153 }
0154 else {
0155 param = param + sens*stepw;
0156 if (sens*(param - Bound) > - tolgui) {
0157 param = Bound;
0158 }
0159 }
0160
0161 }
0162 break;
0163
0164 case Blend_StepTooLarge :
0165 {
0166 stepw = stepw/2.;
0167 if (Abs(stepw) < tolgui) {
0168 /*
0169 Exts.SetValue(previousP.PointOnS(),sol(1),sol(2),tolesp);
0170 Extc.SetValue(previousP.PointOnC(),sol(3),sol(4),tolesp);
0171 */
0172 previousP.ParametersOnS(U,V);
0173 Exts.SetValue(previousP.PointOnS(),U,V,
0174 previousP.Parameter(),tolpoint3d);
0175 Extc.SetValue(previousP.PointOnC(),previousP.ParameterOnC(),
0176 previousP.Parameter(),tolpoint3d);
0177 Arrive = Standard_True;
0178 if (line->NbPoints()>=2) {
0179 // Indiquer qu on s arrete en cours de cheminement
0180 }
0181 // else {
0182 // line->Clear();
0183 // }
0184 }
0185 else {
0186 param = parprec + sens*stepw; // on ne risque pas de depasser Bound.
0187 }
0188 }
0189 break;
0190
0191 case Blend_StepTooSmall :
0192 {
0193 #ifdef OCCT_DEBUG
0194 if (Blend_GettraceDRAWSECT()){
0195 Drawsect(surf,curv,param,Func);
0196 }
0197 #endif
0198 // Mettre a jour la ligne.
0199 if (sens>0.) {
0200 line->Append(previousP);
0201 }
0202 else {
0203 line->Prepend(previousP);
0204 }
0205 parinit = sol;
0206 parprec = param;
0207
0208 stepw = Min(1.5*stepw,pasmax);
0209 if (param == Bound) {
0210 Arrive = Standard_True;
0211 /*
0212 Exts.SetValue(previousP.PointOnS(),sol(1),sol(2),tolesp);
0213 Extc.SetValue(previousP.PointOnC(),sol(3),tolesp);
0214 */
0215 previousP.ParametersOnS(U,V);
0216 Exts.SetValue(previousP.PointOnS(),U,V,
0217 previousP.Parameter(),tolpoint3d);
0218 Extc.SetValue(previousP.PointOnC(),previousP.ParameterOnC(),
0219 previousP.Parameter(),tolpoint3d);
0220 // Indiquer que fin sur Bound.
0221 }
0222 else {
0223 param = param + sens*stepw;
0224 if (sens*(param - Bound) > - tolgui) {
0225 param = Bound;
0226 }
0227 }
0228 }
0229 break;
0230
0231 case Blend_OnRst1 :
0232 {
0233 #ifdef OCCT_DEBUG
0234 if (Blend_GettraceDRAWSECT()){
0235 Drawsect(surf,curv,param,Func);
0236 }
0237 #endif
0238 if (sens>0.) {
0239 line->Append(previousP);
0240 }
0241 else {
0242 line->Prepend(previousP);
0243 }
0244 MakeExtremity(Exts,Index,solrst(1),Isvtx,Vtx);
0245 // Extc.SetValue(previousP.PointOnC(),sol(3),tolesp);
0246 Extc.SetValue(previousP.PointOnC(),previousP.ParameterOnC(),
0247 previousP.Parameter(),tolpoint3d);
0248 Arrive = Standard_True;
0249 }
0250 break;
0251
0252 case Blend_SamePoints :
0253 {
0254 // On arrete
0255 std::cout << " Points confondus dans le cheminement" << std::endl;
0256 /*
0257 Exts.SetValue(previousP.PointOnS(),sol(1),sol(2),tolesp);
0258 Extc.SetValue(previousP.PointOnC(),sol(3),tolesp);
0259 */
0260 previousP.ParametersOnS(U,V);
0261 Exts.SetValue(previousP.PointOnS(),U,V,
0262 previousP.Parameter(),tolpoint3d);
0263 Extc.SetValue(previousP.PointOnC(),previousP.ParameterOnC(),
0264 previousP.Parameter(),tolpoint3d);
0265 Arrive = Standard_True;
0266 }
0267 break;
0268
0269 default:
0270 break;
0271 }
0272 if (Arrive) {
0273 if (sens > 0.) {
0274 line->SetEndPoints(Exts,Extc);
0275 }
0276 else {
0277 line->SetStartPoints(Exts,Extc);
0278
0279 }
0280 }
0281
0282 }
0283
0284 }
0285
0286
0287