]> OCCT Git - occt-copy.git/commitdiff
Next version (26 cases) CR26907_5
authorjgv <jgv@opencascade.com>
Tue, 19 Feb 2019 13:08:24 +0000 (16:08 +0300)
committerjgv <jgv@opencascade.com>
Tue, 19 Feb 2019 13:08:24 +0000 (16:08 +0300)
src/ChFi3d/ChFi3d_Builder_0.cxx
src/ChFi3d/ChFi3d_Builder_0.hxx
src/ChFi3d/ChFi3d_Builder_2.cxx
tests/blend/seam_and_degenerated/A10
tests/blend/seam_and_degenerated/A12_3 [new file with mode: 0644]
tests/blend/seam_and_degenerated/A16
tests/blend/seam_and_degenerated/A16_1

index f0a8616fa97cc4137a6441e56fd64370572500ea..741a710dd440746ca066181d384b86418e38e558 100644 (file)
@@ -177,6 +177,64 @@ extern void ChFi3d_SettraceDRAWSPINE(const Standard_Boolean b);
 #include <BRepAdaptor_HSurface.hxx>
 #include <TopOpeBRepDS_SurfaceCurveInterference.hxx>
 
+
+//=======================================================================
+//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<<endl<<"Both points outside!"<<endl;
+    return Standard_True;
+  }
+}
+
+//=======================================================================
+//function : ChFi3d_AdjustPCurve
+//purpose  : 
+//=======================================================================
+void ChFi3d_AdjustPCurve(Geom2dAdaptor_Curve&   thePCurve,
+                         const Standard_Real    theCoordOnPCurve,
+                         const Standard_Real    theRefCoord,
+                         const Standard_Real    thePeriod,
+                         const Standard_Boolean theInUdirection)
+{
+  Standard_Real aCoord = theCoordOnPCurve;
+  Standard_Real Sign = (aCoord < theRefCoord)? 1 : -1;
+  
+  while (Abs(aCoord - theRefCoord) > 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()) {
index 7261eba498f4f1f0ed08df2774e2a3ae583743d9..d2c341cf7380c7f98ddf37e6a5027560bc74eb3d 100644 (file)
@@ -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);
index bf4773ae655089ff0f9c0c6bd3816528e4544cf8..bfa5e51b5ca83b1398f1465574dda1bf707994f9 100644 (file)
@@ -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);
index 6b238a375d01ffdbd6bd025445be6b4f2e0369aa..cc55e867da888ad40f0ac53cc236fb342918e824 100644 (file)
@@ -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 (file)
index 0000000..2ae7bf3
--- /dev/null
@@ -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
index 77208f3934a68c14a366a69ee84e020ef914734c..7a02d79f5bc5ba41dbfe329336f2efbdfe6b5e17 100644 (file)
@@ -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
index fdd817431460f5188008acc151ddfef5b9900bf0..521ffdce754a64b75fcd3c6b09d645f8d6f3af51 100644 (file)
@@ -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