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 #include <TopoDS_Edge.hxx>
21 #include <Geom_Curve.hxx>
22 #include <BRepAdaptor_Curve.hxx>
23 #include <Adaptor3d_HSurface.hxx>
24 #include <GeomAbs_SurfaceType.hxx>
25 #include <BRep_Tool.hxx>
26 #include <Geom_Line.hxx>
30 #include <gp_Cylinder.hxx>
34 #include <GeomAdaptor_Curve.hxx>
35 #include <Precision.hxx>
36 #include <Extrema_ExtCC.hxx>
37 #include <Extrema_POnCurv.hxx>
39 #include <math_FunctionSample.hxx>
40 #include <math_FunctionAllRoots.hxx>
41 #include <TColgp_SequenceOfPnt.hxx>
43 // Modified by skv - Tue Aug 31 12:13:51 2004 OCC569
45 #include <Precision.hxx>
46 #include <IntSurf_Quadric.hxx>
48 static void FindVertex (const TheArc&,
49 const Handle(TheTopolTool)&,
51 IntStart_SequenceOfPathPoint&,
55 static void BoundedArc (const TheArc& A,
56 const Handle(TheTopolTool)& Domain,
57 const Standard_Real Pdeb,
58 const Standard_Real Pfin,
60 IntStart_SequenceOfPathPoint& pnt,
61 IntStart_SequenceOfSegment& seg,
62 const Standard_Real TolBoundary,
63 const Standard_Real TolTangency,
64 Standard_Boolean& Arcsol,
65 const Standard_Boolean RecheckOnRegularity);
67 static void PointProcess (const gp_Pnt&,
70 const Handle(TheTopolTool)&,
71 IntStart_SequenceOfPathPoint&,
75 static Standard_Integer TreatLC (const TheArc& A,
76 const Handle(TheTopolTool)& aDomain,
77 const IntSurf_Quadric& aQuadric,
78 const Standard_Real TolBoundary,
79 IntStart_SequenceOfPathPoint& pnt);
81 static Standard_Boolean IsRegularity(const TheArc& A,
82 const Handle(TheTopolTool)& aDomain);
85 //=======================================================================
86 //function : FindVertex
88 //=======================================================================
89 void FindVertex (const TheArc& A,
90 const Handle(TheTopolTool)& Domain,
92 IntStart_SequenceOfPathPoint& pnt,
93 const Standard_Real Toler)
96 // Find the vertex of the arc A restriction solutions. It stores
97 // Vertex in the list solutions pnt.
101 Standard_Real param,valf;
102 Standard_Integer itemp;
104 Domain->Initialize(A);
105 Domain->InitVertexIterator();
106 while (Domain->MoreVertex()) {
107 vtx = Domain->Vertex();
108 param = TheSOBTool::Parameter(vtx,A);
110 // Evaluate the function and look compared to tolerance of the
111 // Vertex. If distance <= tolerance then add a vertex to the list of solutions.
112 // The arc is already assumed in the load function.
114 Func.Value(param,valf);
115 if (Abs(valf) <= Toler) {
116 itemp = Func.GetStateNumber();
117 pnt.Append(IntStart_ThePathPoint(Func.Valpoint(itemp),Toler, vtx,A,param));
120 Domain->NextVertex();
125 void BoundedArc (const TheArc& A,
126 const Handle(TheTopolTool)& Domain,
127 const Standard_Real Pdeb,
128 const Standard_Real Pfin,
130 IntStart_SequenceOfPathPoint& pnt,
131 IntStart_SequenceOfSegment& seg,
132 const Standard_Real TolBoundary,
133 const Standard_Real TolTangency,
134 Standard_Boolean& Arcsol,
135 const Standard_Boolean RecheckOnRegularity)
138 // Recherche des points solutions et des bouts d arc solution sur un arc donne.
139 // On utilise la fonction math_FunctionAllRoots. Ne convient donc que pour
140 // des arcs ayant un point debut et un point de fin (intervalle ferme de
143 Standard_Integer i,Nbi,Nbp;
146 Standard_Real pardeb = 0., parfin = 0.;
147 Standard_Integer ideb,ifin,range,ranged,rangef;
150 // Creer l echantillonage (math_FunctionSample ou classe heritant)
151 // Appel a math_FunctionAllRoots
153 Standard_Real EpsX = TheArcTool::Resolution(A,Precision::Confusion());
154 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
155 //@@@ La Tolerance est asociee a l arc ( Incoherence avec le cheminement )
156 //@@@ ( EpsX ~ 1e-5 et ResolutionU et V ~ 1e-9 )
157 //@@@ le vertex trouve ici n'est pas retrouve comme point d arret d une
158 //@@@ ligne de cheminement
159 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
161 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
162 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
163 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
165 // Standard_Integer NbEchant = TheSOBTool::NbSamplesOnArc(A);
166 Standard_Integer NbEchant = Func.NbSamples();
168 //-- Modif 24 Aout 93 -----------------------------
169 Standard_Real nTolTangency = TolTangency;
170 if((Pfin - Pdeb) < (TolTangency*10.0)) {
171 nTolTangency=(Pfin-Pdeb)*0.1;
173 if(EpsX>(nTolTangency+nTolTangency)) {
174 EpsX = nTolTangency * 0.1;
176 //--------------------------------------------------
177 //-- Plante avec un edge avec 2 Samples
178 //-- dont les extremites son solutions (f=0)
179 //-- et ou la derivee est nulle
180 //-- Exemple : un segment diametre d une sphere
181 //-- if(NbEchant<3) NbEchant = 3; //-- lbr le 19 Avril 95
182 //--------------------------------------------------
183 Standard_Real para=0,dist,maxdist;
184 /* if(NbEchant<20) NbEchant = 20; //-- lbr le 22 Avril 96
185 //-- Toujours des pbs
187 if(NbEchant<100) NbEchant = 100; //-- lbr le 22 Avril 96
188 //-- Toujours des pbs
191 //-------------------------------------------------------------- REJECTIONS le 15 oct 98
192 Standard_Boolean Rejection=Standard_True;
193 Standard_Real maxdr,maxr,minr,ur,dur;
198 for(i=1,ur=Pdeb;i<=6;i++) {
200 if(Func.Values(ur,F,D)) {
201 Standard_Real lminr,lmaxr;
207 if(lminr<minr) minr=lminr;
208 if(lmaxr>maxr) maxr=lmaxr;
209 if(minr<0.0 && maxr>0.0) {
210 Rejection=Standard_False;
218 dur=0.001+maxdr+(maxr-minr)*0.1;
221 if(minr<0.0 && maxr>0.0) {
222 Rejection=Standard_False;
226 Arcsol=Standard_False;
228 if(Rejection==Standard_False) {
229 math_FunctionSample Echant(Pdeb,Pfin,NbEchant);
231 Standard_Boolean aelargir=Standard_True;
232 //modified by NIZNHY-PKV Thu Apr 12 09:25:19 2001 f
234 //maxdist = 100.0*TolBoundary;
235 maxdist = TolBoundary+TolTangency;
237 //modified by NIZNHY-PKV Thu Apr 12 09:25:23 2001 t
238 for(i=1; i<=NbEchant && aelargir;i++) {
239 Standard_Real u = Echant.GetParameter(i);
240 if(Func.Value(u,dist)) {
241 if(dist>maxdist || -dist>maxdist) {
242 aelargir=Standard_False;
246 if(!(aelargir && maxdist<0.01)) {
247 maxdist = TolBoundary;
250 math_FunctionAllRoots Sol(Func,Echant,EpsX,maxdist,maxdist); //-- TolBoundary,nTolTangency);
252 if (!Sol.IsDone()) {Standard_Failure::Raise();}
256 //jgv: build solution on the whole boundary
257 if (RecheckOnRegularity && Nbp > 0 && IsRegularity(A, Domain))
259 //Standard_Real theTol = Domain->MaxTolerance(A);
261 Standard_Real theTol = 5.e-4;
262 math_FunctionAllRoots SolAgain(Func,Echant,EpsX,theTol,theTol); //-- TolBoundary,nTolTangency);
264 if (!SolAgain.IsDone()) {Standard_Failure::Raise();}
266 Standard_Integer Nbi_again = SolAgain.NbIntervals();
270 Standard_Integer NbSamples = 10;
271 Standard_Real delta = (Pfin - Pdeb)/NbSamples;
272 Standard_Real GlobalTol = theTol*10;
273 Standard_Boolean SolOnBoundary = Standard_True;
274 for (i = 0; i <= NbSamples; i++)
276 Standard_Real aParam = Pdeb + i*delta;
277 Standard_Real aValue;
278 Func.Value(aParam, aValue);
279 if (Abs(aValue) > GlobalTol)
281 SolOnBoundary = Standard_False;
288 for (i = 1; i <= Nbi_again; i++)
290 IntStart_TheSegment newseg;
292 // Recuperer point debut et fin, et leur parametre.
293 SolAgain.GetInterval(i,pardeb,parfin);
295 if (Abs(pardeb - Pdeb) <= Precision::PConfusion())
297 if (Abs(parfin - Pfin) <= Precision::PConfusion())
300 SolAgain.GetIntervalState(i,ideb,ifin);
302 //-- cout<<" Debug : IntStart_SearchOnBoundaries_1.gxx : i= "<<i<<" ParDeb:"<<pardeb<<" ParFin:"<<parfin<<endl;
304 ptdeb=Func.Valpoint(ideb);
305 ptfin=Func.Valpoint(ifin);
307 PointProcess(ptdeb,pardeb,A,Domain,pnt,theTol,ranged);
308 newseg.SetLimitPoint(pnt.Value(ranged),Standard_True);
309 PointProcess(ptfin,parfin,A,Domain,pnt,theTol,rangef);
310 newseg.SetLimitPoint(pnt.Value(rangef),Standard_False);
313 Arcsol=Standard_True;
318 ////////////////////////////////////////////
320 //-- detection du cas ou la fonction est quasi tangente et que les
321 //-- zeros sont quasi confondus.
322 //-- Dans ce cas on prend le point "milieu"
323 //-- On suppose que les solutions sont triees.
325 Standard_Real *TabSol=NULL;
327 TabSol = new Standard_Real [Nbp+2];
328 for(i=1;i<=Nbp;i++) {
329 TabSol[i]=Sol.GetPoint(i);
335 if(TabSol[i]>TabSol[i+1]) {
337 para=TabSol[i]; TabSol[i]=TabSol[i+1]; TabSol[i+1]=para;
342 while(ok==Standard_False);
343 //modified by NIZNHY-PKV Wed Mar 21 18:34:18 2001 f
344 //////////////////////////////////////////////////////////
345 // The treatment of the situation when line(arc) that is
346 // tangent to cylinder(domain).
347 // We should have only one solution i.e Nbp=1. Ok?
348 // But we have 2,3,.. solutions. That is wrong ersult.
349 // The TreatLC(...) function is dedicated to solve the pb.
350 // PKV Fri Mar 23 12:17:29 2001
352 const IntSurf_Quadric& aQuadric=Func.Quadric();
354 ip=TreatLC (A, Domain, aQuadric, TolBoundary, pnt);
356 //////////////////////////////////////////////////////////
357 //modified by NIZNHY-PKV Wed Mar 21 18:34:23 2001 t
359 // Using of old usual way proposed by Laurent
362 Standard_Real parap1=TabSol[i+1];
364 Standard_Real param=(para+parap1)*0.5;
366 if(Func.Value(param,ym)) {
367 if(Abs(ym)<maxdist) {
368 // Modified by skv - Tue Aug 31 12:13:51 2004 OCC569 Begin
369 // Consider this interval as tangent one. Treat it to find
370 // parameter with the lowest function value.
372 // Compute the number of nodes.
373 Standard_Real aTol = TolBoundary*1000.0;
377 // fix floating point exception 569, chl-922-e9
378 parap1 = (Abs(parap1) < 1.e9) ? parap1 : ((parap1 >= 0.) ? 1.e9 : -1.e9);
379 para = (Abs(para) < 1.e9) ? para : ((para >= 0.) ? 1.e9 : -1.e9);
381 Standard_Integer aNbNodes = RealToInt(Ceiling((parap1 - para)/aTol));
383 Standard_Real aVal = RealLast();
384 //Standard_Integer aNbNodes = 23;
385 Standard_Real aDelta = (parap1 - para)/(aNbNodes + 1.);
387 Standard_Real aCurPar;
388 Standard_Real aCurVal;
390 for (ii = 0; ii <= aNbNodes + 1; ii++) {
391 aCurPar = (ii < aNbNodes + 1) ? para + ii*aDelta : parap1;
393 if (Func.Value(aCurPar, aCurVal)) {
394 //if (aCurVal < aVal) {
395 if (Abs(aCurVal) < aVal) {
402 // Modified by skv - Tue Aug 31 12:13:51 2004 OCC569 End
409 for (i=1; i<=Nbp; i++) {
411 if((para-Pdeb)<EpsX || (Pfin-para)<EpsX) {
414 if(Func.Value(para,dist)) {
415 //modified by jgv 5.07.01 for the bug buc60927
416 Standard_Integer anIndx;
417 Standard_Real aParam;
418 if (Abs(dist) < maxdist)
420 aParam = Sol.GetPoint(i);
421 if (Abs(aParam-Pdeb)<=Precision::PConfusion() || Abs(aParam-Pfin)<=Precision::PConfusion())
422 anIndx = Sol.GetPointState(i);
425 anIndx = Func.GetStateNumber(); //take the middle point
431 anIndx = Sol.GetPointState(i);
432 aParam = Sol.GetPoint(i);
434 const gp_Pnt& aPnt = Func.Valpoint(anIndx);
435 //////////////////////////////////////////////
437 PointProcess(aPnt, aParam, A, Domain, pnt, TolBoundary, range);
448 // Pour chaque intervalle trouve faire
449 // Traiter les extremites comme des points
450 // Ajouter intervalle dans la liste des segments
452 Nbi=Sol.NbIntervals();
455 if (!RecheckOnRegularity && Nbp) {
456 //--cout<<" Debug : IntStart_SearchOnBoundaries_1.gxx :Nbp>0 0 <- Nbi "<<Nbi<<endl;
460 //-- cout<<" Debug : IntStart_SearchOnBoundaries_1.gxx : Nbi : "<<Nbi<<endl;
462 for (i=1; i<=Nbi; i++) {
463 IntStart_TheSegment newseg;
465 // Recuperer point debut et fin, et leur parametre.
466 Sol.GetInterval(i,pardeb,parfin);
467 Sol.GetIntervalState(i,ideb,ifin);
470 //-- cout<<" Debug : IntStart_SearchOnBoundaries_1.gxx : i= "<<i<<" ParDeb:"<<pardeb<<" ParFin:"<<parfin<<endl;
472 ptdeb=Func.Valpoint(ideb);
473 ptfin=Func.Valpoint(ifin);
475 PointProcess(ptdeb,pardeb,A,Domain,pnt,TolBoundary,ranged);
476 newseg.SetLimitPoint(pnt.Value(ranged),Standard_True);
477 PointProcess(ptfin,parfin,A,Domain,pnt,TolBoundary,rangef);
478 newseg.SetLimitPoint(pnt.Value(rangef),Standard_False);
483 if (pardeb == Pdeb && parfin == Pfin) {
484 Arcsol=Standard_True;
490 //=======================================================================
491 //function : ComputeBoundsfromInfinite
493 //=======================================================================
494 // - PROVISIONAL - TEMPORARY - NOT GOOD - NYI - TO DO
495 // - Temporary - temporary - not good - nyi - to do
496 void ComputeBoundsfromInfinite(TheFunction& Func,
499 Standard_Integer& NbEchant)
502 // - We are looking for parameters for start and end of the arc (2d curve)
503 // - Infinity, a way to intersect the quadric with a portion of arc
506 // - The quadric is a plane, a cylinder, a cone and a sphere.
507 // - Idea: We take any point on the arc and the fact grow
508 // - Terminals to the signed distance function values ​​or is likely
511 // - WARNING: The following calculations provide a very estimated coarse parameters.
512 // - This avoids the raises and allows a case of Boxes
513 // - Inifinies walk. It will take this code
514 // - With curve surface intersections.
518 Standard_Real U0 = 0.0;
519 Standard_Real dU = 0.001;
520 Standard_Real Dist0,Dist1;
522 Func.Value(U0 , Dist0);
523 Func.Value(U0+dU, Dist1);
524 Standard_Real dDist = Dist1 - Dist0;
526 U0 -= dU*Dist0 / dDist;
528 Standard_Real Umin = U0 - 1e5;
529 Func.Value(Umin , Dist0);
530 Func.Value(Umin+dU, Dist1);
533 Umin -= dU*Dist0 / dDist;
538 Standard_Real Umax = U0 + 1e8;
539 Func.Value(Umax , Dist0);
540 Func.Value(Umax+dU, Dist1);
543 Umax -= dU*Dist0 / dDist;
548 if(Umin>U0) { Umin=U0-10.0; }
549 if(Umax<U0) { Umax=U0+10.0; }
551 PFin = Umax + 10. * (Umax - Umin);
552 PDeb = Umin - 10. * (Umax - Umin);
555 //-- Possibilite de Arc totalement inclu ds Quad
561 //=======================================================================
562 //function : PointProcess
564 //=======================================================================
565 void PointProcess (const gp_Pnt& Pt,
566 const Standard_Real Para,
568 const Handle(TheTopolTool)& Domain,
569 IntStart_SequenceOfPathPoint& pnt,
570 const Standard_Real Tol,
571 Standard_Integer& Range)
574 // Check to see if a solution point is coincident with a vertex.
575 // If confused, you should find this vertex in the list of
576 // Start. It then returns the position of this point in the list pnt.
577 // Otherwise, add the point in the list.
580 Standard_Boolean found,goon;
581 Standard_Real dist,toler;
583 Standard_Integer Nbsol = pnt.Length();
585 IntStart_ThePathPoint ptsol;
587 Domain->Initialize(A);
588 Domain->InitVertexIterator();
589 found = Standard_False;
590 goon = Domain->MoreVertex();
592 vtx = Domain->Vertex();
593 dist= Abs(Para-TheSOBTool::Parameter(vtx,A));
594 toler = TheSOBTool::Tolerance(vtx,A);
597 cout<<"IntStart_SearchOnBoundaries_1.gxx : ** WARNING ** Tol Vertex="<<toler<<endl;
598 cout<<" Ou Edge degenere Ou Kro pointu"<<endl;
599 if(toler>10000) toler=1e-7;
604 // Locate the vertex in the list of solutions
608 ptsol = pnt.Value(k);
609 if (!ptsol.IsNew()) {
610 //jag 940608 if (ptsol.Vertex() == vtx && ptsol.Arc() == A) {
611 if (Domain->Identical(ptsol.Vertex(),vtx) &&
613 Abs(ptsol.Parameter()-Para) <= toler) {
626 if (k<=Nbsol) { // We find the vertex
630 ptsol.SetValue(Pt,Tol,vtx,A,Para);
632 Range = pnt.Length();
634 found = Standard_True;
635 goon = Standard_False;
638 Domain->NextVertex();
639 goon = Domain->MoreVertex();
643 if (!found) { // No one is falling on a vertex
644 //jgv: do not add segment's extremities if they already exist
645 Standard_Boolean found_internal = Standard_False;
646 for (k = 1; k <= pnt.Length(); k++)
648 ptsol = pnt.Value(k);
649 if (ptsol.Arc() != A ||
650 !ptsol.IsNew()) //vertex
652 if (Abs(ptsol.Parameter()-Para) <= Precision::PConfusion())
654 found_internal = Standard_True;
658 /////////////////////////////////////////////////////////////
662 Standard_Real TOL=Tol;
664 if(TOL>0.001) TOL=0.001;
666 ptsol.SetValue(Pt,TOL,A,Para);
668 Range = pnt.Length();
673 //=======================================================================
674 //function : IsRegularity
676 //=======================================================================
677 Standard_Boolean IsRegularity(const TheArc& /*A*/,
678 const Handle(TheTopolTool)& aDomain)
680 Standard_Address anEAddress=aDomain->Edge();
681 if (anEAddress==NULL) {
682 return Standard_False;
685 TopoDS_Edge* anE=(TopoDS_Edge*)anEAddress;
687 return (BRep_Tool::HasContinuity(*anE));
690 //=======================================================================
693 //=======================================================================
694 Standard_Integer TreatLC (const TheArc& A,
695 const Handle(TheTopolTool)& aDomain,
696 const IntSurf_Quadric& aQuadric,
697 const Standard_Real TolBoundary,
698 IntStart_SequenceOfPathPoint& pnt)
700 Standard_Integer anExitCode=1, aNbExt;
702 Standard_Address anEAddress=aDomain->Edge();
703 if (anEAddress==NULL) {
707 TopoDS_Edge* anE=(TopoDS_Edge*)anEAddress;
709 if (BRep_Tool::Degenerated(*anE)) {
713 GeomAbs_CurveType aTypeE;
714 BRepAdaptor_Curve aBAC(*anE);
715 aTypeE=aBAC.GetType();
717 if (aTypeE!=GeomAbs_Line) {
721 GeomAbs_SurfaceType aTypeS;
722 aTypeS=aQuadric.TypeQuadric();
724 if (aTypeS!=GeomAbs_Cylinder) {
728 Standard_Real f, l, U1f, U1l, U2f, U2l, U1, UEgde, TOL, aDist, aR, aRRel, Tol;
729 Handle(Geom_Curve) aCEdge=BRep_Tool::Curve(*anE, f, l);
731 gp_Cylinder aCyl=aQuadric.Cylinder();
732 const gp_Ax1& anAx1=aCyl.Axis();
734 Handle(Geom_Line) aCAxis=new Geom_Line (aLin);
737 U1f = aCAxis->FirstParameter();
738 U1l = aCAxis->LastParameter();
740 U2f = aCEdge->FirstParameter();
741 U2l = aCEdge->LastParameter();
744 GeomAdaptor_Curve C1, C2;
749 Tol = Precision::PConfusion();
751 Extrema_ExtCC anExtCC(C1, C2, U1f, U1l, U2f, U2l, Tol, Tol);
753 aNbExt=anExtCC.NbExt();
759 Extrema_POnCurv PC1, PC2;
761 anExtCC.Points(1, PC1, PC2);
767 UEgde=PC2.Parameter();
769 aDist=PEdge.Distance(P1);
770 aRRel=fabs(aDist-aR)/aR;
771 if (aRRel > TolBoundary) {
775 if (UEgde < (f+TolBoundary) || UEgde > (l-TolBoundary)) {
780 // It was done as into PointProcess(...) function
781 //printf("TreatLC()=> tangent line is found\n");
782 TOL=1000.*TolBoundary;
783 if(TOL>0.001) TOL=0.001;
785 IntStart_ThePathPoint ptsol;
786 ptsol.SetValue(PEdge, TOL, A, UEgde);
795 //=======================================================================
796 //function : IntStart_SearchOnBoundaries::IntStart_SearchOnBoundaries
798 //=======================================================================
799 IntStart_SearchOnBoundaries::IntStart_SearchOnBoundaries ()
800 : done(Standard_False)
804 //=======================================================================
807 //=======================================================================
808 void IntStart_SearchOnBoundaries::Perform (TheFunction& Func,
809 const Handle(TheTopolTool)& Domain,
810 const Standard_Real TolBoundary,
811 const Standard_Real TolTangency,
812 const Standard_Boolean RecheckOnRegularity)
815 done = Standard_False;
819 Standard_Boolean Arcsol;
820 Standard_Real PDeb,PFin, prm, tol;
821 Standard_Integer i, nbknown, nbfound,index;
826 if (Domain->More()) {
830 all = Standard_False;
833 while (Domain->More()) {
834 TheArc A = Domain->Value();
835 if (!TheSOBTool::HasBeenSeen(A)) {
837 FindVertex(A,Domain,Func,spnt,TolBoundary);
838 TheSOBTool::Bounds(A,PDeb,PFin);
839 if(Precision::IsNegativeInfinite(PDeb) ||
840 Precision::IsPositiveInfinite(PFin)) {
841 Standard_Integer NbEchant;
842 ComputeBoundsfromInfinite(Func,PDeb,PFin,NbEchant);
844 BoundedArc(A,Domain,PDeb,PFin,Func,spnt,sseg,TolBoundary,TolTangency,Arcsol,RecheckOnRegularity);
845 all = (all && Arcsol);
849 // as it seems we'll never be here, because
850 // TheSOBTool::HasBeenSeen(A) always returns FALSE
851 nbfound = spnt.Length();
853 // On recupere les points connus
854 nbknown = TheSOBTool::NbPoints(A);
855 for (i=1; i<=nbknown; i++) {
856 TheSOBTool::Value(A,i,pt,tol,prm);
857 if (TheSOBTool::IsVertex(A,i)) {
859 TheSOBTool::Vertex(A,i,vtx);
860 spnt.Append(IntStart_ThePathPoint(pt,tol,vtx,A,prm));
863 spnt.Append(IntStart_ThePathPoint(pt,tol,A,prm));
866 // On recupere les arcs solutions
867 nbknown = TheSOBTool::NbSegments(A);
868 for (i=1; i<=nbknown; i++) {
869 IntStart_TheSegment newseg;
871 if (TheSOBTool::HasFirstPoint(A,i,index)) {
872 newseg.SetLimitPoint(spnt.Value(nbfound+index),Standard_True);
874 if (TheSOBTool::HasLastPoint(A,i,index)) {
875 newseg.SetLimitPoint(spnt.Value(nbfound+index),Standard_False);
879 all = (all& TheSOBTool::IsAllSolution(A));
883 done = Standard_True;