1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-16 10:08:36 +03:00

0024981: IntTools_FaceFace enters to infinite loop on the attached case

class IntTools_Tools
method
  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)
The new function has been implemented for fast adjustment of pcurves to the range of surface.
Test case correction for issue CR24981
This commit is contained in:
emv 2014-06-11 10:41:15 +04:00 committed by apn
parent a4e383e1b8
commit 655fddc854
9 changed files with 2464 additions and 2536 deletions

View File

@ -70,6 +70,7 @@
#include <BOPCol_IndexedMapOfShape.hxx> #include <BOPCol_IndexedMapOfShape.hxx>
#include <BOPTools.hxx> #include <BOPTools.hxx>
#include <IntTools_Tools.hxx>
static static
Standard_Boolean CheckEdgeLength (const TopoDS_Edge& ); Standard_Boolean CheckEdgeLength (const TopoDS_Edge& );
@ -296,10 +297,9 @@ void BOPTools_AlgoTools2D::AdjustPCurveOnFace
const Handle(Geom2d_Curve)& aC2D, const Handle(Geom2d_Curve)& aC2D,
Handle(Geom2d_Curve)& aC2DA) Handle(Geom2d_Curve)& aC2DA)
{ {
Standard_Boolean mincond, maxcond, decalu, decalv; Standard_Boolean mincond, maxcond;
Standard_Integer k, iCnt;
Standard_Real UMin, UMax, VMin, VMax, aT, u2, v2, du, dv, aDelta; Standard_Real UMin, UMax, VMin, VMax, aT, u2, v2, du, dv, aDelta;
Standard_Real aUPeriod, aUP2, aUP1, aUNew, aDif, aUx; Standard_Real aUPeriod;
// //
aDelta=Precision::PConfusion(); aDelta=Precision::PConfusion();
@ -317,65 +317,24 @@ void BOPTools_AlgoTools2D::AdjustPCurveOnFace
du = 0.; du = 0.;
if (aBAS.IsUPeriodic()) { if (aBAS.IsUPeriodic()) {
aUPeriod=aBAS.UPeriod(); Standard_Real newu;
mincond = (u2 < UMin-aDelta); aUPeriod = aBAS.UPeriod();
maxcond = (u2 > UMax+aDelta);
decalu = mincond || maxcond;
if (decalu) {
//du = ( mincond ) ? UPeriod : -UPeriod;
//
iCnt=1;
aUP2=aUPeriod+aUPeriod+aDelta;
aUP1=aUPeriod+aDelta;
//
if (u2 > aUP2) {
k=1;
do {
aUx=u2-k*aUPeriod;
iCnt = k++;
} while (aUx >= aUP1);
}
else if (u2 < -aUP2) {
k=1;
do {
aUx=u2+k*aUPeriod;
iCnt = (k++) + 1;
} while (aUx <= -aUP1);
}
du = ( mincond ) ? aUPeriod : -aUPeriod;
du=iCnt*du;
}
// //
aUNew=u2+du; IntTools_Tools::AdjustPeriodic(u2, UMin, UMax, aUPeriod, newu, du);
if (aUNew<(UMin-aDelta) || }
aUNew>(UMax+aDelta)) {
// So previous correction was wrong.
// Try to be closer to UMin or UMax.
du=0.;
if (u2>UMax){
aDif=u2-UMax;
if (aDif < 4.e-7) {
du=-aDif;
}
}
}
} // if (BAHS->IsUPeriodic())
//
// dv // dv
dv = 0.; dv = 0.;
if (aBAS.IsVPeriodic()) { if (aBAS.IsVPeriodic()) {
Standard_Real aVPeriod, aVm, aVr, aVmid, dVm, dVr; Standard_Real aVPeriod, aVm, aVr, aVmid, dVm, dVr;
// //
aVPeriod=aBAS.VPeriod(); aVPeriod = aBAS.VPeriod();
mincond = (VMin - v2 > aDelta); mincond = (VMin - v2 > aDelta);
maxcond = (v2 - VMax > aDelta); maxcond = (v2 - VMax > aDelta);
decalv = mincond || maxcond; //
if (decalv) { if (mincond || maxcond) {
dv = ( mincond ) ? aVPeriod : -aVPeriod; dv = ( mincond ) ? aVPeriod : -aVPeriod;
} }
// //
//xf
if ((VMax-VMin<aVPeriod) && dv) { if ((VMax-VMin<aVPeriod) && dv) {
aVm=v2; aVm=v2;
aVr=v2+dv; aVr=v2+dv;
@ -386,7 +345,6 @@ void BOPTools_AlgoTools2D::AdjustPCurveOnFace
dv=0.; dv=0.;
} }
} }
//xt
} }
// //
{ {

View File

@ -58,12 +58,6 @@
#include <ElCLib.hxx> #include <ElCLib.hxx>
#include <ElSLib.hxx> #include <ElSLib.hxx>
static Standard_Boolean AdjustPeriodic(const Standard_Real U,
const Standard_Real UFirst,
const Standard_Real ULast,
const Standard_Real Period,
Standard_Real& UResult);
static Standard_Boolean SetEmptyResultRange(const Standard_Real theParameter, static Standard_Boolean SetEmptyResultRange(const Standard_Real theParameter,
IntTools_MarkedRangeSet& theMarkedRange); IntTools_MarkedRangeSet& theMarkedRange);
@ -645,37 +639,39 @@ void IntTools_BeanFaceIntersector::ComputeAroundExactIntersection()
Standard_Real V = aPoint.V(); Standard_Real V = aPoint.V();
if(UIsNotValid || VIsNotValid) { if(UIsNotValid || VIsNotValid) {
// modified by NIZHNY-MKK Thu Jun 17 12:50:39 2004
Standard_Boolean bUCorrected = Standard_True; Standard_Boolean bUCorrected = Standard_True;
if(UIsNotValid) { if(UIsNotValid) {
// modified by NIZHNY-MKK Thu Jun 17 12:50:37 2004
bUCorrected = Standard_False; bUCorrected = Standard_False;
solutionIsValid = Standard_False; solutionIsValid = Standard_False;
//
if(mySurface.IsUPeriodic()) { if(mySurface.IsUPeriodic()) {
Standard_Real aNewU = U; Standard_Real aNewU, aUPeriod, aEps, du;
//
if(AdjustPeriodic(U, myUMinParameter, myUMaxParameter, mySurface.UPeriod(), aNewU)) { aUPeriod = mySurface.UPeriod();
solutionIsValid = Standard_True; aEps = Epsilon(aUPeriod);
// modified by NIZHNY-MKK Thu Jun 17 12:51:01 2004 //
bUCorrected = Standard_True; IntTools_Tools::AdjustPeriodic(U, myUMinParameter, myUMaxParameter,
U = aNewU; aUPeriod, aNewU, du, aEps);
} solutionIsValid = Standard_True;
bUCorrected = Standard_True;
U = aNewU;
} }
} }
// modified by NIZHNY-MKK Thu Jun 17 12:51:03 2004
// if(solutionIsValid && VIsNotValid) { // if(solutionIsValid && VIsNotValid) {
if(bUCorrected && VIsNotValid) { if(bUCorrected && VIsNotValid) {
solutionIsValid = Standard_False; solutionIsValid = Standard_False;
//
if(mySurface.IsVPeriodic()) { if(mySurface.IsVPeriodic()) {
Standard_Real aNewV = V; Standard_Real aNewV, aVPeriod, aEps, dv;
//
if(AdjustPeriodic(V, myVMinParameter, myVMaxParameter, mySurface.VPeriod(), aNewV)) { aVPeriod = mySurface.VPeriod();
solutionIsValid = Standard_True; aEps = Epsilon(aVPeriod);
V = aNewV; //
} IntTools_Tools::AdjustPeriodic(V, myVMinParameter, myVMaxParameter,
aVPeriod, aNewV, dv, aEps);
solutionIsValid = Standard_True;
V = aNewV;
} }
} }
} }
@ -1388,27 +1384,6 @@ void IntTools_BeanFaceIntersector::ComputeRangeFromStartPoint(const Standard_Boo
} }
} }
// ---------------------------------------------------------------------------------
// static function: AdjustPeriodic
// purpose:
// ---------------------------------------------------------------------------------
static Standard_Boolean AdjustPeriodic(const Standard_Real U,
const Standard_Real UFirst,
const Standard_Real ULast,
const Standard_Real Period,
Standard_Real& UResult) {
UResult = U;
Standard_Real u = U;
Standard_Real Eps = Epsilon(Period);
while (Eps < (UFirst-u)) u += Period;
while (Eps > (ULast -u)) u -= Period;
if ( u < UFirst)
return Standard_False;
UResult = u;
return Standard_True;
}
// --------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------
// static function: SetEmptyResultRange // static function: SetEmptyResultRange
// purpose: // purpose:

