//-- File IntWalk_IWalking_3.gxx #ifndef DEB #define No_Standard_RangeError #define No_Standard_OutOfRange #endif // modified by NIZHNY-MKK Thu Nov 2 15:07:26 2000.BEGIN static Standard_Boolean TestPassedSolutionWithNegativeState(const TColStd_SequenceOfInteger& etat, const TColStd_SequenceOfReal& Umult, const TColStd_SequenceOfReal& Vmult, const TColStd_SequenceOfReal& ustart, const TColStd_SequenceOfReal& vstart, const Standard_Real& prevUp, const Standard_Real& prevVp, const TColStd_SequenceOfInteger& nbMultiplicities, const math_Vector& tolerance, TheIWFunction& sp, math_Vector& UV, Standard_Integer& Irang); // modified by NIZHNY-MKK Thu Nov 2 15:07:39 2000.END void IntWalk_IWalking::ComputeOpenLine(const TColStd_SequenceOfReal& Umult, const TColStd_SequenceOfReal& Vmult, const ThePOPIterator& Pnts1, TheIWFunction& Func, Standard_Boolean& Rajout) // traitement ligne ouvert. // // 1) pour tout point de depart non passant et non tangent et non encore traite // calcul du pas d'avancement = pas en fonction de la fleche et du pas max. // // 2) calcul d'un point approche (ce point est sur la tangente a la section // de distance = pas du point interieur) // // 3) tant que { // (l'ensemble des points calcules ne depassent pas un point dans la // liste des points de depart) // ou // (l'ensemble des points ne forme pas une ligne ouverte allant // d 'une frontiere du domaine a un autre ou d un point de tangence // a une frontiere ou de 2 points de tangence : cas singuliers) // // 1) cadrage du point approche sur les frontieres si necessaire (il // y a calcul du pas) // 2) calcul du point // 3) si point non trouve on divise le pas // 4) tests d'arrets // 5) calcul du pas en fonction de la fleche et du pas maxi, // (TestDeflection) // arret possible. // fin tant que. { Standard_Integer I, N; static math_Vector BornInf(1,2), BornSup(1,2), UVap(1,2); Standard_Real PasC, PasCu, PasCv; Standard_Boolean Arrive; // indique si ligne terminee Standard_Boolean Cadre; //indique si on est sur frontiere du domaine Standard_Boolean ArretAjout; //indique si on est sur point ajoute IntSurf_PntOn2S Psol; Handle(IntWalk_TheIWLine) CurrentLine; // ligne en construction Standard_Boolean Tgtend; IntWalk_StatusDeflection Status, StatusPrecedent; Standard_Integer NbDivision; // nombre de fois que l on a divise le pas pour une section Standard_Integer StepSign; ThePointOfPath PathPnt; BornInf(1) = Um; BornSup(1) = UM; BornInf(2) = Vm; BornSup(2) = VM; math_FunctionSetRoot Rsnld(Func, tolerance); Standard_Integer nbPath = Pnts1.Length(); // modified by NIZHNY-MKK Fri Oct 27 12:32:34 2000.BEGIN TColStd_SequenceOfInteger movementdirectioninfo; for (I = 1; I <= nbPath; I++) { movementdirectioninfo.Append(0); } // modified by NIZHNY-MKK Fri Oct 27 12:32:38 2000.END for (I = 1; I <= nbPath; I++) { //point de depart de cheminement // if (etat1(I) > 11) { // modified by NIZHNY-MKK Fri Oct 27 12:33:37 2000.BEGIN if ((etat1(I) > 11) || ((etat1(I) < -11) && (movementdirectioninfo(I)!=0))) { // modified by NIZHNY-MKK Fri Oct 27 12:33:43 2000.END PathPnt = Pnts1.Value(I); CurrentLine = new IntWalk_TheIWLine (); CurrentLine->SetTangencyAtBegining(Standard_False); Tgtend = Standard_False; CurrentLine->AddStatusFirst(Standard_False, Standard_True, I, PathPnt); UVap(1) = ustart1(I); UVap(2) = vstart1(I); MakeWalkingPoint(11, UVap(1), UVap(2), Func, previousPoint); previousd3d = Func.Direction3d(); previousd2d = Func.Direction2d(); CurrentLine->AddPoint(previousPoint); // modified by NIZHNY-MKK Fri Oct 27 12:34:32 2000.BEGIN if(movementdirectioninfo(I) !=0) { if(movementdirectioninfo(I) < 0) { StepSign = -1; CurrentLine->SetTangentVector(previousd3d.Reversed(),1); } else { StepSign = 1; CurrentLine->SetTangentVector(previousd3d,1); } } else { Standard_Real tyutuyt=ThePointOfPathTool::Direction3d(PathPnt) * previousd3d; if( tyutuyt < 0) { StepSign = -1; CurrentLine->SetTangentVector(previousd3d.Reversed(),1); } else { StepSign = 1; CurrentLine->SetTangentVector(previousd3d,1); } } // modified by NIZHNY-MKK Fri Oct 27 12:34:37 2000.END // Modified by Sergey KHROMOV - Tue Nov 20 10:41:45 2001 Begin etat1(I) = - abs(etat1(I)); movementdirectioninfo(I) = (movementdirectioninfo(I)==0) ? StepSign : 0; // Modified by Sergey KHROMOV - Tue Nov 20 10:41:56 2001 End // premier pas d avancement Standard_Real d2dx = Abs(previousd2d.X()); Standard_Real d2dy = Abs(previousd2d.Y()); if (d2dx < tolerance(1)) { PasC = pas * (VM-Vm)/d2dy; } else if (d2dy < tolerance(2)) { PasC = pas * (UM-Um)/d2dx; } else { PasC = pas * Min((UM-Um)/d2dx,(VM-Vm)/d2dy); } Arrive = Standard_False; ArretAjout = Standard_False; NbDivision = 0; StatusPrecedent = IntWalk_OK; // modified by NIZHNY-MKK Fri Oct 27 12:39:37 2000 Standard_Integer IndexOfPathPointDoNotCheck=0; while (!Arrive) { // tant que un des tests d arret est non verifie Cadre = Cadrage(BornInf,BornSup,UVap,PasC,StepSign); // Frontiere? #ifdef CHRONO Chronrsnld.Start(); #endif Rsnld.Perform(Func,UVap,BornInf,BornSup); #ifdef CHRONO Chronrsnld.Stop(); #endif if (Cadre) { BornInf(1) = Um; BornSup(1) = UM; BornInf(2) = Vm; BornSup(2) = VM; } if (Rsnld.IsDone()) { if (Abs(Func.Root()) > Func.Tolerance()) { PasC = PasC / 2.0; PasCu = Abs(PasC*previousd2d.X()); PasCv = Abs(PasC*previousd2d.Y()); if (PasCu <= tolerance(1) && PasCv <= tolerance(2)) { if (CurrentLine->NbPoints() == 1) break; Arrive = Standard_True; CurrentLine->AddStatusLast(Standard_False); Tgtend = Standard_True; // a voir Rajout = Standard_True; seqAjout.Append(lines.Length() + 1); } } else { // test arret Rsnld.Root(UVap); Arrive = TestArretPassage(Umult, Vmult, Func, UVap, N); if (Arrive) { Cadre = Standard_False; //au cas ou on aurait cadre et arrive en meme temps } else { if (Rajout) { ArretAjout =TestArretAjout(Func, UVap, N, Psol); if (ArretAjout) { // jag 940615 Tgtend = lines.Value(N)->IsTangentAtEnd(); N = -N; } } // modified by NIZHNY-MKK Thu Nov 2 15:09:08 2000.BEGIN if(!(Rajout && ArretAjout)) { Standard_Real prevUp, prevVp; if (!reversed) { previousPoint.ParametersOnS2(prevUp, prevVp); } else { previousPoint.ParametersOnS1(prevUp, prevVp); } Arrive = TestPassedSolutionWithNegativeState(etat1, Umult, Vmult, ustart1, vstart1, prevUp, prevVp, nbMultiplicities, tolerance, Func, UVap, N); if(Arrive) { Cadre = Standard_False; } } // modified by NIZHNY-MKK Thu Nov 2 15:09:13 2000.END if (!ArretAjout && Cadre) { if (CurrentLine->NbPoints() == 1) break; // annuler la ligne TestArretCadre(Umult, Vmult, CurrentLine, Func, UVap, N); // if (N == 0) { if (N <= 0) { // jag 941017 MakeWalkingPoint(2, UVap(1), UVap(2), Func, Psol); Tgtend = Func.IsTangent(); N = -N; } } } Status = TestDeflection(Func, Arrive, UVap, StatusPrecedent, NbDivision,PasC,StepSign); StatusPrecedent = Status; if (Status == IntWalk_PasTropGrand) { Arrive = Standard_False; ArretAjout = Standard_False; Tgtend = Standard_False; // jag 940615 if (!reversed) { previousPoint.ParametersOnS2(UVap(1), UVap(2)); } else { previousPoint.ParametersOnS1(UVap(1), UVap(2)); } } else if (ArretAjout || Cadre) { Arrive = Standard_True; CurrentLine->AddStatusLast(Standard_False); if (Status != IntWalk_ArretSurPointPrecedent) { CurrentLine->AddPoint(Psol); } if (Cadre && N==0) { Rajout = Standard_True; seqAjout.Append(lines.Length()+1); } } else if (Status == IntWalk_ArretSurPointPrecedent) { if (CurrentLine->NbPoints() == 1) { //annuler la ligne Arrive = Standard_False; break; } Arrive = Standard_True; Rajout = Standard_True; seqAjout.Append(lines.Length() + 1); CurrentLine->AddStatusLast(Standard_False); Tgtend = Standard_True; // a voir } else if (Arrive) { if (CurrentLine->NbPoints() == 1 && // annuler la ligne (N == I || Status == IntWalk_PointConfondu) ) { // si N == I on s est probablement trompe de uv // principal ou bien le point // est un point d accumulation // si point confondu les donnees de depart sont mauvaises Arrive = Standard_False; break; } // on a necessairement N > 0 jag 940617 // point d arret donne en entree PathPnt = Pnts1.Value(N); Standard_Integer etat1N=etat1(N); // modified by NIZHNY-MKK Thu Nov 2 15:09:51 2000.BEGIN // if (etat1N < 11) { // point passant qui est un arret if (Abs(etat1N) < 11) { // point passant qui est un arret // modified by NIZHNY-MKK Thu Nov 2 15:12:11 2000.END if (Status == IntWalk_ArretSurPoint) { CurrentLine->AddStatusLast(Standard_False); Tgtend = Standard_True; // a voir } else { Arrive = Standard_False; } CurrentLine->AddIndexPassing(N); } else { // point d arret donne en entree if (etat1N == 11) { Tgtend = Standard_True; } CurrentLine->AddStatusLast(Standard_True, N, PathPnt); } AddPointInCurrentLine(N,PathPnt,CurrentLine); if ((etat1N != 1 && etat1N != 11)) { // modified by NIZHNY-MKK Fri Oct 27 12:43:05 2000.BEGIN // etat1(N)= - etat1N; etat1(N)= - Abs(etat1N); movementdirectioninfo(N) = (movementdirectioninfo(N)==0) ? StepSign : 0; if(Arrive && movementdirectioninfo(N)!=0) { IndexOfPathPointDoNotCheck = N; } if(Arrive) { Rajout = Standard_True; seqAjout.Append(lines.Length() + 1); } // modified by NIZHNY-MKK Fri Oct 27 12:45:33 2000.END } } else if (Status == IntWalk_ArretSurPoint) { Arrive = Standard_True; CurrentLine->AddStatusLast(Standard_False); Tgtend = Standard_True; MakeWalkingPoint(1, UVap(1), UVap(2), Func, Psol); CurrentLine->AddPoint(Psol); Rajout = Standard_True; seqAjout.Append(lines.Length() + 1); } else if (Status == IntWalk_OK) { MakeWalkingPoint(2, UVap(1), UVap(2), Func, previousPoint); previousd3d = Func.Direction3d(); previousd2d = Func.Direction2d(); CurrentLine->AddPoint(previousPoint); } } } else { // pas de solution numerique PasC = PasC / 2.; PasCu = Abs(PasC*previousd2d.X()); PasCv = Abs(PasC*previousd2d.Y()); if (PasCu <= tolerance(1) && PasCv <= tolerance(2)) { if (CurrentLine->NbPoints()==1) break; Arrive = Standard_True; CurrentLine->AddStatusLast(Standard_False); Tgtend = Standard_True; // a voir Rajout = Standard_True; seqAjout.Append(lines.Length() + 1); } } } // fin de la ligne commencee if (Arrive) { CurrentLine->SetTangencyAtEnd(Tgtend); lines.Append(CurrentLine); // modified by NIZHNY-MKK Fri Oct 27 12:59:29 2000.BEGIN movementdirectioninfo(I)=0; if(etat1(I) > 0) // modified by NIZHNY-MKK Fri Oct 27 12:59:42 2000.END etat1(I)=-etat1(I); //-- lbr le 5 juin 97 (Pb ds Contap) for(Standard_Integer av=1; av<=nbPath; av++) { // modified by NIZHNY-MKK Fri Oct 27 13:00:22 2000.BEGIN // if (etat1(av) > 11) { if ((etat1(av) > 11) || ((av!=I) && (av!=IndexOfPathPointDoNotCheck) && (etat1(av) < -11) && (movementdirectioninfo(av)!=0))) { // modified by NIZHNY-MKK Fri Oct 27 13:00:26 2000.END Standard_Real Uav=ustart1(av); Standard_Real Vav=vstart1(av); Standard_Real Uavp,Vavp; const IntSurf_PntOn2S &avP=CurrentLine->Value(CurrentLine->NbPoints()); if (!reversed) { avP.ParametersOnS2(Uavp,Vavp); } else { avP.ParametersOnS1(Uavp,Vavp); } Uav-=Uavp; Vav-=Vavp; Uav*=0.001; Vav*=0.001; if(Abs(Uav)AddStatusLast(Standard_True, av, Pnts1.Value(av)); //-- cout<<"\n Debug ? lbr ds IntWalk_IWalking_3.gxx"<Value(1); if (!reversed) { avPP.ParametersOnS2(Uavp,Vavp); } else { avPP.ParametersOnS1(Uavp,Vavp); } Uav=ustart1(av); Vav=vstart1(av); Uav-=Uavp; Vav-=Vavp; Uav*=0.001; Vav*=0.001; if(Abs(Uav)AddStatusFirst(Standard_False, Standard_True, av, Pnts1.Value(av)); } } } } } //fin de traitement d un point } //fin de tous les points } // modified by NIZHNY-MKK Thu Nov 2 15:07:53 2000.BEGIN static Standard_Boolean TestPassedSolutionWithNegativeState(const TColStd_SequenceOfInteger& etat, const TColStd_SequenceOfReal& Umult, const TColStd_SequenceOfReal& Vmult, const TColStd_SequenceOfReal& ustart, const TColStd_SequenceOfReal& vstart, const Standard_Real& prevUp, const Standard_Real& prevVp, const TColStd_SequenceOfInteger& nbMultiplicities, const math_Vector& tolerance, TheIWFunction& sp, math_Vector& UV, Standard_Integer& Irang) { Standard_Boolean Arrive = Standard_False; Standard_Real Dup, Dvp, Utest,Vtest; Standard_Real tolu = tolerance(1); Standard_Real tolv = tolerance(2); Standard_Integer i, j, k, N; for (i = 1; i <= etat.Length(); i++) { if (etat(i) < -11) { // debug jag voir avec isg Utest = ustart(i); Vtest = vstart(i); Dup = prevUp - Utest; Dvp = prevVp - Vtest; if (Abs(Dup) >= tolu || Abs(Dvp) >= tolv) { Standard_Real UV1mUtest = UV(1)-Utest; Standard_Real UV2mVtest = UV(2)-Vtest; if(( (Dup*UV1mUtest + Dvp*UV2mVtest) < 0) || ( Abs(UV1mUtest) < tolu && Abs(UV2mVtest) < tolv)) { Irang=i; Arrive = Standard_True; UV(1) = Utest; UV(2) = Vtest; } else if (nbMultiplicities(i) > 0) { N=0; for (k = 1; k < i; k++) { N+=nbMultiplicities(k); } for (j = N + 1; j <= N + nbMultiplicities(i); j++) { if (((prevUp-Umult(j))*(UV(1)-Umult(j)) + (prevVp-Vmult(j))*(UV(2)-Vmult(j)) < 0) || (Abs(UV(1)-Umult(j)) < tolu && Abs(UV(2)-Vmult(j)) < tolv)) { Irang=i; Arrive = Standard_True; UV(1) = Utest; UV(2) = Vtest; break; } } } if (Arrive) { static math_Vector bidF(1,1); static math_Matrix bidD(1,1,1,2); sp.Values(UV,bidF,bidD); break; } } } } return Arrive; } // modified by NIZHNY-MKK Thu Nov 2 15:07:58 2000.END