1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2012 OPEN CASCADE SAS
4 // The content of this file is subject to the Open CASCADE Technology Public
5 // License Version 6.5 (the "License"). You may not use the content of this file
6 // except in compliance with the License. Please obtain a copy of the License
7 // at http://www.opencascade.org and read it completely before using this file.
9 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 // The Original Code and all software distributed under the License is
13 // distributed on an "AS IS" basis, without warranty of any kind, and the
14 // Initial Developer hereby disclaims all such warranties, including without
15 // limitation, any warranties of merchantability, fitness for a particular
16 // purpose or non-infringement. Please see the License for the specific terms
17 // and conditions governing the rights and limitations under the License.
20 // Modified by skv - Tue Aug 31 12:13:51 2004 OCC569
22 #include <Precision.hxx>
23 #include <IntSurf_Quadric.hxx>
26 void FindVertex (const TheArc&,
27 const Handle(TheTopolTool)&,
29 IntStart_SequenceOfPathPoint&,
34 void BoundedArc (const TheArc&,
35 const Handle(TheTopolTool)&,
39 IntStart_SequenceOfPathPoint&,
40 IntStart_SequenceOfSegment&,
47 void InfiniteArc (const TheArc&,
48 const Handle(TheTopolTool)&,
52 IntStart_SequenceOfPathPoint&,
53 IntStart_SequenceOfSegment&,
60 void PointProcess (const gp_Pnt&,
63 const Handle(TheTopolTool)&,
64 IntStart_SequenceOfPathPoint&,
70 Standard_Integer TreatLC (const TheArc& A,
71 const Handle(TheTopolTool)& aDomain,
72 const IntSurf_Quadric& aQuadric,
73 const Standard_Real TolBoundary,
74 IntStart_SequenceOfPathPoint& pnt);
77 Standard_Boolean IsRegularity(const TheArc& A,
78 const Handle(TheTopolTool)& aDomain);
81 //=======================================================================
82 //function : FindVertex
84 //=======================================================================
85 void FindVertex (const TheArc& A,
86 const Handle(TheTopolTool)& Domain,
88 IntStart_SequenceOfPathPoint& pnt,
89 const Standard_Real Toler)
92 // Recherche des vertex de l arc de restriction A solutions. On stocke les
93 // vertex solutions dans la liste pnt.
98 Standard_Real param,valf;
99 Standard_Integer itemp;
101 // Domain.InitVertexIterator(A);
102 Domain->Initialize(A);
103 Domain->InitVertexIterator();
104 while (Domain->MoreVertex()) {
105 vtx = Domain->Vertex();
106 param = TheSOBTool::Parameter(vtx,A);
108 // Evaluer la fonction et regarder par rapport a la tolerance
109 // du vertex. Si la distance <= tolerance alors ajouter le vertex a
110 // la liste des points solutions
111 // L arc est suppose deja charge dans la fonction.
113 Func.Value(param,valf);
114 if (Abs(valf) <= Toler) {
115 itemp = Func.GetStateNumber();
116 pnt.Append(IntStart_ThePathPoint(Func.Valpoint(itemp),Toler,
118 // on rajoute la solution
120 Domain->NextVertex();
125 //=======================================================================
126 //function : BoundedArc
128 //=======================================================================
129 void BoundedArc (const TheArc& A,
130 const Handle(TheTopolTool)& Domain,
131 const Standard_Real Pdeb,
132 const Standard_Real Pfin,
134 IntStart_SequenceOfPathPoint& pnt,
135 IntStart_SequenceOfSegment& seg,
136 const Standard_Real TolBoundary,
137 const Standard_Real TolTangency,
138 Standard_Boolean& Arcsol,
139 const Standard_Boolean RecheckOnRegularity)
142 // Recherche des points solutions et des bouts d arc solution sur un arc donne.
143 // On utilise la fonction math_FunctionAllRoots. Ne convient donc que pour
144 // des arcs ayant un point debut et un point de fin (intervalle ferme de
147 Standard_Integer i,Nbi,Nbp;
150 Standard_Real pardeb,parfin;
151 Standard_Integer ideb,ifin,range,ranged,rangef;
154 // Creer l echantillonage (math_FunctionSample ou classe heritant)
155 // Appel a math_FunctionAllRoots
157 Standard_Real EpsX = TheArcTool::Resolution(A,Precision::Confusion());
158 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
159 //@@@ La Tolerance est asociee a l arc ( Incoherence avec le cheminement )
160 //@@@ ( EpsX ~ 1e-5 et ResolutionU et V ~ 1e-9 )
161 //@@@ le vertex trouve ici n'est pas retrouve comme point d arret d une
162 //@@@ ligne de cheminement
163 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
165 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
166 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
167 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
169 // Standard_Integer NbEchant = TheSOBTool::NbSamplesOnArc(A);
170 Standard_Integer NbEchant = Func.NbSamples();
172 //-- Modif 24 Aout 93 -----------------------------
173 Standard_Real nTolTangency = TolTangency;
174 if((Pfin - Pdeb) < (TolTangency*10.0)) {
175 nTolTangency=(Pfin-Pdeb)*0.1;
177 if(EpsX>(nTolTangency+nTolTangency)) {
178 EpsX = nTolTangency * 0.1;
180 //--------------------------------------------------
181 //-- Plante avec un edge avec 2 Samples
182 //-- dont les extremites son solutions (f=0)
183 //-- et ou la derivee est nulle
184 //-- Exemple : un segment diametre d une sphere
185 //-- if(NbEchant<3) NbEchant = 3; //-- lbr le 19 Avril 95
186 //--------------------------------------------------
187 Standard_Real para=0,dist,maxdist;
188 /* if(NbEchant<20) NbEchant = 20; //-- lbr le 22 Avril 96
189 //-- Toujours des pbs
191 if(NbEchant<100) NbEchant = 100; //-- lbr le 22 Avril 96
192 //-- Toujours des pbs
195 //-------------------------------------------------------------- REJECTIONS le 15 oct 98
196 Standard_Boolean Rejection=Standard_True;
197 Standard_Real maxdr,maxr,minr,ur,dur;
202 for(i=1,ur=Pdeb;i<=6;i++) {
204 if(Func.Values(ur,F,D)) {
205 Standard_Real lminr,lmaxr;
211 if(lminr<minr) minr=lminr;
212 if(lmaxr>maxr) maxr=lmaxr;
213 if(minr<0.0 && maxr>0.0) {
214 Rejection=Standard_False;
220 dur=0.001+maxdr+(maxr-minr)*0.1;
223 if(minr<0.0 && maxr>0.0) {
224 Rejection=Standard_False;
227 Arcsol=Standard_False;
229 if(Rejection==Standard_False) {
230 math_FunctionSample Echant(Pdeb,Pfin,NbEchant);
232 Standard_Boolean aelargir=Standard_True;
233 //modified by NIZNHY-PKV Thu Apr 12 09:25:19 2001 f
235 //maxdist = 100.0*TolBoundary;
236 maxdist = TolBoundary+TolTangency;
238 //modified by NIZNHY-PKV Thu Apr 12 09:25:23 2001 t
239 for(i=1; i<=NbEchant && aelargir;i++) {
240 Standard_Real u = Echant.GetParameter(i);
241 if(Func.Value(u,dist)) {
242 if(dist>maxdist || -dist>maxdist) {
243 aelargir=Standard_False;
247 if(aelargir && maxdist<0.01) {
249 //-- cout<<"\n Tolerance elargie a "<<maxdist<<" dans IntStart_SearchOnBoundaries_1.gxx"<<endl;
253 maxdist = TolBoundary;
256 math_FunctionAllRoots Sol(Func,Echant,EpsX,maxdist,maxdist); //-- TolBoundary,nTolTangency);
258 if (!Sol.IsDone()) {Standard_Failure::Raise();}
262 //jgv: build solution on the whole boundary
263 if (RecheckOnRegularity && Nbp > 0 && IsRegularity(A, Domain))
265 //Standard_Real theTol = Domain->MaxTolerance(A);
267 Standard_Real theTol = 5.e-4;
268 math_FunctionAllRoots SolAgain(Func,Echant,EpsX,theTol,theTol); //-- TolBoundary,nTolTangency);
270 if (!SolAgain.IsDone()) {Standard_Failure::Raise();}
272 Standard_Integer Nbp_again = SolAgain.NbPoints();
273 Standard_Integer Nbi_again = SolAgain.NbIntervals();
277 Standard_Integer NbSamples = 10;
278 Standard_Real delta = (Pfin - Pdeb)/NbSamples;
279 Standard_Real GlobalTol = theTol*10;
280 Standard_Boolean SolOnBoundary = Standard_True;
281 for (i = 0; i <= NbSamples; i++)
283 Standard_Real aParam = Pdeb + i*delta;
284 Standard_Real aValue;
285 Func.Value(aParam, aValue);
286 if (Abs(aValue) > GlobalTol)
288 SolOnBoundary = Standard_False;
295 for (i = 1; i <= Nbi_again; i++)
297 IntStart_TheSegment newseg;
299 // Recuperer point debut et fin, et leur parametre.
300 SolAgain.GetInterval(i,pardeb,parfin);
302 if (Abs(pardeb - Pdeb) <= Precision::PConfusion())
304 if (Abs(parfin - Pfin) <= Precision::PConfusion())
307 SolAgain.GetIntervalState(i,ideb,ifin);
309 //-- cout<<" Debug : IntStart_SearchOnBoundaries_1.gxx : i= "<<i<<" ParDeb:"<<pardeb<<" ParFin:"<<parfin<<endl;
311 ptdeb=Func.Valpoint(ideb);
312 ptfin=Func.Valpoint(ifin);
314 PointProcess(ptdeb,pardeb,A,Domain,pnt,theTol,ranged);
315 newseg.SetLimitPoint(pnt.Value(ranged),Standard_True);
316 PointProcess(ptfin,parfin,A,Domain,pnt,theTol,rangef);
317 newseg.SetLimitPoint(pnt.Value(rangef),Standard_False);
320 Arcsol=Standard_True;
325 ////////////////////////////////////////////
327 //-- detection du cas ou la fonction est quasi tangente et que les
328 //-- zeros sont quasi confondus.
329 //-- Dans ce cas on prend le point "milieu"
330 //-- On suppose que les solutions sont triees.
332 Standard_Real *TabSol=NULL;
334 TabSol = new Standard_Real [Nbp+2];
335 for(i=1;i<=Nbp;i++) {
336 TabSol[i]=Sol.GetPoint(i);
342 if(TabSol[i]>TabSol[i+1]) {
344 para=TabSol[i]; TabSol[i]=TabSol[i+1]; TabSol[i+1]=para;
349 while(ok==Standard_False);
350 //modified by NIZNHY-PKV Wed Mar 21 18:34:18 2001 f
351 //////////////////////////////////////////////////////////
352 // The treatment of the situation when line(arc) that is
353 // tangent to cylinder(domain).
354 // We should have only one solution i.e Nbp=1. Ok?
355 // But we have 2,3,.. solutions. That is wrong ersult.
356 // The TreatLC(...) function is dedicated to solve the pb.
357 // PKV Fri Mar 23 12:17:29 2001
359 const IntSurf_Quadric& aQuadric=Func.Quadric();
361 ip=TreatLC (A, Domain, aQuadric, TolBoundary, pnt);
363 //////////////////////////////////////////////////////////
364 //modified by NIZNHY-PKV Wed Mar 21 18:34:23 2001 t
366 // Using of old usual way proposed by Laurent
369 Standard_Real parap1=TabSol[i+1];
371 Standard_Real param=(para+parap1)*0.5;
373 if(Func.Value(param,ym)) {
374 if(Abs(ym)<maxdist) {
375 // Modified by skv - Tue Aug 31 12:13:51 2004 OCC569 Begin
376 // Consider this interval as tangent one. Treat it to find
377 // parameter with the lowest function value.
379 // Compute the number of nodes.
380 Standard_Real aTol = TolBoundary*1000.0;
384 // fix floating point exception 569, chl-922-e9
385 parap1 = (Abs(parap1) < 1.e9) ? parap1 : ((parap1 >= 0.) ? 1.e9 : -1.e9);
386 para = (Abs(para) < 1.e9) ? para : ((para >= 0.) ? 1.e9 : -1.e9);
388 Standard_Integer aNbNodes = RealToInt(Ceiling((parap1 - para)/aTol));
390 Standard_Real aVal = RealLast();
391 //Standard_Integer aNbNodes = 23;
392 Standard_Real aDelta = (parap1 - para)/(aNbNodes + 1.);
394 Standard_Real aCurPar;
395 Standard_Real aCurVal;
397 for (ii = 0; ii <= aNbNodes + 1; ii++) {
398 aCurPar = (ii < aNbNodes + 1) ? para + ii*aDelta : parap1;
400 if (Func.Value(aCurPar, aCurVal)) {
401 //if (aCurVal < aVal) {
402 if (Abs(aCurVal) < aVal) {
409 // Modified by skv - Tue Aug 31 12:13:51 2004 OCC569 End
416 for (i=1; i<=Nbp; i++) {
418 if((para-Pdeb)<EpsX || (Pfin-para)<EpsX) {
421 if(Func.Value(para,dist)) {
422 //modified by jgv 5.07.01 for the bug buc60927
423 Standard_Integer anIndx;
424 Standard_Real aParam;
425 if (Abs(dist) < maxdist)
427 aParam = Sol.GetPoint(i);
428 if (Abs(aParam-Pdeb)<=Precision::PConfusion() || Abs(aParam-Pfin)<=Precision::PConfusion())
429 anIndx = Sol.GetPointState(i);
432 anIndx = Func.GetStateNumber(); //take the middle point
438 anIndx = Sol.GetPointState(i);
439 aParam = Sol.GetPoint(i);
441 const gp_Pnt& aPnt = Func.Valpoint(anIndx);
442 //////////////////////////////////////////////
444 PointProcess(aPnt, aParam, A, Domain, pnt, TolBoundary, range);
455 // Pour chaque intervalle trouve faire
456 // Traiter les extremites comme des points
457 // Ajouter intervalle dans la liste des segments
459 Nbi=Sol.NbIntervals();
462 if (!RecheckOnRegularity && Nbp) {
463 //--cout<<" Debug : IntStart_SearchOnBoundaries_1.gxx :Nbp>0 0 <- Nbi "<<Nbi<<endl;
467 //-- cout<<" Debug : IntStart_SearchOnBoundaries_1.gxx : Nbi : "<<Nbi<<endl;
469 for (i=1; i<=Nbi; i++) {
470 IntStart_TheSegment newseg;
472 // Recuperer point debut et fin, et leur parametre.
473 Sol.GetInterval(i,pardeb,parfin);
474 Sol.GetIntervalState(i,ideb,ifin);
477 //-- cout<<" Debug : IntStart_SearchOnBoundaries_1.gxx : i= "<<i<<" ParDeb:"<<pardeb<<" ParFin:"<<parfin<<endl;
479 ptdeb=Func.Valpoint(ideb);
480 ptfin=Func.Valpoint(ifin);
482 PointProcess(ptdeb,pardeb,A,Domain,pnt,TolBoundary,ranged);
483 newseg.SetLimitPoint(pnt.Value(ranged),Standard_True);
484 PointProcess(ptfin,parfin,A,Domain,pnt,TolBoundary,rangef);
485 newseg.SetLimitPoint(pnt.Value(rangef),Standard_False);
490 if (pardeb == Pdeb && parfin == Pfin) {
491 Arcsol=Standard_True;
497 //=======================================================================
498 //function : ComputeBoundsfromInfinite
500 //=======================================================================
501 //-- PROVISOIRE - TEMPORAIRE - PAS BON - NYI - A FAIRE
502 //-- provisoire - temporaire - pas bon - nyi - a faire
503 void ComputeBoundsfromInfinite(TheFunction& Func,
506 Standard_Integer& NbEchant)
509 //-- On cherche des parametres de debut et de fin de l arc (courbe 2d)
510 //-- infini, de facon a intersecter la quadrique avec une portion d arc
513 //-- La quadrique est un plan, un cylindre, un cone ou une sphere.
515 //-- Idee : On prend un point quelconque sur l'arc et on fait croitre les
516 //-- bornes vers des valeurs ou la fonction distance signee a des chances
519 //-- ATTENTION : Les calculs ci-dessous fournissent une estimation tres
520 //-- grossiere des parametres .
521 //-- Cela evite les raises et permet a des cas de Boites
522 //-- inifinies de marcher. Il faudra reprendre ce code
523 //-- avec des intersections Courbe Surface.
527 Standard_Real U0 = 0.0;
529 Standard_Real dU = 0.001;
530 Standard_Real Dist0,Dist1;//Grad0,Grad1;
531 //Standard_Real D1OnArc;
532 Func.Value(U0 , Dist0);
533 Func.Value(U0+dU, Dist1);
534 Standard_Real dDist = Dist1 - Dist0;
536 U0 -= dU*Dist0 / dDist;
538 Standard_Real Umin = U0 - 1e5;
539 Func.Value(Umin , Dist0);
540 Func.Value(Umin+dU, Dist1);
543 Umin -= dU*Dist0 / dDist;
548 Standard_Real Umax = U0 + 1e8;
549 Func.Value(Umax , Dist0);
550 Func.Value(Umax+dU, Dist1);
553 Umax -= dU*Dist0 / dDist;
558 if(Umin>U0) { Umin=U0-10.0; }
559 if(Umax<U0) { Umax=U0+10.0; }
565 //-- Possibilite de Arc totalement inclu ds Quad
571 //=======================================================================
572 //function : InfiniteArc
574 //=======================================================================
575 void InfiniteArc (const TheArc& A,
576 const Handle(TheTopolTool)& Domain,
577 const Standard_Real Pdeb,
578 const Standard_Real Pfin,
580 IntStart_SequenceOfPathPoint& pnt,
581 IntStart_SequenceOfSegment& seg,
582 const Standard_Real TolBoundary,
583 const Standard_Real TolTangency,
584 Standard_Boolean& Arcsol)
587 // Recherche des points solutions et des bouts d arc solution sur un arc donne.
588 // On utilise la fonction math_FunctionAllRoots. Ne convient donc que pour
589 // des arcs ayant un point debut et un point de fin (intervalle ferme de
593 Standard_Integer i,Nbi,Nbp;
596 Standard_Real pardeb,parfin;
597 Standard_Integer ideb,ifin,range,ranged,rangef;
600 // Creer l echantillonage (math_FunctionSample ou classe heritant)
601 // Appel a math_FunctionAllRoots
603 Standard_Real EpsX = TheArcTool::Resolution(A,Precision::Confusion());
604 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
605 //@@@ La Tolerance est asociee a l arc ( Incoherence avec le cheminement )
606 //@@@ ( EpsX ~ 1e-5 et ResolutionU et V ~ 1e-9 )
607 //@@@ le vertex trouve ici n'est pas retrouve comme point d arret d une
608 //@@@ ligne de cheminement
609 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
611 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
612 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
613 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
615 // Standard_Integer NbEchant = TheSOBTool::NbSamplesOnArc(A);
616 Standard_Integer NbEchant = Func.NbSamples();
618 //-- Modif 24 Aout 93 -----------------------------
619 Standard_Real nTolTangency = TolTangency;
620 if((Pfin - Pdeb) < (TolTangency*10.0)) {
621 nTolTangency=(Pfin-Pdeb)*0.1;
623 if(EpsX>(nTolTangency+nTolTangency)) {
624 EpsX = nTolTangency * 0.1;
626 //--------------------------------------------------
627 //-- Plante avec un edge avec 2 Samples
628 //-- dont les extremites sont solutions (f=0)
629 //-- et ou la derivee est nulle
630 //-- Exemple : un segment diametre d une sphere
631 if(NbEchant<3) NbEchant = 3; //-- lbr le 19 Avril 95
632 //--------------------------------------------------
634 Standard_Real PDeb = Pdeb;
635 Standard_Real PFin = Pfin;
637 ComputeBoundsfromInfinite(Func,PDeb,PFin,NbEchant);
639 math_FunctionSample Echant(PDeb,PFin,NbEchant);
640 math_FunctionAllRoots Sol(Func,Echant,EpsX,TolBoundary,nTolTangency);
642 if (!Sol.IsDone()) {Standard_Failure::Raise();}
645 for (i=1; i<=Nbp; i++) {
646 Standard_Real para = Sol.GetPoint(i);
648 if(Func.Value(para,dist)) {
649 //--if(Abs(dist)>nTolTangency) {
650 //--cout<<" Point sur restriction a dist="<<dist<<endl;
652 PointProcess(Func.Valpoint(Sol.GetPointState(i)),Sol.GetPoint(i),
653 A,Domain,pnt,TolBoundary,range);
656 //-- cout<<" Point Rejete dans IntStart_SearchOnBoundaries_1.gxx "<<endl;
660 // Pour chaque intervalle trouve faire
661 // Traiter les extremites comme des points
662 // Ajouter intervalle dans la liste des segments
664 Nbi=Sol.NbIntervals();
666 for (i=1; i<=Nbi; i++) {
667 IntStart_TheSegment newseg;
669 // Recuperer point debut et fin, et leur parametre.
670 Sol.GetInterval(i,pardeb,parfin);
671 Sol.GetIntervalState(i,ideb,ifin);
672 ptdeb=Func.Valpoint(ideb);
673 ptfin=Func.Valpoint(ifin);
675 PointProcess(ptdeb,pardeb,A,Domain,pnt,TolBoundary,ranged);
676 newseg.SetLimitPoint(pnt.Value(ranged),Standard_True);
677 PointProcess(ptfin,parfin,A,Domain,pnt,TolBoundary,rangef);
678 newseg.SetLimitPoint(pnt.Value(rangef),Standard_False);
683 Arcsol=Standard_False;
685 if (pardeb == Pdeb && parfin == Pfin) {
686 Arcsol=Standard_True;
690 //=======================================================================
691 //function : PointProcess
693 //=======================================================================
694 void PointProcess (const gp_Pnt& Pt,
695 const Standard_Real Para,
697 const Handle(TheTopolTool)& Domain,
698 IntStart_SequenceOfPathPoint& pnt,
699 const Standard_Real Tol,
700 Standard_Integer& Range)
703 // Regarder si un point solution est confondu avec un vertex.
704 // Si confondu, on doit retrouver ce vertex dans la liste des points de
705 // depart. On renvoie alors le rang de ce point dans la liste pnt.
706 // Sinon, on ajoute le point dans la liste.
710 Standard_Boolean found,goon;
711 Standard_Real dist,toler;
713 Standard_Integer Nbsol = pnt.Length();
715 IntStart_ThePathPoint ptsol;
717 // Domain.InitVertexIterator(A);
718 Domain->Initialize(A);
719 Domain->InitVertexIterator();
720 found = Standard_False;
721 goon = Domain->MoreVertex();
723 vtx = Domain->Vertex();
724 dist= Abs(Para-TheSOBTool::Parameter(vtx,A));
725 toler = TheSOBTool::Tolerance(vtx,A);
728 cout<<"IntStart_SearchOnBoundaries_1.gxx : ** WARNING ** Tol Vertex="<<toler<<endl;
729 cout<<" Ou Edge degenere Ou Kro pointu"<<endl;
730 if(toler>10000) toler=1e-7;
735 // Localiser le vertex dans la liste des solutions
739 ptsol = pnt.Value(k);
740 if (!ptsol.IsNew()) {
741 //jag 940608 if (ptsol.Vertex() == vtx &&
742 //jag 940608 ptsol.Arc() == A) {
743 if (Domain->Identical(ptsol.Vertex(),vtx) &&
745 Abs(ptsol.Parameter()-Para) <= toler) {
758 if (k<=Nbsol) { // on a retrouve le vertex
761 else { // au cas ou...
762 ptsol.SetValue(Pt,Tol,vtx,A,Para);
764 Range = pnt.Length();
766 found = Standard_True;
767 goon = Standard_False;
770 Domain->NextVertex();
771 goon = Domain->MoreVertex();
775 if (!found) { // on n est pas tombe sur un vertex
776 //jgv: do not add segment's extremities if they already exist
777 Standard_Boolean found_internal = Standard_False;
778 for (k = 1; k <= pnt.Length(); k++)
780 ptsol = pnt.Value(k);
781 if (ptsol.Arc() != A ||
782 !ptsol.IsNew()) //vertex
784 if (Abs(ptsol.Parameter()-Para) <= Precision::PConfusion())
786 found_internal = Standard_True;
790 /////////////////////////////////////////////////////////////
794 Standard_Real TOL=Tol;
796 if(TOL>0.001) TOL=0.001;
798 ptsol.SetValue(Pt,TOL,A,Para);
800 Range = pnt.Length();
805 //modified by NIZNHY-PKV Fri Mar 23 10:53:15 2001
806 #include <TopoDS_Edge.hxx>
807 #include <Geom_Curve.hxx>
808 #include <BRepAdaptor_Curve.hxx>
809 #include <Adaptor3d_HSurface.hxx>
810 #include <GeomAbs_SurfaceType.hxx>
811 #include <BRep_Tool.hxx>
812 #include <Geom_Line.hxx>
813 #include <gp_Lin.hxx>
814 #include <gp_Vec.hxx>
815 #include <gp_Dir.hxx>
816 #include <gp_Cylinder.hxx>
817 #include <gp_Ax1.hxx>
818 #include <gp_Lin.hxx>
820 #include <GeomAdaptor_Curve.hxx>
821 #include <Precision.hxx>
822 #include <Extrema_ExtCC.hxx>
823 #include <Extrema_POnCurv.hxx>
825 //=======================================================================
826 //function : IsRegularity
828 //=======================================================================
829 Standard_Boolean IsRegularity(const TheArc& A,
830 const Handle(TheTopolTool)& aDomain)
832 Standard_Address anEAddress=aDomain->Edge();
833 if (anEAddress==NULL) {
834 return Standard_False;
837 TopoDS_Edge* anE=(TopoDS_Edge*)anEAddress;
839 return (BRep_Tool::HasContinuity(*anE));
842 //=======================================================================
845 //=======================================================================
846 Standard_Integer TreatLC (const TheArc& A,
847 const Handle(TheTopolTool)& aDomain,
848 const IntSurf_Quadric& aQuadric,
849 const Standard_Real TolBoundary,
850 IntStart_SequenceOfPathPoint& pnt)
852 Standard_Integer anExitCode=1, aNbExt;
854 Standard_Address anEAddress=aDomain->Edge();
855 if (anEAddress==NULL) {
859 TopoDS_Edge* anE=(TopoDS_Edge*)anEAddress;
861 if (BRep_Tool::Degenerated(*anE)) {
865 GeomAbs_CurveType aTypeE;
866 BRepAdaptor_Curve aBAC(*anE);
867 aTypeE=aBAC.GetType();
869 if (aTypeE!=GeomAbs_Line) {
873 GeomAbs_SurfaceType aTypeS;
874 aTypeS=aQuadric.TypeQuadric();
876 if (aTypeS!=GeomAbs_Cylinder) {
880 Standard_Real f, l, U1f, U1l, U2f, U2l, U1, UEgde, TOL, aDist, aR, aRRel, Tol;
881 Handle(Geom_Curve) aCEdge=BRep_Tool::Curve(*anE, f, l);
883 gp_Cylinder aCyl=aQuadric.Cylinder();
884 const gp_Ax1& anAx1=aCyl.Axis();
886 Handle(Geom_Line) aCAxis=new Geom_Line (aLin);
889 U1f = aCAxis->FirstParameter();
890 U1l = aCAxis->LastParameter();
892 U2f = aCEdge->FirstParameter();
893 U2l = aCEdge->LastParameter();
896 GeomAdaptor_Curve C1, C2;
901 Tol = Precision::PConfusion();
903 Extrema_ExtCC anExtCC(C1, C2, U1f, U1l, U2f, U2l, Tol, Tol);
905 aNbExt=anExtCC.NbExt();
911 Extrema_POnCurv PC1, PC2;
913 anExtCC.Points(1, PC1, PC2);
919 UEgde=PC2.Parameter();
921 aDist=PEdge.Distance(P1);
922 aRRel=fabs(aDist-aR)/aR;
923 if (aRRel > TolBoundary) {
927 if (UEgde < (f+TolBoundary) || UEgde > (l-TolBoundary)) {
932 // It was done as into PointProcess(...) function
933 //printf("TreatLC()=> tangent line is found\n");
934 TOL=1000.*TolBoundary;
935 if(TOL>0.001) TOL=0.001;
937 IntStart_ThePathPoint ptsol;
938 ptsol.SetValue(PEdge, TOL, A, UEgde);