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 <GeomInt_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>
30 #include <Precision.hxx>
31 #include <gp_Pnt2d.hxx>
32 #include <Adaptor2d_HCurve2d.hxx>
34 #include <GeomAdaptor_HSurface.hxx>
35 #include <Standard_ConstructionError.hxx>
36 #include <IntSurf_Quadric.hxx>
37 #include <IntSurf_PntOn2S.hxx>
39 #include <GeomAbs_SurfaceType.hxx>
41 #include <TColStd_IndexedMapOfInteger.hxx>
42 #include <GeomInt.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 //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
74 //=======================================================================
75 //class : GeomInt_RealWithFlag
77 //=======================================================================
78 class GeomInt_RealWithFlag {
80 GeomInt_RealWithFlag() :
81 myValue(-99.), myFlag(1)
85 ~GeomInt_RealWithFlag() {
88 void SetValue(const Standard_Real aT) {
92 Standard_Real Value() const {
96 void SetFlag(const Standard_Integer aFlag) {
100 Standard_Integer Flag() const {
104 Standard_Boolean operator < (const GeomInt_RealWithFlag& aOther) {
105 return myValue<aOther.myValue;
109 Standard_Real myValue;
110 Standard_Integer myFlag;
114 void SortShell(const Standard_Integer,
115 GeomInt_RealWithFlag *);
117 void RejectDuplicates(Standard_Integer& aNbVtx,
118 GeomInt_RealWithFlag *pVtx,
119 Standard_Real aTolPrm);
121 void RejectNearBeacons(Standard_Integer& aNbVtx,
122 GeomInt_RealWithFlag *pVtx,
123 Standard_Real aTolPC1,
124 const GeomAbs_SurfaceType aTS1,
125 const GeomAbs_SurfaceType aTS2);
127 Standard_Real AdjustOnPeriod(const Standard_Real aTr,
128 const Standard_Real aPeriod);
131 Standard_Boolean RejectMicroCircle(const Handle(IntPatch_GLine)& aGLine,
132 const IntPatch_IType aType,
133 const Standard_Real aTol3D);
135 //=======================================================================
138 //=======================================================================
139 void GeomInt_LineConstructor::Perform(const Handle(IntPatch_Line)& L)
141 Standard_Integer i,nbvtx;
142 Standard_Real firstp,lastp;
143 const Standard_Real Tol = Precision::PConfusion() * 35.0;
145 const IntPatch_IType typl = L->ArcType();
146 if(typl == IntPatch_Analytic) {
147 Standard_Real u1,v1,u2,v2;
148 Handle(IntPatch_ALine)& ALine = Handle(IntPatch_ALine)::DownCast (L);
150 nbvtx = GeomInt_LineTool::NbVertex(L);
151 for(i=1;i<nbvtx;i++) {
152 firstp = GeomInt_LineTool::Vertex(L,i).ParameterOnLine();
153 lastp = GeomInt_LineTool::Vertex(L,i+1).ParameterOnLine();
155 const Standard_Real pmid = (firstp+lastp)*0.5;
156 const gp_Pnt Pmid = ALine->Value(pmid);
157 Parameters(myHS1,myHS2,Pmid,u1,v1,u2,v2);
158 Recadre(myHS1,myHS2,u1,v1,u2,v2);
159 const TopAbs_State in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol);
160 if(in1 != TopAbs_OUT) {
161 const TopAbs_State in2 = myDom2->Classify(gp_Pnt2d(u2,v2),Tol);
162 if(in2 != TopAbs_OUT) {
169 done = Standard_True;
171 } // if(typl == IntPatch_Analytic) {
172 else if(typl == IntPatch_Walking) {
173 Standard_Real u1,v1,u2,v2;
174 Handle(IntPatch_WLine)& WLine = Handle(IntPatch_WLine)::DownCast (L);
176 nbvtx = GeomInt_LineTool::NbVertex(L);
177 for(i=1;i<nbvtx;i++) {
178 firstp = GeomInt_LineTool::Vertex(L,i).ParameterOnLine();
179 lastp = GeomInt_LineTool::Vertex(L,i+1).ParameterOnLine();
181 if(lastp != firstp+1) {
182 const Standard_Integer pmid = (Standard_Integer )( (firstp+lastp)/2);
183 const IntSurf_PntOn2S& Pmid = WLine->Point(pmid);
184 Pmid.Parameters(u1,v1,u2,v2);
185 Recadre(myHS1,myHS2,u1,v1,u2,v2);
186 const TopAbs_State in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol);
187 if(in1 != TopAbs_OUT) {
188 const TopAbs_State in2 = myDom2->Classify(gp_Pnt2d(u2,v2),Tol);
189 if(in2 != TopAbs_OUT) {
196 const IntSurf_PntOn2S& Pfirst = WLine->Point((Standard_Integer)(firstp));
197 Pfirst.Parameters(u1,v1,u2,v2);
198 Recadre(myHS1,myHS2,u1,v1,u2,v2);
199 TopAbs_State in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol);
200 if(in1 != TopAbs_OUT) { //-- !=ON donne Pb
201 TopAbs_State in2 = myDom2->Classify(gp_Pnt2d(u2,v2),Tol);
202 if(in2 != TopAbs_OUT) { //-- !=ON
203 const IntSurf_PntOn2S& Plast = WLine->Point((Standard_Integer)(lastp));
204 Plast.Parameters(u1,v1,u2,v2);
205 Recadre(myHS1,myHS2,u1,v1,u2,v2);
206 in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol);
207 if(in1 != TopAbs_OUT) { //-- !=ON donne Pb
208 in2 = myDom2->Classify(gp_Pnt2d(u2,v2),Tol);
209 if(in2 != TopAbs_OUT) {
220 // The One resulting curve consists of 7 segments that are
221 // connected between each other.
222 // The aim of the block is to reject these segments and have
223 // one segment instead of 7.
224 // The other reason to do that is value of TolReached3D=49.
225 // Why -? It is not known yet.
228 Standard_Integer aNbParts;
230 aNbParts = seqp.Length()/2;
232 Standard_Boolean bCond;
233 GeomAbs_SurfaceType aST1, aST2;
234 aST1 = myHS1->Surface().GetType();
235 aST2 = myHS2->Surface().GetType();
237 bCond=Standard_False;
238 if (aST1==GeomAbs_Plane) {
239 if (aST2==GeomAbs_SurfaceOfExtrusion ||
240 aST2==GeomAbs_SurfaceOfRevolution) {//+zft
244 else if (aST2==GeomAbs_Plane) {
245 if (aST1==GeomAbs_SurfaceOfExtrusion ||
246 aST1==GeomAbs_SurfaceOfRevolution) {//+zft
252 Standard_Integer aNb, anIndex, aNbTmp, jx;
253 TColStd_IndexedMapOfInteger aMap;
254 TColStd_SequenceOfReal aSeqTmp;
257 for(i=1; i<=aNb; ++i) {
259 anIndex=(Standard_Integer)lastp;
260 if (!aMap.Contains(anIndex)){
262 aSeqTmp.Append(lastp);
265 aNbTmp=aSeqTmp.Length();
266 aSeqTmp.Remove(aNbTmp);
272 aNb=aSeqTmp.Length()/2;
273 for(i=1; i<=aNb;++i) {
275 firstp=aSeqTmp(jx-1);
282 done = Standard_True;
284 }// else if(typl == IntPatch_Walking) {
286 //-----------------------------------------------------------
287 else if (typl != IntPatch_Restriction) {
290 Handle(IntPatch_GLine)& GLine = Handle(IntPatch_GLine)::DownCast (L);
292 if(typl == IntPatch_Circle || typl == IntPatch_Ellipse) {
297 //----------------------------
298 Standard_Boolean intrvtested;
299 Standard_Real u1,v1,u2,v2;
301 nbvtx = GeomInt_LineTool::NbVertex(L);
302 intrvtested = Standard_False;
303 for(i=1; i<nbvtx; ++i) {
304 firstp = GeomInt_LineTool::Vertex(L,i).ParameterOnLine();
305 lastp = GeomInt_LineTool::Vertex(L,i+1).ParameterOnLine();
306 if(Abs(firstp-lastp)>Precision::PConfusion()) {
307 intrvtested = Standard_True;
308 const Standard_Real pmid = (firstp+lastp)*0.5;
310 GLinePoint(typl, GLine, pmid, Pmid);
312 Parameters(myHS1,myHS2,Pmid,u1,v1,u2,v2);
313 Recadre(myHS1,myHS2,u1,v1,u2,v2);
314 const TopAbs_State in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol);
315 if(in1 != TopAbs_OUT) {
316 const TopAbs_State in2 = myDom2->Classify(gp_Pnt2d(u2,v2),Tol);
317 if(in2 != TopAbs_OUT) {
326 // Keep a priori. A point 2d on each
327 // surface is required to make the decision. Will be done in the caller
328 seqp.Append(GeomInt_LineTool::FirstParameter(L));
329 seqp.Append(GeomInt_LineTool::LastParameter(L));
334 } // else if (typl != IntPatch_Restriction) {
336 done = Standard_False;
338 nbvtx = GeomInt_LineTool::NbVertex(L);
339 if (nbvtx == 0) { // Keep a priori. Point 2d is required on each
340 // surface to make the decision. Will be done in the caller
341 seqp.Append(GeomInt_LineTool::FirstParameter(L));
342 seqp.Append(GeomInt_LineTool::LastParameter(L));
343 done = Standard_True;
347 GeomInt_SequenceOfParameterAndOrientation seqpss;
348 TopAbs_Orientation or1=TopAbs_FORWARD,or2=TopAbs_FORWARD;
350 for (i=1; i<=nbvtx; i++) {
351 const IntPatch_Point& thevtx = GeomInt_LineTool::Vertex(L,i);
352 const Standard_Real prm = thevtx.ParameterOnLine();
353 if (thevtx.IsOnDomS1()) {
354 switch (thevtx.TransitionLineArc1().TransitionType()) {
355 case IntSurf_In: or1 = TopAbs_FORWARD; break;
356 case IntSurf_Out: or1 = TopAbs_REVERSED; break;
357 case IntSurf_Touch: or1 = TopAbs_INTERNAL; break;
358 case IntSurf_Undecided: or1 = TopAbs_INTERNAL; break;
362 or1 = TopAbs_INTERNAL;
365 if (thevtx.IsOnDomS2()) {
366 switch (thevtx.TransitionLineArc2().TransitionType()) {
367 case IntSurf_In: or2 = TopAbs_FORWARD; break;
368 case IntSurf_Out: or2 = TopAbs_REVERSED; break;
369 case IntSurf_Touch: or2 = TopAbs_INTERNAL; break;
370 case IntSurf_Undecided: or2 = TopAbs_INTERNAL; break;
374 or2 = TopAbs_INTERNAL;
377 const Standard_Integer nbinserted = seqpss.Length();
378 Standard_Boolean inserted = Standard_False;
379 for (Standard_Integer j=1; j<=nbinserted;j++) {
380 if (Abs(prm-seqpss(j).Parameter()) <= Tol) {
382 GeomInt_ParameterAndOrientation& valj = seqpss.ChangeValue(j);
383 if (or1 != TopAbs_INTERNAL) {
384 if (valj.Orientation1() != TopAbs_INTERNAL) {
385 if (or1 != valj.Orientation1()) {
386 valj.SetOrientation1(TopAbs_INTERNAL);
390 valj.SetOrientation1(or1);
394 if (or2 != TopAbs_INTERNAL) {
395 if (valj.Orientation2() != TopAbs_INTERNAL) {
396 if (or2 != valj.Orientation2()) {
397 valj.SetOrientation2(TopAbs_INTERNAL);
401 valj.SetOrientation2(or2);
404 inserted = Standard_True;
408 if (prm < seqpss(j).Parameter()-Tol ) {
409 // insert before position j
410 seqpss.InsertBefore(j,GeomInt_ParameterAndOrientation(prm,or1,or2));
411 inserted = Standard_True;
417 seqpss.Append(GeomInt_ParameterAndOrientation(prm,or1,or2));
421 // determine the state at the beginning of line
422 Standard_Boolean trim = Standard_False;
423 Standard_Boolean dansS1 = Standard_False;
424 Standard_Boolean dansS2 = Standard_False;
426 nbvtx = seqpss.Length();
427 for (i=1; i<= nbvtx; i++) {
428 or1 = seqpss(i).Orientation1();
429 if (or1 != TopAbs_INTERNAL) {
430 trim = Standard_True;
431 dansS1 = (or1 != TopAbs_FORWARD);
438 for (i=1; i<=GeomInt_LineTool::NbVertex(L); i++ ) {
439 if (!GeomInt_LineTool::Vertex(L,i).IsOnDomS1() ) {
440 GeomInt_LineTool::Vertex(L,i).ParametersOnS1(U,V);
442 if (myDom1->Classify(PPCC,Tol) == TopAbs_OUT) {
443 done = Standard_True;
449 dansS1 = Standard_True; // Keep in doubt
452 for (i=1; i<= nbvtx; i++) {
453 or2 = seqpss(i).Orientation2();
454 if (or2 != TopAbs_INTERNAL) {
455 trim = Standard_True;
456 dansS2 = (or2 != TopAbs_FORWARD);
463 for (i=1; i<=GeomInt_LineTool::NbVertex(L); i++ ) {
464 if (!GeomInt_LineTool::Vertex(L,i).IsOnDomS2() ) {
465 GeomInt_LineTool::Vertex(L,i).ParametersOnS2(U,V);
466 if (myDom2->Classify(gp_Pnt2d(U,V),Tol) == TopAbs_OUT) {
467 done = Standard_True;
473 dansS2 = Standard_True; // Keep in doubt
476 if (!trim) { // necessarily dansS1 == dansS2 == Standard_True
477 seqp.Append(GeomInt_LineTool::FirstParameter(L));
478 seqp.Append(GeomInt_LineTool::LastParameter(L));
479 done = Standard_True;
483 // sequence seqpss is peeled to create valid ends
484 // and store them in seqp(2*i+1) and seqp(2*i+2)
485 Standard_Real thefirst = GeomInt_LineTool::FirstParameter(L);
486 Standard_Real thelast = GeomInt_LineTool::LastParameter(L);
489 for (i=1; i<=nbvtx; i++) {
490 or1 = seqpss(i).Orientation1();
491 or2 = seqpss(i).Orientation2();
492 if (dansS1 && dansS2) {
493 if (or1 == TopAbs_REVERSED){
494 dansS1 = Standard_False;
497 if (or2 == TopAbs_REVERSED){
498 dansS2 = Standard_False;
500 if (!dansS1 || !dansS2) {
501 lastp = seqpss(i).Parameter();
502 Standard_Real stofirst = Max(firstp, thefirst);
503 Standard_Real stolast = Min(lastp, thelast) ;
505 if (stolast > stofirst) {
506 seqp.Append(stofirst);
507 seqp.Append(stolast);
509 if (lastp > thelast) {
516 if (or1 == TopAbs_REVERSED) {
517 dansS1 = Standard_False;
521 if (or1 == TopAbs_FORWARD){
522 dansS1 = Standard_True;
526 if (or2 == TopAbs_REVERSED) {
527 dansS2 = Standard_False;
531 if (or2 == TopAbs_FORWARD){
532 dansS2 = Standard_True;
535 if (dansS1 && dansS2){
536 firstp = seqpss(i).Parameter();
542 if (dansS1 && dansS2) {
544 firstp = Max(firstp,thefirst);
545 if (lastp > firstp) {
550 done = Standard_True;
554 //=======================================================================
557 //=======================================================================
558 void Recadre(const Handle(GeomAdaptor_HSurface)& myHS1,
559 const Handle(GeomAdaptor_HSurface)& myHS2,
565 Standard_Boolean myHS1IsUPeriodic,myHS1IsVPeriodic;
566 const GeomAbs_SurfaceType typs1 = myHS1->GetType();
569 case GeomAbs_Cylinder:
573 myHS1IsUPeriodic = Standard_True;
574 myHS1IsVPeriodic = Standard_False;
579 myHS1IsUPeriodic = myHS1IsVPeriodic = Standard_True;
584 //-- Case of periodic biparameters is processed upstream
585 myHS1IsUPeriodic = myHS1IsVPeriodic = Standard_False;
589 Standard_Boolean myHS2IsUPeriodic,myHS2IsVPeriodic;
590 const GeomAbs_SurfaceType typs2 = myHS2->GetType();
593 case GeomAbs_Cylinder:
597 myHS2IsUPeriodic = Standard_True;
598 myHS2IsVPeriodic = Standard_False;
603 myHS2IsUPeriodic = myHS2IsVPeriodic = Standard_True;
608 //-- Case of periodic biparameters is processed upstream
609 myHS2IsUPeriodic = myHS2IsVPeriodic = Standard_False;
613 Standard_Real du, dv;
615 if(myHS1IsUPeriodic) {
616 const Standard_Real lmf = M_PI+M_PI; //-- myHS1->UPeriod();
617 const Standard_Real f = myHS1->FirstUParameter();
618 const Standard_Real l = myHS1->LastUParameter();
619 GeomInt::AdjustPeriodic(u1, f, l, lmf, u1, du);
621 if(myHS1IsVPeriodic) {
622 const Standard_Real lmf = M_PI+M_PI; //-- myHS1->VPeriod();
623 const Standard_Real f = myHS1->FirstVParameter();
624 const Standard_Real l = myHS1->LastVParameter();
625 GeomInt::AdjustPeriodic(v1, f, l, lmf, v1, dv);
627 if(myHS2IsUPeriodic) {
628 const Standard_Real lmf = M_PI+M_PI; //-- myHS2->UPeriod();
629 const Standard_Real f = myHS2->FirstUParameter();
630 const Standard_Real l = myHS2->LastUParameter();
631 GeomInt::AdjustPeriodic(u2, f, l, lmf, u2, du);
633 if(myHS2IsVPeriodic) {
634 const Standard_Real lmf = M_PI+M_PI; //-- myHS2->VPeriod();
635 const Standard_Real f = myHS2->FirstVParameter();
636 const Standard_Real l = myHS2->LastVParameter();
637 GeomInt::AdjustPeriodic(v2, f, l, lmf, v2, dv);
640 //=======================================================================
641 //function : Parameters
643 //=======================================================================
644 void Parameters(const Handle(GeomAdaptor_HSurface)& myHS1,
645 const Handle(GeomAdaptor_HSurface)& myHS2,
652 Parameters(myHS1, Ptref, U1, V1);
653 Parameters(myHS2, Ptref, U2, V2);
655 //=======================================================================
656 //function : Parameter
658 //=======================================================================
659 void Parameters(const Handle(GeomAdaptor_HSurface)& myHS1,
664 IntSurf_Quadric quad1;
666 switch (myHS1->Surface().GetType()) {
668 quad1.SetValue(myHS1->Surface().Plane());
670 case GeomAbs_Cylinder:
671 quad1.SetValue(myHS1->Surface().Cylinder());
674 quad1.SetValue(myHS1->Surface().Cone());
677 quad1.SetValue(myHS1->Surface().Sphere());
680 quad1.SetValue(myHS1->Surface().Torus());
683 Standard_ConstructionError::Raise("GeomInt_LineConstructor::Parameters");
685 quad1.Parameters(Ptref,U1,V1);
688 //=======================================================================
689 //function : GLinePoint
691 //=======================================================================
692 void GLinePoint(const IntPatch_IType typl,
693 const Handle(IntPatch_GLine)& GLine,
694 const Standard_Real aT,
699 aP = ElCLib::Value(aT, GLine->Line());
701 case IntPatch_Circle:
702 aP = ElCLib::Value(aT, GLine->Circle());
704 case IntPatch_Ellipse:
705 aP = ElCLib::Value(aT, GLine->Ellipse());
707 case IntPatch_Hyperbola:
708 aP = ElCLib::Value(aT, GLine->Hyperbola());
710 case IntPatch_Parabola:
711 aP = ElCLib::Value(aT, GLine->Parabola());
714 Standard_ConstructionError::Raise("GeomInt_LineConstructor::Parameters");
718 //=======================================================================
719 //function : TreatCircle
721 //=======================================================================
722 void GeomInt_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)::DownCast (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 GeomInt_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 GeomInt_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 - 1; ++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 GeomInt_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 GeomInt_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 GeomInt_RealWithFlag *a)
959 Standard_Integer nd, i, j, l, d=1;
960 GeomInt_RealWithFlag x;
970 for (i=0; i<nd; ++i) {
979 if (j > -1) goto m30;
981 }//for (i=0; i<nd; ++i)