From 635a14248628c6baa02a19857551ebd03fe4dfc9 Mon Sep 17 00:00:00 2001 From: jgv Date: Tue, 19 Feb 2019 16:08:24 +0300 Subject: [PATCH] Next version (26 cases) --- src/ChFi3d/ChFi3d_Builder_0.cxx | 119 +++++++++++++++++++++---- src/ChFi3d/ChFi3d_Builder_0.hxx | 1 + src/ChFi3d/ChFi3d_Builder_2.cxx | 10 ++- tests/blend/seam_and_degenerated/A10 | 2 +- tests/blend/seam_and_degenerated/A12_3 | 14 +++ tests/blend/seam_and_degenerated/A16 | 4 +- tests/blend/seam_and_degenerated/A16_1 | 4 +- 7 files changed, 129 insertions(+), 25 deletions(-) create mode 100644 tests/blend/seam_and_degenerated/A12_3 diff --git a/src/ChFi3d/ChFi3d_Builder_0.cxx b/src/ChFi3d/ChFi3d_Builder_0.cxx index f0a8616fa9..741a710dd4 100644 --- a/src/ChFi3d/ChFi3d_Builder_0.cxx +++ b/src/ChFi3d/ChFi3d_Builder_0.cxx @@ -177,6 +177,64 @@ extern void ChFi3d_SettraceDRAWSPINE(const Standard_Boolean b); #include #include + +//======================================================================= +//function : ChFi3d_IsFirstInside +//purpose : +//======================================================================= +Standard_Boolean ChFi3d_IsFirstInside(const Standard_Real theVal1, + const Standard_Real theVal2, + const Standard_Real theMin, + const Standard_Real theMax) +{ + Standard_Real IsFirstInside = (theMin < theVal1 && theVal1 < theMax); + Standard_Real IsSecondInside = (theMin < theVal2 && theVal2 < theMax); + if (IsFirstInside && !IsSecondInside) + return Standard_True; + if (!IsFirstInside && IsSecondInside) + return Standard_False; + + if (IsFirstInside && IsSecondInside) + { + Standard_Real MinDistForFirst = Min(theVal1 - theMin, theMax - theVal1); + Standard_Real MinDistForSecond = Min(theVal2 - theMin, theMax - theVal2); + return (MinDistForFirst > MinDistForSecond); + } + else + { + cout< thePeriod/2) + aCoord += Sign * thePeriod; + + Standard_Real Offset = aCoord - theCoordOnPCurve; + gp_Vec2d OffsetVector; + if (theInUdirection) + OffsetVector.SetCoord(Offset, 0.); + else + OffsetVector.SetCoord(0., Offset); + + Handle(Geom2d_Curve) aPCurve = thePCurve.Curve(); + aPCurve->Translate(OffsetVector); + thePCurve.Load(aPCurve); +} + //======================================================================= //function : ChFi3d_InPeriod //purpose : @@ -1038,7 +1096,9 @@ Standard_Boolean ChFi3d_IsInFront(TopOpeBRepDS_DataStructure& DStr, gp_Pnt2d P2d; if (Check2dDistance) P2d = BRep_Tool::Parameters( Vtx, face ); - if(ChFi3d_IntTraces(fd1,pref1,p1,jf1,sens1,fd2,pref2,p2,jf2,sens2,P2d,Check2dDistance,enlarge)) { + if(ChFi3d_IntTraces(fd1,pref1,p1,jf1,sens1, + fd2,pref2,p2,jf2,sens2, + face,P2d,Check2dDistance,enlarge)) { u1 = p1; u2 = p2; ss = sameside; j1 = jf1; j2 = jf2; ff = face; ok = 1; } @@ -1059,7 +1119,9 @@ Standard_Boolean ChFi3d_IsInFront(TopOpeBRepDS_DataStructure& DStr, gp_Pnt2d P2d; if (Check2dDistance) P2d = BRep_Tool::Parameters( Vtx, face ); - if(ChFi3d_IntTraces(fd1,pref1,p1,jf1,sens1,fd2,pref2,p2,jf2,sens2,P2d,Check2dDistance,enlarge)) { + if(ChFi3d_IntTraces(fd1,pref1,p1,jf1,sens1, + fd2,pref2,p2,jf2,sens2, + face,P2d,Check2dDistance,enlarge)) { Standard_Boolean restore = ok && ((j1 == jf1 && sens1*(p1 - u1) > 0.) || (j2 == jf2 && sens2*(p2 - u2) > 0.)); @@ -1092,7 +1154,9 @@ Standard_Boolean ChFi3d_IsInFront(TopOpeBRepDS_DataStructure& DStr, gp_Pnt2d P2d; if (Check2dDistance) P2d = BRep_Tool::Parameters( Vtx, face ); - if(ChFi3d_IntTraces(fd1,pref1,p1,jf1,sens1,fd2,pref2,p2,jf2,sens2,P2d,Check2dDistance,enlarge)) { + if(ChFi3d_IntTraces(fd1,pref1,p1,jf1,sens1, + fd2,pref2,p2,jf2,sens2, + face,P2d,Check2dDistance,enlarge)) { Standard_Boolean restore = ok && ((j1 == jf1 && sens1*(p1 - u1) > 0.) || (j2 == jf2 && sens2*(p2 - u2) > 0.)); @@ -1125,7 +1189,9 @@ Standard_Boolean ChFi3d_IsInFront(TopOpeBRepDS_DataStructure& DStr, gp_Pnt2d P2d; if (Check2dDistance) P2d = BRep_Tool::Parameters( Vtx, face ); - if(ChFi3d_IntTraces(fd1,pref1,p1,jf1,sens1,fd2,pref2,p2,jf2,sens2,P2d,Check2dDistance,enlarge)) { + if(ChFi3d_IntTraces(fd1,pref1,p1,jf1,sens1, + fd2,pref2,p2,jf2,sens2, + face,P2d,Check2dDistance,enlarge)) { Standard_Boolean restore = ok && ((j1 == jf1 && sens1*(p1 - u1) > 0.) || (j2 == jf2 && sens2*(p2 - u2) > 0.)); @@ -1162,18 +1228,19 @@ static Standard_Real recadre(const Standard_Real p, //purpose : //======================================================================= Standard_Boolean ChFi3d_IntTraces(const Handle(ChFiDS_SurfData)& fd1, - const Standard_Real pref1, - Standard_Real& p1, - const Standard_Integer jf1, - const Standard_Integer sens1, - const Handle(ChFiDS_SurfData)& fd2, - const Standard_Real pref2, - Standard_Real& p2, - const Standard_Integer jf2, - const Standard_Integer sens2, - const gp_Pnt2d& RefP2d, - const Standard_Boolean Check2dDistance, - const Standard_Boolean enlarge) + const Standard_Real pref1, + Standard_Real& p1, + const Standard_Integer jf1, + const Standard_Integer sens1, + const Handle(ChFiDS_SurfData)& fd2, + const Standard_Real pref2, + Standard_Real& p2, + const Standard_Integer jf2, + const Standard_Integer sens2, + const TopoDS_Face& theFace, + const gp_Pnt2d& RefP2d, + const Standard_Boolean Check2dDistance, + const Standard_Boolean enlarge) { Geom2dAdaptor_Curve C1; Geom2dAdaptor_Curve C2; @@ -1227,6 +1294,26 @@ Standard_Boolean ChFi3d_IntTraces(const Handle(ChFiDS_SurfData)& fd1, Intersection.Perform(C1,C2, Precision::PIntersection(), Precision::PIntersection()); + + if (!Intersection.IsDone() || Intersection.IsEmpty()) + { + BRepAdaptor_Surface BAsurf(theFace, Standard_False); + if (BAsurf.IsUPeriodic()) + { + //put the pcurves in the same parametric context + Standard_Real Uperiod = BAsurf.UPeriod(); + Standard_Real Umin = BAsurf.FirstUParameter(); + Standard_Real Umax = BAsurf.LastUParameter(); + gp_Pnt2d Origin1 = C1.Value(0.); + gp_Pnt2d Origin2 = C2.Value(0.); + Standard_Boolean IsFirstPointInside = + ChFi3d_IsFirstInside(Origin1.X(), Origin2.X(), Umin, Umax); + if (IsFirstPointInside) + ChFi3d_AdjustPCurve(C2, Origin2.X(), Origin1.X(), Uperiod, Standard_True); + else + ChFi3d_AdjustPCurve(C1, Origin1.X(), Origin2.X(), Uperiod, Standard_True); + } + } } if (Intersection.IsDone()) { if (!Intersection.IsEmpty()) { diff --git a/src/ChFi3d/ChFi3d_Builder_0.hxx b/src/ChFi3d/ChFi3d_Builder_0.hxx index 7261eba498..d2c341cf73 100644 --- a/src/ChFi3d/ChFi3d_Builder_0.hxx +++ b/src/ChFi3d/ChFi3d_Builder_0.hxx @@ -335,6 +335,7 @@ Standard_Boolean ChFi3d_IntTraces(const Handle(ChFiDS_SurfData)& fd1, Standard_Real& p2, const Standard_Integer jf2, const Standard_Integer sens2, + const TopoDS_Face& theFace, const gp_Pnt2d& RefP2d, const Standard_Boolean Check2dDistance = Standard_False, const Standard_Boolean enlarge = Standard_False); diff --git a/src/ChFi3d/ChFi3d_Builder_2.cxx b/src/ChFi3d/ChFi3d_Builder_2.cxx index bf4773ae65..bfa5e51b5c 100644 --- a/src/ChFi3d/ChFi3d_Builder_2.cxx +++ b/src/ChFi3d/ChFi3d_Builder_2.cxx @@ -2729,9 +2729,10 @@ void ChFi3d_Builder::PerformSetOfKGen(Handle(ChFiDS_Stripe)& Stripe, // Modified by Sergey KHROMOV - Wed Feb 5 12:03:17 2003 Begin // if(ChFi3d_IntTraces(prevsd,prevpar1,nprevpar1,1,1, // nextsd,nextpar1,nnextpar1,1,-1,p2d)){ + TopoDS_Face FaceOfPCurves = TopoDS::Face(DStr.Shape(prevsd->Index(1))); if(ChFi3d_IntTraces(prevsd,prevpar1,nprevpar1,1,1, - nextsd,nextpar1,nnextpar1,1,-1,p2d, - Standard_False, Standard_True)){ + nextsd,nextpar1,nnextpar1,1,-1, + FaceOfPCurves,p2d,Standard_False, Standard_True)){ // Modified by Sergey KHROMOV - Wed Feb 5 12:03:17 2003 End previntf1.SetLastParameter(nprevpar1); nextintf1.SetFirstParameter(nnextpar1); @@ -2787,9 +2788,10 @@ void ChFi3d_Builder::PerformSetOfKGen(Handle(ChFiDS_Stripe)& Stripe, // Modified by Sergey KHROMOV - Wed Feb 5 12:03:17 2003 Begin // if(ChFi3d_IntTraces(prevsd,prevpar2,nprevpar2,2,1, // nextsd,nextpar2,nnextpar2,2,-1,p2d)){ + TopoDS_Face FaceOfPCurves = TopoDS::Face(DStr.Shape(prevsd->Index(2))); if(ChFi3d_IntTraces(prevsd,prevpar2,nprevpar2,2,1, - nextsd,nextpar2,nnextpar2,2,-1,p2d, - Standard_False, Standard_True)){ + nextsd,nextpar2,nnextpar2,2,-1, + FaceOfPCurves,p2d,Standard_False, Standard_True)){ // Modified by Sergey KHROMOV - Wed Feb 5 12:03:17 2003 End previntf2.SetLastParameter(nprevpar2); nextintf2.SetFirstParameter(nnextpar2); diff --git a/tests/blend/seam_and_degenerated/A10 b/tests/blend/seam_and_degenerated/A10 index 6b238a375d..cc55e867da 100644 --- a/tests/blend/seam_and_degenerated/A10 +++ b/tests/blend/seam_and_degenerated/A10 @@ -11,4 +11,4 @@ explode a e blend result a 5 a_1 5 a_3 -checknbshapes result -solid 1 -shell 1 -face 6 -wire 6 -edge 15 -vertex 10 +checknbshapes result -solid 1 -shell 1 -face 6 -wire 6 -edge 17 -vertex 11 diff --git a/tests/blend/seam_and_degenerated/A12_3 b/tests/blend/seam_and_degenerated/A12_3 new file mode 100644 index 0000000000..2ae7bf30aa --- /dev/null +++ b/tests/blend/seam_and_degenerated/A12_3 @@ -0,0 +1,14 @@ +puts "==========================================================================================================================" +puts "OCC26907: ChFi3d_Builder algorithm uses old Boolean operations: wrong processing of shapes with seam and degenerated edges" +puts "==========================================================================================================================" +puts "" + +set maxtol 5.e-5 +set volume 3.66244e+006 + +restore [locate_data_file HollowedBall.brep] a +explode a e + +blend result a 5 a_1 5 a_3 5 a_6 + +checknbshapes result -solid 1 -shell 1 -face 7 -wire 7 -edge 15 -vertex 9 diff --git a/tests/blend/seam_and_degenerated/A16 b/tests/blend/seam_and_degenerated/A16 index 77208f3934..7a02d79f5b 100644 --- a/tests/blend/seam_and_degenerated/A16 +++ b/tests/blend/seam_and_degenerated/A16 @@ -3,7 +3,7 @@ puts "OCC26907: ChFi3d_Builder algorithm uses old Boolean operations: wrong proc puts "==========================================================================================================================" puts "" -set maxtol 5.e-5 +set maxtol 5.e-4 set volume 3.66397e+006 restore [locate_data_file HollowedBall.brep] a @@ -11,4 +11,4 @@ explode a e blend result a 3 a_1 5 a_3 -checknbshapes result -solid 1 -shell 1 -face 6 -wire 6 -edge 17 -vertex 12 +checknbshapes result -solid 1 -shell 1 -face 6 -wire 6 -edge 19 -vertex 13 diff --git a/tests/blend/seam_and_degenerated/A16_1 b/tests/blend/seam_and_degenerated/A16_1 index fdd8174314..521ffdce75 100644 --- a/tests/blend/seam_and_degenerated/A16_1 +++ b/tests/blend/seam_and_degenerated/A16_1 @@ -3,7 +3,7 @@ puts "OCC26907: ChFi3d_Builder algorithm uses old Boolean operations: wrong proc puts "==========================================================================================================================" puts "" -set maxtol 5.e-5 +set maxtol 5.e-4 set volume 3.66397e+006 restore [locate_data_file HollowedBall.brep] a @@ -11,4 +11,4 @@ explode a e blend result a 5 a_1 3 a_3 -checknbshapes result -solid 1 -shell 1 -face 6 -wire 6 -edge 17 -vertex 12 +checknbshapes result -solid 1 -shell 1 -face 6 -wire 6 -edge 19 -vertex 13 -- 2.39.5