0023903: Invalid result of pipe operation on closed path
authorskv <skv@opencascade.com>
Thu, 16 May 2013 07:35:11 +0000 (11:35 +0400)
committerskv <skv@opencascade.com>
Thu, 16 May 2013 07:35:11 +0000 (11:35 +0400)
Add test case for this fix

src/BRepFill/BRepFill_Pipe.cxx
src/BRepFill/BRepFill_Sweep.cxx
tests/bugs/modalg_5/bug23903 [new file with mode: 0755]

index 74a9336..3184071 100755 (executable)
@@ -849,13 +849,7 @@ TopoDS_Shape BRepFill_Pipe::ShareFaces
       anExp.Init(myFaces->Value(ii, jj), TopAbs_EDGE);
   
       for (; anExp.More(); anExp.Next()) {
-        if (aMapBndEdgeIndex.IsBound(anExp.Current())) {
-          // This is not boundary edge. Remove it.
-          aMapBndEdgeIndex.UnBind(anExp.Current());
-        } else {
-          // Add boundary edge.
-          aMapBndEdgeIndex.Bind(anExp.Current(), ii);
-        }
+        aMapBndEdgeIndex.Bind(anExp.Current(), ii);
       }
     }
 
index 74e5208..dc8791b 100755 (executable)
@@ -2065,143 +2065,141 @@ BRepFill_Sweep::BRepFill_Sweep(const Handle(BRepFill_SectionLaw)& Section,
   Standard_Boolean exuv, singu, singv;
   Handle(Geom_Surface) S;
 
-  if (! vclose) {
-    // (2.0) return preexisting Edges and vertices
-    TopoDS_Edge E;
-    if (! FirstShape.IsNull() && (IFirst==1)) {
-      mySec->Init(FirstShape);
-      for (isec=1; isec<=NbLaw; isec++) {
-       E = mySec->CurrentEdge();
-       VEdge(isec, 1) = E;
-        if (E.Orientation() == TopAbs_REVERSED)
-          Vertex(isec+1, 1) = TopExp::FirstVertex(E);
-        else 
-          Vertex(isec+1, 1) =  TopExp::LastVertex(E);
-       UpdateVertex(IFirst-1, isec+1, 
-                    TabErr(isec, 1), Vi(1),  Vertex(isec+1, 1));
-       }
-      if (VEdge(1, 1).Orientation() == TopAbs_REVERSED)
-       Vertex(1, 1) =  TopExp::LastVertex(TopoDS::Edge(VEdge(1, 1)));
-      else
-       Vertex(1, 1) = TopExp::FirstVertex(TopoDS::Edge(VEdge(1, 1)));
-      UpdateVertex(IFirst-1, 1, 
-                  TabErr(1, 1), Vi(1),  Vertex(1, 1));
-    }
-    else { // Otherwise construct vertices
-      Standard_Real u, v, aux;
-      Standard_Boolean ureverse;
-      for (isec=1; isec<=NbLaw+1; isec++) {
-       // Return data
-       if (isec >NbLaw) {
-         S = TabS(NbLaw, 1);
-         ureverse = UReverse(NbLaw, 1);
-         exuv = ExchUV(NbLaw, 1);
-       }
-       else  {
-         S = TabS(isec, 1);
-         ureverse = UReverse(isec, 1);
-         exuv = ExchUV(isec, 1);
-       }
-       S->Bounds(UFirst, ULast, VFirst, VLast);
-
-       // Choice of parameters
-       if (ureverse) {
-         if (exuv) {
-           aux = VFirst; VFirst = VLast; VLast = aux;    
-         }
-         else {
-           aux = UFirst; UFirst = ULast; ULast = aux;
-         }
-       }
-       if (isec!= NbLaw+1) {
-         u = UFirst;
-         v = VFirst;
-       }
-       else {
-         if (exuv) {
-           u = UFirst;
-           v = VLast;
-         }
-         else {
-           u = ULast;
-           v = VFirst;
-         }
-       }
-
-       // construction of vertices
-       B.MakeVertex(TopoDS::Vertex(Vertex(isec, 1)), 
-                    S->Value(u,v), 
-                    mySec->VertexTol(isec-1,Vi(1)));
+  // (2.0) return preexisting Edges and vertices
+  TopoDS_Edge E;
+  if (! FirstShape.IsNull() && (IFirst==1)) {
+    mySec->Init(FirstShape);
+    for (isec=1; isec<=NbLaw; isec++) {
+      E = mySec->CurrentEdge();
+      VEdge(isec, 1) = E;
+      if (E.Orientation() == TopAbs_REVERSED)
+        Vertex(isec+1, 1) = TopExp::FirstVertex(E);
+      else 
+        Vertex(isec+1, 1) =  TopExp::LastVertex(E);
+      UpdateVertex(IFirst-1, isec+1, 
+                   TabErr(isec, 1), Vi(1),  Vertex(isec+1, 1));
+    }
+    if (VEdge(1, 1).Orientation() == TopAbs_REVERSED)
+      Vertex(1, 1) =  TopExp::LastVertex(TopoDS::Edge(VEdge(1, 1)));
+    else
+      Vertex(1, 1) = TopExp::FirstVertex(TopoDS::Edge(VEdge(1, 1)));
+    UpdateVertex(IFirst-1, 1, 
+                 TabErr(1, 1), Vi(1),  Vertex(1, 1));
+  }
+  else { // Otherwise construct vertices
+    Standard_Real u, v, aux;
+    Standard_Boolean ureverse;
+    for (isec=1; isec<=NbLaw+1; isec++) {
+      // Return data
+      if (isec >NbLaw) {
+        S = TabS(NbLaw, 1);
+        ureverse = UReverse(NbLaw, 1);
+        exuv = ExchUV(NbLaw, 1);
       }
-   }
+      else {
+        S = TabS(isec, 1);
+        ureverse = UReverse(isec, 1);
+        exuv = ExchUV(isec, 1);
+      }
+      S->Bounds(UFirst, ULast, VFirst, VLast);
 
-    if (! LastShape.IsNull() && (ILast==myLoc->NbLaw()+1) ) {
-      mySec->Init(LastShape);
-      for (isec=1; isec<=NbLaw; isec++) {
-       E = mySec->CurrentEdge();
-       VEdge(isec, NbPath+1) = E;
-       if (E.Orientation() == TopAbs_REVERSED)
-          Vertex(isec+1, NbPath+1) = TopExp::FirstVertex(E);
-       else 
-         Vertex(isec+1, NbPath+1) = TopExp::LastVertex(E);
-       UpdateVertex(ILast-1, isec+1, TabErr(isec, NbPath), 
-                    Vi(NbPath+1),  Vertex(isec+1, NbPath+1));
+      // Choice of parameters
+      if (ureverse) {
+        if (exuv) {
+          aux = VFirst; VFirst = VLast; VLast = aux;     
+        }
+        else {
+          aux = UFirst; UFirst = ULast; ULast = aux;
+        }
+      }
+      if (isec!= NbLaw+1) {
+        u = UFirst;
+        v = VFirst;
+      }
+      else {
+        if (exuv) {
+          u = UFirst;
+          v = VLast;
+        }
+        else {
+          u = ULast;
+          v = VFirst;
+        }
       }
-      if (VEdge(1,  NbPath+1).Orientation() == TopAbs_REVERSED)
-       Vertex(1,  NbPath+1) =  
-         TopExp::LastVertex(TopoDS::Edge(VEdge(1,  NbPath+1)));
-      else
-       Vertex(1,  NbPath+1) = 
-         TopExp::FirstVertex(TopoDS::Edge(VEdge(1, NbPath+1)));
-      UpdateVertex(ILast-1, 1, 
-                  TabErr(1, NbPath), Vi(NbPath+1),  Vertex(1, NbPath+1 ));
-    }    
-    else {
-      Standard_Real u, v, aux;
-      Standard_Boolean ureverse;
-      for (isec=1; isec<=NbLaw+1; isec++) {
-       // Return data
-       if (isec >NbLaw) {
-         S = TabS(NbLaw, NbPath);
-         ureverse = UReverse(NbLaw, NbPath);
-         exuv = ExchUV(NbLaw, NbPath);
-       }
-       else  {
-         S = TabS(isec, NbPath);
-         ureverse = UReverse(isec, NbPath);
-         exuv = ExchUV(isec, NbPath);
-       }
-       S->Bounds(UFirst, ULast, VFirst, VLast);
 
-       // Choice of parametres
-       if (ureverse) {
-         if (exuv) {
-           aux = VFirst; VFirst = VLast; VLast = aux;    
-         }
-         else {
-           aux = UFirst; UFirst = ULast; ULast = aux;
-         }
-       }
-       if (isec == NbLaw+1) {
-         u = ULast;
-         v = VLast;
-       }
-       else {
-         if (exuv) {
-           u = ULast;
-           v = VFirst;
-         }
-         else {
-           u = UFirst;
-           v = VLast;
-         }
-       }
+      // construction of vertices
+      B.MakeVertex(TopoDS::Vertex(Vertex(isec, 1)), 
+                   S->Value(u,v), 
+                   mySec->VertexTol(isec-1,Vi(1)));
+    }
+  }
 
-       // construction of vertex
-       B.MakeVertex(TopoDS::Vertex(Vertex(isec, NbPath+1)), 
-                    S->Value(u,v), 
-                    mySec->VertexTol(isec-1, Vi(NbPath+1)));
+  if (! LastShape.IsNull() && (ILast==myLoc->NbLaw()+1) ) {
+    mySec->Init(LastShape);
+    for (isec=1; isec<=NbLaw; isec++) {
+      E = mySec->CurrentEdge();
+      VEdge(isec, NbPath+1) = E;
+      if (E.Orientation() == TopAbs_REVERSED)
+        Vertex(isec+1, NbPath+1) = TopExp::FirstVertex(E);
+      else 
+        Vertex(isec+1, NbPath+1) = TopExp::LastVertex(E);
+      UpdateVertex(ILast-1, isec+1, TabErr(isec, NbPath), 
+                   Vi(NbPath+1),  Vertex(isec+1, NbPath+1));
+    }
+    if (VEdge(1,  NbPath+1).Orientation() == TopAbs_REVERSED)
+      Vertex(1,  NbPath+1) =  
+        TopExp::LastVertex(TopoDS::Edge(VEdge(1,  NbPath+1)));
+    else
+      Vertex(1,  NbPath+1) = 
+        TopExp::FirstVertex(TopoDS::Edge(VEdge(1, NbPath+1)));
+    UpdateVertex(ILast-1, 1, 
+                 TabErr(1, NbPath), Vi(NbPath+1),  Vertex(1, NbPath+1 ));
+  }    
+  else {
+    Standard_Real u, v, aux;
+    Standard_Boolean ureverse;
+    for (isec=1; isec<=NbLaw+1; isec++) {
+      // Return data
+      if (isec >NbLaw) {
+        S = TabS(NbLaw, NbPath);
+        ureverse = UReverse(NbLaw, NbPath);
+        exuv = ExchUV(NbLaw, NbPath);
       }
+      else {
+        S = TabS(isec, NbPath);
+        ureverse = UReverse(isec, NbPath);
+        exuv = ExchUV(isec, NbPath);
+      }
+      S->Bounds(UFirst, ULast, VFirst, VLast);
+
+      // Choice of parametres
+      if (ureverse) {
+        if (exuv) {
+          aux = VFirst; VFirst = VLast; VLast = aux;     
+        }
+        else {
+          aux = UFirst; UFirst = ULast; ULast = aux;
+        }
+      }
+      if (isec == NbLaw+1) {
+        u = ULast;
+        v = VLast;
+      }
+      else {
+        if (exuv) {
+          u = ULast;
+          v = VFirst;
+        }
+        else {
+          u = UFirst;
+          v = VLast;
+        }
+      }
+
+      // construction of vertex
+      B.MakeVertex(TopoDS::Vertex(Vertex(isec, NbPath+1)), 
+                   S->Value(u,v), 
+                   mySec->VertexTol(isec-1, Vi(NbPath+1)));
     }
   }
 
diff --git a/tests/bugs/modalg_5/bug23903 b/tests/bugs/modalg_5/bug23903
new file mode 100755 (executable)
index 0000000..8928279
--- /dev/null
@@ -0,0 +1,24 @@
+puts "============"
+puts "OCC23903"
+puts "============"
+puts ""
+#######################################################################
+# Invalid result of pipe operation on closed path
+#######################################################################
+
+restore [locate_data_file bug23903_base.brep] sh 
+restore [locate_data_file bug23903_path.brep] w 
+
+pipe result w sh
+
+set nb_v_good 2
+set nb_e_good 5
+set nb_w_good 3
+set nb_f_good 3
+set nb_sh_good 2
+set nb_sol_good 2
+set nb_compsol_good 0
+set nb_compound_good 1
+set nb_shape_good 18
+
+set 2dviewer 1