From 1d18c75e70dca1edd5d91287725bf3fcea1dec0e Mon Sep 17 00:00:00 2001 From: emv Date: Thu, 20 Feb 2014 17:14:04 +0400 Subject: [PATCH] 0024648: Different types of intersection curves between Cone and Torus with a different order of arguments Correct treatment of the cases with Cone and Torus. Test cases for issue CR24648 --- src/BOPAlgo/BOPAlgo_PaveFiller_3.cxx | 4 + src/BOPAlgo/BOPAlgo_PaveFiller_5.cxx | 4 + src/IntPatch/IntPatch_Intersection.cxx | 579 +++++++++++++------------ tests/bugs/modalg_5/bug24648 | 36 ++ 4 files changed, 345 insertions(+), 278 deletions(-) create mode 100644 tests/bugs/modalg_5/bug24648 diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller_3.cxx b/src/BOPAlgo/BOPAlgo_PaveFiller_3.cxx index d07a4ec919..9a4f51c630 100644 --- a/src/BOPAlgo/BOPAlgo_PaveFiller_3.cxx +++ b/src/BOPAlgo/BOPAlgo_PaveFiller_3.cxx @@ -691,6 +691,10 @@ void BOPAlgo_PaveFiller::ForceInterfVE(const Standard_Integer nV, aT=aProjector.LowerDistanceParameter(); // BOPDS_VectorOfInterfVE& aVEs=myDS->InterfVE(); + if (aVEs.Extent() == 0) { + aVEs.Init(); + } + // i=aVEs.Append()-1; BOPDS_InterfVE& aVE=aVEs(i); aVE.SetIndices(nV, nE); diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller_5.cxx b/src/BOPAlgo/BOPAlgo_PaveFiller_5.cxx index fa443034d2..3b3d71f40a 100644 --- a/src/BOPAlgo/BOPAlgo_PaveFiller_5.cxx +++ b/src/BOPAlgo/BOPAlgo_PaveFiller_5.cxx @@ -537,6 +537,10 @@ Standard_Boolean BOPAlgo_PaveFiller::ForceInterfVF(const Standard_Integer nV, BRep_Builder aBB; // BOPDS_VectorOfInterfVF& aVFs=myDS->InterfVF(); + if (aVFs.Extent() == 0) { + aVFs.Init(); + } + // i=aVFs.Append()-1; BOPDS_InterfVF& aVF=aVFs(i); aVF.SetIndices(nV, nF); diff --git a/src/IntPatch/IntPatch_Intersection.cxx b/src/IntPatch/IntPatch_Intersection.cxx index 4756b16bfe..5d43ec6dfe 100644 --- a/src/IntPatch/IntPatch_Intersection.cxx +++ b/src/IntPatch/IntPatch_Intersection.cxx @@ -139,16 +139,16 @@ void IntPatch_Intersection::Perform(const Handle(Adaptor3d_HSurface)& S1, case GeomAbs_Torus: break; default: { - IntPatch_PrmPrmIntersection interpp; - interpp.Perform(S1,D1,TolArc,TolTang,myFleche,myUVMaxStep); - if (interpp.IsDone()) - { - done = Standard_True; - tgte = Standard_False; - empt = interpp.IsEmpty(); - const Standard_Integer nblm = interpp.NbLines(); - for (Standard_Integer i=1; i<=nblm; i++) slin.Append(interpp.Line(i)); - } + IntPatch_PrmPrmIntersection interpp; + interpp.Perform(S1,D1,TolArc,TolTang,myFleche,myUVMaxStep); + if (interpp.IsDone()) + { + done = Standard_True; + tgte = Standard_False; + empt = interpp.IsEmpty(); + const Standard_Integer nblm = interpp.NbLines(); + for (Standard_Integer i=1; i<=nblm; i++) slin.Append(interpp.Line(i)); + } } break; } @@ -200,12 +200,12 @@ static void FUN_GetMinMaxXYZPnt( const Handle(Adaptor3d_HSurface)& S, for(Standard_Real U = S->FirstUParameter(); U <= S->LastUParameter(); U += DU) { for(Standard_Real V = S->FirstVParameter(); V <= S->LastVParameter(); V += DV) - { - S->D0(U,V,PUV); + { + S->D0(U,V,PUV); const Standard_Real cXYZ = PUV.XYZ().Modulus(); - if(cXYZ > tMaxXYZ) { tMaxXYZ = cXYZ; ptMax = PUV; } - if(cXYZ < tMinXYZ) { tMinXYZ = cXYZ; ptMin = PUV; } - } + if(cXYZ > tMaxXYZ) { tMaxXYZ = cXYZ; ptMax = PUV; } + if(cXYZ < tMinXYZ) { tMinXYZ = cXYZ; ptMin = PUV; } + } } pMin = ptMin; pMax = ptMax; @@ -226,19 +226,19 @@ static void FUN_TrimInfSurf(const gp_Pnt& Pmin, { Standard_Real Umax = -1.e+100, Umin = 1.e+100, Vmax = -1.e+100, Vmin = 1.e+100, cU, cV; if(ext1.IsDone()) - { + { for(Standard_Integer i = 1; i <= ext1.NbExt(); i++) { - const Extrema_POnSurf & pons = ext1.Point(i); - pons.Parameter(cU,cV); - if(cU > Umax) Umax = cU; - if(cU < Umin) Umin = cU; - if(cV > Vmax) Vmax = cV; - if(cV < Vmin) Vmin = cV; + const Extrema_POnSurf & pons = ext1.Point(i); + pons.Parameter(cU,cV); + if(cU > Umax) Umax = cU; + if(cU < Umin) Umin = cU; + if(cV > Vmax) Vmax = cV; + if(cV < Vmin) Vmin = cV; } - } + } if(ext2.IsDone()) - { + { for(Standard_Integer i = 1; i <= ext2.NbExt(); i++) { const Extrema_POnSurf & pons = ext2.Point(i); @@ -248,7 +248,7 @@ static void FUN_TrimInfSurf(const gp_Pnt& Pmin, if(cV > Vmax) Vmax = cV; if(cV < Vmin) Vmin = cV; } - } + } TP = Max(Abs(Umin),Max(Abs(Umax),Max(Abs(Vmin),Abs(Vmax)))); } if(TP == 0.) { TrimS = InfSurf; return; } @@ -265,18 +265,18 @@ static void FUN_TrimInfSurf(const gp_Pnt& Pmin, if(Vinf && !Vsup){ TrimS = InfSurf->VTrim(-tp, InfSurf->LastVParameter(), 1.0e-7); IsTrimed = 1; } if(!Vinf && Vsup){ TrimS = InfSurf->VTrim(InfSurf->FirstVParameter(), tp, 1.0e-7); IsTrimed = 1; } if(IsTrimed) - { - TmpSS = TrimS; - if(Uinf && Usup) TrimS = TmpSS->UTrim(-tp, tp, 1.0e-7); - if(Uinf && !Usup) TrimS = TmpSS->UTrim(-tp, InfSurf->LastUParameter(), 1.0e-7); - if(!Uinf && Usup) TrimS = TmpSS->UTrim(InfSurf->FirstUParameter(), tp, 1.0e-7); - } + { + TmpSS = TrimS; + if(Uinf && Usup) TrimS = TmpSS->UTrim(-tp, tp, 1.0e-7); + if(Uinf && !Usup) TrimS = TmpSS->UTrim(-tp, InfSurf->LastUParameter(), 1.0e-7); + if(!Uinf && Usup) TrimS = TmpSS->UTrim(InfSurf->FirstUParameter(), tp, 1.0e-7); + } else - { - if(Uinf && Usup) TrimS = InfSurf->UTrim(-tp, tp, 1.0e-7); - if(Uinf && !Usup) TrimS = InfSurf->UTrim(-tp, InfSurf->LastUParameter(), 1.0e-7); - if(!Uinf && Usup) TrimS = InfSurf->UTrim(InfSurf->FirstUParameter(), tp, 1.0e-7); - } + { + if(Uinf && Usup) TrimS = InfSurf->UTrim(-tp, tp, 1.0e-7); + if(Uinf && !Usup) TrimS = InfSurf->UTrim(-tp, InfSurf->LastUParameter(), 1.0e-7); + if(!Uinf && Usup) TrimS = InfSurf->UTrim(InfSurf->FirstUParameter(), tp, 1.0e-7); + } } } //================================================================================ @@ -296,11 +296,11 @@ static void FUN_GetUiso(const Handle(Geom_Surface)& GS, Handle(Geom_Curve) gc = GS->UIso(U); if(IsVP && (FirstV == 0.0 && LastV == (2.*M_PI))) I = gc; else - { - Handle(Geom_TrimmedCurve) gtc = new Geom_TrimmedCurve(gc,FirstV,LastV); - //szv:I = Handle(Geom_Curve)::DownCast(gtc); - I = gtc; - } + { + Handle(Geom_TrimmedCurve) gtc = new Geom_TrimmedCurve(gc,FirstV,LastV); + //szv:I = Handle(Geom_Curve)::DownCast(gtc); + I = gtc; + } } else//OffsetSurface { @@ -310,43 +310,43 @@ static void FUN_GetUiso(const Handle(Geom_Surface)& GS, GeomAdaptor_Curve gac(gcbs); const GeomAbs_CurveType GACT = gac.GetType(); if(IsVP || IsVC || GACT == GeomAbs_BSplineCurve || GACT == GeomAbs_BezierCurve || Abs(LastV - FirstV) < 1.e+5) - { - Handle(Geom_Curve) gc = gos->UIso(U); - if(IsVP && (FirstV == 0.0 && LastV == (2*M_PI))) I = gc; - else + { + Handle(Geom_Curve) gc = gos->UIso(U); + if(IsVP && (FirstV == 0.0 && LastV == (2*M_PI))) I = gc; + else { - Handle(Geom_TrimmedCurve) gtc = new Geom_TrimmedCurve(gc,FirstV,LastV); - //szv:I = Handle(Geom_Curve)::DownCast(gtc); - I = gtc; - } - } + Handle(Geom_TrimmedCurve) gtc = new Geom_TrimmedCurve(gc,FirstV,LastV); + //szv:I = Handle(Geom_Curve)::DownCast(gtc); + I = gtc; + } + } else//Offset Line, Parab, Hyperb - { - Standard_Real VmTr, VMTr; - if(GACT != GeomAbs_Hyperbola) + { + Standard_Real VmTr, VMTr; + if(GACT != GeomAbs_Hyperbola) { - if(FirstV >= 0. && LastV >= 0.){ VmTr = FirstV; VMTr = ((LastV - FirstV) > 1.e+4) ? (FirstV + 1.e+4) : LastV; } - else if(FirstV < 0. && LastV < 0.){ VMTr = LastV; VmTr = ((FirstV - LastV) < -1.e+4) ? (LastV - 1.e+4) : FirstV; } - else { VmTr = (FirstV < -1.e+4) ? -1.e+4 : FirstV; VMTr = (LastV > 1.e+4) ? 1.e+4 : LastV; } - } - else//Hyperbola - { - if(FirstV >= 0. && LastV >= 0.) - { - if(FirstV > 4.) return; - VmTr = FirstV; VMTr = (LastV > 4.) ? 4. : LastV; - } - else if(FirstV < 0. && LastV < 0.) - { - if(LastV < -4.) return; - VMTr = LastV; VmTr = (FirstV < -4.) ? -4. : FirstV; - } - else { VmTr = (FirstV < -4.) ? -4. : FirstV; VMTr = (LastV > 4.) ? 4. : LastV; } - } - //Make trimmed surface - Handle(Geom_RectangularTrimmedSurface) rts = new Geom_RectangularTrimmedSurface(gos,VmTr,VMTr,Standard_True); - I = rts->UIso(U); - } + if(FirstV >= 0. && LastV >= 0.){ VmTr = FirstV; VMTr = ((LastV - FirstV) > 1.e+4) ? (FirstV + 1.e+4) : LastV; } + else if(FirstV < 0. && LastV < 0.){ VMTr = LastV; VmTr = ((FirstV - LastV) < -1.e+4) ? (LastV - 1.e+4) : FirstV; } + else { VmTr = (FirstV < -1.e+4) ? -1.e+4 : FirstV; VMTr = (LastV > 1.e+4) ? 1.e+4 : LastV; } + } + else//Hyperbola + { + if(FirstV >= 0. && LastV >= 0.) + { + if(FirstV > 4.) return; + VmTr = FirstV; VMTr = (LastV > 4.) ? 4. : LastV; + } + else if(FirstV < 0. && LastV < 0.) + { + if(LastV < -4.) return; + VMTr = LastV; VmTr = (FirstV < -4.) ? -4. : FirstV; + } + else { VmTr = (FirstV < -4.) ? -4. : FirstV; VMTr = (LastV > 4.) ? 4. : LastV; } + } + //Make trimmed surface + Handle(Geom_RectangularTrimmedSurface) rts = new Geom_RectangularTrimmedSurface(gos,VmTr,VMTr,Standard_True); + I = rts->UIso(U); + } } } //================================================================================ @@ -366,11 +366,11 @@ static void FUN_GetViso(const Handle(Geom_Surface)& GS, Handle(Geom_Curve) gc = GS->VIso(V); if(IsUP && (FirstU == 0.0 && LastU == (2*M_PI))) I = gc; else - { - Handle(Geom_TrimmedCurve) gtc = new Geom_TrimmedCurve(gc,FirstU,LastU); - //szv:I = Handle(Geom_Curve)::DownCast(gtc); - I = gtc; - } + { + Handle(Geom_TrimmedCurve) gtc = new Geom_TrimmedCurve(gc,FirstU,LastU); + //szv:I = Handle(Geom_Curve)::DownCast(gtc); + I = gtc; + } } else//OffsetSurface { @@ -380,43 +380,43 @@ static void FUN_GetViso(const Handle(Geom_Surface)& GS, GeomAdaptor_Curve gac(gcbs); const GeomAbs_CurveType GACT = gac.GetType(); if(IsUP || IsUC || GACT == GeomAbs_BSplineCurve || GACT == GeomAbs_BezierCurve || Abs(LastU - FirstU) < 1.e+5) - { - Handle(Geom_Curve) gc = gos->VIso(V); - if(IsUP && (FirstU == 0.0 && LastU == (2*M_PI))) I = gc; - else - { - Handle(Geom_TrimmedCurve) gtc = new Geom_TrimmedCurve(gc,FirstU,LastU); - //szv:I = Handle(Geom_Curve)::DownCast(gtc); - I = gtc; - } - } + { + Handle(Geom_Curve) gc = gos->VIso(V); + if(IsUP && (FirstU == 0.0 && LastU == (2*M_PI))) I = gc; + else + { + Handle(Geom_TrimmedCurve) gtc = new Geom_TrimmedCurve(gc,FirstU,LastU); + //szv:I = Handle(Geom_Curve)::DownCast(gtc); + I = gtc; + } + } else//Offset Line, Parab, Hyperb - { - Standard_Real UmTr, UMTr; - if(GACT != GeomAbs_Hyperbola) - { - if(FirstU >= 0. && LastU >= 0.){ UmTr = FirstU; UMTr = ((LastU - FirstU) > 1.e+4) ? (FirstU + 1.e+4) : LastU; } - else if(FirstU < 0. && LastU < 0.){ UMTr = LastU; UmTr = ((FirstU - LastU) < -1.e+4) ? (LastU - 1.e+4) : FirstU; } - else { UmTr = (FirstU < -1.e+4) ? -1.e+4 : FirstU; UMTr = (LastU > 1.e+4) ? 1.e+4 : LastU; } - } - else//Hyperbola - { - if(FirstU >= 0. && LastU >= 0.) - { - if(FirstU > 4.) return; - UmTr = FirstU; UMTr = (LastU > 4.) ? 4. : LastU; - } - else if(FirstU < 0. && LastU < 0.) - { - if(LastU < -4.) return; - UMTr = LastU; UmTr = (FirstU < -4.) ? -4. : FirstU; - } - else { UmTr = (FirstU < -4.) ? -4. : FirstU; UMTr = (LastU > 4.) ? 4. : LastU; } - } - //Make trimmed surface - Handle(Geom_RectangularTrimmedSurface) rts = new Geom_RectangularTrimmedSurface(gos,UmTr,UMTr,Standard_True); - I = rts->VIso(V); - } + { + Standard_Real UmTr, UMTr; + if(GACT != GeomAbs_Hyperbola) + { + if(FirstU >= 0. && LastU >= 0.){ UmTr = FirstU; UMTr = ((LastU - FirstU) > 1.e+4) ? (FirstU + 1.e+4) : LastU; } + else if(FirstU < 0. && LastU < 0.){ UMTr = LastU; UmTr = ((FirstU - LastU) < -1.e+4) ? (LastU - 1.e+4) : FirstU; } + else { UmTr = (FirstU < -1.e+4) ? -1.e+4 : FirstU; UMTr = (LastU > 1.e+4) ? 1.e+4 : LastU; } + } + else//Hyperbola + { + if(FirstU >= 0. && LastU >= 0.) + { + if(FirstU > 4.) return; + UmTr = FirstU; UMTr = (LastU > 4.) ? 4. : LastU; + } + else if(FirstU < 0. && LastU < 0.) + { + if(LastU < -4.) return; + UMTr = LastU; UmTr = (FirstU < -4.) ? -4. : FirstU; + } + else { UmTr = (FirstU < -4.) ? -4. : FirstU; UMTr = (LastU > 4.) ? 4. : LastU; } + } + //Make trimmed surface + Handle(Geom_RectangularTrimmedSurface) rts = new Geom_RectangularTrimmedSurface(gos,UmTr,UMTr,Standard_True); + I = rts->VIso(V); + } } } //================================================================================ @@ -553,11 +553,11 @@ static void FUN_PL_Intersection(const Handle(Adaptor3d_HSurface)& S1, if(ICC.NbPoints() > 0 ) { for(Standard_Integer ip = 1; ip <= ICC.NbPoints(); ip++) - { - gp_Pnt2d P = ICC.Point(ip); - gp_Pnt P3d = ElCLib::To3d(gp_Ax2(puvS1,gp_Dir(DV)),P); - SP.Append(P3d); - } + { + gp_Pnt2d P = ICC.Point(ip); + gp_Pnt P3d = ElCLib::To3d(gp_Ax2(puvS1,gp_Dir(DV)),P); + SP.Append(P3d); + } } } //================================================================================ @@ -578,58 +578,58 @@ static void FUN_NewFirstLast(const GeomAbs_CurveType& ga_ct, case GeomAbs_Parabola: { if(Abs(Lst - Fst) > TrVal) - { - if(Fst >= 0. && Lst >= 0.) + { + if(Fst >= 0. && Lst >= 0.) { - NewFst = Fst; - NewLst = ((Fst + TrVal) < Lst) ? (Fst + TrVal) : Lst; - } - if(Fst < 0. && Lst < 0.) - { - NewLst = Lst; - NewFst = ((Lst - TrVal) > Fst) ? (Lst - TrVal) : Fst; - } - else - { - NewFst = (Fst < -TrVal) ? -TrVal : Fst; - NewLst = (Lst > TrVal) ? TrVal : Lst; - } - NeedTr = Standard_True; - } - break; - } - case GeomAbs_Hyperbola: - { - if(Abs(Lst - Fst) > 10.) - { - if(Fst >= 0. && Lst >= 0.) - { - if(Fst > 4.) return; - NewFst = Fst; - NewLst = (Lst > 4.) ? 4. : Lst; - } - if(Fst < 0. && Lst < 0.) - { - if(Lst < -4.) return; - NewLst = Lst; - NewFst = (Fst < -4.) ? -4. : Fst; - } - else - { - NewFst = (Fst < -4.) ? -4. : Fst; - NewLst = (Lst > 4.) ? 4. : Lst; - } - NeedTr = Standard_True; - } + NewFst = Fst; + NewLst = ((Fst + TrVal) < Lst) ? (Fst + TrVal) : Lst; + } + if(Fst < 0. && Lst < 0.) + { + NewLst = Lst; + NewFst = ((Lst - TrVal) > Fst) ? (Lst - TrVal) : Fst; + } + else + { + NewFst = (Fst < -TrVal) ? -TrVal : Fst; + NewLst = (Lst > TrVal) ? TrVal : Lst; + } + NeedTr = Standard_True; + } break; } - default: + case GeomAbs_Hyperbola: + { + if(Abs(Lst - Fst) > 10.) + { + if(Fst >= 0. && Lst >= 0.) + { + if(Fst > 4.) return; + NewFst = Fst; + NewLst = (Lst > 4.) ? 4. : Lst; + } + if(Fst < 0. && Lst < 0.) + { + if(Lst < -4.) return; + NewLst = Lst; + NewFst = (Fst < -4.) ? -4. : Fst; + } + else + { + NewFst = (Fst < -4.) ? -4. : Fst; + NewLst = (Lst > 4.) ? 4. : Lst; + } + NeedTr = Standard_True; + } + break; + } + default: break; } } //================================================================================ //function: FUN_TrimBothSurf -//================================================================================ +//================================================================================ static void FUN_TrimBothSurf(const Handle(Adaptor3d_HSurface)& S1, const GeomAbs_SurfaceType& T1, const Handle(Adaptor3d_HSurface)& S2, @@ -684,19 +684,19 @@ static void FUN_TrimBothSurf(const Handle(Adaptor3d_HSurface)& S1, if(TrmU1) { if(TrmV1) - { - Handle(Adaptor3d_HSurface) TS = NS1; - NS1 = TS->UTrim(U1S1, U2S1, 1.0e-7); - } + { + Handle(Adaptor3d_HSurface) TS = NS1; + NS1 = TS->UTrim(U1S1, U2S1, 1.0e-7); + } else NS1 = S1->UTrim(U1S1, U2S1, 1.0e-7); } if(TrmU2) { if(TrmV2) - { - Handle(Adaptor3d_HSurface) TS = NS2; - NS2 = TS->UTrim(U1S2, U2S2, 1.0e-7); - } + { + Handle(Adaptor3d_HSurface) TS = NS2; + NS2 = TS->UTrim(U1S2, U2S2, 1.0e-7); + } else NS2 = S2->UTrim(U1S2, U2S2, 1.0e-7); } } @@ -732,7 +732,7 @@ void IntPatch_Intersection::Perform(const Handle(Adaptor3d_HSurface)& theS1, //treatment of the cases with cone or torus Standard_Boolean TreatAsBiParametric = Standard_False; - Standard_Integer bImp = 0; + Standard_Integer bGeomGeom = 0; // if (typs1 == GeomAbs_Cone || typs2 == GeomAbs_Cone || typs1 == GeomAbs_Torus || typs2 == GeomAbs_Torus) { @@ -748,36 +748,47 @@ void IntPatch_Intersection::Perform(const Handle(Adaptor3d_HSurface)& theS1, aCTType = aCTSurf->GetType(); bToCheck = Standard_False; // - if (aCTType == GeomAbs_Cone) { - Standard_Real a1 = Abs(aCTSurf->Cone().SemiAngle()); + if (typs1 == GeomAbs_Cone || typs2 == GeomAbs_Cone) { + const gp_Cone aCon1 = (aCTType == GeomAbs_Cone) ? + aCTSurf->Cone() : aGeomSurf->Cone(); + Standard_Real a1 = Abs(aCon1.SemiAngle()); bToCheck = (a1 < 0.02) || (a1 > 1.55); + // if (typs1 == typs2) { - Standard_Real a2 = Abs(aGeomSurf->Cone().SemiAngle()); + const gp_Cone aCon2 = aGeomSurf->Cone(); + Standard_Real a2 = Abs(aCon2.SemiAngle()); bToCheck = bToCheck || (a2 < 0.02) || (a2 > 1.55); // if (a1 > 1.55 && a2 > 1.55) {//quasi-planes: if same domain, treat as canonic - const gp_Cone aCon1 = aCTSurf->Cone(); - const gp_Cone aCon2 = aGeomSurf->Cone(); const gp_Ax1 A1 = aCon1.Axis(), A2 = aCon2.Axis(); if (A1.IsParallel(A2,Precision::Angular())) { const gp_Pnt Apex1 = aCon1.Apex(), Apex2 = aCon2.Apex(); const gp_Pln Plan1( Apex1, A1.Direction() ); if (Plan1.Distance( Apex2 ) <= Precision::Confusion()) { bToCheck = Standard_False; - bImp = 1; } } } } // - aCTAx = aCTSurf->Cone().Axis(); - } - else { - bToCheck = aCTSurf->Torus().MajorRadius() > aCTSurf->Torus().MinorRadius(); - if (bToCheck && (typs1 == typs2)) { - bToCheck = aGeomSurf->Torus().MajorRadius() > aGeomSurf->Torus().MinorRadius(); + TreatAsBiParametric = bToCheck; + if (aCTType == GeomAbs_Cone) { + aCTAx = aCon1.Axis(); + } + } + // + if (typs1 == GeomAbs_Torus || typs2 == GeomAbs_Torus) { + const gp_Torus aTor1 = (aCTType == GeomAbs_Torus) ? + aCTSurf->Torus() : aGeomSurf->Torus(); + bToCheck = aTor1.MajorRadius() > aTor1.MinorRadius(); + if (typs1 == typs2) { + const gp_Torus aTor2 = aGeomSurf->Torus(); + bToCheck = aTor2.MajorRadius() > aTor2.MinorRadius(); + } + // + if (aCTType == GeomAbs_Torus) { + aCTAx = aTor1.Axis(); } - aCTAx = aCTSurf->Torus().Axis(); } // if (bToCheck) { @@ -787,11 +798,11 @@ void IntPatch_Intersection::Perform(const Handle(Adaptor3d_HSurface)& theS1, case GeomAbs_Plane: { aGeomAx = aGeomSurf->Plane().Axis(); if (aCTType == GeomAbs_Cone) { - bImp = 1; + bGeomGeom = 1; if (Abs(aCTSurf->Cone().SemiAngle()) < 0.02) { Standard_Real ps = Abs(aCTAx.Direction().Dot(aGeomAx.Direction())); if(ps < 0.015) { - bImp = 0; + bGeomGeom = 0; } } } @@ -799,7 +810,7 @@ void IntPatch_Intersection::Perform(const Handle(Adaptor3d_HSurface)& theS1, if (aCTAx.IsParallel(aGeomAx, Precision::Angular()) || (aCTAx.IsNormal(aGeomAx, Precision::Angular()) && (aGeomSurf->Plane().Distance(aCTAx.Location()) < Precision::Confusion()))) { - bImp = 1; + bGeomGeom = 1; } } bToCheck = Standard_False; @@ -807,7 +818,7 @@ void IntPatch_Intersection::Perform(const Handle(Adaptor3d_HSurface)& theS1, } case GeomAbs_Sphere: { if (aL1.Distance(aGeomSurf->Sphere().Location()) < Precision::Confusion()) { - bImp = 1; + bGeomGeom = 1; } bToCheck = Standard_False; break; @@ -829,12 +840,12 @@ void IntPatch_Intersection::Perform(const Handle(Adaptor3d_HSurface)& theS1, if (bToCheck) { if (aCTAx.IsParallel(aGeomAx, Precision::Angular()) && (aL1.Distance(aGeomAx.Location()) <= Precision::Confusion())) { - bImp = 1; + bGeomGeom = 1; } } // - if (aCTType == GeomAbs_Cone) { - TreatAsBiParametric = (bImp == 0); + if (bGeomGeom == 1) { + TreatAsBiParametric = Standard_False; } } } @@ -868,7 +879,7 @@ void IntPatch_Intersection::Perform(const Handle(Adaptor3d_HSurface)& theS1, case GeomAbs_Cylinder: case GeomAbs_Sphere: case GeomAbs_Cone: ts1 = 1; break; - case GeomAbs_Torus: ts1 = bImp; break; + case GeomAbs_Torus: ts1 = bGeomGeom; break; default: break; } @@ -879,7 +890,7 @@ void IntPatch_Intersection::Perform(const Handle(Adaptor3d_HSurface)& theS1, case GeomAbs_Cylinder: case GeomAbs_Sphere: case GeomAbs_Cone: ts2 = 1; break; - case GeomAbs_Torus: ts2 = bImp; break; + case GeomAbs_Torus: ts2 = bGeomGeom; break; default: break; } // @@ -955,7 +966,7 @@ void IntPatch_Intersection::Perform(const Handle(Adaptor3d_HSurface)& theS1, // //treatment of the cases with cone or torus Standard_Boolean TreatAsBiParametric = Standard_False; - Standard_Integer bImp = 0; + Standard_Integer bGeomGeom = 0; // if (typs1 == GeomAbs_Cone || typs2 == GeomAbs_Cone || typs1 == GeomAbs_Torus || typs2 == GeomAbs_Torus) { @@ -971,36 +982,47 @@ void IntPatch_Intersection::Perform(const Handle(Adaptor3d_HSurface)& theS1, aCTType = aCTSurf->GetType(); bToCheck = Standard_False; // - if (aCTType == GeomAbs_Cone) { - Standard_Real a1 = Abs(aCTSurf->Cone().SemiAngle()); + if (typs1 == GeomAbs_Cone || typs2 == GeomAbs_Cone) { + const gp_Cone aCon1 = (aCTType == GeomAbs_Cone) ? + aCTSurf->Cone() : aGeomSurf->Cone(); + Standard_Real a1 = Abs(aCon1.SemiAngle()); bToCheck = (a1 < 0.02) || (a1 > 1.55); + // if (typs1 == typs2) { - Standard_Real a2 = Abs(aGeomSurf->Cone().SemiAngle()); + const gp_Cone aCon2 = aGeomSurf->Cone(); + Standard_Real a2 = Abs(aCon2.SemiAngle()); bToCheck = bToCheck || (a2 < 0.02) || (a2 > 1.55); // if (a1 > 1.55 && a2 > 1.55) {//quasi-planes: if same domain, treat as canonic - const gp_Cone aCon1 = aCTSurf->Cone(); - const gp_Cone aCon2 = aGeomSurf->Cone(); const gp_Ax1 A1 = aCon1.Axis(), A2 = aCon2.Axis(); if (A1.IsParallel(A2,Precision::Angular())) { const gp_Pnt Apex1 = aCon1.Apex(), Apex2 = aCon2.Apex(); const gp_Pln Plan1( Apex1, A1.Direction() ); if (Plan1.Distance( Apex2 ) <= Precision::Confusion()) { bToCheck = Standard_False; - bImp = 1; } } } } // - aCTAx = aCTSurf->Cone().Axis(); - } - else { - bToCheck = aCTSurf->Torus().MajorRadius() > aCTSurf->Torus().MinorRadius(); - if (bToCheck && (typs1 == typs2)) { - bToCheck = aGeomSurf->Torus().MajorRadius() > aGeomSurf->Torus().MinorRadius(); + TreatAsBiParametric = bToCheck; + if (aCTType == GeomAbs_Cone) { + aCTAx = aCon1.Axis(); + } + } + // + if (typs1 == GeomAbs_Torus || typs2 == GeomAbs_Torus) { + const gp_Torus aTor1 = (aCTType == GeomAbs_Torus) ? + aCTSurf->Torus() : aGeomSurf->Torus(); + bToCheck = aTor1.MajorRadius() > aTor1.MinorRadius(); + if (typs1 == typs2) { + const gp_Torus aTor2 = aGeomSurf->Torus(); + bToCheck = aTor2.MajorRadius() > aTor2.MinorRadius(); + } + // + if (aCTType == GeomAbs_Torus) { + aCTAx = aTor1.Axis(); } - aCTAx = aCTSurf->Torus().Axis(); } // if (bToCheck) { @@ -1010,11 +1032,11 @@ void IntPatch_Intersection::Perform(const Handle(Adaptor3d_HSurface)& theS1, case GeomAbs_Plane: { aGeomAx = aGeomSurf->Plane().Axis(); if (aCTType == GeomAbs_Cone) { - bImp = 1; + bGeomGeom = 1; if (Abs(aCTSurf->Cone().SemiAngle()) < 0.02) { Standard_Real ps = Abs(aCTAx.Direction().Dot(aGeomAx.Direction())); if(ps < 0.015) { - bImp = 0; + bGeomGeom = 0; } } } @@ -1022,7 +1044,7 @@ void IntPatch_Intersection::Perform(const Handle(Adaptor3d_HSurface)& theS1, if (aCTAx.IsParallel(aGeomAx, Precision::Angular()) || (aCTAx.IsNormal(aGeomAx, Precision::Angular()) && (aGeomSurf->Plane().Distance(aCTAx.Location()) < Precision::Confusion()))) { - bImp = 1; + bGeomGeom = 1; } } bToCheck = Standard_False; @@ -1030,7 +1052,7 @@ void IntPatch_Intersection::Perform(const Handle(Adaptor3d_HSurface)& theS1, } case GeomAbs_Sphere: { if (aL1.Distance(aGeomSurf->Sphere().Location()) < Precision::Confusion()) { - bImp = 1; + bGeomGeom = 1; } bToCheck = Standard_False; break; @@ -1052,12 +1074,12 @@ void IntPatch_Intersection::Perform(const Handle(Adaptor3d_HSurface)& theS1, if (bToCheck) { if (aCTAx.IsParallel(aGeomAx, Precision::Angular()) && (aL1.Distance(aGeomAx.Location()) <= Precision::Confusion())) { - bImp = 1; + bGeomGeom = 1; } } // - if (aCTType == GeomAbs_Cone) { - TreatAsBiParametric = (bImp == 0); + if (bGeomGeom == 1) { + TreatAsBiParametric = Standard_False; } } } @@ -1082,7 +1104,7 @@ void IntPatch_Intersection::Perform(const Handle(Adaptor3d_HSurface)& theS1, case GeomAbs_Cylinder: case GeomAbs_Sphere: case GeomAbs_Cone: ts1 = 1; break; - case GeomAbs_Torus: ts1 = bImp; break; + case GeomAbs_Torus: ts1 = bGeomGeom; break; default: break; } @@ -1093,7 +1115,7 @@ void IntPatch_Intersection::Perform(const Handle(Adaptor3d_HSurface)& theS1, case GeomAbs_Cylinder: case GeomAbs_Sphere: case GeomAbs_Cone: ts2 = 1; break; - case GeomAbs_Torus: ts2 = bImp; break; + case GeomAbs_Torus: ts2 = bGeomGeom; break; default: break; } // @@ -1475,7 +1497,7 @@ void IntPatch_Intersection::Perform(const Handle(Adaptor3d_HSurface)& S1, IntPatch_PrmPrmIntersection interpp; interpp.Perform(S1,D1,S2,D2,U1,V1,U2,V2,TolArc,TolTang,myFleche,myUVMaxStep); if (interpp.IsDone()) - { + { done = Standard_True; tgte = Standard_False; empt = interpp.IsEmpty(); @@ -1493,19 +1515,19 @@ void IntPatch_Intersection::Perform(const Handle(Adaptor3d_HSurface)& S1, //void IntPatch_Intersection__MAJ_R(Handle_Adaptor2d_HCurve2d *R1, -// Handle_Adaptor2d_HCurve2d *R2, -// int *NR1, -// int *NR2, -// Standard_Integer nbR1, -// Standard_Integer nbR2, -// const IntPatch_Point& VTX) +// Handle_Adaptor2d_HCurve2d *R2, +// int *NR1, +// int *NR2, +// Standard_Integer nbR1, +// Standard_Integer nbR2, +// const IntPatch_Point& VTX) void IntPatch_Intersection__MAJ_R(Handle_Adaptor2d_HCurve2d *, - Handle_Adaptor2d_HCurve2d *, - int *, - int *, - Standard_Integer , - Standard_Integer , - const IntPatch_Point& ) + Handle_Adaptor2d_HCurve2d *, + int *, + int *, + Standard_Integer , + Standard_Integer , + const IntPatch_Point& ) { /* if(VTX.IsOnDomS1()) { @@ -1513,9 +1535,9 @@ void IntPatch_Intersection__MAJ_R(Handle_Adaptor2d_HCurve2d *, //-- long unsigned ptr= *((long unsigned *)(((Handle_Standard_Transient *)(&(VTX.ArcOnS1()))))); for(Standard_Integer i=0; iIsArcOnS1()) nbr1++; if(rlin->IsArcOnS2()) nbr2++; } else if(IType == IntPatch_Analytic) nba++; - else { nbg++; - if(IType == IntPatch_Lin) nbgl++; - else if(IType == IntPatch_Circle) nbgc++; - else if(IType == IntPatch_Parabola) nbgp++; - else if(IType == IntPatch_Hyperbola) nbgh++; - else if(IType == IntPatch_Ellipse) nbge++; - } + else { + nbg++; + if(IType == IntPatch_Lin) nbgl++; + else if(IType == IntPatch_Circle) nbgc++; + else if(IType == IntPatch_Parabola) nbgp++; + else if(IType == IntPatch_Hyperbola) nbgh++; + else if(IType == IntPatch_Ellipse) nbge++; + } } printf("\nDUMP_INT:Lines:%2d Wlin:%2d Restr:%2d(On1:%2d On2:%2d) Ana:%2d Geom:%2d(L:%2d C:%2d E:%2d H:%2d P:%2d)", - nbl,nbw,nbr,nbr1,nbr2,nba,nbg,nbgl,nbgc,nbge,nbgh,nbgp); + nbl,nbw,nbr,nbr1,nbr2,nba,nbg,nbgl,nbgc,nbge,nbgh,nbgp); IntPatch_LineConstructor LineConstructor(2); @@ -1596,47 +1619,47 @@ void IntPatch_Intersection::Dump(const Standard_Integer , nbllc++; const Handle(IntPatch_Line)& LineK = LineConstructor.Line(k); if (LineK->ArcType() == IntPatch_Analytic) { - Handle(IntPatch_ALine)& alin = - *((Handle(IntPatch_ALine) *)&LineK); - nbvtx=alin->NbVertex(); - nbva+=nbvtx; nba++; - for(v=1;v<=nbvtx;v++) { - IntPatch_Intersection__MAJ_R(R1,R2,NR1,NR2,nbR1,nbR2,alin->Vertex(v)); - } + Handle(IntPatch_ALine)& alin = + *((Handle(IntPatch_ALine) *)&LineK); + nbvtx=alin->NbVertex(); + nbva+=nbvtx; nba++; + for(v=1;v<=nbvtx;v++) { + IntPatch_Intersection__MAJ_R(R1,R2,NR1,NR2,nbR1,nbR2,alin->Vertex(v)); + } } else if (LineK->ArcType() == IntPatch_Restriction) { - Handle(IntPatch_RLine)& rlin = - *((Handle(IntPatch_RLine) *)&LineK); - nbvtx=rlin->NbVertex(); - nbvr+=nbvtx; nbr++; - for(v=1;v<=nbvtx;v++) { - IntPatch_Intersection__MAJ_R(R1,R2,NR1,NR2,nbR1,nbR2,rlin->Vertex(v)); - } + Handle(IntPatch_RLine)& rlin = + *((Handle(IntPatch_RLine) *)&LineK); + nbvtx=rlin->NbVertex(); + nbvr+=nbvtx; nbr++; + for(v=1;v<=nbvtx;v++) { + IntPatch_Intersection__MAJ_R(R1,R2,NR1,NR2,nbR1,nbR2,rlin->Vertex(v)); + } } else if (LineK->ArcType() == IntPatch_Walking) { - Handle(IntPatch_WLine)& wlin = - *((Handle(IntPatch_WLine) *)&LineK); - nbvtx=wlin->NbVertex(); - nbvw+=nbvtx; nbw++; - for(v=1;v<=nbvtx;v++) { - IntPatch_Intersection__MAJ_R(R1,R2,NR1,NR2,nbR1,nbR2,wlin->Vertex(v)); - } + Handle(IntPatch_WLine)& wlin = + *((Handle(IntPatch_WLine) *)&LineK); + nbvtx=wlin->NbVertex(); + nbvw+=nbvtx; nbw++; + for(v=1;v<=nbvtx;v++) { + IntPatch_Intersection__MAJ_R(R1,R2,NR1,NR2,nbR1,nbR2,wlin->Vertex(v)); + } } else { - Handle(IntPatch_GLine)& glin = - *((Handle(IntPatch_GLine) *)&LineK); - nbvtx=glin->NbVertex(); - nbvg+=nbvtx; nbg++; - for(v=1;v<=nbvtx;v++) { - IntPatch_Intersection__MAJ_R(R1,R2,NR1,NR2,nbR1,nbR2,glin->Vertex(v)); - } + Handle(IntPatch_GLine)& glin = + *((Handle(IntPatch_GLine) *)&LineK); + nbvtx=glin->NbVertex(); + nbvg+=nbvtx; nbg++; + for(v=1;v<=nbvtx;v++) { + IntPatch_Intersection__MAJ_R(R1,R2,NR1,NR2,nbR1,nbR2,glin->Vertex(v)); + } } } } printf("\nDUMP_LC :Lines:%2d WLin:%2d Restr:%2d Ana:%2d Geom:%2d", - nbllc,nbw,nbr,nba,nbg); + nbllc,nbw,nbr,nba,nbg); printf("\nDUMP_LC :vtx :%2d r:%2d :%2d :%2d", - nbvw,nbvr,nbva,nbvg); + nbvw,nbvr,nbva,nbvg); diff --git a/tests/bugs/modalg_5/bug24648 b/tests/bugs/modalg_5/bug24648 new file mode 100644 index 0000000000..1bf040724b --- /dev/null +++ b/tests/bugs/modalg_5/bug24648 @@ -0,0 +1,36 @@ +puts "===========" +puts "OCC24648" +puts "===========" +puts "" +############################################################## +# Different types of intersection curves between Cone and Torus with a different order of arguments +############################################################## + +cone s1 60 0 +torus s2 30 20 + +intersect i1 s1 s2 +set info1 [dump i1_1] + +intersect i2 s2 s1 +set info2 [dump i2_1] + +set type_of_curve "Circle" + +if { [regexp ${type_of_curve} ${info1}] != 1 } { + puts "Error : Wrong type of intersection curve #1" +} else { + puts "OK : Good type of intersection curve #1" +} + +if { [regexp ${type_of_curve} ${info2}] != 1 } { + puts "Error : Wrong type of intersection curve #2" +} else { + puts "OK : Good type of intersection curve #2" +} + +smallview +donly i1_1 i2_1 +fit +set only_screen_axo 1 +