From 2a78ec6a074716322d15275a771c5c1105fa4057 Mon Sep 17 00:00:00 2001 From: jgv Date: Thu, 4 Sep 2014 13:49:45 +0400 Subject: [PATCH] 0025192: Unification of LineConstructor algorithms used by GeomInt_IntSS and BOP Small correction. Correction of test case bug/modalg_5/bug24472 --- src/BOPTools/BOPTools_AlgoTools2D.cxx | 3 +- src/GeomInt/GeomInt.cdl | 12 +- src/GeomInt/GeomInt.cxx | 39 + src/GeomInt/GeomInt_LineConstructor.cdl | 10 +- src/GeomInt/GeomInt_LineConstructor.cxx | 1482 ++++++++++------- src/IntTools/IntTools.cdl | 2 +- src/IntTools/IntTools_BeanFaceIntersector.cxx | 5 +- src/IntTools/IntTools_FClass2d.cxx | 9 +- src/IntTools/IntTools_FaceFace.cdl | 4 +- src/IntTools/IntTools_FaceFace.cxx | 13 +- src/IntTools/IntTools_LineConstructor.cdl | 100 -- src/IntTools/IntTools_LineConstructor.cxx | 982 ----------- src/IntTools/IntTools_LineConstructor.lxx | 82 - src/IntTools/IntTools_Tools.cdl | 11 - src/IntTools/IntTools_Tools.cxx | 33 - tests/bugs/modalg_5/bug24472 | 2 +- 16 files changed, 920 insertions(+), 1869 deletions(-) create mode 100644 src/GeomInt/GeomInt.cxx delete mode 100644 src/IntTools/IntTools_LineConstructor.cdl delete mode 100644 src/IntTools/IntTools_LineConstructor.cxx delete mode 100644 src/IntTools/IntTools_LineConstructor.lxx diff --git a/src/BOPTools/BOPTools_AlgoTools2D.cxx b/src/BOPTools/BOPTools_AlgoTools2D.cxx index fd0f644792..4c6d976190 100644 --- a/src/BOPTools/BOPTools_AlgoTools2D.cxx +++ b/src/BOPTools/BOPTools_AlgoTools2D.cxx @@ -73,6 +73,7 @@ #include #include #include +#include static Standard_Boolean CheckEdgeLength (const TopoDS_Edge& ); @@ -325,7 +326,7 @@ void BOPTools_AlgoTools2D::AdjustPCurveOnFace Standard_Real newu; aUPeriod = aBAS.UPeriod(); // - IntTools_Tools::AdjustPeriodic(u2, UMin, UMax, aUPeriod, newu, du); + GeomInt::AdjustPeriodic(u2, UMin, UMax, aUPeriod, newu, du); // if (du==0.) { if (aBAS.GetType()==GeomAbs_Cylinder) { diff --git a/src/GeomInt/GeomInt.cdl b/src/GeomInt/GeomInt.cdl index 7b9c80eb38..700e591a93 100644 --- a/src/GeomInt/GeomInt.cdl +++ b/src/GeomInt/GeomInt.cdl @@ -51,10 +51,20 @@ is Quadric from IntSurf, QuadricTool from IntSurf, WLine from IntPatch); - + private class ParameterAndOrientation; private class SequenceOfParameterAndOrientation instantiates Sequence from TCollection(ParameterAndOrientation); + AdjustPeriodic(thePar : Real from Standard; + theParMin : Real from Standard; + theParMax : Real from Standard; + thePeriod : Real from Standard; + theNewPar : out Real from Standard; + theOffset : out Real from Standard; + theEps : Real from Standard = 0.0) + returns Boolean from Standard; + ---Purpose: Adjusts the parameter to the range [theParMin, theParMax] + end GeomInt; diff --git a/src/GeomInt/GeomInt.cxx b/src/GeomInt/GeomInt.cxx new file mode 100644 index 0000000000..3b88d1ffe4 --- /dev/null +++ b/src/GeomInt/GeomInt.cxx @@ -0,0 +1,39 @@ +// File: GeomInt.cxx +// Created: 25.08.14 17:59:59 +// Author: jgv@VIVEX +// Copyright: Open CASCADE 2014 + +#include +#include + +//======================================================================= +//function : AdjustPeriodic +//purpose : +//======================================================================= +Standard_Boolean GeomInt::AdjustPeriodic(const Standard_Real thePar, + const Standard_Real theParMin, + const Standard_Real theParMax, + const Standard_Real thePeriod, + Standard_Real &theNewPar, + Standard_Real &theOffset, + const Standard_Real theEps) +{ + Standard_Boolean bMin, bMax; + // + theOffset = 0.; + theNewPar = thePar; + bMin = theParMin - thePar > theEps; + bMax = thePar - theParMax > theEps; + // + if (bMin || bMax) { + Standard_Real dp, aNbPer; + // + dp = (bMin) ? (theParMax - thePar) : (theParMin - thePar); + modf(dp / thePeriod, &aNbPer); + // + theOffset = aNbPer * thePeriod; + theNewPar += theOffset; + } + // + return (theOffset > 0.); +} diff --git a/src/GeomInt/GeomInt_LineConstructor.cdl b/src/GeomInt/GeomInt_LineConstructor.cdl index e803964c88..9a25b78e8d 100644 --- a/src/GeomInt/GeomInt_LineConstructor.cdl +++ b/src/GeomInt/GeomInt_LineConstructor.cdl @@ -77,8 +77,14 @@ is --- for given index of split --- - PeriodicLine(me; L: Line from IntPatch) - is static private; + TreatCircle(me:out; + aLine : Line from IntPatch; + aTol: Real from Standard) + is protected; + + + --PeriodicLine(me; L: Line from IntPatch) + --is static private; fields diff --git a/src/GeomInt/GeomInt_LineConstructor.cxx b/src/GeomInt/GeomInt_LineConstructor.cxx index 04e8a2382d..04167298d3 100644 --- a/src/GeomInt/GeomInt_LineConstructor.cxx +++ b/src/GeomInt/GeomInt_LineConstructor.cxx @@ -38,25 +38,537 @@ #include #include +#include +#include + + +static + void Parameters(const Handle(GeomAdaptor_HSurface)& myHS1, + const gp_Pnt& Ptref, + Standard_Real& U1, + Standard_Real& V1); +static + void Parameters(const Handle(GeomAdaptor_HSurface)& myHS1, + const Handle(GeomAdaptor_HSurface)& myHS2, + const gp_Pnt& Ptref, + Standard_Real& U1, + Standard_Real& V1, + Standard_Real& U2, + Standard_Real& V2); + +static + void GLinePoint(const IntPatch_IType typl, + const Handle(IntPatch_GLine)& GLine, + const Standard_Real aT, + gp_Pnt& aP); +static + void Recadre(const Handle(GeomAdaptor_HSurface)& myHS1, + const Handle(GeomAdaptor_HSurface)& myHS2, + Standard_Real& u1, + Standard_Real& v1, + Standard_Real& u2, + Standard_Real& v2); + +//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX +// +//======================================================================= +//class : GeomInt_RealWithFlag +//purpose : +//======================================================================= +class GeomInt_RealWithFlag { + public: + GeomInt_RealWithFlag() : + myValue(-99.), myFlag(1) + { + }; + // + ~GeomInt_RealWithFlag() { + }; + // + void SetValue(const Standard_Real aT) { + myValue=aT; + }; + // + Standard_Real Value() const { + return myValue; + } + // + void SetFlag(const Standard_Integer aFlag) { + myFlag=aFlag; + }; + // + Standard_Integer Flag() const { + return myFlag; + } + // + Standard_Boolean operator < (const GeomInt_RealWithFlag& aOther) { + return myValueArcType(); + if(typl == IntPatch_Analytic) { + Standard_Real u1,v1,u2,v2; + Handle(IntPatch_ALine)& ALine = *((Handle(IntPatch_ALine) *)&L); + seqp.Clear(); + nbvtx = GeomInt_LineTool::NbVertex(L); + for(i=1;iValue(pmid); + Parameters(myHS1,myHS2,Pmid,u1,v1,u2,v2); + Recadre(myHS1,myHS2,u1,v1,u2,v2); + const TopAbs_State in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol); + if(in1 != TopAbs_OUT) { + const TopAbs_State in2 = myDom2->Classify(gp_Pnt2d(u2,v2),Tol); + if(in2 != TopAbs_OUT) { + seqp.Append(firstp); + seqp.Append(lastp); + } + } + } + } + done = Standard_True; + return; + } // if(typl == IntPatch_Analytic) { + else if(typl == IntPatch_Walking) { + Standard_Real u1,v1,u2,v2; + Handle(IntPatch_WLine)& WLine = *((Handle(IntPatch_WLine) *)&L); + seqp.Clear(); + nbvtx = GeomInt_LineTool::NbVertex(L); + for(i=1;iPoint(pmid); + Pmid.Parameters(u1,v1,u2,v2); + Recadre(myHS1,myHS2,u1,v1,u2,v2); + const TopAbs_State in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol); + if(in1 != TopAbs_OUT) { + const TopAbs_State in2 = myDom2->Classify(gp_Pnt2d(u2,v2),Tol); + if(in2 != TopAbs_OUT) { + seqp.Append(firstp); + seqp.Append(lastp); + } + } + } + else { + const IntSurf_PntOn2S& Pfirst = WLine->Point((Standard_Integer)(firstp)); + Pfirst.Parameters(u1,v1,u2,v2); + Recadre(myHS1,myHS2,u1,v1,u2,v2); + TopAbs_State in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol); + if(in1 != TopAbs_OUT) { //-- !=ON donne Pb + TopAbs_State in2 = myDom2->Classify(gp_Pnt2d(u2,v2),Tol); + if(in2 != TopAbs_OUT) { //-- !=ON + const IntSurf_PntOn2S& Plast = WLine->Point((Standard_Integer)(lastp)); + Plast.Parameters(u1,v1,u2,v2); + Recadre(myHS1,myHS2,u1,v1,u2,v2); + in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol); + if(in1 != TopAbs_OUT) { //-- !=ON donne Pb + in2 = myDom2->Classify(gp_Pnt2d(u2,v2),Tol); + if(in2 != TopAbs_OUT) { + seqp.Append(firstp); + seqp.Append(lastp); + } + } + } + } + } + } + } + // + // The One resulting curve consists of 7 segments that are + // connected between each other. + // The aim of the block is to reject these segments and have + // one segment instead of 7. + // The other reason to do that is value of TolReached3D=49. + // Why -? It is not known yet. + // PKV 22.Apr.2002 + // + Standard_Integer aNbParts; + // + aNbParts = seqp.Length()/2; + if (aNbParts > 1) { + Standard_Boolean bCond; + GeomAbs_SurfaceType aST1, aST2; + aST1 = myHS1->Surface().GetType(); + aST2 = myHS2->Surface().GetType(); + // + bCond=Standard_False; + if (aST1==GeomAbs_Plane) { + if (aST2==GeomAbs_SurfaceOfExtrusion || + aST2==GeomAbs_SurfaceOfRevolution) {//+zft + bCond=!bCond; + } + } + else if (aST2==GeomAbs_Plane) { + if (aST1==GeomAbs_SurfaceOfExtrusion || + aST1==GeomAbs_SurfaceOfRevolution) {//+zft + bCond=!bCond; + } + } + // + if (bCond) { + Standard_Integer aNb, anIndex, aNbTmp, jx; + TColStd_IndexedMapOfInteger aMap; + TColStd_SequenceOfReal aSeqTmp; + // + aNb=seqp.Length(); + for(i=1; i<=aNb; ++i) { + lastp =seqp(i); + anIndex=(Standard_Integer)lastp; + if (!aMap.Contains(anIndex)){ + aMap.Add(anIndex); + aSeqTmp.Append(lastp); + } + else { + aNbTmp=aSeqTmp.Length(); + aSeqTmp.Remove(aNbTmp); + } + } + // + seqp.Clear(); + // + aNb=aSeqTmp.Length()/2; + for(i=1; i<=aNb;++i) { + jx=2*i; + firstp=aSeqTmp(jx-1); + lastp =aSeqTmp(jx); + seqp.Append(firstp); + seqp.Append(lastp); + } + }//if (bCond) { + } + done = Standard_True; + return; + }// else if(typl == IntPatch_Walking) { + // + //----------------------------------------------------------- + else if (typl != IntPatch_Restriction) { + seqp.Clear(); + // + Handle(IntPatch_GLine)& GLine = *((Handle(IntPatch_GLine) *)&L); + // + if(typl == IntPatch_Circle || typl == IntPatch_Ellipse) { + TreatCircle(L, Tol); + done=Standard_True; + return; + } + //---------------------------- + Standard_Boolean intrvtested; + Standard_Real u1,v1,u2,v2; + // + nbvtx = GeomInt_LineTool::NbVertex(L); + intrvtested = Standard_False; + for(i=1; iPrecision::PConfusion()) { + intrvtested = Standard_True; + const Standard_Real pmid = (firstp+lastp)*0.5; + gp_Pnt Pmid; + GLinePoint(typl, GLine, pmid, Pmid); + // + Parameters(myHS1,myHS2,Pmid,u1,v1,u2,v2); + Recadre(myHS1,myHS2,u1,v1,u2,v2); + const TopAbs_State in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol); + if(in1 != TopAbs_OUT) { + const TopAbs_State in2 = myDom2->Classify(gp_Pnt2d(u2,v2),Tol); + if(in2 != TopAbs_OUT) { + seqp.Append(firstp); + seqp.Append(lastp); + } + } + } + } + // + if (!intrvtested) { + // Keep a priori. A point 2d on each + // surface is required to make the decision. Will be done in the caller + seqp.Append(GeomInt_LineTool::FirstParameter(L)); + seqp.Append(GeomInt_LineTool::LastParameter(L)); + } + // + done =Standard_True; + return; + } // else if (typl != IntPatch_Restriction) { + + done = Standard_False; + seqp.Clear(); + nbvtx = GeomInt_LineTool::NbVertex(L); + if (nbvtx == 0) { // Keep a priori. Point 2d is required on each + // surface to make the decision. Will be done in the caller + seqp.Append(GeomInt_LineTool::FirstParameter(L)); + seqp.Append(GeomInt_LineTool::LastParameter(L)); + done = Standard_True; + return; + } + + GeomInt_SequenceOfParameterAndOrientation seqpss; + TopAbs_Orientation or1=TopAbs_FORWARD,or2=TopAbs_FORWARD; + + for (i=1; i<=nbvtx; i++) { + const IntPatch_Point& thevtx = GeomInt_LineTool::Vertex(L,i); + const Standard_Real prm = thevtx.ParameterOnLine(); + if (thevtx.IsOnDomS1()) { + switch (thevtx.TransitionLineArc1().TransitionType()) { + case IntSurf_In: or1 = TopAbs_FORWARD; break; + case IntSurf_Out: or1 = TopAbs_REVERSED; break; + case IntSurf_Touch: or1 = TopAbs_INTERNAL; break; + case IntSurf_Undecided: or1 = TopAbs_INTERNAL; break; + } + } + else { + or1 = TopAbs_INTERNAL; + } + + if (thevtx.IsOnDomS2()) { + switch (thevtx.TransitionLineArc2().TransitionType()) { + case IntSurf_In: or2 = TopAbs_FORWARD; break; + case IntSurf_Out: or2 = TopAbs_REVERSED; break; + case IntSurf_Touch: or2 = TopAbs_INTERNAL; break; + case IntSurf_Undecided: or2 = TopAbs_INTERNAL; break; + } + } + else { + or2 = TopAbs_INTERNAL; + } + // + const Standard_Integer nbinserted = seqpss.Length(); + Standard_Boolean inserted = Standard_False; + for (Standard_Integer j=1; j<=nbinserted;j++) { + if (Abs(prm-seqpss(j).Parameter()) <= Tol) { + // accumulate + GeomInt_ParameterAndOrientation& valj = seqpss.ChangeValue(j); + if (or1 != TopAbs_INTERNAL) { + if (valj.Orientation1() != TopAbs_INTERNAL) { + if (or1 != valj.Orientation1()) { + valj.SetOrientation1(TopAbs_INTERNAL); + } + } + else { + valj.SetOrientation1(or1); + } + } + + if (or2 != TopAbs_INTERNAL) { + if (valj.Orientation2() != TopAbs_INTERNAL) { + if (or2 != valj.Orientation2()) { + valj.SetOrientation2(TopAbs_INTERNAL); + } + } + else { + valj.SetOrientation2(or2); + } + } + inserted = Standard_True; + break; + } + + if (prm < seqpss(j).Parameter()-Tol ) { + // insert before position j + seqpss.InsertBefore(j,GeomInt_ParameterAndOrientation(prm,or1,or2)); + inserted = Standard_True; + break; + } + + } + if (!inserted) { + seqpss.Append(GeomInt_ParameterAndOrientation(prm,or1,or2)); + } + } + + // determine the state at the beginning of line + Standard_Boolean trim = Standard_False; + Standard_Boolean dansS1 = Standard_False; + Standard_Boolean dansS2 = Standard_False; + + nbvtx = seqpss.Length(); + for (i=1; i<= nbvtx; i++) { + or1 = seqpss(i).Orientation1(); + if (or1 != TopAbs_INTERNAL) { + trim = Standard_True; + dansS1 = (or1 != TopAbs_FORWARD); + break; + } + } + + if (i > nbvtx) { + Standard_Real U,V; + for (i=1; i<=GeomInt_LineTool::NbVertex(L); i++ ) { + if (!GeomInt_LineTool::Vertex(L,i).IsOnDomS1() ) { + GeomInt_LineTool::Vertex(L,i).ParametersOnS1(U,V); + gp_Pnt2d PPCC(U,V); + if (myDom1->Classify(PPCC,Tol) == TopAbs_OUT) { + done = Standard_True; + return; + } + break; + } + } + dansS1 = Standard_True; // Keep in doubt + } + // + for (i=1; i<= nbvtx; i++) { + or2 = seqpss(i).Orientation2(); + if (or2 != TopAbs_INTERNAL) { + trim = Standard_True; + dansS2 = (or2 != TopAbs_FORWARD); + break; + } + } + + if (i > nbvtx) { + Standard_Real U,V; + for (i=1; i<=GeomInt_LineTool::NbVertex(L); i++ ) { + if (!GeomInt_LineTool::Vertex(L,i).IsOnDomS2() ) { + GeomInt_LineTool::Vertex(L,i).ParametersOnS2(U,V); + if (myDom2->Classify(gp_Pnt2d(U,V),Tol) == TopAbs_OUT) { + done = Standard_True; + return; + } + break; + } + } + dansS2 = Standard_True; // Keep in doubt + } + + if (!trim) { // necessarily dansS1 == dansS2 == Standard_True + seqp.Append(GeomInt_LineTool::FirstParameter(L)); + seqp.Append(GeomInt_LineTool::LastParameter(L)); + done = Standard_True; + return; + } + + // sequence seqpss is peeled to create valid ends + // and store them in seqp(2*i+1) and seqp(2*i+2) + Standard_Real thefirst = GeomInt_LineTool::FirstParameter(L); + Standard_Real thelast = GeomInt_LineTool::LastParameter(L); + firstp = thefirst; + + for (i=1; i<=nbvtx; i++) { + or1 = seqpss(i).Orientation1(); + or2 = seqpss(i).Orientation2(); + if (dansS1 && dansS2) { + if (or1 == TopAbs_REVERSED){ + dansS1 = Standard_False; + } + + if (or2 == TopAbs_REVERSED){ + dansS2 = Standard_False; + } + if (!dansS1 || !dansS2) { + lastp = seqpss(i).Parameter(); + Standard_Real stofirst = Max(firstp, thefirst); + Standard_Real stolast = Min(lastp, thelast) ; + + if (stolast > stofirst) { + seqp.Append(stofirst); + seqp.Append(stolast); + } + if (lastp > thelast) { + break; + } + } + } + else { + if (dansS1) { + if (or1 == TopAbs_REVERSED) { + dansS1 = Standard_False; + } + } + else { + if (or1 == TopAbs_FORWARD){ + dansS1 = Standard_True; + } + } + if (dansS2) { + if (or2 == TopAbs_REVERSED) { + dansS2 = Standard_False; + } + } + else { + if (or2 == TopAbs_FORWARD){ + dansS2 = Standard_True; + } + } + if (dansS1 && dansS2){ + firstp = seqpss(i).Parameter(); + } + } + } + // + // finally to add + if (dansS1 && dansS2) { + lastp = thelast; + firstp = Max(firstp,thefirst); + if (lastp > firstp) { + seqp.Append(firstp); + seqp.Append(lastp); + } + } + done = Standard_True; +} + //======================================================================= //function : Recadre //purpose : //======================================================================= -static void Recadre(const Handle(GeomAdaptor_HSurface)& myHS1, - const Handle(GeomAdaptor_HSurface)& myHS2, - Standard_Real& u1, - Standard_Real& v1, - Standard_Real& u2, - Standard_Real& v2) -{ +void Recadre(const Handle(GeomAdaptor_HSurface)& myHS1, + const Handle(GeomAdaptor_HSurface)& myHS2, + Standard_Real& u1, + Standard_Real& v1, + Standard_Real& u2, + Standard_Real& v2) +{ Standard_Boolean myHS1IsUPeriodic,myHS1IsVPeriodic; const GeomAbs_SurfaceType typs1 = myHS1->GetType(); switch (typs1) - { + { case GeomAbs_Cylinder: case GeomAbs_Cone: - case GeomAbs_Sphere: + case GeomAbs_Sphere: { myHS1IsUPeriodic = Standard_True; myHS1IsVPeriodic = Standard_False; @@ -69,7 +581,7 @@ static void Recadre(const Handle(GeomAdaptor_HSurface)& myHS1, } default: { - //-- Le cas de biparametrees periodiques est gere en amont + //-- Case of periodic biparameters is processed upstream myHS1IsUPeriodic = myHS1IsVPeriodic = Standard_False; break; } @@ -77,7 +589,7 @@ static void Recadre(const Handle(GeomAdaptor_HSurface)& myHS1, Standard_Boolean myHS2IsUPeriodic,myHS2IsVPeriodic; const GeomAbs_SurfaceType typs2 = myHS2->GetType(); switch (typs2) - { + { case GeomAbs_Cylinder: case GeomAbs_Cone: case GeomAbs_Sphere: @@ -93,691 +605,379 @@ static void Recadre(const Handle(GeomAdaptor_HSurface)& myHS1, } default: { - //-- Le cas de biparametrees periodiques est gere en amont + //-- Case of periodic biparameters is processed upstream myHS2IsUPeriodic = myHS2IsVPeriodic = Standard_False; break; } } + Standard_Real du, dv; + // if(myHS1IsUPeriodic) { const Standard_Real lmf = M_PI+M_PI; //-- myHS1->UPeriod(); const Standard_Real f = myHS1->FirstUParameter(); const Standard_Real l = myHS1->LastUParameter(); - while(u1 < f) { u1+=lmf; } - while(u1 > l) { u1-=lmf; } + GeomInt::AdjustPeriodic(u1, f, l, lmf, u1, du); } if(myHS1IsVPeriodic) { const Standard_Real lmf = M_PI+M_PI; //-- myHS1->VPeriod(); const Standard_Real f = myHS1->FirstVParameter(); const Standard_Real l = myHS1->LastVParameter(); - while(v1 < f) { v1+=lmf; } - while(v1 > l) { v1-=lmf; } + GeomInt::AdjustPeriodic(v1, f, l, lmf, v1, dv); } if(myHS2IsUPeriodic) { const Standard_Real lmf = M_PI+M_PI; //-- myHS2->UPeriod(); const Standard_Real f = myHS2->FirstUParameter(); const Standard_Real l = myHS2->LastUParameter(); - while(u2 < f) { u2+=lmf; } - while(u2 > l) { u2-=lmf; } + GeomInt::AdjustPeriodic(u2, f, l, lmf, u2, du); } if(myHS2IsVPeriodic) { const Standard_Real lmf = M_PI+M_PI; //-- myHS2->VPeriod(); const Standard_Real f = myHS2->FirstVParameter(); const Standard_Real l = myHS2->LastVParameter(); - while(v2 < f) { v2+=lmf; } - while(v2 > l) { v2-=lmf; } + GeomInt::AdjustPeriodic(v2, f, l, lmf, v2, dv); } } - - //======================================================================= //function : Parameters //purpose : //======================================================================= -static void Parameters(const Handle(GeomAdaptor_HSurface)& myHS1, - const Handle(GeomAdaptor_HSurface)& myHS2, - const gp_Pnt& Ptref, - Standard_Real& U1, - Standard_Real& V1, - Standard_Real& U2, - Standard_Real& V2) +void Parameters(const Handle(GeomAdaptor_HSurface)& myHS1, + const Handle(GeomAdaptor_HSurface)& myHS2, + const gp_Pnt& Ptref, + Standard_Real& U1, + Standard_Real& V1, + Standard_Real& U2, + Standard_Real& V2) { - IntSurf_Quadric quad1,quad2; - switch (myHS1->Surface().GetType()) - { - case GeomAbs_Plane: quad1.SetValue(myHS1->Surface().Plane()); break; - case GeomAbs_Cylinder: quad1.SetValue(myHS1->Surface().Cylinder()); break; - case GeomAbs_Cone: quad1.SetValue(myHS1->Surface().Cone()); break; - case GeomAbs_Sphere: quad1.SetValue(myHS1->Surface().Sphere()); break; - case GeomAbs_Torus: quad1.SetValue(myHS1->Surface().Torus()); break; - default: Standard_ConstructionError::Raise("GeomInt_LineConstructor::Parameters"); - } - switch (myHS2->Surface().GetType()) - { - case GeomAbs_Plane: quad2.SetValue(myHS2->Surface().Plane()); break; - case GeomAbs_Cylinder: quad2.SetValue(myHS2->Surface().Cylinder()); break; - case GeomAbs_Cone: quad2.SetValue(myHS2->Surface().Cone()); break; - case GeomAbs_Sphere: quad2.SetValue(myHS2->Surface().Sphere()); break; - case GeomAbs_Torus: quad2.SetValue(myHS2->Surface().Torus()); break; - default: Standard_ConstructionError::Raise("GeomInt_LineConstructor::Parameters"); + Parameters(myHS1, Ptref, U1, V1); + Parameters(myHS2, Ptref, U2, V2); +} +//======================================================================= +//function : Parameter +//purpose : +//======================================================================= +void Parameters(const Handle(GeomAdaptor_HSurface)& myHS1, + const gp_Pnt& Ptref, + Standard_Real& U1, + Standard_Real& V1) +{ + IntSurf_Quadric quad1; + // + switch (myHS1->Surface().GetType()) { + case GeomAbs_Plane: + quad1.SetValue(myHS1->Surface().Plane()); + break; + case GeomAbs_Cylinder: + quad1.SetValue(myHS1->Surface().Cylinder()); + break; + case GeomAbs_Cone: + quad1.SetValue(myHS1->Surface().Cone()); + break; + case GeomAbs_Sphere: + quad1.SetValue(myHS1->Surface().Sphere()); + break; + case GeomAbs_Torus: + quad1.SetValue(myHS1->Surface().Torus()); + break; + default: + Standard_ConstructionError::Raise("GeomInt_LineConstructor::Parameters"); } quad1.Parameters(Ptref,U1,V1); - quad2.Parameters(Ptref,U2,V2); } - //======================================================================= -//function : Perform +//function : GLinePoint //purpose : //======================================================================= -void GeomInt_LineConstructor::Perform(const Handle(IntPatch_Line)& L) +void GLinePoint(const IntPatch_IType typl, + const Handle(IntPatch_GLine)& GLine, + const Standard_Real aT, + gp_Pnt& aP) { - Standard_Integer i,nbvtx; - Standard_Real firstp,lastp; - const Standard_Real Tol = Precision::PConfusion() * 35.0; + switch (typl) { + case IntPatch_Lin: + aP = ElCLib::Value(aT, GLine->Line()); + break; + case IntPatch_Circle: + aP = ElCLib::Value(aT, GLine->Circle()); + break; + case IntPatch_Ellipse: + aP = ElCLib::Value(aT, GLine->Ellipse()); + break; + case IntPatch_Hyperbola: + aP = ElCLib::Value(aT, GLine->Hyperbola()); + break; + case IntPatch_Parabola: + aP = ElCLib::Value(aT, GLine->Parabola()); + break; + default: + Standard_ConstructionError::Raise("GeomInt_LineConstructor::Parameters"); + } +} + +//======================================================================= +//function : TreatCircle +//purpose : +//======================================================================= +void GeomInt_LineConstructor::TreatCircle(const Handle(IntPatch_Line)& aLine, + const Standard_Real aTol) +{ + Standard_Boolean bRejected; + IntPatch_IType aType; + // + aType=aLine->ArcType(); + Handle(IntPatch_GLine)& aGLine=*((Handle(IntPatch_GLine) *)&aLine); + // + bRejected=RejectMicroCircle(aGLine, aType, aTol); + if (bRejected) { + return; + } + //---------------------------------------- + Standard_Boolean bFound; + Standard_Integer aNbVtx, aNbVtxWas, i; + Standard_Real aTolPC, aT, aT1, aT2, aTmid, aTwoPI, aTolPC1; + Standard_Real aU1, aV1, aU2, aV2; + TopAbs_State aIn1, aIn2; + GeomAbs_SurfaceType aTS1, aTS2; + gp_Pnt aPmid; + gp_Pnt2d aP2D; + GeomInt_RealWithFlag *pVtx; + //-------------------------------------1 + aTwoPI=M_PI+M_PI; + aTolPC=Precision::PConfusion(); + aNbVtxWas=GeomInt_LineTool::NbVertex(aLine); - const IntPatch_IType typl = L->ArcType(); - if(typl == IntPatch_Analytic) - { - Standard_Real u1,v1,u2,v2; - Handle(IntPatch_ALine)& ALine = *((Handle(IntPatch_ALine) *)&L); - seqp.Clear(); - nbvtx = GeomInt_LineTool::NbVertex(L); - for(i=1;iValue(pmid); - - //Checking, if it is an "micro-curve" (can it be collapsed in one point?). - //If "yes" then first-, last- and midpoints are same point. - gp_Pnt aP1 = ALine->Value(RealToInt(firstp)), - aP2 = ALine->Value(RealToInt(lastp)); - - Standard_Real aSQDist = aP1.SquareDistance(aP2); - aSQDist = Max(aSQDist, aP1.SquareDistance(Pmid)); - aSQDist = Max(aSQDist, aP2.SquareDistance(Pmid)); - - Standard_Boolean isMicro = aSQDist*100.0 < Tol; - - if((Abs(firstp-lastp)>Precision::PConfusion()) && !isMicro) - { - Parameters(myHS1,myHS2,Pmid,u1,v1,u2,v2); - Recadre(myHS1,myHS2,u1,v1,u2,v2); - const TopAbs_State in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol); - if(in1 != TopAbs_OUT) { - const TopAbs_State in2 = myDom2->Classify(gp_Pnt2d(u2,v2),Tol); - if(in2 != TopAbs_OUT) { - seqp.Append(firstp); - seqp.Append(lastp); - } - } - } - } - done = Standard_True; - return; + aNbVtx=aNbVtxWas+2; + //-------------------------------------2 + aTS1=myHS1->GetType(); + aTS2=myHS2->GetType(); + // + // About the value aTolPC1=1000.*aTolPC, + // see IntPatch_GLine.cxx, line:398 + // for more details; + aTolPC1=1000.*aTolPC; + //------------------------------------- + // + pVtx=new GeomInt_RealWithFlag [aNbVtx]; + // + pVtx[0].SetValue(0.); + pVtx[1].SetValue(aTwoPI); + // + for(i=1; i<=aNbVtxWas; ++i) { + aT=GeomInt_LineTool::Vertex(aLine, i).ParameterOnLine(); + aT=AdjustOnPeriod(aT, aTwoPI); + pVtx[i+1].SetValue(aT); } - else if(typl == IntPatch_Walking) - { - Standard_Real u1,v1,u2,v2; - Handle(IntPatch_WLine)& WLine = *((Handle(IntPatch_WLine) *)&L); - seqp.Clear(); - - i = 1; - - { - firstp = GeomInt_LineTool::Vertex(L,1).ParameterOnLine(); - const IntSurf_PntOn2S& Pf = WLine->Point(RealToInt(firstp)); - - Pf.Parameters(u1,v1,u2,v2); - -//Inscribe parameters into main period for periodic surfaces - Recadre(myHS1,myHS2,u1,v1,u2,v2); - - const TopAbs_State in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol); - const TopAbs_State in2 = myDom2->Classify(gp_Pnt2d(u2,v2),Tol); - if((in1 == TopAbs_OUT) || (in2 == TopAbs_OUT)) - { - i = 2; - } - } - - nbvtx = GeomInt_LineTool::NbVertex(L); - for(;iPoint(pmid); - - //Checking, if it is an "micro-curve" (can it be collapsed in one point?). - //If "yes" then first-, last- and midpoints are same point. - gp_Pnt aP1 = WLine->Point(RealToInt(firstp)).Value(), - aP2 = WLine->Point(RealToInt(lastp)).Value(); - - Standard_Real aSQDist = aP1.SquareDistance(aP2); - aSQDist = Max(aSQDist, aP1.SquareDistance(Pmid.Value())); - aSQDist = Max(aSQDist, aP2.SquareDistance(Pmid.Value())); - - Standard_Boolean isMicro = aSQDist*100.0 < Tol; - - if(isMicro) - {//3D-dimension is small. Checking 2D-dimension - aSQDist = 0.0; - Standard_Real u1f, v1f, u2f, v2f; - Standard_Real u1l, v1l, u2l, v2l; - Standard_Real u1m, v1m, u2m, v2m; - - WLine->Point(RealToInt(firstp)).Parameters(u1f, v1f, u2f, v2f); - WLine->Point(RealToInt(lastp)).Parameters(u1l, v1l, u2l, v2l); - WLine->Point(pmid).Parameters(u1m, v1m, u2m, v2m); - - Standard_Real aDelta = u1m - u1f; - aSQDist += aDelta*aDelta; - aDelta = v1m - v1f; - aSQDist += aDelta*aDelta; - aDelta = u2m - u2f; - aSQDist += aDelta*aDelta; - aDelta = v2m - v2f; - aSQDist += aDelta*aDelta; - - aDelta = u1m - u1l; - aSQDist += aDelta*aDelta; - aDelta = v1m - v1l; - aSQDist += aDelta*aDelta; - aDelta = u2m - u2l; - aSQDist += aDelta*aDelta; - aDelta = v2m - v2l; - aSQDist += aDelta*aDelta; - - isMicro = aSQDist*100.0 < Tol; - } - - if((Abs(firstp-lastp)>Precision::PConfusion()) && !isMicro) - { - Pmid.Parameters(u1,v1,u2,v2); -//Inscribe parameters into main period for periodic surfaces - Recadre(myHS1,myHS2,u1,v1,u2,v2); - - const TopAbs_State in1m = myDom1->Classify(gp_Pnt2d(u1,v1),Tol); - if(in1m == TopAbs_OUT) - { - continue; - } - - const TopAbs_State in2m = myDom2->Classify(gp_Pnt2d(u2,v2),Tol); - if(in2m == TopAbs_OUT) - { - continue; - } - - const IntSurf_PntOn2S& Plast = WLine->Point(RealToInt(lastp)); - Plast.Parameters(u1,v1,u2,v2); -//Inscribe parameters into main period for periodic surfaces - Recadre(myHS1,myHS2,u1,v1,u2,v2); - - const TopAbs_State in1l = myDom1->Classify(gp_Pnt2d(u1,v1),Tol); - if(in1l == TopAbs_OUT) - { - continue; - } - - const TopAbs_State in2l = myDom2->Classify(gp_Pnt2d(u2,v2),Tol); - if(in2l == TopAbs_OUT) - { - continue; - } - - seqp.Append(firstp); - seqp.Append(lastp); - } - } - done = Standard_True; - return; - } - else if (typl != IntPatch_Restriction) - { - Standard_Real u1,v1,u2,v2; - Handle(IntPatch_GLine)& GLine = *((Handle(IntPatch_GLine) *)&L); - seqp.Clear(); - nbvtx = GeomInt_LineTool::NbVertex(L); - Standard_Boolean intrvtested = Standard_False; - for(i=1;iPrecision::PConfusion())) - { - intrvtested = Standard_True; - const Standard_Real pmid = (firstp+lastp)*0.5; - gp_Pnt Pmid, aP1, aP2; - switch (typl) - { - case IntPatch_Lin: - Pmid = ElCLib::Value(pmid,GLine->Line()); - aP1 = ElCLib::Value(firstp,GLine->Line()); - aP2 = ElCLib::Value(lastp,GLine->Line()); - break; - case IntPatch_Circle: - Pmid = ElCLib::Value(pmid,GLine->Circle()); - aP1 = ElCLib::Value(firstp,GLine->Circle()); - aP2 = ElCLib::Value(lastp,GLine->Circle()); - break; - case IntPatch_Ellipse: - Pmid = ElCLib::Value(pmid,GLine->Ellipse()); - aP1 = ElCLib::Value(firstp,GLine->Ellipse()); - aP2 = ElCLib::Value(lastp,GLine->Ellipse()); - break; - case IntPatch_Hyperbola: - Pmid = ElCLib::Value(pmid,GLine->Hyperbola()); - aP1 = ElCLib::Value(firstp,GLine->Hyperbola()); - aP2 = ElCLib::Value(lastp,GLine->Hyperbola()); - break; - case IntPatch_Parabola: - Pmid = ElCLib::Value(pmid,GLine->Parabola()); - aP1 = ElCLib::Value(firstp,GLine->Parabola()); - aP2 = ElCLib::Value(lastp,GLine->Parabola()); - break; - case IntPatch_Analytic: - case IntPatch_Walking: - case IntPatch_Restriction: break; // cases Analytic, Walking and Restriction are handled above - } - - Standard_Real aSQDist = aP1.SquareDistance(aP2); - aSQDist = Max(aSQDist, aP1.SquareDistance(Pmid)); - aSQDist = Max(aSQDist, aP2.SquareDistance(Pmid)); - - if(aSQDist*100.0 > Tol) - { //if it is not an "micro-curve" (can it be collapsed in one point?). - //If "yes" then first-, last- and midpoints are same point. - Parameters(myHS1,myHS2,Pmid,u1,v1,u2,v2); - Recadre(myHS1,myHS2,u1,v1,u2,v2); - const TopAbs_State in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol); - if(in1 != TopAbs_OUT) { - const TopAbs_State in2 = myDom2->Classify(gp_Pnt2d(u2,v2),Tol); - if(in2 != TopAbs_OUT) { - seqp.Append(firstp); - seqp.Append(lastp); - } - } - } - } - } - if(typl == IntPatch_Circle || typl == IntPatch_Ellipse) - { - const Standard_Real aT = M_PI + M_PI; - firstp = GeomInt_LineTool::Vertex(L,nbvtx).ParameterOnLine(); - lastp = aT + GeomInt_LineTool::Vertex(L,1).ParameterOnLine(); - const Standard_Real cadrinf = GeomInt_LineTool::FirstParameter(L); - const Standard_Real cadrsup = GeomInt_LineTool::LastParameter(L); - Standard_Real acadr = (firstp+lastp)*0.5; - while(acadr < cadrinf) - { - acadr+=aT; - } - - while(acadr > cadrsup) - { - acadr-=aT; - } - - if(acadr>=cadrinf && acadr<=cadrsup) - { - if(Abs(firstp-lastp) > Precision::PConfusion()) - { - intrvtested = Standard_True; - const Standard_Real pmid = (firstp+lastp)*0.5; - gp_Pnt Pmid; - if (typl == IntPatch_Circle) - Pmid = ElCLib::Value(pmid,GLine->Circle()); - else - Pmid = ElCLib::Value(pmid,GLine->Ellipse()); - Parameters(myHS1,myHS2,Pmid,u1,v1,u2,v2); - Recadre(myHS1,myHS2,u1,v1,u2,v2); - const TopAbs_State in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol); - if(in1 != TopAbs_OUT) - { - const TopAbs_State in2 = myDom2->Classify(gp_Pnt2d(u2,v2),Tol); - if(in2 != TopAbs_OUT) - { - seqp.Append(firstp); - seqp.Append(lastp); - } - } - } - } - } - - if (!intrvtested) { - // on garde a priori. Il faudrait un point 2d sur chaque - // surface pour prendre la decision. Sera fait dans - // l`appelant - seqp.Append(GeomInt_LineTool::FirstParameter(L)); - seqp.Append(GeomInt_LineTool::LastParameter(L)); - } - done = Standard_True; - return; - } - - done = Standard_False; - seqp.Clear(); - nbvtx = GeomInt_LineTool::NbVertex(L); - if (nbvtx == 0) { // on garde a priori. Il faudrait un point 2d sur chaque - // surface pour prendre la decision. Sera fait dans - // l`appelant - seqp.Append(GeomInt_LineTool::FirstParameter(L)); - seqp.Append(GeomInt_LineTool::LastParameter(L)); - done = Standard_True; - return; - } - - GeomInt_SequenceOfParameterAndOrientation seqpss; - TopAbs_Orientation or1=TopAbs_FORWARD,or2=TopAbs_FORWARD; - - for (i=1; i<=nbvtx; i++) - { - const IntPatch_Point& thevtx = GeomInt_LineTool::Vertex(L,i); - const Standard_Real prm = thevtx.ParameterOnLine(); - if (thevtx.IsOnDomS1()) - { - switch (thevtx.TransitionLineArc1().TransitionType()) - { - case IntSurf_In: or1 = TopAbs_FORWARD; break; - case IntSurf_Out: or1 = TopAbs_REVERSED; break; - case IntSurf_Touch: or1 = TopAbs_INTERNAL; break; - case IntSurf_Undecided: or1 = TopAbs_INTERNAL; break; - } - } - else - or1 = TopAbs_INTERNAL; - - if (thevtx.IsOnDomS2()) - { - switch (thevtx.TransitionLineArc2().TransitionType()) - { - case IntSurf_In: or2 = TopAbs_FORWARD; break; - case IntSurf_Out: or2 = TopAbs_REVERSED; break; - case IntSurf_Touch: or2 = TopAbs_INTERNAL; break; - case IntSurf_Undecided: or2 = TopAbs_INTERNAL; break; - } - } - else - or2 = TopAbs_INTERNAL; - - const Standard_Integer nbinserted = seqpss.Length(); - Standard_Boolean inserted = Standard_False; - for (Standard_Integer j=1; j<=nbinserted;j++) - { - if (Abs(prm-seqpss(j).Parameter()) <= Tol) - { - // on cumule - GeomInt_ParameterAndOrientation& valj = seqpss.ChangeValue(j); - if (or1 != TopAbs_INTERNAL) - { - if (valj.Orientation1() != TopAbs_INTERNAL) - { - if (or1 != valj.Orientation1()) - { - valj.SetOrientation1(TopAbs_INTERNAL); - } - } - else - { - valj.SetOrientation1(or1); - } - } - - if (or2 != TopAbs_INTERNAL) - { - if (valj.Orientation2() != TopAbs_INTERNAL) - { - if (or2 != valj.Orientation2()) - { - valj.SetOrientation2(TopAbs_INTERNAL); - } - } - else - { - valj.SetOrientation2(or2); - } - } - - inserted = Standard_True; - break; - } - - if (prm < seqpss(j).Parameter()-Tol ) { - // on insere avant la position j - seqpss.InsertBefore(j,GeomInt_ParameterAndOrientation(prm,or1,or2)); - inserted = Standard_True; + // + SortShell(aNbVtx, pVtx); + // + RejectNearBeacons(aNbVtx, pVtx, aTolPC1, aTS1, aTS2); + // + RejectDuplicates(aNbVtx, pVtx, aTolPC); + // + if ((aType==IntPatch_Circle || aType==IntPatch_Ellipse)&& aNbVtx>2) { // zz + bFound=Standard_False; + for(i=1; i<=aNbVtxWas; ++i) { + aT=GeomInt_LineTool::Vertex(aLine, i).ParameterOnLine(); + if (fabs(aT) < aTolPC1 || fabs(aT-aTwoPI) < aTolPC1) { + bFound=!bFound; break; } } - - if (!inserted) - { - seqpss.Append(GeomInt_ParameterAndOrientation(prm,or1,or2)); + if (!bFound) { + aT=pVtx[1].Value()+aTwoPI; + pVtx[aNbVtx-1].SetValue(aT); + // + for(i=0; i nbvtx) - { - Standard_Real U,V; - for (i=1; i<=GeomInt_LineTool::NbVertex(L); i++ ) - { - if (!GeomInt_LineTool::Vertex(L,i).IsOnDomS1() ) - { - GeomInt_LineTool::Vertex(L,i).ParametersOnS1(U,V); - gp_Pnt2d PPCC(U,V); - if (myDom1->Classify(PPCC,Tol) == TopAbs_OUT) { - done = Standard_True; - return; - } - break; + // + for(i=0; iClassify(aP2D, aTol); + if(aIn1 != TopAbs_OUT) { + aP2D.SetCoord(aU2, aV2); + aIn2=myDom2->Classify(aP2D, aTol); + if(aIn2 != TopAbs_OUT) { + seqp.Append(aT1); + seqp.Append(aT2); } } - dansS1 = Standard_True; // on garde dans le doute } - - for (i=1; i<= nbvtx; i++) - { - or2 = seqpss(i).Orientation2(); - if (or2 != TopAbs_INTERNAL) - { - trim = Standard_True; - dansS2 = (or2 != TopAbs_FORWARD); - break; - } - } - - if (i > nbvtx) - { - Standard_Real U,V; - for (i=1; i<=GeomInt_LineTool::NbVertex(L); i++ ) - { - if (!GeomInt_LineTool::Vertex(L,i).IsOnDomS2() ) - { - GeomInt_LineTool::Vertex(L,i).ParametersOnS2(U,V); - if (myDom2->Classify(gp_Pnt2d(U,V),Tol) == TopAbs_OUT) { - done = Standard_True; - return; - } - break; - } - } - dansS2 = Standard_True; // on garde dans le doute - } - - if (!trim) { // on a necessairement dansS1 == dansS2 == Standard_True - seqp.Append(GeomInt_LineTool::FirstParameter(L)); - seqp.Append(GeomInt_LineTool::LastParameter(L)); - done = Standard_True; - return; - } - - // On epluche la sequence seqpss pour constituer les bouts valides - // et les stocker dans seqp(2*i+1) et seqp(2*i+2) - Standard_Real thefirst = GeomInt_LineTool::FirstParameter(L); - Standard_Real thelast = GeomInt_LineTool::LastParameter(L); - firstp = thefirst; - - for (i=1; i<=nbvtx; i++) - { - or1 = seqpss(i).Orientation1(); - or2 = seqpss(i).Orientation2(); - if (dansS1 && dansS2) - { - if (or1 == TopAbs_REVERSED) - dansS1 = Standard_False; - /*else if (or1 == TopAbs_FORWARD) { - }*/ - if (or2 == TopAbs_REVERSED) - dansS2 = Standard_False; - /*else if (or2 == TopAbs_FORWARD) { - }*/ - if (!dansS1 || !dansS2) - { - lastp = seqpss(i).Parameter(); - Standard_Real stofirst = Max(firstp, thefirst); - Standard_Real stolast = Min(lastp, thelast) ; - if (stolast > stofirst) - { - seqp.Append(stofirst); - seqp.Append(stolast); - } - - if (lastp > thelast) + // + delete [] pVtx; +} +//======================================================================= +//function : RejectNearBeacons +//purpose : Reject the thickenings near the beacon points (if exist) +// The gifts, made by sweep algo. +// chl/930/B5 B8 C2 C5 E2 E5 E8 F2 G8 H2 H5 H8 +//======================================================================= +void RejectNearBeacons(Standard_Integer& aNbVtx, + GeomInt_RealWithFlag *pVtx, + Standard_Real aTolPC1, + const GeomAbs_SurfaceType aTS1, + const GeomAbs_SurfaceType aTS2) +{ + Standard_Integer i, j, iBcn; + Standard_Real aT, aBcn[2]; + // + if (aTS1==GeomAbs_Cylinder && aTS2==GeomAbs_Cylinder) { + aBcn[0]=0.5*M_PI; + aBcn[1]=1.5*M_PI; + // + for (j=0; j<2; ++j) { + iBcn=-1; + for(i=0; i firstp) { - seqp.Append(firstp); - seqp.Append(lastp); - } - } - done = Standard_True; -} - - -//======================================================================= -//function : PeriodicLine -//purpose : -//======================================================================= -void GeomInt_LineConstructor::PeriodicLine (const Handle(IntPatch_Line)& L) const -{ - const IntPatch_IType typl = L->ArcType(); - if (typl != IntPatch_Circle && typl != IntPatch_Ellipse) - return; - - const Standard_Real Tol = Precision::PConfusion(); - Handle(IntPatch_GLine) glin = Handle(IntPatch_GLine)::DownCast(L); - Standard_Integer i,j,nbvtx = glin->NbVertex(); - for (i=1; i<=nbvtx; i++) - { - IntPatch_Point thevtx = glin->Vertex(i); - const Standard_Real prm = thevtx.ParameterOnLine(); - Standard_Boolean changevtx = Standard_False; - if (thevtx.IsOnDomS1() || thevtx.IsOnDomS2()) - { - for (j=1; j<=nbvtx; j++) - { - if (j!=i) - { - const IntPatch_Point& thevtxbis = glin->Vertex(j); - const Standard_Real prmbis = thevtxbis.ParameterOnLine(); - if (Abs(prm-prmbis) <= Tol) - { - Standard_Real u,v; - gp_Pnt2d p2d; - if (thevtx.IsOnDomS1() && thevtxbis.IsOnDomS1() && - thevtxbis.TransitionLineArc1().TransitionType()==IntSurf_In) - { - p2d = thevtx.ArcOnS1()->Value(thevtx.ParameterOnArc1()); - u = p2d.X(); v = p2d.Y(); - p2d = thevtxbis.ArcOnS1()->Value(thevtxbis.ParameterOnArc1()); - if (Abs(u-p2d.X()) > Tol || Abs(v-p2d.Y()) > Tol) - { - changevtx = Standard_True; - break; - } - } - if (thevtx.IsOnDomS2() && thevtxbis.IsOnDomS2() && - thevtxbis.TransitionLineArc2().TransitionType()==IntSurf_In) - { - p2d = thevtx.ArcOnS2()->Value(thevtx.ParameterOnArc2()); - u = p2d.X(); v = p2d.Y(); - p2d = thevtxbis.ArcOnS2()->Value(thevtxbis.ParameterOnArc2()); - if (Abs(u-p2d.X()) > Tol || Abs(v-p2d.Y()) > Tol) - { - changevtx = Standard_True; - break; - } - } + // + for(i=0; iReplace(i,thevtx); + aNbVtx=j; + }// if (aTS1==GeomAbs_Cylinder && aTS2==GeomAbs_Cylinder) { +} + +//======================================================================= +//function : RejectDuplicates +//purpose : +//======================================================================= +void RejectDuplicates(Standard_Integer& aNbVtx, + GeomInt_RealWithFlag *pVtx, + Standard_Real aTolPC) +{ + Standard_Integer i, j; + Standard_Real dX, aT1, aT2; + // + for(i=0; i=0. && aT<=aPeriod)) { + k=(Standard_Integer)(aT/aPeriod); + aT=aT-k*aPeriod; + } + // + return aT; +} +//======================================================================= +//function : RejectMicroCrcles +//purpose : +//======================================================================= +Standard_Boolean RejectMicroCircle(const Handle(IntPatch_GLine)& aGLine, + const IntPatch_IType aType, + const Standard_Real aTol3D) +{ + Standard_Boolean bRet; + Standard_Real aR; + // + bRet=Standard_False; + // + if (aType==IntPatch_Circle) { + aR=aGLine->Circle().Radius(); + bRet=(aREllipse().MajorRadius(); + bRet=(aR -1) goto m30; + }//if (a[l] < a[j]){ + }//for (i=0; i #include #include +#include static Standard_Boolean SetEmptyResultRange(const Standard_Real theParameter, IntTools_MarkedRangeSet& theMarkedRange); @@ -651,7 +652,7 @@ void IntTools_BeanFaceIntersector::ComputeAroundExactIntersection() aUPeriod = mySurface.UPeriod(); aEps = Epsilon(aUPeriod); // - IntTools_Tools::AdjustPeriodic(U, myUMinParameter, myUMaxParameter, + GeomInt::AdjustPeriodic(U, myUMinParameter, myUMaxParameter, aUPeriod, aNewU, du, aEps); solutionIsValid = Standard_True; bUCorrected = Standard_True; @@ -668,7 +669,7 @@ void IntTools_BeanFaceIntersector::ComputeAroundExactIntersection() aVPeriod = mySurface.VPeriod(); aEps = Epsilon(aVPeriod); // - IntTools_Tools::AdjustPeriodic(V, myVMinParameter, myVMaxParameter, + GeomInt::AdjustPeriodic(V, myVMinParameter, myVMaxParameter, aVPeriod, aNewV, dv, aEps); solutionIsValid = Standard_True; V = aNewV; diff --git a/src/IntTools/IntTools_FClass2d.cxx b/src/IntTools/IntTools_FClass2d.cxx index c677d2b7c4..a08e0774a6 100644 --- a/src/IntTools/IntTools_FClass2d.cxx +++ b/src/IntTools/IntTools_FClass2d.cxx @@ -45,6 +45,7 @@ #include #include #include +#include //======================================================================= //function : IntTools_FClass2d:IntTools:_FClass2d @@ -554,11 +555,11 @@ IntTools_FClass2d::IntTools_FClass2d() if (RecadreOnPeriodic) { Standard_Real du, dv; if (IsUPer) { - IntTools_Tools::AdjustPeriodic(uu, Umin, Umax, uperiod, uu, du); + GeomInt::AdjustPeriodic(uu, Umin, Umax, uperiod, uu, du); }// if (IsUPer) { // if (IsVPer) { - IntTools_Tools::AdjustPeriodic(vv, Vmin, Vmax, vperiod, vv, dv); + GeomInt::AdjustPeriodic(vv, Vmin, Vmax, vperiod, vv, dv); }//if (IsVPer) { } // @@ -685,11 +686,11 @@ IntTools_FClass2d::IntTools_FClass2d() if (RecadreOnPeriodic) { Standard_Real du, dv; if (IsUPer) { - IntTools_Tools::AdjustPeriodic(uu, Umin, Umax, uperiod, uu, du); + GeomInt::AdjustPeriodic(uu, Umin, Umax, uperiod, uu, du); }// if (IsUPer) { // if (IsVPer) { - IntTools_Tools::AdjustPeriodic(vv, Vmin, Vmax, vperiod, vv, dv); + GeomInt::AdjustPeriodic(vv, Vmin, Vmax, vperiod, vv, dv); }//if (IsVPer) { } // diff --git a/src/IntTools/IntTools_FaceFace.cdl b/src/IntTools/IntTools_FaceFace.cdl index 129b5876a2..ef9573c3a3 100644 --- a/src/IntTools/IntTools_FaceFace.cdl +++ b/src/IntTools/IntTools_FaceFace.cdl @@ -26,7 +26,7 @@ uses Intersection from IntPatch, Face from TopoDS, SequenceOfCurves from IntTools, - LineConstructor from IntTools, + LineConstructor from GeomInt, SequenceOfPntOn2Faces from IntTools, Context from IntTools @@ -148,7 +148,7 @@ fields myIsDone : Boolean from Standard; myIntersector : Intersection from IntPatch; - myLConstruct : LineConstructor from IntTools; + myLConstruct : LineConstructor from GeomInt; myHS1 : HSurface from GeomAdaptor; myHS2 : HSurface from GeomAdaptor; myNbrestr : Integer from Standard; diff --git a/src/IntTools/IntTools_FaceFace.cxx b/src/IntTools/IntTools_FaceFace.cxx index dc358b7ce6..d31012bc9b 100644 --- a/src/IntTools/IntTools_FaceFace.cxx +++ b/src/IntTools/IntTools_FaceFace.cxx @@ -113,6 +113,7 @@ #include #include #include +#include static void RefineVector(gp_Vec2d& aV2D); @@ -175,7 +176,7 @@ static const Handle(GeomAdaptor_HSurface)& theSurface2, const TopoDS_Face& theFace1, const TopoDS_Face& theFace2, - const IntTools_LineConstructor& theLConstructor, + const GeomInt_LineConstructor& theLConstructor, const Standard_Boolean theAvoidLConstructor, IntPatch_SequenceOfLine& theNewLines, Standard_Real& theReachedTol3d, @@ -2407,7 +2408,7 @@ void BuildPCurves (Standard_Real f, U0 = pm.X(); // bAdjust = - IntTools_Tools::AdjustPeriodic(U0, umin, umax, period, U0x, du, aEps); + GeomInt::AdjustPeriodic(U0, umin, umax, period, U0x, du, aEps); if (bAdjust) { gp_Vec2d T1(du, 0.); C2d->Translate(T1); @@ -3561,7 +3562,7 @@ Standard_Boolean DecompositionOfWLine(const Handle(IntPatch_WLine)& theWLine, const Handle(GeomAdaptor_HSurface)& theSurface2, const TopoDS_Face& theFace1, const TopoDS_Face& theFace2, - const IntTools_LineConstructor& theLConstructor, + const GeomInt_LineConstructor& theLConstructor, const Standard_Boolean theAvoidLConstructor, IntPatch_SequenceOfLine& theNewLines, Standard_Real& theReachedTol3d, @@ -3649,7 +3650,7 @@ Standard_Boolean DecompositionOfWLine(const Handle(IntPatch_WLine)& theWLine, aParameter=V; } - IntTools_Tools::AdjustPeriodic(aParameter, + GeomInt::AdjustPeriodic(aParameter, alowerboundary, aupperboundary, aPeriod, @@ -3791,7 +3792,7 @@ Standard_Boolean DecompositionOfWLine(const Handle(IntPatch_WLine)& theWLine, else { Standard_Real aPeriod = (parit == 0) ? aGASurface->UPeriod() : aGASurface->VPeriod(); Standard_Real anoffset, anAdjustPar; - IntTools_Tools::AdjustPeriodic(aParameter, alowerboundary, aupperboundary, + GeomInt::AdjustPeriodic(aParameter, alowerboundary, aupperboundary, aPeriod, anAdjustPar, anoffset); bIsPointOnBoundary= @@ -3856,7 +3857,7 @@ Standard_Boolean DecompositionOfWLine(const Handle(IntPatch_WLine)& theWLine, Standard_Real aPeriod = (bIsUBoundary) ? aGASurface->UPeriod() : aGASurface->VPeriod(); Standard_Real aParameter = (bIsUBoundary) ? U : V; Standard_Real anoffset, anAdjustPar; - IntTools_Tools::AdjustPeriodic(aParameter, alowerboundary, aupperboundary, + GeomInt::AdjustPeriodic(aParameter, alowerboundary, aupperboundary, aPeriod, anAdjustPar, anoffset); Standard_Real adist = (bIsFirstBoundary) ? fabs(anAdjustPar - alowerboundary) : fabs(anAdjustPar - aupperboundary); diff --git a/src/IntTools/IntTools_LineConstructor.cdl b/src/IntTools/IntTools_LineConstructor.cdl deleted file mode 100644 index 4157b4ba57..0000000000 --- a/src/IntTools/IntTools_LineConstructor.cdl +++ /dev/null @@ -1,100 +0,0 @@ --- Created on: 1995-02-07 --- Created by: Jacques GOUSSARD --- Copyright (c) 1995-1999 Matra Datavision --- Copyright (c) 1999-2014 OPEN CASCADE SAS --- --- This file is part of Open CASCADE Technology software library. --- --- This library is free software; you can redistribute it and/or modify it under --- the terms of the GNU Lesser General Public License version 2.1 as published --- by the Free Software Foundation, with special exception defined in the file --- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT --- distribution for complete text of the license and disclaimer of any warranty. --- --- Alternatively, this file may be used under the terms of Open CASCADE --- commercial license or contractual agreement. - -class LineConstructor from IntTools - - ---Purpose: Splits given Line. - -- Class provides post-processing of results of - -- surfaces intersection - -uses Line from IntPatch, - TopolTool from Adaptor3d, - HSurface from GeomAdaptor, - SequenceOfReal from TColStd - - -raises NotDone from StdFail, - OutOfRange from Standard - -is - - Create - returns LineConstructor from IntTools; - ---C++: inline - ---Purpose: - --- Empty constructor - --- - - Load(me: in out; D1,D2: TopolTool from Adaptor3d; - S1,S2: HSurface from GeomAdaptor) - is static; - ---C++: inline - ---Purpose: - --- Initializes me by two surfaces and corresponding - --- tools which represent boundaries of surfaces - --- - - Perform(me: in out; L: Line from IntPatch) - is static; - ---Purpose: - --- Splits line - --- - - IsDone(me) - returns Boolean from Standard - is static; - ---C++: inline - ---Purpose: - --- Returns True if splitting was successful - --- - - NbParts(me) - returns Integer from Standard - raises NotDone from StdFail - is static; - ---C++: inline - ---Purpose: - --- Returns number of splits - --- - - Part(me; I: Integer from Standard; WFirst,WLast: out Real from Standard) - raises NotDone from StdFail, - OutOfRange from Standard - is static; - ---C++: inline - ---Purpose: - --- Return first and last parameters - --- for given index of split - --- - - ---PeriodicLine(me; L: Line from IntPatch) - --- is protected; - - TreatCircle(me:out; - aLine : Line from IntPatch; - aTol: Real from Standard) - is protected; - -fields - - done : Boolean from Standard; - seqp : SequenceOfReal from TColStd; - myDom1: TopolTool from Adaptor3d; - myDom2: TopolTool from Adaptor3d; - myHS1 : HSurface from GeomAdaptor; - myHS2 : HSurface from GeomAdaptor; - -end LineConstructor; diff --git a/src/IntTools/IntTools_LineConstructor.cxx b/src/IntTools/IntTools_LineConstructor.cxx deleted file mode 100644 index 690c3bf484..0000000000 --- a/src/IntTools/IntTools_LineConstructor.cxx +++ /dev/null @@ -1,982 +0,0 @@ -// Created on: 1995-02-07 -// Created by: Jacques GOUSSARD -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - - -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -static - void Parameters(const Handle(GeomAdaptor_HSurface)& myHS1, - const gp_Pnt& Ptref, - Standard_Real& U1, - Standard_Real& V1); -static - void Parameters(const Handle(GeomAdaptor_HSurface)& myHS1, - const Handle(GeomAdaptor_HSurface)& myHS2, - const gp_Pnt& Ptref, - Standard_Real& U1, - Standard_Real& V1, - Standard_Real& U2, - Standard_Real& V2); - -static - void GLinePoint(const IntPatch_IType typl, - const Handle(IntPatch_GLine)& GLine, - const Standard_Real aT, - gp_Pnt& aP); -static - void Recadre(const Handle(GeomAdaptor_HSurface)& myHS1, - const Handle(GeomAdaptor_HSurface)& myHS2, - Standard_Real& u1, - Standard_Real& v1, - Standard_Real& u2, - Standard_Real& v2); - -//======================================================================= -//function : Perform -//purpose : -//======================================================================= -void IntTools_LineConstructor::Perform(const Handle(IntPatch_Line)& L) -{ - Standard_Integer i,nbvtx; - Standard_Real firstp,lastp; - const Standard_Real Tol = Precision::PConfusion() * 35.0; - - const IntPatch_IType typl = L->ArcType(); - if(typl == IntPatch_Analytic) { - Standard_Real u1,v1,u2,v2; - Handle(IntPatch_ALine)& ALine = *((Handle(IntPatch_ALine) *)&L); - seqp.Clear(); - nbvtx = GeomInt_LineTool::NbVertex(L); - for(i=1;iValue(pmid); - Parameters(myHS1,myHS2,Pmid,u1,v1,u2,v2); - Recadre(myHS1,myHS2,u1,v1,u2,v2); - const TopAbs_State in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol); - if(in1 != TopAbs_OUT) { - const TopAbs_State in2 = myDom2->Classify(gp_Pnt2d(u2,v2),Tol); - if(in2 != TopAbs_OUT) { - seqp.Append(firstp); - seqp.Append(lastp); - } - } - } - } - done = Standard_True; - return; - } // if(typl == IntPatch_Analytic) { - else if(typl == IntPatch_Walking) { - Standard_Real u1,v1,u2,v2; - Handle(IntPatch_WLine)& WLine = *((Handle(IntPatch_WLine) *)&L); - seqp.Clear(); - nbvtx = GeomInt_LineTool::NbVertex(L); - for(i=1;iPoint(pmid); - Pmid.Parameters(u1,v1,u2,v2); - Recadre(myHS1,myHS2,u1,v1,u2,v2); - const TopAbs_State in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol); - if(in1 != TopAbs_OUT) { - const TopAbs_State in2 = myDom2->Classify(gp_Pnt2d(u2,v2),Tol); - if(in2 != TopAbs_OUT) { - seqp.Append(firstp); - seqp.Append(lastp); - } - } - } - else { - const IntSurf_PntOn2S& Pfirst = WLine->Point((Standard_Integer)(firstp)); - Pfirst.Parameters(u1,v1,u2,v2); - Recadre(myHS1,myHS2,u1,v1,u2,v2); - TopAbs_State in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol); - if(in1 != TopAbs_OUT) { //-- !=ON donne Pb - TopAbs_State in2 = myDom2->Classify(gp_Pnt2d(u2,v2),Tol); - if(in2 != TopAbs_OUT) { //-- !=ON - const IntSurf_PntOn2S& Plast = WLine->Point((Standard_Integer)(lastp)); - Plast.Parameters(u1,v1,u2,v2); - Recadre(myHS1,myHS2,u1,v1,u2,v2); - in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol); - if(in1 != TopAbs_OUT) { //-- !=ON donne Pb - in2 = myDom2->Classify(gp_Pnt2d(u2,v2),Tol); - if(in2 != TopAbs_OUT) { - seqp.Append(firstp); - seqp.Append(lastp); - } - } - } - } - } - } - } - // - // The One resulting curve consists of 7 segments that are - // connected between each other. - // The aim of the block is to reject these segments and have - // one segment instead of 7. - // The other reason to do that is value of TolReached3D=49. - // Why -? It is not known yet. - // PKV 22.Apr.2002 - // - Standard_Integer aNbParts; - // - aNbParts = seqp.Length()/2; - if (aNbParts > 1) { - Standard_Boolean bCond; - GeomAbs_SurfaceType aST1, aST2; - aST1 = myHS1->Surface().GetType(); - aST2 = myHS2->Surface().GetType(); - // - bCond=Standard_False; - if (aST1==GeomAbs_Plane) { - if (aST2==GeomAbs_SurfaceOfExtrusion || - aST2==GeomAbs_SurfaceOfRevolution) {//+zft - bCond=!bCond; - } - } - else if (aST2==GeomAbs_Plane) { - if (aST1==GeomAbs_SurfaceOfExtrusion || - aST1==GeomAbs_SurfaceOfRevolution) {//+zft - bCond=!bCond; - } - } - // - if (bCond) { - Standard_Integer aNb, anIndex, aNbTmp, jx; - TColStd_IndexedMapOfInteger aMap; - TColStd_SequenceOfReal aSeqTmp; - // - aNb=seqp.Length(); - for(i=1; i<=aNb; ++i) { - lastp =seqp(i); - anIndex=(Standard_Integer)lastp; - if (!aMap.Contains(anIndex)){ - aMap.Add(anIndex); - aSeqTmp.Append(lastp); - } - else { - aNbTmp=aSeqTmp.Length(); - aSeqTmp.Remove(aNbTmp); - } - } - // - seqp.Clear(); - // - aNb=aSeqTmp.Length()/2; - for(i=1; i<=aNb;++i) { - jx=2*i; - firstp=aSeqTmp(jx-1); - lastp =aSeqTmp(jx); - seqp.Append(firstp); - seqp.Append(lastp); - } - }//if (bCond) { - } - done = Standard_True; - return; - }// else if(typl == IntPatch_Walking) { - // - //----------------------------------------------------------- - else if (typl != IntPatch_Restriction) { - seqp.Clear(); - // - Handle(IntPatch_GLine)& GLine = *((Handle(IntPatch_GLine) *)&L); - // - if(typl == IntPatch_Circle || typl == IntPatch_Ellipse) { - TreatCircle(L, Tol); - done=Standard_True; - return; - } - //---------------------------- - Standard_Boolean intrvtested; - Standard_Real u1,v1,u2,v2; - // - nbvtx = GeomInt_LineTool::NbVertex(L); - intrvtested = Standard_False; - for(i=1; iPrecision::PConfusion()) { - intrvtested = Standard_True; - const Standard_Real pmid = (firstp+lastp)*0.5; - gp_Pnt Pmid; - GLinePoint(typl, GLine, pmid, Pmid); - // - Parameters(myHS1,myHS2,Pmid,u1,v1,u2,v2); - Recadre(myHS1,myHS2,u1,v1,u2,v2); - const TopAbs_State in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol); - if(in1 != TopAbs_OUT) { - const TopAbs_State in2 = myDom2->Classify(gp_Pnt2d(u2,v2),Tol); - if(in2 != TopAbs_OUT) { - seqp.Append(firstp); - seqp.Append(lastp); - } - } - } - } - // - if (!intrvtested) { - // Keep a priori. A point 2d on each - // surface is required to make the decision. Will be done in the caller - seqp.Append(GeomInt_LineTool::FirstParameter(L)); - seqp.Append(GeomInt_LineTool::LastParameter(L)); - } - // - done =Standard_True; - return; - } // else if (typl != IntPatch_Restriction) { - - done = Standard_False; - seqp.Clear(); - nbvtx = GeomInt_LineTool::NbVertex(L); - if (nbvtx == 0) { // Keep a priori. Point 2d is required on each - // surface to make the decision. Will be done in the caller - seqp.Append(GeomInt_LineTool::FirstParameter(L)); - seqp.Append(GeomInt_LineTool::LastParameter(L)); - done = Standard_True; - return; - } - - GeomInt_SequenceOfParameterAndOrientation seqpss; - TopAbs_Orientation or1=TopAbs_FORWARD,or2=TopAbs_FORWARD; - - for (i=1; i<=nbvtx; i++) { - const IntPatch_Point& thevtx = GeomInt_LineTool::Vertex(L,i); - const Standard_Real prm = thevtx.ParameterOnLine(); - if (thevtx.IsOnDomS1()) { - switch (thevtx.TransitionLineArc1().TransitionType()) { - case IntSurf_In: or1 = TopAbs_FORWARD; break; - case IntSurf_Out: or1 = TopAbs_REVERSED; break; - case IntSurf_Touch: or1 = TopAbs_INTERNAL; break; - case IntSurf_Undecided: or1 = TopAbs_INTERNAL; break; - } - } - else { - or1 = TopAbs_INTERNAL; - } - - if (thevtx.IsOnDomS2()) { - switch (thevtx.TransitionLineArc2().TransitionType()) { - case IntSurf_In: or2 = TopAbs_FORWARD; break; - case IntSurf_Out: or2 = TopAbs_REVERSED; break; - case IntSurf_Touch: or2 = TopAbs_INTERNAL; break; - case IntSurf_Undecided: or2 = TopAbs_INTERNAL; break; - } - } - else { - or2 = TopAbs_INTERNAL; - } - // - const Standard_Integer nbinserted = seqpss.Length(); - Standard_Boolean inserted = Standard_False; - for (Standard_Integer j=1; j<=nbinserted;j++) { - if (Abs(prm-seqpss(j).Parameter()) <= Tol) { - // accumulate - GeomInt_ParameterAndOrientation& valj = seqpss.ChangeValue(j); - if (or1 != TopAbs_INTERNAL) { - if (valj.Orientation1() != TopAbs_INTERNAL) { - if (or1 != valj.Orientation1()) { - valj.SetOrientation1(TopAbs_INTERNAL); - } - } - else { - valj.SetOrientation1(or1); - } - } - - if (or2 != TopAbs_INTERNAL) { - if (valj.Orientation2() != TopAbs_INTERNAL) { - if (or2 != valj.Orientation2()) { - valj.SetOrientation2(TopAbs_INTERNAL); - } - } - else { - valj.SetOrientation2(or2); - } - } - inserted = Standard_True; - break; - } - - if (prm < seqpss(j).Parameter()-Tol ) { - // insert before position j - seqpss.InsertBefore(j,GeomInt_ParameterAndOrientation(prm,or1,or2)); - inserted = Standard_True; - break; - } - - } - if (!inserted) { - seqpss.Append(GeomInt_ParameterAndOrientation(prm,or1,or2)); - } - } - - // determine the state at the beginning of line - Standard_Boolean trim = Standard_False; - Standard_Boolean dansS1 = Standard_False; - Standard_Boolean dansS2 = Standard_False; - - nbvtx = seqpss.Length(); - for (i=1; i<= nbvtx; i++) { - or1 = seqpss(i).Orientation1(); - if (or1 != TopAbs_INTERNAL) { - trim = Standard_True; - dansS1 = (or1 != TopAbs_FORWARD); - break; - } - } - - if (i > nbvtx) { - Standard_Real U,V; - for (i=1; i<=GeomInt_LineTool::NbVertex(L); i++ ) { - if (!GeomInt_LineTool::Vertex(L,i).IsOnDomS1() ) { - GeomInt_LineTool::Vertex(L,i).ParametersOnS1(U,V); - gp_Pnt2d PPCC(U,V); - if (myDom1->Classify(PPCC,Tol) == TopAbs_OUT) { - done = Standard_True; - return; - } - break; - } - } - dansS1 = Standard_True; // Keep in doubt - } - // - for (i=1; i<= nbvtx; i++) { - or2 = seqpss(i).Orientation2(); - if (or2 != TopAbs_INTERNAL) { - trim = Standard_True; - dansS2 = (or2 != TopAbs_FORWARD); - break; - } - } - - if (i > nbvtx) { - Standard_Real U,V; - for (i=1; i<=GeomInt_LineTool::NbVertex(L); i++ ) { - if (!GeomInt_LineTool::Vertex(L,i).IsOnDomS2() ) { - GeomInt_LineTool::Vertex(L,i).ParametersOnS2(U,V); - if (myDom2->Classify(gp_Pnt2d(U,V),Tol) == TopAbs_OUT) { - done = Standard_True; - return; - } - break; - } - } - dansS2 = Standard_True; // Keep in doubt - } - - if (!trim) { // necessarily dansS1 == dansS2 == Standard_True - seqp.Append(GeomInt_LineTool::FirstParameter(L)); - seqp.Append(GeomInt_LineTool::LastParameter(L)); - done = Standard_True; - return; - } - - // sequence seqpss is peeled to create valid ends - // and store them in seqp(2*i+1) and seqp(2*i+2) - Standard_Real thefirst = GeomInt_LineTool::FirstParameter(L); - Standard_Real thelast = GeomInt_LineTool::LastParameter(L); - firstp = thefirst; - - for (i=1; i<=nbvtx; i++) { - or1 = seqpss(i).Orientation1(); - or2 = seqpss(i).Orientation2(); - if (dansS1 && dansS2) { - if (or1 == TopAbs_REVERSED){ - dansS1 = Standard_False; - } - - if (or2 == TopAbs_REVERSED){ - dansS2 = Standard_False; - } - if (!dansS1 || !dansS2) { - lastp = seqpss(i).Parameter(); - Standard_Real stofirst = Max(firstp, thefirst); - Standard_Real stolast = Min(lastp, thelast) ; - - if (stolast > stofirst) { - seqp.Append(stofirst); - seqp.Append(stolast); - } - if (lastp > thelast) { - break; - } - } - } - else { - if (dansS1) { - if (or1 == TopAbs_REVERSED) { - dansS1 = Standard_False; - } - } - else { - if (or1 == TopAbs_FORWARD){ - dansS1 = Standard_True; - } - } - if (dansS2) { - if (or2 == TopAbs_REVERSED) { - dansS2 = Standard_False; - } - } - else { - if (or2 == TopAbs_FORWARD){ - dansS2 = Standard_True; - } - } - if (dansS1 && dansS2){ - firstp = seqpss(i).Parameter(); - } - } - } - // - // finally to add - if (dansS1 && dansS2) { - lastp = thelast; - firstp = Max(firstp,thefirst); - if (lastp > firstp) { - seqp.Append(firstp); - seqp.Append(lastp); - } - } - done = Standard_True; -} -//======================================================================= -//function : Recadre -//purpose : -//======================================================================= -void Recadre(const Handle(GeomAdaptor_HSurface)& myHS1, - const Handle(GeomAdaptor_HSurface)& myHS2, - Standard_Real& u1, - Standard_Real& v1, - Standard_Real& u2, - Standard_Real& v2) -{ - Standard_Boolean myHS1IsUPeriodic,myHS1IsVPeriodic; - const GeomAbs_SurfaceType typs1 = myHS1->GetType(); - switch (typs1) - { - case GeomAbs_Cylinder: - case GeomAbs_Cone: - case GeomAbs_Sphere: - { - myHS1IsUPeriodic = Standard_True; - myHS1IsVPeriodic = Standard_False; - break; - } - case GeomAbs_Torus: - { - myHS1IsUPeriodic = myHS1IsVPeriodic = Standard_True; - break; - } - default: - { - //-- Case of periodic biparameters is processed upstream - myHS1IsUPeriodic = myHS1IsVPeriodic = Standard_False; - break; - } - } - Standard_Boolean myHS2IsUPeriodic,myHS2IsVPeriodic; - const GeomAbs_SurfaceType typs2 = myHS2->GetType(); - switch (typs2) - { - case GeomAbs_Cylinder: - case GeomAbs_Cone: - case GeomAbs_Sphere: - { - myHS2IsUPeriodic = Standard_True; - myHS2IsVPeriodic = Standard_False; - break; - } - case GeomAbs_Torus: - { - myHS2IsUPeriodic = myHS2IsVPeriodic = Standard_True; - break; - } - default: - { - //-- Case of periodic biparameters is processed upstream - myHS2IsUPeriodic = myHS2IsVPeriodic = Standard_False; - break; - } - } - Standard_Real du, dv; - // - if(myHS1IsUPeriodic) { - const Standard_Real lmf = M_PI+M_PI; //-- myHS1->UPeriod(); - const Standard_Real f = myHS1->FirstUParameter(); - const Standard_Real l = myHS1->LastUParameter(); - IntTools_Tools::AdjustPeriodic(u1, f, l, lmf, u1, du); - } - if(myHS1IsVPeriodic) { - const Standard_Real lmf = M_PI+M_PI; //-- myHS1->VPeriod(); - const Standard_Real f = myHS1->FirstVParameter(); - const Standard_Real l = myHS1->LastVParameter(); - IntTools_Tools::AdjustPeriodic(v1, f, l, lmf, v1, dv); - } - if(myHS2IsUPeriodic) { - const Standard_Real lmf = M_PI+M_PI; //-- myHS2->UPeriod(); - const Standard_Real f = myHS2->FirstUParameter(); - const Standard_Real l = myHS2->LastUParameter(); - IntTools_Tools::AdjustPeriodic(u2, f, l, lmf, u2, du); - } - if(myHS2IsVPeriodic) { - const Standard_Real lmf = M_PI+M_PI; //-- myHS2->VPeriod(); - const Standard_Real f = myHS2->FirstVParameter(); - const Standard_Real l = myHS2->LastVParameter(); - IntTools_Tools::AdjustPeriodic(v2, f, l, lmf, v2, dv); - } -} -//======================================================================= -//function : Parameters -//purpose : -//======================================================================= -void Parameters(const Handle(GeomAdaptor_HSurface)& myHS1, - const Handle(GeomAdaptor_HSurface)& myHS2, - const gp_Pnt& Ptref, - Standard_Real& U1, - Standard_Real& V1, - Standard_Real& U2, - Standard_Real& V2) -{ - Parameters(myHS1, Ptref, U1, V1); - Parameters(myHS2, Ptref, U2, V2); -} -//======================================================================= -//function : Parameter -//purpose : -//======================================================================= -void Parameters(const Handle(GeomAdaptor_HSurface)& myHS1, - const gp_Pnt& Ptref, - Standard_Real& U1, - Standard_Real& V1) -{ - IntSurf_Quadric quad1; - // - switch (myHS1->Surface().GetType()) { - case GeomAbs_Plane: - quad1.SetValue(myHS1->Surface().Plane()); - break; - case GeomAbs_Cylinder: - quad1.SetValue(myHS1->Surface().Cylinder()); - break; - case GeomAbs_Cone: - quad1.SetValue(myHS1->Surface().Cone()); - break; - case GeomAbs_Sphere: - quad1.SetValue(myHS1->Surface().Sphere()); - break; - case GeomAbs_Torus: - quad1.SetValue(myHS1->Surface().Torus()); - break; - default: - Standard_ConstructionError::Raise("IntTools_LineConstructor::Parameters"); - } - quad1.Parameters(Ptref,U1,V1); -} - -//======================================================================= -//function : GLinePoint -//purpose : -//======================================================================= -void GLinePoint(const IntPatch_IType typl, - const Handle(IntPatch_GLine)& GLine, - const Standard_Real aT, - gp_Pnt& aP) -{ - switch (typl) { - case IntPatch_Lin: - aP = ElCLib::Value(aT, GLine->Line()); - break; - case IntPatch_Circle: - aP = ElCLib::Value(aT, GLine->Circle()); - break; - case IntPatch_Ellipse: - aP = ElCLib::Value(aT, GLine->Ellipse()); - break; - case IntPatch_Hyperbola: - aP = ElCLib::Value(aT, GLine->Hyperbola()); - break; - case IntPatch_Parabola: - aP = ElCLib::Value(aT, GLine->Parabola()); - break; - default: - Standard_ConstructionError::Raise("IntTools_LineConstructor::Parameters"); - } -} - -//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -// -//======================================================================= -//class : IntTools_RealWithFlag -//purpose : -//======================================================================= -class IntTools_RealWithFlag { - public: - IntTools_RealWithFlag() : - myValue(-99.), myFlag(1) - { - }; - // - ~IntTools_RealWithFlag() { - }; - // - void SetValue(const Standard_Real aT) { - myValue=aT; - }; - // - Standard_Real Value() const { - return myValue; - } - // - void SetFlag(const Standard_Integer aFlag) { - myFlag=aFlag; - }; - // - Standard_Integer Flag() const { - return myFlag; - } - // - Standard_Boolean operator < (const IntTools_RealWithFlag& aOther) { - return myValueArcType(); - Handle(IntPatch_GLine)& aGLine=*((Handle(IntPatch_GLine) *)&aLine); - // - bRejected=RejectMicroCircle(aGLine, aType, aTol); - if (bRejected) { - return; - } - //---------------------------------------- - Standard_Boolean bFound; - Standard_Integer aNbVtx, aNbVtxWas, i; - Standard_Real aTolPC, aT, aT1, aT2, aTmid, aTwoPI, aTolPC1; - Standard_Real aU1, aV1, aU2, aV2; - TopAbs_State aIn1, aIn2; - GeomAbs_SurfaceType aTS1, aTS2; - gp_Pnt aPmid; - gp_Pnt2d aP2D; - IntTools_RealWithFlag *pVtx; - //-------------------------------------1 - aTwoPI=M_PI+M_PI; - aTolPC=Precision::PConfusion(); - aNbVtxWas=GeomInt_LineTool::NbVertex(aLine); - - aNbVtx=aNbVtxWas+2; - //-------------------------------------2 - aTS1=myHS1->GetType(); - aTS2=myHS2->GetType(); - // - // About the value aTolPC1=1000.*aTolPC, - // see IntPatch_GLine.cxx, line:398 - // for more details; - aTolPC1=1000.*aTolPC; - //------------------------------------- - // - pVtx=new IntTools_RealWithFlag [aNbVtx]; - // - pVtx[0].SetValue(0.); - pVtx[1].SetValue(aTwoPI); - // - for(i=1; i<=aNbVtxWas; ++i) { - aT=GeomInt_LineTool::Vertex(aLine, i).ParameterOnLine(); - aT=AdjustOnPeriod(aT, aTwoPI); - pVtx[i+1].SetValue(aT); - } - // - SortShell(aNbVtx, pVtx); - // - RejectNearBeacons(aNbVtx, pVtx, aTolPC1, aTS1, aTS2); - // - RejectDuplicates(aNbVtx, pVtx, aTolPC); - // - if ((aType==IntPatch_Circle || aType==IntPatch_Ellipse)&& aNbVtx>2) { // zz - bFound=Standard_False; - for(i=1; i<=aNbVtxWas; ++i) { - aT=GeomInt_LineTool::Vertex(aLine, i).ParameterOnLine(); - if (fabs(aT) < aTolPC1 || fabs(aT-aTwoPI) < aTolPC1) { - bFound=!bFound; - break; - } - } - if (!bFound) { - aT=pVtx[1].Value()+aTwoPI; - pVtx[aNbVtx-1].SetValue(aT); - // - for(i=0; iClassify(aP2D, aTol); - if(aIn1 != TopAbs_OUT) { - aP2D.SetCoord(aU2, aV2); - aIn2=myDom2->Classify(aP2D, aTol); - if(aIn2 != TopAbs_OUT) { - seqp.Append(aT1); - seqp.Append(aT2); - } - } - } - // - delete [] pVtx; -} -//======================================================================= -//function : RejectNearBeacons -//purpose : Reject the thickenings near the beacon points (if exist) -// The gifts, made by sweep algo. -// chl/930/B5 B8 C2 C5 E2 E5 E8 F2 G8 H2 H5 H8 -//======================================================================= -void RejectNearBeacons(Standard_Integer& aNbVtx, - IntTools_RealWithFlag *pVtx, - Standard_Real aTolPC1, - const GeomAbs_SurfaceType aTS1, - const GeomAbs_SurfaceType aTS2) -{ - Standard_Integer i, j, iBcn; - Standard_Real aT, aBcn[2]; - // - if (aTS1==GeomAbs_Cylinder && aTS2==GeomAbs_Cylinder) { - aBcn[0]=0.5*M_PI; - aBcn[1]=1.5*M_PI; - // - for (j=0; j<2; ++j) { - iBcn=-1; - for(i=0; i=0. && aT<=aPeriod)) { - k=(Standard_Integer)(aT/aPeriod); - aT=aT-k*aPeriod; - } - // - return aT; -} -//======================================================================= -//function : RejectMicroCrcles -//purpose : -//======================================================================= -Standard_Boolean RejectMicroCircle(const Handle(IntPatch_GLine)& aGLine, - const IntPatch_IType aType, - const Standard_Real aTol3D) -{ - Standard_Boolean bRet; - Standard_Real aR; - // - bRet=Standard_False; - // - if (aType==IntPatch_Circle) { - aR=aGLine->Circle().Radius(); - bRet=(aREllipse().MajorRadius(); - bRet=(aR -1) goto m30; - }//if (a[l] < a[j]){ - }//for (i=0; i - -//======================================================================= -//function : GeomInt_LineConstructor -//purpose : -//======================================================================= - -inline IntTools_LineConstructor::IntTools_LineConstructor () - : done(Standard_False) -{ -} - - -//======================================================================= -//function : Load -//purpose : -//======================================================================= - -inline void IntTools_LineConstructor::Load(const Handle(Adaptor3d_TopolTool)& D1, - const Handle(Adaptor3d_TopolTool)& D2, - const Handle(GeomAdaptor_HSurface)& S1, - const Handle(GeomAdaptor_HSurface)& S2) -{ - myDom1 = D1; - myDom2 = D2; - myHS1 = S1; - myHS2 = S2; -} - - -//======================================================================= -//function : IsDone -//purpose : -//======================================================================= - -inline Standard_Boolean IntTools_LineConstructor::IsDone () const -{ - return done; -} - - -//======================================================================= -//function : NbParts -//purpose : -//======================================================================= - -inline Standard_Integer IntTools_LineConstructor::NbParts () const -{ - if (!done) { StdFail_NotDone::Raise(); } - return (seqp.Length() / 2); -} - - -//======================================================================= -//function : Part -//purpose : -//======================================================================= - -inline void IntTools_LineConstructor::Part (const Standard_Integer I, - Standard_Real& WFirst, - Standard_Real& WLast) const -{ - if (!done) { StdFail_NotDone::Raise(); } - WFirst = seqp(2*I-1); - WLast = seqp(2*I); -} diff --git a/src/IntTools/IntTools_Tools.cdl b/src/IntTools/IntTools_Tools.cdl index 7763165e40..1c5bcf7390 100644 --- a/src/IntTools/IntTools_Tools.cdl +++ b/src/IntTools/IntTools_Tools.cdl @@ -237,15 +237,4 @@ is theTmax :out Real from Standard) returns Integer from Standard; - AdjustPeriodic(myclass; - thePar : Real from Standard; - theParMin : Real from Standard; - theParMax : Real from Standard; - thePeriod : Real from Standard; - theNewPar : out Real from Standard; - theOffset : out Real from Standard; - theEps : Real from Standard = 0.0) - returns Boolean from Standard; - ---Purpose: Adjusts the parameter to the range [theParMin, theParMax] - end Tools; diff --git a/src/IntTools/IntTools_Tools.cxx b/src/IntTools/IntTools_Tools.cxx index 38a6ed1d04..f9c005a544 100644 --- a/src/IntTools/IntTools_Tools.cxx +++ b/src/IntTools/IntTools_Tools.cxx @@ -777,36 +777,3 @@ Standard_Integer IntTools_Tools::SegPln(const gp_Lin& theLin, iRet=0; // intersection point return iRet; } - -//======================================================================= -//function : AdjustPeriodic -//purpose : -//======================================================================= -Standard_Boolean IntTools_Tools::AdjustPeriodic(const Standard_Real thePar, - const Standard_Real theParMin, - const Standard_Real theParMax, - const Standard_Real thePeriod, - Standard_Real &theNewPar, - Standard_Real &theOffset, - const Standard_Real theEps) -{ - Standard_Boolean bMin, bMax; - // - theOffset = 0.; - theNewPar = thePar; - bMin = theParMin - thePar > theEps; - bMax = thePar - theParMax > theEps; - // - if (bMin || bMax) { - Standard_Real dp, aNbPer; - // - dp = (bMin) ? (theParMax - thePar) : (theParMin - thePar); - modf(dp / thePeriod, &aNbPer); - // - theOffset = aNbPer * thePeriod; - theNewPar += theOffset; - } - // - return (theOffset > 0.); -} - diff --git a/tests/bugs/modalg_5/bug24472 b/tests/bugs/modalg_5/bug24472 index 255e723a7e..b140618514 100755 --- a/tests/bugs/modalg_5/bug24472 +++ b/tests/bugs/modalg_5/bug24472 @@ -46,7 +46,7 @@ xdistcs i_22 s1 0 1 10 set Log1 [dlog get] set List1 [split ${Log1} {TD= \t\n}] -set Tolerance 1.0e-12 +set Tolerance 1.0e-7 set D_good 0. checkList ${List1} ${Tolerance} ${D_good}