View File

@ -44,6 +44,7 @@
#include <TopoDS_Wire.hxx> #include <TopoDS_Wire.hxx>
#include <TColStd_DataMapOfIntegerInteger.hxx> #include <TColStd_DataMapOfIntegerInteger.hxx>
#include <TColgp_SequenceOfVec2d.hxx> #include <TColgp_SequenceOfVec2d.hxx>
#include <IntTools_Tools.hxx>
//======================================================================= //=======================================================================
//function : IntTools_FClass2d:IntTools:_FClass2d //function : IntTools_FClass2d:IntTools:_FClass2d
@ -57,7 +58,7 @@ IntTools_FClass2d::IntTools_FClass2d()
//purpose : //purpose :
//======================================================================= //=======================================================================
IntTools_FClass2d::IntTools_FClass2d(const TopoDS_Face& aFace, IntTools_FClass2d::IntTools_FClass2d(const TopoDS_Face& aFace,
const Standard_Real TolUV) const Standard_Real TolUV)
: Toluv(TolUV), Face(aFace) : Toluv(TolUV), Face(aFace)
{ {
Init(Face, Toluv); Init(Face, Toluv);
@ -75,7 +76,7 @@ IntTools_FClass2d::IntTools_FClass2d()
//purpose : //purpose :
//======================================================================= //=======================================================================
void IntTools_FClass2d::Init(const TopoDS_Face& aFace, void IntTools_FClass2d::Init(const TopoDS_Face& aFace,
const Standard_Real TolUV) const Standard_Real TolUV)
{ {
Standard_Boolean WireIsNotEmpty, Ancienpnt3dinitialise, degenerated; Standard_Boolean WireIsNotEmpty, Ancienpnt3dinitialise, degenerated;
Standard_Integer nbpnts, firstpoint, NbEdges; Standard_Integer nbpnts, firstpoint, NbEdges;
@ -149,12 +150,12 @@ IntTools_FClass2d::IntTools_FClass2d()
edge = aWExp.Current(); edge = aWExp.Current();
Or = edge.Orientation(); Or = edge.Orientation();
if(!(Or==TopAbs_FORWARD || Or==TopAbs_REVERSED)) { if(!(Or==TopAbs_FORWARD || Or==TopAbs_REVERSED)) {
continue; continue;
} }
// //
aC2D=BRep_Tool::CurveOnSurface(edge, Face, pfbid, plbid); aC2D=BRep_Tool::CurveOnSurface(edge, Face, pfbid, plbid);
if (aC2D.IsNull()) { if (aC2D.IsNull()) {
return; return;
} }
// //
BRepAdaptor_Curve2d C(edge,Face); BRepAdaptor_Curve2d C(edge,Face);
@ -162,8 +163,8 @@ IntTools_FClass2d::IntTools_FClass2d()
//------------------------------------------ //------------------------------------------
degenerated=Standard_False; degenerated=Standard_False;
if(BRep_Tool::Degenerated(edge) || if(BRep_Tool::Degenerated(edge) ||
BRep_Tool::IsClosed(edge, Face)) { BRep_Tool::IsClosed(edge, Face)) {
degenerated=Standard_True; degenerated=Standard_True;
} }
// //
TopExp::Vertices(edge,Va,Vb); TopExp::Vertices(edge,Va,Vb);
@ -171,20 +172,20 @@ IntTools_FClass2d::IntTools_FClass2d()
TolVertex1=0.; TolVertex1=0.;
TolVertex=0.; TolVertex=0.;
if (Va.IsNull()) { if (Va.IsNull()) {
degenerated=Standard_True; degenerated=Standard_True;
} }
else { else {
TolVertex1=BRep_Tool::Tolerance(Va); TolVertex1=BRep_Tool::Tolerance(Va);
} }
if (Vb.IsNull()){ if (Vb.IsNull()){
degenerated=Standard_True; degenerated=Standard_True;
} }
else { else {
TolVertex=BRep_Tool::Tolerance(Vb); TolVertex=BRep_Tool::Tolerance(Vb);
} }
// //
if(TolVertex<TolVertex1) { if(TolVertex<TolVertex1) {
TolVertex=TolVertex1; TolVertex=TolVertex1;
} }
// //
//-- Verification of cases when forgotten to code degenereted //-- Verification of cases when forgotten to code degenereted
@ -211,26 +212,26 @@ IntTools_FClass2d::IntTools_FClass2d()
//-- ---------------------------------------- //-- ----------------------------------------
Tole = BRep_Tool::Tolerance(edge); Tole = BRep_Tool::Tolerance(edge);
if(Tole>Tol) { if(Tole>Tol) {
Tol=Tole; Tol=Tole;
} }
// //
// NbSamples +> nbs // NbSamples +> nbs
nbs = Geom2dInt_Geom2dCurveTool::NbSamples(C); nbs = Geom2dInt_Geom2dCurveTool::NbSamples(C);
if (nbs > 2) { if (nbs > 2) {
nbs*=4; nbs*=4;
} }
du = (plbid-pfbid)/(Standard_Real)(nbs-1); du = (plbid-pfbid)/(Standard_Real)(nbs-1);
// //
if(Or==TopAbs_FORWARD) { if(Or==TopAbs_FORWARD) {
u = pfbid; u = pfbid;
uFirst=pfbid; uFirst=pfbid;
uLast=plbid; uLast=plbid;
} }
else { else {
u = plbid; u = plbid;
uFirst=plbid; uFirst=plbid;
uLast=pfbid; uLast=pfbid;
du=-du; du=-du;
} }
// //
// aPrms // aPrms
@ -238,18 +239,18 @@ IntTools_FClass2d::IntTools_FClass2d()
TColStd_Array1OfReal aPrms(1, aNbs1); TColStd_Array1OfReal aPrms(1, aNbs1);
// //
if (nbs==2) { if (nbs==2) {
Standard_Real aCoef=0.0025; Standard_Real aCoef=0.0025;
aPrms(1)=uFirst; aPrms(1)=uFirst;
aPrms(2)=uFirst+aCoef*(uLast-uFirst); aPrms(2)=uFirst+aCoef*(uLast-uFirst);
aPrms(3)=uLast; aPrms(3)=uLast;
} }
else if (nbs>2) { else if (nbs>2) {
aNbs1=nbs; aNbs1=nbs;
aPrms(1)=uFirst; aPrms(1)=uFirst;
for (iX=2; iX<aNbs1; ++iX) { for (iX=2; iX<aNbs1; ++iX) {
aPrms(iX)=u+(iX-1)*du; aPrms(iX)=u+(iX-1)*du;
} }
aPrms(aNbs1)=uLast; aPrms(aNbs1)=uLast;
} }
// //
//-- ------------------------------------------------------------ //-- ------------------------------------------------------------
@ -259,75 +260,75 @@ IntTools_FClass2d::IntTools_FClass2d()
//-- afar from the last saved point //-- afar from the last saved point
Avant = nbpnts; Avant = nbpnts;
for(iX=firstpoint; iX<=aNbs1; iX++) { for(iX=firstpoint; iX<=aNbs1; iX++) {
Standard_Boolean IsRealCurve3d; Standard_Boolean IsRealCurve3d;
Standard_Integer ii; Standard_Integer ii;
Standard_Real aDstX; Standard_Real aDstX;
gp_Pnt2d P2d; gp_Pnt2d P2d;
gp_Pnt P3d; gp_Pnt P3d;
// //
u=aPrms(iX); u=aPrms(iX);
P2d = C.Value(u); P2d = C.Value(u);
if(P2d.X()<Umin) Umin = P2d.X(); if(P2d.X()<Umin) Umin = P2d.X();
if(P2d.X()>Umax) Umax = P2d.X(); if(P2d.X()>Umax) Umax = P2d.X();
if(P2d.Y()<Vmin) Vmin = P2d.Y(); if(P2d.Y()<Vmin) Vmin = P2d.Y();
if(P2d.Y()>Vmax) Vmax = P2d.Y(); if(P2d.Y()>Vmax) Vmax = P2d.Y();
// //
aDstX=RealLast(); aDstX=RealLast();
if(degenerated==Standard_False) { if(degenerated==Standard_False) {
P3d=C3d.Value(u); P3d=C3d.Value(u);
if(nbpnts>1) { if(nbpnts>1) {
if(Ancienpnt3dinitialise) { if(Ancienpnt3dinitialise) {
aDstX=P3d.SquareDistance(Ancienpnt3d); aDstX=P3d.SquareDistance(Ancienpnt3d);
} }
} }
} }
// //
IsRealCurve3d = Standard_True; IsRealCurve3d = Standard_True;
if (aDstX < aPrCf2) { if (aDstX < aPrCf2) {
if(iX>1) { if(iX>1) {
Standard_Real aDstX1; Standard_Real aDstX1;
gp_Pnt MidP3d; gp_Pnt MidP3d;
// //
MidP3d = C3d.Value(0.5*(u+aPrms(iX-1))); MidP3d = C3d.Value(0.5*(u+aPrms(iX-1)));
aDstX1=P3d.SquareDistance( MidP3d ); aDstX1=P3d.SquareDistance( MidP3d );
if (aDstX1 < aPrCf2){ if (aDstX1 < aPrCf2){
IsRealCurve3d = Standard_False; IsRealCurve3d = Standard_False;
} }
} }
} }
// //
if (IsRealCurve3d) { if (IsRealCurve3d) {
if(degenerated==Standard_False) { if(degenerated==Standard_False) {
Ancienpnt3d=P3d; Ancienpnt3d=P3d;
Ancienpnt3dinitialise=Standard_True; Ancienpnt3dinitialise=Standard_True;
} }
nbpnts++; nbpnts++;
SeqPnt2d.Append(P2d); SeqPnt2d.Append(P2d);
} }
// //
ii=nbpnts; ii=nbpnts;
if(ii>(Avant+4)) { if(ii>(Avant+4)) {
Standard_Real ul, dU, dV; Standard_Real ul, dU, dV;
gp_Pnt2d Pp; gp_Pnt2d Pp;
// //
gp_Lin2d Lin(SeqPnt2d(ii-2),gp_Dir2d(gp_Vec2d(SeqPnt2d(ii-2),SeqPnt2d(ii)))); gp_Lin2d Lin(SeqPnt2d(ii-2),gp_Dir2d(gp_Vec2d(SeqPnt2d(ii-2),SeqPnt2d(ii))));
ul = ElCLib::Parameter(Lin,SeqPnt2d(ii-1)); ul = ElCLib::Parameter(Lin,SeqPnt2d(ii-1));
Pp = ElCLib::Value(ul,Lin); Pp = ElCLib::Value(ul,Lin);
dU = Abs(Pp.X()-SeqPnt2d(ii-1).X()); dU = Abs(Pp.X()-SeqPnt2d(ii-1).X());
dV = Abs(Pp.Y()-SeqPnt2d(ii-1).Y()); dV = Abs(Pp.Y()-SeqPnt2d(ii-1).Y());
if(dU>FlecheU) { if(dU>FlecheU) {
FlecheU = dU; FlecheU = dU;
} }
if(dV>FlecheV) { if(dV>FlecheV) {
FlecheV = dV; FlecheV = dV;
} }
} }
}// for(iX=firstpoint; iX<=aNbs1; iX++) { }// for(iX=firstpoint; iX<=aNbs1; iX++) {
// //
if(BadWire) { if(BadWire) {
continue; //if face has several wires and one of them is bad, continue; //if face has several wires and one of them is bad,
//it is necessary to process all of them for correct //it is necessary to process all of them for correct
//calculation of Umin, Umax, Vmin, Vmax - ifv, 23.08.06 //calculation of Umin, Umax, Vmin, Vmax - ifv, 23.08.06
} }
// //
if(firstpoint==1) firstpoint=2; if(firstpoint==1) firstpoint=2;
@ -340,7 +341,7 @@ IntTools_FClass2d::IntTools_FClass2d()
C.D1(aU, aP, aV); C.D1(aU, aP, aV);
if(Or == TopAbs_REVERSED) if(Or == TopAbs_REVERSED)
aV.Reverse(); aV.Reverse();
aD1Next.Append(aV); aD1Next.Append(aV);
@ -349,18 +350,18 @@ IntTools_FClass2d::IntTools_FClass2d()
C.D1(aU, aP, aV); C.D1(aU, aP, aV);
if(Or == TopAbs_REVERSED) if(Or == TopAbs_REVERSED)
aV.Reverse(); aV.Reverse();
if (NbEdges > 0) if (NbEdges > 0)
aD1Prev.Append(aV); aD1Prev.Append(aV);
else else
aD1Prev.Prepend(aV); aD1Prev.Prepend(aV);
// Fill the map anIndexMap. // Fill the map anIndexMap.
if (Avant > 0) if (Avant > 0)
anIndexMap.Bind(Avant, aD1Next.Length()); anIndexMap.Bind(Avant, aD1Next.Length());
else else
anIndexMap.Bind(1, aD1Next.Length()); anIndexMap.Bind(1, aD1Next.Length());
} //for(;aWExp.More(); aWExp.Next()) { } //for(;aWExp.More(); aWExp.Next()) {
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// //
@ -381,91 +382,91 @@ IntTools_FClass2d::IntTools_FClass2d()
// //
PClass.Init(anInitPnt); PClass.Init(anInitPnt);
if(nbpnts>3) { if(nbpnts>3) {
Standard_Integer im2=nbpnts-2; Standard_Integer im2=nbpnts-2;
Standard_Integer im1=nbpnts-1; Standard_Integer im1=nbpnts-1;
Standard_Integer im0=1; Standard_Integer im0=1;
Standard_Integer ii; Standard_Integer ii;
Standard_Real angle = 0.0; Standard_Real angle = 0.0;
Standard_Real aX0, aY0, aX1, aY1, aS; Standard_Real aX0, aY0, aX1, aY1, aS;
// //
aS=0.; aS=0.;
// //
Standard_Integer iFlag=1; Standard_Integer iFlag=1;
PClass(im2)=SeqPnt2d.Value(im2); PClass(im2)=SeqPnt2d.Value(im2);
PClass(im1)=SeqPnt2d.Value(im1); PClass(im1)=SeqPnt2d.Value(im1);
PClass(nbpnts)=SeqPnt2d.Value(nbpnts); PClass(nbpnts)=SeqPnt2d.Value(nbpnts);
for(ii=1; ii<nbpnts; ii++,im0++,im1++,im2++) { for(ii=1; ii<nbpnts; ii++,im0++,im1++,im2++) {
if(im2>=nbpnts) im2=1; if(im2>=nbpnts) im2=1;
if(im1>=nbpnts) im1=1; if(im1>=nbpnts) im1=1;
PClass(ii)=SeqPnt2d.Value(ii); PClass(ii)=SeqPnt2d.Value(ii);
// //
const gp_Pnt2d& aP2D1=PClass(im1); const gp_Pnt2d& aP2D1=PClass(im1);
const gp_Pnt2d& aP2D0=PClass(im0); const gp_Pnt2d& aP2D0=PClass(im0);
//aP2D0 is next to aP2D1 //aP2D0 is next to aP2D1
aP2D0.Coord(aX0, aY0); aP2D0.Coord(aX0, aY0);
aP2D1.Coord(aX1, aY1); aP2D1.Coord(aX1, aY1);
aS=aS+(aY0+aY1)*(aX1-aX0); aS=aS+(aY0+aY1)*(aX1-aX0);
gp_Vec2d A(PClass(im2),PClass(im1)); gp_Vec2d A(PClass(im2),PClass(im1));
gp_Vec2d B(PClass(im1),PClass(im0)); gp_Vec2d B(PClass(im1),PClass(im0));
Standard_Real N = A.Magnitude() * B.Magnitude(); Standard_Real N = A.Magnitude() * B.Magnitude();
if(N>1e-16) { if(N>1e-16) {
Standard_Real a=A.Angle(B); Standard_Real a=A.Angle(B);
// //
if (anIndexMap.IsBound(im1)) { if (anIndexMap.IsBound(im1)) {
Standard_Integer anInd = anIndexMap.Find(im1); Standard_Integer anInd = anIndexMap.Find(im1);
const gp_Vec2d &aVPrev = aD1Prev.Value(anInd); const gp_Vec2d &aVPrev = aD1Prev.Value(anInd);
const gp_Vec2d &aVNext = aD1Next.Value(anInd); const gp_Vec2d &aVNext = aD1Next.Value(anInd);
Standard_Real aN = aVPrev.Magnitude() * aVNext.Magnitude(); Standard_Real aN = aVPrev.Magnitude() * aVNext.Magnitude();
if(aN > 1e-16) { if(aN > 1e-16) {
Standard_Real aDerivAngle = aVPrev.Angle(aVNext); Standard_Real aDerivAngle = aVPrev.Angle(aVNext);
//ifv 23.08.06 //ifv 23.08.06
if(Abs(aDerivAngle) <= Precision::Angular()) aDerivAngle = 0.; if(Abs(aDerivAngle) <= Precision::Angular()) aDerivAngle = 0.;
//ifv 23.08.06 : if edges continuity > G1, |aDerivAngle| ~0, //ifv 23.08.06 : if edges continuity > G1, |aDerivAngle| ~0,
//but can has wrong sign and causes condition aDerivAngle * a < 0. //but can has wrong sign and causes condition aDerivAngle * a < 0.
//that is wrong in such situation //that is wrong in such situation
if (iFlag && aDerivAngle * a < 0.) { if (iFlag && aDerivAngle * a < 0.) {
iFlag=0; iFlag=0;
// Bad case. // Bad case.
angle = 0.; angle = 0.;
} }
} }
} }
angle+=a; angle+=a;
} }
}//for(ii=1; ii<nbpnts; ii++,im0++,im1++,im2++) { }//for(ii=1; ii<nbpnts; ii++,im0++,im1++,im2++) {
if (!iFlag) { if (!iFlag) {
angle = 0.; angle = 0.;
} }
if(aS>0.){ if(aS>0.){
myIsHole=Standard_False; myIsHole=Standard_False;
} }
// //
if(FlecheU<Toluv) if(FlecheU<Toluv)
FlecheU = Toluv; FlecheU = Toluv;
if(FlecheV<Toluv) if(FlecheV<Toluv)
FlecheV = Toluv; FlecheV = Toluv;
TabClass.Append((void *)new CSLib_Class2d(PClass,FlecheU,FlecheV,Umin,Vmin,Umax,Vmax)); TabClass.Append((void *)new CSLib_Class2d(PClass,FlecheU,FlecheV,Umin,Vmin,Umax,Vmax));
// //
if((angle<2 && angle>-2)||(angle>10)||(angle<-10)) { if((angle<2 && angle>-2)||(angle>10)||(angle<-10)) {
BadWire=1; BadWire=1;
TabOrien.Append(-1); TabOrien.Append(-1);
} }
else { else {
TabOrien.Append((angle>0.0)? 1 : 0); TabOrien.Append((angle>0.0)? 1 : 0);
} }
} }
else { else {
BadWire=1; BadWire=1;
TabOrien.Append(-1); TabOrien.Append(-1);
TColgp_Array1OfPnt2d PPClass(1,2); TColgp_Array1OfPnt2d PPClass(1,2);
PPClass.Init(anInitPnt); PPClass.Init(anInitPnt);
TabClass.Append((void *)new CSLib_Class2d(PPClass,FlecheU,FlecheV,Umin,Vmin,Umax,Vmax)); TabClass.Append((void *)new CSLib_Class2d(PPClass,FlecheU,FlecheV,Umin,Vmin,Umax,Vmax));
} }
}// else if(WireIsNotEmpty) }// else if(WireIsNotEmpty)
} // for(; aExpF.More(); aExpF.Next()) { } // for(; aExpF.More(); aExpF.Next()) {
@ -551,31 +552,13 @@ IntTools_FClass2d::IntTools_FClass2d()
vrecadre = Standard_False; vrecadre = Standard_False;
// //
if (RecadreOnPeriodic) { if (RecadreOnPeriodic) {
Standard_Real du, dv;
if (IsUPer) { if (IsUPer) {
if (uu < Umin) IntTools_Tools::AdjustPeriodic(uu, Umin, Umax, uperiod, uu, du);
while (uu < Umin) {
uu += uperiod;
}
else {
while (uu >= Umin){
uu -= uperiod;
}
uu += uperiod;
}
}// if (IsUPer) { }// if (IsUPer) {
//
if (IsVPer) { if (IsVPer) {
if (vv < Vmin) IntTools_Tools::AdjustPeriodic(vv, Vmin, Vmax, vperiod, vv, dv);
while (vv < Vmin){
vv += vperiod;
}
else {
while (vv >= Vmin) {
vv -= vperiod;
}
vv += vperiod;
}
}//if (IsVPer) { }//if (IsVPer) {
} }
// //
@ -675,8 +658,8 @@ IntTools_FClass2d::IntTools_FClass2d()
//purpose : //purpose :
//======================================================================= //=======================================================================
TopAbs_State IntTools_FClass2d::TestOnRestriction(const gp_Pnt2d& _Puv, TopAbs_State IntTools_FClass2d::TestOnRestriction(const gp_Pnt2d& _Puv,
const Standard_Real Tol, const Standard_Real Tol,
const Standard_Boolean RecadreOnPeriodic) const const Standard_Boolean RecadreOnPeriodic) const
{ {
Standard_Integer nbtabclass = TabClass.Length(); Standard_Integer nbtabclass = TabClass.Length();
if (nbtabclass == 0) if (nbtabclass == 0)
@ -699,66 +682,49 @@ IntTools_FClass2d::IntTools_FClass2d()
Standard_Boolean urecadre = Standard_False, vrecadre = Standard_False; Standard_Boolean urecadre = Standard_False, vrecadre = Standard_False;
Standard_Integer dedans = 1; Standard_Integer dedans = 1;
if (RecadreOnPeriodic) if (RecadreOnPeriodic) {
{ Standard_Real du, dv;
if (IsUPer) if (IsUPer) {
{ IntTools_Tools::AdjustPeriodic(uu, Umin, Umax, uperiod, uu, du);
if (uu < Umin) }// if (IsUPer) {
while (uu < Umin) //
uu += uperiod; if (IsVPer) {
else IntTools_Tools::AdjustPeriodic(vv, Vmin, Vmax, vperiod, vv, dv);
{ }//if (IsVPer) {
while (uu >= Umin) }
uu -= uperiod; //
uu += uperiod;
}
}
if (IsVPer)
{
if (vv < Vmin)
while (vv < Vmin)
vv += vperiod;
else
{
while (vv >= Vmin)
vv -= vperiod;
vv += vperiod;
}
}
}
for (;;) { for (;;) {
dedans = 1; dedans = 1;
gp_Pnt2d Puv(u,v); gp_Pnt2d Puv(u,v);
if(TabOrien(1)!=-1) { if(TabOrien(1)!=-1) {
for(Standard_Integer n=1; n<=nbtabclass; n++) { for(Standard_Integer n=1; n<=nbtabclass; n++) {
Standard_Integer cur = ((CSLib_Class2d *)TabClass(n))->SiDans_OnMode(Puv,Tol); Standard_Integer cur = ((CSLib_Class2d *)TabClass(n))->SiDans_OnMode(Puv,Tol);
if(cur==1) { if(cur==1) {
if(TabOrien(n)==0) { if(TabOrien(n)==0) {
dedans = -1; dedans = -1;
break; break;
} }
} }
else if(cur==-1) { else if(cur==-1) {
if(TabOrien(n)==1) { if(TabOrien(n)==1) {
dedans = -1; dedans = -1;
break; break;
} }
} }
else { else {
dedans = 0; dedans = 0;
break; break;
} }
} }
if(dedans==0) { if(dedans==0) {
Status = TopAbs_ON; Status = TopAbs_ON;
} }
if(dedans == 1) { if(dedans == 1) {
Status = TopAbs_IN; Status = TopAbs_IN;
} }
if(dedans == -1) { if(dedans == -1) {
Status = TopAbs_OUT; Status = TopAbs_OUT;
} }
} }
else { //-- TabOrien(1)=-1 Wrong Wire else { //-- TabOrien(1)=-1 Wrong Wire
@ -774,27 +740,27 @@ IntTools_FClass2d::IntTools_FClass2d()
if (!urecadre) if (!urecadre)
{ {
u = uu; u = uu;
urecadre = Standard_True; urecadre = Standard_True;
} }
else else
if (IsUPer) if (IsUPer)
u += uperiod; u += uperiod;
if (u > Umax || !IsUPer) if (u > Umax || !IsUPer)
{ {
if (!vrecadre) if (!vrecadre)
{ {
v = vv; v = vv;
vrecadre = Standard_True; vrecadre = Standard_True;
} }
else else
if (IsVPer) if (IsVPer)
v += vperiod; v += vperiod;
u = uu; u = uu;
if (v > Vmax || !IsVPer) if (v > Vmax || !IsVPer)
return Status; return Status;
} }
} //for (;;) } //for (;;)
} }

File diff suppressed because it is too large Load Diff

View File

@ -41,33 +41,34 @@
#include <ElCLib.hxx> #include <ElCLib.hxx>
#include <GeomAbs_SurfaceType.hxx> #include <GeomAbs_SurfaceType.hxx>
#include <TColStd_IndexedMapOfInteger.hxx> #include <TColStd_IndexedMapOfInteger.hxx>
#include <IntTools_Tools.hxx>
static static
void Parameters(const Handle(GeomAdaptor_HSurface)& myHS1, void Parameters(const Handle(GeomAdaptor_HSurface)& myHS1,
const gp_Pnt& Ptref, const gp_Pnt& Ptref,
Standard_Real& U1, Standard_Real& U1,
Standard_Real& V1); Standard_Real& V1);
static static
void Parameters(const Handle(GeomAdaptor_HSurface)& myHS1, void Parameters(const Handle(GeomAdaptor_HSurface)& myHS1,
const Handle(GeomAdaptor_HSurface)& myHS2, const Handle(GeomAdaptor_HSurface)& myHS2,
const gp_Pnt& Ptref, const gp_Pnt& Ptref,
Standard_Real& U1, Standard_Real& U1,
Standard_Real& V1, Standard_Real& V1,
Standard_Real& U2, Standard_Real& U2,
Standard_Real& V2); Standard_Real& V2);
static static
void GLinePoint(const IntPatch_IType typl, void GLinePoint(const IntPatch_IType typl,
const Handle(IntPatch_GLine)& GLine, const Handle(IntPatch_GLine)& GLine,
const Standard_Real aT, const Standard_Real aT,
gp_Pnt& aP); gp_Pnt& aP);
static static
void Recadre(const Handle(GeomAdaptor_HSurface)& myHS1, void Recadre(const Handle(GeomAdaptor_HSurface)& myHS1,
const Handle(GeomAdaptor_HSurface)& myHS2, const Handle(GeomAdaptor_HSurface)& myHS2,
Standard_Real& u1, Standard_Real& u1,
Standard_Real& v1, Standard_Real& v1,
Standard_Real& u2, Standard_Real& u2,
Standard_Real& v2); Standard_Real& v2);
//======================================================================= //=======================================================================
//function : Perform //function : Perform
@ -89,18 +90,18 @@ void IntTools_LineConstructor::Perform(const Handle(IntPatch_Line)& L)
firstp = GeomInt_LineTool::Vertex(L,i).ParameterOnLine(); firstp = GeomInt_LineTool::Vertex(L,i).ParameterOnLine();
lastp = GeomInt_LineTool::Vertex(L,i+1).ParameterOnLine(); lastp = GeomInt_LineTool::Vertex(L,i+1).ParameterOnLine();
if(firstp!=lastp) { if(firstp!=lastp) {
const Standard_Real pmid = (firstp+lastp)*0.5; const Standard_Real pmid = (firstp+lastp)*0.5;
const gp_Pnt Pmid = ALine->Value(pmid); const gp_Pnt Pmid = ALine->Value(pmid);
Parameters(myHS1,myHS2,Pmid,u1,v1,u2,v2); Parameters(myHS1,myHS2,Pmid,u1,v1,u2,v2);
Recadre(myHS1,myHS2,u1,v1,u2,v2); Recadre(myHS1,myHS2,u1,v1,u2,v2);
const TopAbs_State in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol); const TopAbs_State in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol);
if(in1 != TopAbs_OUT) { if(in1 != TopAbs_OUT) {
const TopAbs_State in2 = myDom2->Classify(gp_Pnt2d(u2,v2),Tol); const TopAbs_State in2 = myDom2->Classify(gp_Pnt2d(u2,v2),Tol);
if(in2 != TopAbs_OUT) { if(in2 != TopAbs_OUT) {
seqp.Append(firstp); seqp.Append(firstp);
seqp.Append(lastp); seqp.Append(lastp);
} }
} }
} }
} }
done = Standard_True; done = Standard_True;
@ -115,42 +116,42 @@ void IntTools_LineConstructor::Perform(const Handle(IntPatch_Line)& L)
firstp = GeomInt_LineTool::Vertex(L,i).ParameterOnLine(); firstp = GeomInt_LineTool::Vertex(L,i).ParameterOnLine();
lastp = GeomInt_LineTool::Vertex(L,i+1).ParameterOnLine(); lastp = GeomInt_LineTool::Vertex(L,i+1).ParameterOnLine();
if(firstp!=lastp) { if(firstp!=lastp) {
if(lastp != firstp+1) { if(lastp != firstp+1) {
const Standard_Integer pmid = (Standard_Integer )( (firstp+lastp)/2); const Standard_Integer pmid = (Standard_Integer )( (firstp+lastp)/2);
const IntSurf_PntOn2S& Pmid = WLine->Point(pmid); const IntSurf_PntOn2S& Pmid = WLine->Point(pmid);
Pmid.Parameters(u1,v1,u2,v2); Pmid.Parameters(u1,v1,u2,v2);
Recadre(myHS1,myHS2,u1,v1,u2,v2); Recadre(myHS1,myHS2,u1,v1,u2,v2);
const TopAbs_State in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol); const TopAbs_State in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol);
if(in1 != TopAbs_OUT) { if(in1 != TopAbs_OUT) {
const TopAbs_State in2 = myDom2->Classify(gp_Pnt2d(u2,v2),Tol); const TopAbs_State in2 = myDom2->Classify(gp_Pnt2d(u2,v2),Tol);
if(in2 != TopAbs_OUT) { if(in2 != TopAbs_OUT) {
seqp.Append(firstp); seqp.Append(firstp);
seqp.Append(lastp); seqp.Append(lastp);
} }
} }
} }
else { else {
const IntSurf_PntOn2S& Pfirst = WLine->Point((Standard_Integer)(firstp)); const IntSurf_PntOn2S& Pfirst = WLine->Point((Standard_Integer)(firstp));
Pfirst.Parameters(u1,v1,u2,v2); Pfirst.Parameters(u1,v1,u2,v2);
Recadre(myHS1,myHS2,u1,v1,u2,v2); Recadre(myHS1,myHS2,u1,v1,u2,v2);
TopAbs_State in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol); TopAbs_State in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol);
if(in1 != TopAbs_OUT) { //-- !=ON donne Pb if(in1 != TopAbs_OUT) { //-- !=ON donne Pb
TopAbs_State in2 = myDom2->Classify(gp_Pnt2d(u2,v2),Tol); TopAbs_State in2 = myDom2->Classify(gp_Pnt2d(u2,v2),Tol);
if(in2 != TopAbs_OUT) { //-- !=ON if(in2 != TopAbs_OUT) { //-- !=ON
const IntSurf_PntOn2S& Plast = WLine->Point((Standard_Integer)(lastp)); const IntSurf_PntOn2S& Plast = WLine->Point((Standard_Integer)(lastp));
Plast.Parameters(u1,v1,u2,v2); Plast.Parameters(u1,v1,u2,v2);
Recadre(myHS1,myHS2,u1,v1,u2,v2); Recadre(myHS1,myHS2,u1,v1,u2,v2);
in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol); in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol);
if(in1 != TopAbs_OUT) { //-- !=ON donne Pb if(in1 != TopAbs_OUT) { //-- !=ON donne Pb
in2 = myDom2->Classify(gp_Pnt2d(u2,v2),Tol); in2 = myDom2->Classify(gp_Pnt2d(u2,v2),Tol);
if(in2 != TopAbs_OUT) { if(in2 != TopAbs_OUT) {
seqp.Append(firstp); seqp.Append(firstp);
seqp.Append(lastp); seqp.Append(lastp);
} }
} }
} }
} }
} }
} }
} }
// //
@ -173,47 +174,47 @@ void IntTools_LineConstructor::Perform(const Handle(IntPatch_Line)& L)
// //
bCond=Standard_False; bCond=Standard_False;
if (aST1==GeomAbs_Plane) { if (aST1==GeomAbs_Plane) {
if (aST2==GeomAbs_SurfaceOfExtrusion || if (aST2==GeomAbs_SurfaceOfExtrusion ||
aST2==GeomAbs_SurfaceOfRevolution) {//+zft aST2==GeomAbs_SurfaceOfRevolution) {//+zft
bCond=!bCond; bCond=!bCond;
} }
} }
else if (aST2==GeomAbs_Plane) { else if (aST2==GeomAbs_Plane) {
if (aST1==GeomAbs_SurfaceOfExtrusion || if (aST1==GeomAbs_SurfaceOfExtrusion ||
aST1==GeomAbs_SurfaceOfRevolution) {//+zft aST1==GeomAbs_SurfaceOfRevolution) {//+zft
bCond=!bCond; bCond=!bCond;
} }
} }
// //
if (bCond) { if (bCond) {
Standard_Integer aNb, anIndex, aNbTmp, jx; Standard_Integer aNb, anIndex, aNbTmp, jx;
TColStd_IndexedMapOfInteger aMap; TColStd_IndexedMapOfInteger aMap;
TColStd_SequenceOfReal aSeqTmp; TColStd_SequenceOfReal aSeqTmp;
// //
aNb=seqp.Length(); aNb=seqp.Length();
for(i=1; i<=aNb; ++i) { for(i=1; i<=aNb; ++i) {
lastp =seqp(i); lastp =seqp(i);
anIndex=(Standard_Integer)lastp; anIndex=(Standard_Integer)lastp;
if (!aMap.Contains(anIndex)){ if (!aMap.Contains(anIndex)){
aMap.Add(anIndex); aMap.Add(anIndex);
aSeqTmp.Append(lastp); aSeqTmp.Append(lastp);
} }
else { else {
aNbTmp=aSeqTmp.Length(); aNbTmp=aSeqTmp.Length();
aSeqTmp.Remove(aNbTmp); aSeqTmp.Remove(aNbTmp);
} }
} }
// //
seqp.Clear(); seqp.Clear();
// //
aNb=aSeqTmp.Length()/2; aNb=aSeqTmp.Length()/2;
for(i=1; i<=aNb;++i) { for(i=1; i<=aNb;++i) {
jx=2*i; jx=2*i;
firstp=aSeqTmp(jx-1); firstp=aSeqTmp(jx-1);
lastp =aSeqTmp(jx); lastp =aSeqTmp(jx);
seqp.Append(firstp); seqp.Append(firstp);
seqp.Append(lastp); seqp.Append(lastp);
} }
}//if (bCond) { }//if (bCond) {
} }
done = Standard_True; done = Standard_True;
@ -241,21 +242,21 @@ void IntTools_LineConstructor::Perform(const Handle(IntPatch_Line)& L)
firstp = GeomInt_LineTool::Vertex(L,i).ParameterOnLine(); firstp = GeomInt_LineTool::Vertex(L,i).ParameterOnLine();
lastp = GeomInt_LineTool::Vertex(L,i+1).ParameterOnLine(); lastp = GeomInt_LineTool::Vertex(L,i+1).ParameterOnLine();
if(Abs(firstp-lastp)>Precision::PConfusion()) { if(Abs(firstp-lastp)>Precision::PConfusion()) {
intrvtested = Standard_True; intrvtested = Standard_True;
const Standard_Real pmid = (firstp+lastp)*0.5; const Standard_Real pmid = (firstp+lastp)*0.5;
gp_Pnt Pmid; gp_Pnt Pmid;
GLinePoint(typl, GLine, pmid, Pmid); GLinePoint(typl, GLine, pmid, Pmid);
// //
Parameters(myHS1,myHS2,Pmid,u1,v1,u2,v2); Parameters(myHS1,myHS2,Pmid,u1,v1,u2,v2);
Recadre(myHS1,myHS2,u1,v1,u2,v2); Recadre(myHS1,myHS2,u1,v1,u2,v2);
const TopAbs_State in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol); const TopAbs_State in1 = myDom1->Classify(gp_Pnt2d(u1,v1),Tol);
if(in1 != TopAbs_OUT) { if(in1 != TopAbs_OUT) {
const TopAbs_State in2 = myDom2->Classify(gp_Pnt2d(u2,v2),Tol); const TopAbs_State in2 = myDom2->Classify(gp_Pnt2d(u2,v2),Tol);
if(in2 != TopAbs_OUT) { if(in2 != TopAbs_OUT) {
seqp.Append(firstp); seqp.Append(firstp);
seqp.Append(lastp); seqp.Append(lastp);
} }
} }
} }
} }
// //
@ -315,38 +316,38 @@ void IntTools_LineConstructor::Perform(const Handle(IntPatch_Line)& L)
Standard_Boolean inserted = Standard_False; Standard_Boolean inserted = Standard_False;
for (Standard_Integer j=1; j<=nbinserted;j++) { for (Standard_Integer j=1; j<=nbinserted;j++) {
if (Abs(prm-seqpss(j).Parameter()) <= Tol) { if (Abs(prm-seqpss(j).Parameter()) <= Tol) {
// accumulate // accumulate
GeomInt_ParameterAndOrientation& valj = seqpss.ChangeValue(j); GeomInt_ParameterAndOrientation& valj = seqpss.ChangeValue(j);
if (or1 != TopAbs_INTERNAL) { if (or1 != TopAbs_INTERNAL) {
if (valj.Orientation1() != TopAbs_INTERNAL) { if (valj.Orientation1() != TopAbs_INTERNAL) {
if (or1 != valj.Orientation1()) { if (or1 != valj.Orientation1()) {
valj.SetOrientation1(TopAbs_INTERNAL); valj.SetOrientation1(TopAbs_INTERNAL);
} }
} }
else { else {
valj.SetOrientation1(or1); valj.SetOrientation1(or1);
} }
} }
if (or2 != TopAbs_INTERNAL) { if (or2 != TopAbs_INTERNAL) {
if (valj.Orientation2() != TopAbs_INTERNAL) { if (valj.Orientation2() != TopAbs_INTERNAL) {
if (or2 != valj.Orientation2()) { if (or2 != valj.Orientation2()) {
valj.SetOrientation2(TopAbs_INTERNAL); valj.SetOrientation2(TopAbs_INTERNAL);
} }
} }
else { else {
valj.SetOrientation2(or2); valj.SetOrientation2(or2);
} }
} }
inserted = Standard_True; inserted = Standard_True;
break; break;
} }
if (prm < seqpss(j).Parameter()-Tol ) { if (prm < seqpss(j).Parameter()-Tol ) {
// insert before position j // insert before position j
seqpss.InsertBefore(j,GeomInt_ParameterAndOrientation(prm,or1,or2)); seqpss.InsertBefore(j,GeomInt_ParameterAndOrientation(prm,or1,or2));
inserted = Standard_True; inserted = Standard_True;
break; break;
} }
} }
@ -374,12 +375,12 @@ void IntTools_LineConstructor::Perform(const Handle(IntPatch_Line)& L)
Standard_Real U,V; Standard_Real U,V;
for (i=1; i<=GeomInt_LineTool::NbVertex(L); i++ ) { for (i=1; i<=GeomInt_LineTool::NbVertex(L); i++ ) {
if (!GeomInt_LineTool::Vertex(L,i).IsOnDomS1() ) { if (!GeomInt_LineTool::Vertex(L,i).IsOnDomS1() ) {
GeomInt_LineTool::Vertex(L,i).ParametersOnS1(U,V); GeomInt_LineTool::Vertex(L,i).ParametersOnS1(U,V);
gp_Pnt2d PPCC(U,V); gp_Pnt2d PPCC(U,V);
if (myDom1->Classify(PPCC,Tol) == TopAbs_OUT) { if (myDom1->Classify(PPCC,Tol) == TopAbs_OUT) {
done = Standard_True; done = Standard_True;
return; return;
} }
break; break;
} }
} }
@ -399,11 +400,11 @@ void IntTools_LineConstructor::Perform(const Handle(IntPatch_Line)& L)
Standard_Real U,V; Standard_Real U,V;
for (i=1; i<=GeomInt_LineTool::NbVertex(L); i++ ) { for (i=1; i<=GeomInt_LineTool::NbVertex(L); i++ ) {
if (!GeomInt_LineTool::Vertex(L,i).IsOnDomS2() ) { if (!GeomInt_LineTool::Vertex(L,i).IsOnDomS2() ) {
GeomInt_LineTool::Vertex(L,i).ParametersOnS2(U,V); GeomInt_LineTool::Vertex(L,i).ParametersOnS2(U,V);
if (myDom2->Classify(gp_Pnt2d(U,V),Tol) == TopAbs_OUT) { if (myDom2->Classify(gp_Pnt2d(U,V),Tol) == TopAbs_OUT) {
done = Standard_True; done = Standard_True;
return; return;
} }
break; break;
} }
} }
@ -428,49 +429,49 @@ void IntTools_LineConstructor::Perform(const Handle(IntPatch_Line)& L)
or2 = seqpss(i).Orientation2(); or2 = seqpss(i).Orientation2();
if (dansS1 && dansS2) { if (dansS1 && dansS2) {
if (or1 == TopAbs_REVERSED){ if (or1 == TopAbs_REVERSED){
dansS1 = Standard_False; dansS1 = Standard_False;
} }
if (or2 == TopAbs_REVERSED){ if (or2 == TopAbs_REVERSED){
dansS2 = Standard_False; dansS2 = Standard_False;
} }
if (!dansS1 || !dansS2) { if (!dansS1 || !dansS2) {
lastp = seqpss(i).Parameter(); lastp = seqpss(i).Parameter();
Standard_Real stofirst = Max(firstp, thefirst); Standard_Real stofirst = Max(firstp, thefirst);
Standard_Real stolast = Min(lastp, thelast) ; Standard_Real stolast = Min(lastp, thelast) ;
if (stolast > stofirst) { if (stolast > stofirst) {
seqp.Append(stofirst); seqp.Append(stofirst);
seqp.Append(stolast); seqp.Append(stolast);
} }
if (lastp > thelast) { if (lastp > thelast) {
break; break;
} }
} }
} }
else { else {
if (dansS1) { if (dansS1) {
if (or1 == TopAbs_REVERSED) { if (or1 == TopAbs_REVERSED) {
dansS1 = Standard_False; dansS1 = Standard_False;
} }
} }
else { else {
if (or1 == TopAbs_FORWARD){ if (or1 == TopAbs_FORWARD){
dansS1 = Standard_True; dansS1 = Standard_True;
} }
} }
if (dansS2) { if (dansS2) {
if (or2 == TopAbs_REVERSED) { if (or2 == TopAbs_REVERSED) {
dansS2 = Standard_False; dansS2 = Standard_False;
} }
} }
else { else {
if (or2 == TopAbs_FORWARD){ if (or2 == TopAbs_FORWARD){
dansS2 = Standard_True; dansS2 = Standard_True;
} }
} }
if (dansS1 && dansS2){ if (dansS1 && dansS2){
firstp = seqpss(i).Parameter(); firstp = seqpss(i).Parameter();
} }
} }
} }
@ -491,11 +492,11 @@ void IntTools_LineConstructor::Perform(const Handle(IntPatch_Line)& L)
//purpose : //purpose :
//======================================================================= //=======================================================================
void Recadre(const Handle(GeomAdaptor_HSurface)& myHS1, void Recadre(const Handle(GeomAdaptor_HSurface)& myHS1,
const Handle(GeomAdaptor_HSurface)& myHS2, const Handle(GeomAdaptor_HSurface)& myHS2,
Standard_Real& u1, Standard_Real& u1,
Standard_Real& v1, Standard_Real& v1,
Standard_Real& u2, Standard_Real& u2,
Standard_Real& v2) Standard_Real& v2)
{ {
Standard_Boolean myHS1IsUPeriodic,myHS1IsVPeriodic; Standard_Boolean myHS1IsUPeriodic,myHS1IsVPeriodic;
const GeomAbs_SurfaceType typs1 = myHS1->GetType(); const GeomAbs_SurfaceType typs1 = myHS1->GetType();
@ -545,33 +546,31 @@ void Recadre(const Handle(GeomAdaptor_HSurface)& myHS1,
break; break;
} }
} }
Standard_Real du, dv;
//
if(myHS1IsUPeriodic) { if(myHS1IsUPeriodic) {
const Standard_Real lmf = M_PI+M_PI; //-- myHS1->UPeriod(); const Standard_Real lmf = M_PI+M_PI; //-- myHS1->UPeriod();
const Standard_Real f = myHS1->FirstUParameter(); const Standard_Real f = myHS1->FirstUParameter();
const Standard_Real l = myHS1->LastUParameter(); const Standard_Real l = myHS1->LastUParameter();
while(u1 < f) { u1+=lmf; } IntTools_Tools::AdjustPeriodic(u1, f, l, lmf, u1, du);
while(u1 > l) { u1-=lmf; }
} }
if(myHS1IsVPeriodic) { if(myHS1IsVPeriodic) {
const Standard_Real lmf = M_PI+M_PI; //-- myHS1->VPeriod(); const Standard_Real lmf = M_PI+M_PI; //-- myHS1->VPeriod();
const Standard_Real f = myHS1->FirstVParameter(); const Standard_Real f = myHS1->FirstVParameter();
const Standard_Real l = myHS1->LastVParameter(); const Standard_Real l = myHS1->LastVParameter();
while(v1 < f) { v1+=lmf; } IntTools_Tools::AdjustPeriodic(v1, f, l, lmf, v1, dv);
while(v1 > l) { v1-=lmf; }
} }
if(myHS2IsUPeriodic) { if(myHS2IsUPeriodic) {
const Standard_Real lmf = M_PI+M_PI; //-- myHS2->UPeriod(); const Standard_Real lmf = M_PI+M_PI; //-- myHS2->UPeriod();
const Standard_Real f = myHS2->FirstUParameter(); const Standard_Real f = myHS2->FirstUParameter();
const Standard_Real l = myHS2->LastUParameter(); const Standard_Real l = myHS2->LastUParameter();
while(u2 < f) { u2+=lmf; } IntTools_Tools::AdjustPeriodic(u2, f, l, lmf, u2, du);
while(u2 > l) { u2-=lmf; }
} }
if(myHS2IsVPeriodic) { if(myHS2IsVPeriodic) {
const Standard_Real lmf = M_PI+M_PI; //-- myHS2->VPeriod(); const Standard_Real lmf = M_PI+M_PI; //-- myHS2->VPeriod();
const Standard_Real f = myHS2->FirstVParameter(); const Standard_Real f = myHS2->FirstVParameter();
const Standard_Real l = myHS2->LastVParameter(); const Standard_Real l = myHS2->LastVParameter();
while(v2 < f) { v2+=lmf; } IntTools_Tools::AdjustPeriodic(v2, f, l, lmf, v2, dv);
while(v2 > l) { v2-=lmf; }
} }
} }
//======================================================================= //=======================================================================
@ -579,12 +578,12 @@ void Recadre(const Handle(GeomAdaptor_HSurface)& myHS1,
//purpose : //purpose :
//======================================================================= //=======================================================================
void Parameters(const Handle(GeomAdaptor_HSurface)& myHS1, void Parameters(const Handle(GeomAdaptor_HSurface)& myHS1,
const Handle(GeomAdaptor_HSurface)& myHS2, const Handle(GeomAdaptor_HSurface)& myHS2,
const gp_Pnt& Ptref, const gp_Pnt& Ptref,
Standard_Real& U1, Standard_Real& U1,
Standard_Real& V1, Standard_Real& V1,
Standard_Real& U2, Standard_Real& U2,
Standard_Real& V2) Standard_Real& V2)
{ {
Parameters(myHS1, Ptref, U1, V1); Parameters(myHS1, Ptref, U1, V1);
Parameters(myHS2, Ptref, U2, V2); Parameters(myHS2, Ptref, U2, V2);
@ -627,9 +626,9 @@ void Parameters(const Handle(GeomAdaptor_HSurface)& myHS1,
//purpose : //purpose :
//======================================================================= //=======================================================================
void GLinePoint(const IntPatch_IType typl, void GLinePoint(const IntPatch_IType typl,
const Handle(IntPatch_GLine)& GLine, const Handle(IntPatch_GLine)& GLine,
const Standard_Real aT, const Standard_Real aT,
gp_Pnt& aP) gp_Pnt& aP)
{ {
switch (typl) { switch (typl) {
case IntPatch_Lin: case IntPatch_Lin:
@ -695,32 +694,32 @@ class IntTools_RealWithFlag {
//------------ //------------
static static
void SortShell(const Standard_Integer, void SortShell(const Standard_Integer,
IntTools_RealWithFlag *); IntTools_RealWithFlag *);
static static
void RejectDuplicates(Standard_Integer& aNbVtx, void RejectDuplicates(Standard_Integer& aNbVtx,
IntTools_RealWithFlag *pVtx, IntTools_RealWithFlag *pVtx,
Standard_Real aTolPrm); Standard_Real aTolPrm);
static static
void RejectNearBeacons(Standard_Integer& aNbVtx, void RejectNearBeacons(Standard_Integer& aNbVtx,
IntTools_RealWithFlag *pVtx, IntTools_RealWithFlag *pVtx,
Standard_Real aTolPC1, Standard_Real aTolPC1,
const GeomAbs_SurfaceType aTS1, const GeomAbs_SurfaceType aTS1,
const GeomAbs_SurfaceType aTS2); const GeomAbs_SurfaceType aTS2);
static static
Standard_Real AdjustOnPeriod(const Standard_Real aTr, Standard_Real AdjustOnPeriod(const Standard_Real aTr,
const Standard_Real aPeriod); const Standard_Real aPeriod);
static static
Standard_Boolean RejectMicroCircle(const Handle(IntPatch_GLine)& aGLine, Standard_Boolean RejectMicroCircle(const Handle(IntPatch_GLine)& aGLine,
const IntPatch_IType aType, const IntPatch_IType aType,
const Standard_Real aTol3D); const Standard_Real aTol3D);
// //
//======================================================================= //=======================================================================
//function : TreatCircle //function : TreatCircle
//purpose : //purpose :
//======================================================================= //=======================================================================
void IntTools_LineConstructor::TreatCircle(const Handle(IntPatch_Line)& aLine, void IntTools_LineConstructor::TreatCircle(const Handle(IntPatch_Line)& aLine,
const Standard_Real aTol) const Standard_Real aTol)
{ {
Standard_Boolean bRejected; Standard_Boolean bRejected;
IntPatch_IType aType; IntPatch_IType aType;
@ -780,8 +779,8 @@ void IntTools_LineConstructor::TreatCircle(const Handle(IntPatch_Line)& aLine,
for(i=1; i<=aNbVtxWas; ++i) { for(i=1; i<=aNbVtxWas; ++i) {
aT=GeomInt_LineTool::Vertex(aLine, i).ParameterOnLine(); aT=GeomInt_LineTool::Vertex(aLine, i).ParameterOnLine();
if (fabs(aT) < aTolPC1 || fabs(aT-aTwoPI) < aTolPC1) { if (fabs(aT) < aTolPC1 || fabs(aT-aTwoPI) < aTolPC1) {
bFound=!bFound; bFound=!bFound;
break; break;
} }
} }
if (!bFound) { if (!bFound) {
@ -789,8 +788,8 @@ void IntTools_LineConstructor::TreatCircle(const Handle(IntPatch_Line)& aLine,
pVtx[aNbVtx-1].SetValue(aT); pVtx[aNbVtx-1].SetValue(aT);
// //
for(i=0; i<aNbVtx; ++i) { for(i=0; i<aNbVtx; ++i) {
aT=pVtx[i+1].Value(); aT=pVtx[i+1].Value();
pVtx[i].SetValue(aT); pVtx[i].SetValue(aT);
} }
--aNbVtx; --aNbVtx;
} }
@ -811,8 +810,8 @@ void IntTools_LineConstructor::TreatCircle(const Handle(IntPatch_Line)& aLine,
aP2D.SetCoord(aU2, aV2); aP2D.SetCoord(aU2, aV2);
aIn2=myDom2->Classify(aP2D, aTol); aIn2=myDom2->Classify(aP2D, aTol);
if(aIn2 != TopAbs_OUT) { if(aIn2 != TopAbs_OUT) {
seqp.Append(aT1); seqp.Append(aT1);
seqp.Append(aT2); seqp.Append(aT2);
} }
} }
} }
@ -826,10 +825,10 @@ void IntTools_LineConstructor::TreatCircle(const Handle(IntPatch_Line)& aLine,
// chl/930/B5 B8 C2 C5 E2 E5 E8 F2 G8 H2 H5 H8 // chl/930/B5 B8 C2 C5 E2 E5 E8 F2 G8 H2 H5 H8
//======================================================================= //=======================================================================
void RejectNearBeacons(Standard_Integer& aNbVtx, void RejectNearBeacons(Standard_Integer& aNbVtx,
IntTools_RealWithFlag *pVtx, IntTools_RealWithFlag *pVtx,
Standard_Real aTolPC1, Standard_Real aTolPC1,
const GeomAbs_SurfaceType aTS1, const GeomAbs_SurfaceType aTS1,
const GeomAbs_SurfaceType aTS2) const GeomAbs_SurfaceType aTS2)
{ {
Standard_Integer i, j, iBcn; Standard_Integer i, j, iBcn;
Standard_Real aT, aBcn[2]; Standard_Real aT, aBcn[2];
@ -841,33 +840,33 @@ void RejectNearBeacons(Standard_Integer& aNbVtx,
for (j=0; j<2; ++j) { for (j=0; j<2; ++j) {
iBcn=-1; iBcn=-1;
for(i=0; i<aNbVtx; ++i) { for(i=0; i<aNbVtx; ++i) {
aT=pVtx[i].Value(); aT=pVtx[i].Value();
if (aT==aBcn[j]) { if (aT==aBcn[j]) {
iBcn=i; iBcn=i;
break; break;
} }
} }
// //
if (iBcn<0) { if (iBcn<0) {
// The beacon is not found // The beacon is not found
continue; continue;
} }
// //
for(i=0; i<aNbVtx; ++i) { for(i=0; i<aNbVtx; ++i) {
if (i!=iBcn) { if (i!=iBcn) {
aT=pVtx[i].Value(); aT=pVtx[i].Value();
if (fabs(aT-aBcn[j]) < aTolPC1) { if (fabs(aT-aBcn[j]) < aTolPC1) {
pVtx[i].SetFlag(0); pVtx[i].SetFlag(0);
} }
} }
} }
}// for (j=0; j<2; ++j) { }// for (j=0; j<2; ++j) {
//------------------------------------------ //------------------------------------------
j=0; j=0;
for(i=0; i<aNbVtx; ++i) { for(i=0; i<aNbVtx; ++i) {
if (pVtx[i].Flag()) { if (pVtx[i].Flag()) {
pVtx[j]=pVtx[i]; pVtx[j]=pVtx[i];
++j; ++j;
} }
} }
aNbVtx=j; aNbVtx=j;
@ -879,8 +878,8 @@ void RejectNearBeacons(Standard_Integer& aNbVtx,
//purpose : //purpose :
//======================================================================= //=======================================================================
void RejectDuplicates(Standard_Integer& aNbVtx, void RejectDuplicates(Standard_Integer& aNbVtx,
IntTools_RealWithFlag *pVtx, IntTools_RealWithFlag *pVtx,
Standard_Real aTolPC) Standard_Real aTolPC)
{ {
Standard_Integer i, j; Standard_Integer i, j;
Standard_Real dX, aT1, aT2; Standard_Real dX, aT1, aT2;
@ -908,7 +907,7 @@ void RejectDuplicates(Standard_Integer& aNbVtx,
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Real AdjustOnPeriod(const Standard_Real aTr, Standard_Real AdjustOnPeriod(const Standard_Real aTr,
const Standard_Real aPeriod) const Standard_Real aPeriod)
{ {
Standard_Integer k; Standard_Integer k;
Standard_Real aT; Standard_Real aT;
@ -931,8 +930,8 @@ Standard_Real AdjustOnPeriod(const Standard_Real aTr,
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Boolean RejectMicroCircle(const Handle(IntPatch_GLine)& aGLine, Standard_Boolean RejectMicroCircle(const Handle(IntPatch_GLine)& aGLine,
const IntPatch_IType aType, const IntPatch_IType aType,
const Standard_Real aTol3D) const Standard_Real aTol3D)
{ {
Standard_Boolean bRet; Standard_Boolean bRet;
Standard_Real aR; Standard_Real aR;
@ -954,7 +953,7 @@ Standard_Boolean RejectMicroCircle(const Handle(IntPatch_GLine)& aGLine,
// purpose : // purpose :
//======================================================================= //=======================================================================
void SortShell(const Standard_Integer n, void SortShell(const Standard_Integer n,
IntTools_RealWithFlag *a) IntTools_RealWithFlag *a)
{ {
Standard_Integer nd, i, j, l, d=1; Standard_Integer nd, i, j, l, d=1;
IntTools_RealWithFlag x; IntTools_RealWithFlag x;

View File

@ -237,5 +237,15 @@ is
theTmax :out Real from Standard) theTmax :out Real from Standard)
returns Integer 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 <thePar> to the range [theParMin, theParMax]
end Tools; end Tools;

View File

@ -778,3 +778,35 @@ Standard_Integer IntTools_Tools::SegPln(const gp_Lin& theLin,
return iRet; 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.);
}

View File

@ -1,4 +1,4 @@
puts "TODO OCC11111 ALL: Error : The square of result shape is" puts "TODO ?OCC11111 ALL: Error : The square of result shape is"
puts "TODO ?OCC11111 ALL: Error : Result shape is WRONG" puts "TODO ?OCC11111 ALL: Error : Result shape is WRONG"
puts "============" puts "============"

View File

@ -0,0 +1,33 @@
puts "========="
puts "OCC24981"
puts "========="
puts ""
###########################################################
# IntTools_FaceFace enters to infinite loop on the attached case
###########################################################
restore [locate_data_file bug24981_shapes.brep] a
restore [locate_data_file bug24981_tools.brep] b
explode a So
explode b So
bclearobjects
bcleartools
baddobjects a_1
baddtools b_1 b_2 b_3 b_4 b_5 b_6 b_7 b_8 b_9 b_10 b_11 b_12 b_13 b_14 b_15 b_16 b_17 b_18 b_19 b_20 b_21 b_22 b_23 b_24 b_25
bfillds
bbuild result
set nb_v_good 122
set nb_e_good 220
set nb_w_good 243
set nb_f_good 195
set nb_sh_good 75
set nb_sol_good 75
set nb_compsol_good 0
set nb_compound_good 1
set nb_shape_good 931
set 2dviewer 1