1 // Created on: 1995-02-07
2 // Created by: Jacques GOUSSARD
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <IntTools_LineConstructor.ixx>
19 #include <GeomInt_LineTool.hxx>
20 #include <GeomInt_SequenceOfParameterAndOrientation.hxx>
21 #include <GeomInt_ParameterAndOrientation.hxx>
23 #include <IntPatch_Point.hxx>
24 #include <IntPatch_GLine.hxx>
25 #include <IntPatch_WLine.hxx>
26 #include <IntPatch_ALine.hxx>
27 #include <IntSurf_Transition.hxx>
28 #include <TopAbs_Orientation.hxx>
31 #include <Precision.hxx>
33 #include <gp_Pnt2d.hxx>
35 #include <Adaptor2d_HCurve2d.hxx>
37 #include <GeomAdaptor_HSurface.hxx>
38 #include <Standard_ConstructionError.hxx>
39 #include <IntSurf_Quadric.hxx>
40 #include <IntSurf_PntOn2S.hxx>
42 #include <GeomAbs_SurfaceType.hxx>
43 #include <TColStd_IndexedMapOfInteger.hxx>
46 void Parameters(const Handle(GeomAdaptor_HSurface)& myHS1,
51 void Parameters(const Handle(GeomAdaptor_HSurface)& myHS1,
52 const Handle(GeomAdaptor_HSurface)& myHS2,
60 void GLinePoint(const IntPatch_IType typl,
61 const Handle(IntPatch_GLine)& GLine,
62 const Standard_Real aT,
65 void Recadre(const Handle(GeomAdaptor_HSurface)& myHS1,
66 const Handle(GeomAdaptor_HSurface)& myHS2,
72 //=======================================================================
75 //=======================================================================
76 void IntTools_LineConstructor::Perform(const Handle(IntPatch_Line)& L)
78 Standard_Integer i,nbvtx;
79 Standard_Real firstp,lastp;
80 const Standard_Real Tol = Precision::PConfusion() * 35.0;
82 const IntPatch_IType typl = L->ArcType();
83 if(typl == IntPatch_Analytic) {
84 Standard_Real u1,v1,u2,v2;
85 Handle(IntPatch_ALine)& ALine = *((Handle(IntPatch_ALine) *)&L);
87 nbvtx = GeomInt_LineTool::NbVertex(L);
88 for(i=1;i<nbvtx;i++) {
89 firstp = GeomInt_LineTool::Vertex(L,i).ParameterOnLine();
90 lastp = GeomInt_LineTool::Vertex(L,i+1).ParameterOnLine();
92 const Standard_Real pmid = (firstp+lastp)*0.5;
93 const gp_Pnt Pmid = ALine->Value(pmid);
94 Parameters(myHS1,myHS2,Pmid,u1,v1,u2,v2);
95 Recadre(myHS1,myHS2,u1,v1,u2,v2);
96 const TopAbs_State in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol);
97 if(in1 != TopAbs_OUT) {
98 const TopAbs_State in2 = myDom2->Classify(gp_Pnt2d(u2,v2),Tol);
99 if(in2 != TopAbs_OUT) {
106 done = Standard_True;
108 } // if(typl == IntPatch_Analytic) {
109 else if(typl == IntPatch_Walking) {
110 Standard_Real u1,v1,u2,v2;
111 Handle(IntPatch_WLine)& WLine = *((Handle(IntPatch_WLine) *)&L);
113 nbvtx = GeomInt_LineTool::NbVertex(L);
114 for(i=1;i<nbvtx;i++) {
115 firstp = GeomInt_LineTool::Vertex(L,i).ParameterOnLine();
116 lastp = GeomInt_LineTool::Vertex(L,i+1).ParameterOnLine();
118 if(lastp != firstp+1) {
119 const Standard_Integer pmid = (Standard_Integer )( (firstp+lastp)/2);
120 const IntSurf_PntOn2S& Pmid = WLine->Point(pmid);
121 Pmid.Parameters(u1,v1,u2,v2);
122 Recadre(myHS1,myHS2,u1,v1,u2,v2);
123 const TopAbs_State in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol);
124 if(in1 != TopAbs_OUT) {
125 const TopAbs_State in2 = myDom2->Classify(gp_Pnt2d(u2,v2),Tol);
126 if(in2 != TopAbs_OUT) {
133 const IntSurf_PntOn2S& Pfirst = WLine->Point((Standard_Integer)(firstp));
134 Pfirst.Parameters(u1,v1,u2,v2);
135 Recadre(myHS1,myHS2,u1,v1,u2,v2);
136 TopAbs_State in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol);
137 if(in1 != TopAbs_OUT) { //-- !=ON donne Pb
138 TopAbs_State in2 = myDom2->Classify(gp_Pnt2d(u2,v2),Tol);
139 if(in2 != TopAbs_OUT) { //-- !=ON
140 const IntSurf_PntOn2S& Plast = WLine->Point((Standard_Integer)(lastp));
141 Plast.Parameters(u1,v1,u2,v2);
142 Recadre(myHS1,myHS2,u1,v1,u2,v2);
143 in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol);
144 if(in1 != TopAbs_OUT) { //-- !=ON donne Pb
145 in2 = myDom2->Classify(gp_Pnt2d(u2,v2),Tol);
146 if(in2 != TopAbs_OUT) {
157 // The One resulting curve consists of 7 segments that are
158 // connected between each other.
159 // The aim of the block is to reject these segments and have
160 // one segment instead of 7.
161 // The other reason to do that is value of TolReached3D=49.
162 // Why -? It is not known yet.
165 Standard_Integer aNbParts;
167 aNbParts = seqp.Length()/2;
169 Standard_Boolean bCond;
170 GeomAbs_SurfaceType aST1, aST2;
171 aST1 = myHS1->Surface().GetType();
172 aST2 = myHS2->Surface().GetType();
174 bCond=Standard_False;
175 if (aST1==GeomAbs_Plane) {
176 if (aST2==GeomAbs_SurfaceOfExtrusion ||
177 aST2==GeomAbs_SurfaceOfRevolution) {//+zft
181 else if (aST2==GeomAbs_Plane) {
182 if (aST1==GeomAbs_SurfaceOfExtrusion ||
183 aST1==GeomAbs_SurfaceOfRevolution) {//+zft
189 Standard_Integer aNb, anIndex, aNbTmp, jx;
190 TColStd_IndexedMapOfInteger aMap;
191 TColStd_SequenceOfReal aSeqTmp;
194 for(i=1; i<=aNb; ++i) {
196 anIndex=(Standard_Integer)lastp;
197 if (!aMap.Contains(anIndex)){
199 aSeqTmp.Append(lastp);
202 aNbTmp=aSeqTmp.Length();
203 aSeqTmp.Remove(aNbTmp);
209 aNb=aSeqTmp.Length()/2;
210 for(i=1; i<=aNb;++i) {
212 firstp=aSeqTmp(jx-1);
219 done = Standard_True;
221 }// else if(typl == IntPatch_Walking) {
223 //-----------------------------------------------------------
224 else if (typl != IntPatch_Restriction) {
227 Handle(IntPatch_GLine)& GLine = *((Handle(IntPatch_GLine) *)&L);
229 if(typl == IntPatch_Circle || typl == IntPatch_Ellipse) {
234 //----------------------------
235 Standard_Boolean intrvtested;
236 Standard_Real u1,v1,u2,v2;
238 nbvtx = GeomInt_LineTool::NbVertex(L);
239 intrvtested = Standard_False;
240 for(i=1; i<nbvtx; ++i) {
241 firstp = GeomInt_LineTool::Vertex(L,i).ParameterOnLine();
242 lastp = GeomInt_LineTool::Vertex(L,i+1).ParameterOnLine();
243 if(Abs(firstp-lastp)>Precision::PConfusion()) {
244 intrvtested = Standard_True;
245 const Standard_Real pmid = (firstp+lastp)*0.5;
247 GLinePoint(typl, GLine, pmid, Pmid);
249 Parameters(myHS1,myHS2,Pmid,u1,v1,u2,v2);
250 Recadre(myHS1,myHS2,u1,v1,u2,v2);
251 const TopAbs_State in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol);
252 if(in1 != TopAbs_OUT) {
253 const TopAbs_State in2 = myDom2->Classify(gp_Pnt2d(u2,v2),Tol);
254 if(in2 != TopAbs_OUT) {
263 // Keep a priori. A point 2d on each
264 // surface is required to make the decision. Will be done in the caller
265 seqp.Append(GeomInt_LineTool::FirstParameter(L));
266 seqp.Append(GeomInt_LineTool::LastParameter(L));
271 } // else if (typl != IntPatch_Restriction) {
273 done = Standard_False;
275 nbvtx = GeomInt_LineTool::NbVertex(L);
276 if (nbvtx == 0) { // Keep a priori. Point 2d is required on each
277 // surface to make the decision. Will be done in the caller
278 seqp.Append(GeomInt_LineTool::FirstParameter(L));
279 seqp.Append(GeomInt_LineTool::LastParameter(L));
280 done = Standard_True;
284 GeomInt_SequenceOfParameterAndOrientation seqpss;
285 TopAbs_Orientation or1=TopAbs_FORWARD,or2=TopAbs_FORWARD;
287 for (i=1; i<=nbvtx; i++) {
288 const IntPatch_Point& thevtx = GeomInt_LineTool::Vertex(L,i);
289 const Standard_Real prm = thevtx.ParameterOnLine();
290 if (thevtx.IsOnDomS1()) {
291 switch (thevtx.TransitionLineArc1().TransitionType()) {
292 case IntSurf_In: or1 = TopAbs_FORWARD; break;
293 case IntSurf_Out: or1 = TopAbs_REVERSED; break;
294 case IntSurf_Touch: or1 = TopAbs_INTERNAL; break;
295 case IntSurf_Undecided: or1 = TopAbs_INTERNAL; break;
299 or1 = TopAbs_INTERNAL;
302 if (thevtx.IsOnDomS2()) {
303 switch (thevtx.TransitionLineArc2().TransitionType()) {
304 case IntSurf_In: or2 = TopAbs_FORWARD; break;
305 case IntSurf_Out: or2 = TopAbs_REVERSED; break;
306 case IntSurf_Touch: or2 = TopAbs_INTERNAL; break;
307 case IntSurf_Undecided: or2 = TopAbs_INTERNAL; break;
311 or2 = TopAbs_INTERNAL;
314 const Standard_Integer nbinserted = seqpss.Length();
315 Standard_Boolean inserted = Standard_False;
316 for (Standard_Integer j=1; j<=nbinserted;j++) {
317 if (Abs(prm-seqpss(j).Parameter()) <= Tol) {
319 GeomInt_ParameterAndOrientation& valj = seqpss.ChangeValue(j);
320 if (or1 != TopAbs_INTERNAL) {
321 if (valj.Orientation1() != TopAbs_INTERNAL) {
322 if (or1 != valj.Orientation1()) {
323 valj.SetOrientation1(TopAbs_INTERNAL);
327 valj.SetOrientation1(or1);
331 if (or2 != TopAbs_INTERNAL) {
332 if (valj.Orientation2() != TopAbs_INTERNAL) {
333 if (or2 != valj.Orientation2()) {
334 valj.SetOrientation2(TopAbs_INTERNAL);
338 valj.SetOrientation2(or2);
341 inserted = Standard_True;
345 if (prm < seqpss(j).Parameter()-Tol ) {
346 // insert before position j
347 seqpss.InsertBefore(j,GeomInt_ParameterAndOrientation(prm,or1,or2));
348 inserted = Standard_True;
354 seqpss.Append(GeomInt_ParameterAndOrientation(prm,or1,or2));
358 // determine the state at the beginning of line
359 Standard_Boolean trim = Standard_False;
360 Standard_Boolean dansS1 = Standard_False;
361 Standard_Boolean dansS2 = Standard_False;
363 nbvtx = seqpss.Length();
364 for (i=1; i<= nbvtx; i++) {
365 or1 = seqpss(i).Orientation1();
366 if (or1 != TopAbs_INTERNAL) {
367 trim = Standard_True;
368 dansS1 = (or1 != TopAbs_FORWARD);
375 for (i=1; i<=GeomInt_LineTool::NbVertex(L); i++ ) {
376 if (!GeomInt_LineTool::Vertex(L,i).IsOnDomS1() ) {
377 GeomInt_LineTool::Vertex(L,i).ParametersOnS1(U,V);
379 if (myDom1->Classify(PPCC,Tol) == TopAbs_OUT) {
380 done = Standard_True;
386 dansS1 = Standard_True; // Keep in doubt
389 for (i=1; i<= nbvtx; i++) {
390 or2 = seqpss(i).Orientation2();
391 if (or2 != TopAbs_INTERNAL) {
392 trim = Standard_True;
393 dansS2 = (or2 != TopAbs_FORWARD);
400 for (i=1; i<=GeomInt_LineTool::NbVertex(L); i++ ) {
401 if (!GeomInt_LineTool::Vertex(L,i).IsOnDomS2() ) {
402 GeomInt_LineTool::Vertex(L,i).ParametersOnS2(U,V);
403 if (myDom2->Classify(gp_Pnt2d(U,V),Tol) == TopAbs_OUT) {
404 done = Standard_True;
410 dansS2 = Standard_True; // Keep in doubt
413 if (!trim) { // necessarily dansS1 == dansS2 == Standard_True
414 seqp.Append(GeomInt_LineTool::FirstParameter(L));
415 seqp.Append(GeomInt_LineTool::LastParameter(L));
416 done = Standard_True;
420 // sequence seqpss is peeled to create valid ends
421 // and store them in seqp(2*i+1) and seqp(2*i+2)
422 Standard_Real thefirst = GeomInt_LineTool::FirstParameter(L);
423 Standard_Real thelast = GeomInt_LineTool::LastParameter(L);
426 for (i=1; i<=nbvtx; i++) {
427 or1 = seqpss(i).Orientation1();
428 or2 = seqpss(i).Orientation2();
429 if (dansS1 && dansS2) {
430 if (or1 == TopAbs_REVERSED){
431 dansS1 = Standard_False;
434 if (or2 == TopAbs_REVERSED){
435 dansS2 = Standard_False;
437 if (!dansS1 || !dansS2) {
438 lastp = seqpss(i).Parameter();
439 Standard_Real stofirst = Max(firstp, thefirst);
440 Standard_Real stolast = Min(lastp, thelast) ;
442 if (stolast > stofirst) {
443 seqp.Append(stofirst);
444 seqp.Append(stolast);
446 if (lastp > thelast) {
453 if (or1 == TopAbs_REVERSED) {
454 dansS1 = Standard_False;
458 if (or1 == TopAbs_FORWARD){
459 dansS1 = Standard_True;
463 if (or2 == TopAbs_REVERSED) {
464 dansS2 = Standard_False;
468 if (or2 == TopAbs_FORWARD){
469 dansS2 = Standard_True;
472 if (dansS1 && dansS2){
473 firstp = seqpss(i).Parameter();
479 if (dansS1 && dansS2) {
481 firstp = Max(firstp,thefirst);
482 if (lastp > firstp) {
487 done = Standard_True;
489 //=======================================================================
492 //=======================================================================
493 void Recadre(const Handle(GeomAdaptor_HSurface)& myHS1,
494 const Handle(GeomAdaptor_HSurface)& myHS2,
500 Standard_Boolean myHS1IsUPeriodic,myHS1IsVPeriodic;
501 const GeomAbs_SurfaceType typs1 = myHS1->GetType();
504 case GeomAbs_Cylinder:
508 myHS1IsUPeriodic = Standard_True;
509 myHS1IsVPeriodic = Standard_False;
514 myHS1IsUPeriodic = myHS1IsVPeriodic = Standard_True;
519 //-- Case of periodic biparameters is processed upstream
520 myHS1IsUPeriodic = myHS1IsVPeriodic = Standard_False;
524 Standard_Boolean myHS2IsUPeriodic,myHS2IsVPeriodic;
525 const GeomAbs_SurfaceType typs2 = myHS2->GetType();
528 case GeomAbs_Cylinder:
532 myHS2IsUPeriodic = Standard_True;
533 myHS2IsVPeriodic = Standard_False;
538 myHS2IsUPeriodic = myHS2IsVPeriodic = Standard_True;
543 //-- Case of periodic biparameters is processed upstream
544 myHS2IsUPeriodic = myHS2IsVPeriodic = Standard_False;
548 if(myHS1IsUPeriodic) {
549 const Standard_Real lmf = M_PI+M_PI; //-- myHS1->UPeriod();
550 const Standard_Real f = myHS1->FirstUParameter();
551 const Standard_Real l = myHS1->LastUParameter();
552 while(u1 < f) { u1+=lmf; }
553 while(u1 > l) { u1-=lmf; }
555 if(myHS1IsVPeriodic) {
556 const Standard_Real lmf = M_PI+M_PI; //-- myHS1->VPeriod();
557 const Standard_Real f = myHS1->FirstVParameter();
558 const Standard_Real l = myHS1->LastVParameter();
559 while(v1 < f) { v1+=lmf; }
560 while(v1 > l) { v1-=lmf; }
562 if(myHS2IsUPeriodic) {
563 const Standard_Real lmf = M_PI+M_PI; //-- myHS2->UPeriod();
564 const Standard_Real f = myHS2->FirstUParameter();
565 const Standard_Real l = myHS2->LastUParameter();
566 while(u2 < f) { u2+=lmf; }
567 while(u2 > l) { u2-=lmf; }
569 if(myHS2IsVPeriodic) {
570 const Standard_Real lmf = M_PI+M_PI; //-- myHS2->VPeriod();
571 const Standard_Real f = myHS2->FirstVParameter();
572 const Standard_Real l = myHS2->LastVParameter();
573 while(v2 < f) { v2+=lmf; }
574 while(v2 > l) { v2-=lmf; }
577 //=======================================================================
578 //function : Parameters
580 //=======================================================================
581 void Parameters(const Handle(GeomAdaptor_HSurface)& myHS1,
582 const Handle(GeomAdaptor_HSurface)& myHS2,
589 Parameters(myHS1, Ptref, U1, V1);
590 Parameters(myHS2, Ptref, U2, V2);
592 //=======================================================================
593 //function : Parameter
595 //=======================================================================
596 void Parameters(const Handle(GeomAdaptor_HSurface)& myHS1,
601 IntSurf_Quadric quad1;
603 switch (myHS1->Surface().GetType()) {
605 quad1.SetValue(myHS1->Surface().Plane());
607 case GeomAbs_Cylinder:
608 quad1.SetValue(myHS1->Surface().Cylinder());
611 quad1.SetValue(myHS1->Surface().Cone());
614 quad1.SetValue(myHS1->Surface().Sphere());
617 quad1.SetValue(myHS1->Surface().Torus());
620 Standard_ConstructionError::Raise("IntTools_LineConstructor::Parameters");
622 quad1.Parameters(Ptref,U1,V1);
625 //=======================================================================
626 //function : GLinePoint
628 //=======================================================================
629 void GLinePoint(const IntPatch_IType typl,
630 const Handle(IntPatch_GLine)& GLine,
631 const Standard_Real aT,
636 aP = ElCLib::Value(aT, GLine->Line());
638 case IntPatch_Circle:
639 aP = ElCLib::Value(aT, GLine->Circle());
641 case IntPatch_Ellipse:
642 aP = ElCLib::Value(aT, GLine->Ellipse());
644 case IntPatch_Hyperbola:
645 aP = ElCLib::Value(aT, GLine->Hyperbola());
647 case IntPatch_Parabola:
648 aP = ElCLib::Value(aT, GLine->Parabola());
651 Standard_ConstructionError::Raise("IntTools_LineConstructor::Parameters");
655 //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
657 //=======================================================================
658 //class : IntTools_RealWithFlag
660 //=======================================================================
661 class IntTools_RealWithFlag {
663 IntTools_RealWithFlag() :
664 myValue(-99.), myFlag(1)
668 ~IntTools_RealWithFlag() {
671 void SetValue(const Standard_Real aT) {
675 Standard_Real Value() const {
679 void SetFlag(const Standard_Integer aFlag) {
683 Standard_Integer Flag() const {
687 Standard_Boolean operator < (const IntTools_RealWithFlag& aOther) {
688 return myValue<aOther.myValue;
692 Standard_Real myValue;
693 Standard_Integer myFlag;
697 void SortShell(const Standard_Integer,
698 IntTools_RealWithFlag *);
700 void RejectDuplicates(Standard_Integer& aNbVtx,
701 IntTools_RealWithFlag *pVtx,
702 Standard_Real aTolPrm);
704 void RejectNearBeacons(Standard_Integer& aNbVtx,
705 IntTools_RealWithFlag *pVtx,
706 Standard_Real aTolPC1,
707 const GeomAbs_SurfaceType aTS1,
708 const GeomAbs_SurfaceType aTS2);
710 Standard_Real AdjustOnPeriod(const Standard_Real aTr,
711 const Standard_Real aPeriod);
714 Standard_Boolean RejectMicroCircle(const Handle(IntPatch_GLine)& aGLine,
715 const IntPatch_IType aType,
716 const Standard_Real aTol3D);
718 //=======================================================================
719 //function : TreatCircle
721 //=======================================================================
722 void IntTools_LineConstructor::TreatCircle(const Handle(IntPatch_Line)& aLine,
723 const Standard_Real aTol)
725 Standard_Boolean bRejected;
726 IntPatch_IType aType;
728 aType=aLine->ArcType();
729 Handle(IntPatch_GLine)& aGLine=*((Handle(IntPatch_GLine) *)&aLine);
731 bRejected=RejectMicroCircle(aGLine, aType, aTol);
735 //----------------------------------------
736 Standard_Boolean bFound;
737 Standard_Integer aNbVtx, aNbVtxWas, i;
738 Standard_Real aTolPC, aT, aT1, aT2, aTmid, aTwoPI, aTolPC1;
739 Standard_Real aU1, aV1, aU2, aV2;
740 TopAbs_State aIn1, aIn2;
741 GeomAbs_SurfaceType aTS1, aTS2;
744 IntTools_RealWithFlag *pVtx;
745 //-------------------------------------1
747 aTolPC=Precision::PConfusion();
748 aNbVtxWas=GeomInt_LineTool::NbVertex(aLine);
751 //-------------------------------------2
752 aTS1=myHS1->GetType();
753 aTS2=myHS2->GetType();
755 // About the value aTolPC1=1000.*aTolPC,
756 // see IntPatch_GLine.cxx, line:398
758 aTolPC1=1000.*aTolPC;
759 //-------------------------------------
761 pVtx=new IntTools_RealWithFlag [aNbVtx];
763 pVtx[0].SetValue(0.);
764 pVtx[1].SetValue(aTwoPI);
766 for(i=1; i<=aNbVtxWas; ++i) {
767 aT=GeomInt_LineTool::Vertex(aLine, i).ParameterOnLine();
768 aT=AdjustOnPeriod(aT, aTwoPI);
769 pVtx[i+1].SetValue(aT);
772 SortShell(aNbVtx, pVtx);
774 RejectNearBeacons(aNbVtx, pVtx, aTolPC1, aTS1, aTS2);
776 RejectDuplicates(aNbVtx, pVtx, aTolPC);
778 if ((aType==IntPatch_Circle || aType==IntPatch_Ellipse)&& aNbVtx>2) { // zz
779 bFound=Standard_False;
780 for(i=1; i<=aNbVtxWas; ++i) {
781 aT=GeomInt_LineTool::Vertex(aLine, i).ParameterOnLine();
782 if (fabs(aT) < aTolPC1 || fabs(aT-aTwoPI) < aTolPC1) {
788 aT=pVtx[1].Value()+aTwoPI;
789 pVtx[aNbVtx-1].SetValue(aT);
791 for(i=0; i<aNbVtx; ++i) {
792 aT=pVtx[i+1].Value();
793 pVtx[i].SetValue(aT);
799 for(i=0; i<aNbVtx-1; ++i) {
801 aT2=pVtx[i+1].Value();
803 GLinePoint(aType, aGLine, aTmid, aPmid);
805 Parameters(myHS1, myHS2, aPmid, aU1, aV1, aU2, aV2);
806 Recadre(myHS1, myHS2, aU1, aV1, aU2, aV2);
808 aP2D.SetCoord(aU1, aV1);
809 aIn1=myDom1->Classify(aP2D, aTol);
810 if(aIn1 != TopAbs_OUT) {
811 aP2D.SetCoord(aU2, aV2);
812 aIn2=myDom2->Classify(aP2D, aTol);
813 if(aIn2 != TopAbs_OUT) {
822 //=======================================================================
823 //function : RejectNearBeacons
824 //purpose : Reject the thickenings near the beacon points (if exist)
825 // The gifts, made by sweep algo.
826 // chl/930/B5 B8 C2 C5 E2 E5 E8 F2 G8 H2 H5 H8
827 //=======================================================================
828 void RejectNearBeacons(Standard_Integer& aNbVtx,
829 IntTools_RealWithFlag *pVtx,
830 Standard_Real aTolPC1,
831 const GeomAbs_SurfaceType aTS1,
832 const GeomAbs_SurfaceType aTS2)
834 Standard_Integer i, j, iBcn;
835 Standard_Real aT, aBcn[2];
837 if (aTS1==GeomAbs_Cylinder && aTS2==GeomAbs_Cylinder) {
841 for (j=0; j<2; ++j) {
843 for(i=0; i<aNbVtx; ++i) {
852 // The beacon is not found
856 for(i=0; i<aNbVtx; ++i) {
859 if (fabs(aT-aBcn[j]) < aTolPC1) {
864 }// for (j=0; j<2; ++j) {
865 //------------------------------------------
867 for(i=0; i<aNbVtx; ++i) {
868 if (pVtx[i].Flag()) {
874 }// if (aTS1==GeomAbs_Cylinder && aTS2==GeomAbs_Cylinder) {
877 //=======================================================================
878 //function : RejectDuplicates
880 //=======================================================================
881 void RejectDuplicates(Standard_Integer& aNbVtx,
882 IntTools_RealWithFlag *pVtx,
883 Standard_Real aTolPC)
885 Standard_Integer i, j;
886 Standard_Real dX, aT1, aT2;
888 for(i=0; i<aNbVtx-1; ++i) {
889 aT2=pVtx[i+1].Value();
893 pVtx[i+1].SetFlag(0);
898 for(i=0; i<aNbVtx; ++i) {
899 if (pVtx[i].Flag()) {
906 //=======================================================================
907 //function : AdjustOnPeriod
909 //=======================================================================
910 Standard_Real AdjustOnPeriod(const Standard_Real aTr,
911 const Standard_Real aPeriod)
918 k=-(Standard_Integer)(aT/aPeriod)+1;
922 if (!(aT>=0. && aT<=aPeriod)) {
923 k=(Standard_Integer)(aT/aPeriod);
929 //=======================================================================
930 //function : RejectMicroCrcles
932 //=======================================================================
933 Standard_Boolean RejectMicroCircle(const Handle(IntPatch_GLine)& aGLine,
934 const IntPatch_IType aType,
935 const Standard_Real aTol3D)
937 Standard_Boolean bRet;
942 if (aType==IntPatch_Circle) {
943 aR=aGLine->Circle().Radius();
946 else if (aType==IntPatch_Ellipse) {
947 aR=aGLine->Ellipse().MajorRadius();
952 //=======================================================================
953 // function: SortShell
955 //=======================================================================
956 void SortShell(const Standard_Integer n,
957 IntTools_RealWithFlag *a)
959 Standard_Integer nd, i, j, l, d=1;
960 IntTools_RealWithFlag x;
970 for (i=0; i<nd; ++i) {
979 if (j > -1) goto m30;
981 }//for (i=0; i<nd; ++i)