0025014: ShapeAnalysis_WireOrder produces Standard_RangeError on empty wire (debug...
authornbv <nbv@opencascade.com>
Thu, 11 Sep 2014 12:37:22 +0000 (16:37 +0400)
committerbugmaster <bugmaster@opencascade.com>
Thu, 11 Sep 2014 12:39:56 +0000 (16:39 +0400)
The reason of exception is liquidated.

Test case for issue CR25014

Clean obsolete commented out code

src/SWDRAW/SWDRAW_ShapeUpgrade.cxx
src/ShapeAnalysis/ShapeAnalysis_WireOrder.cxx
tests/bugs/heal/bug25014 [new file with mode: 0755]

index 310837ff5aeaeb58e7eacdeb998cdfebfc6b410f..fc9074212b4bedca7f2a914513651d47f19fa53e 100644 (file)
@@ -908,169 +908,6 @@ di << "transfert resultat" << "\n";
   return 0;
 }
 
-
-
-//=======================================================================
-//function : DT_SupportModification 
-//purpose  : Changes the supports of a Shell
-//           The given surface wil support all the faces of the new shell.
-//           with the PCurves of the old ones.
-//
-//=======================================================================
-/*static Standard_Integer DT_SupportModification (Draw_Interpretor& di,
-                                  Standard_Integer n, const char** a)
-
-{
-  // a[1]= result
-  // a[2]= input Shell
-  // a[3]= new Surface
-  // a[4]= 2d3d Scale Factor
-
-  if (n !=5) {
-    di << "bad number of arguments" <<"\n";
-    return 1;
-  }
-
-  TopoDS_Shape inputShape= DBRep::Get(a[2]);
-  TopoDS_Shell inputShell = TopoDS::Shell(inputShape);
-  if (inputShell.IsNull()) {
-    di << a[2] << " is not a shell" << "\n";
-    return 1;
-  }
-
-  Handle(Geom_Surface) theSurf = DrawTrSurf::GetSurface(a[3]);
-  if ( theSurf.IsNull()) {
-    di << a[3] << " is not a surface" << "\n";
-    return 1;
-  }
-
-  ShapeUpgrade_DataMapOfShapeSurface theMap;
-  // Associates thesurf to each face of inputShell.
-  TopExp_Explorer ExpSh;
-  for (ExpSh.Init(inputShell,TopAbs_FACE); ExpSh.More(); ExpSh.Next()){
-    TopoDS_Face theFace= TopoDS::Face(ExpSh.Current());
-    theMap.Bind(theFace,theSurf);
-  }
-
-  Standard_Real the2d3dFactor=Draw::Atof(a[4]);
-  ShapeUpgrade_SupportModification theTool(inputShell,theMap,the2d3dFactor);
-
-  TopoDS_Shell res = theTool.Shell();
-  DBRep::Set(a[1],res);
-
-  return 0;
-}*/
-
-//=======================================================================
-//function : DT_Debug
-//purpose  : activation of the debug mode
-//
-//=======================================================================
-/*
-static Standard_Integer DT_Debug (Draw_Interpretor& di,
-                                  Standard_Integer n, const char** a)
-
-{
-  // a[1]= 0/1
-
-  if (n !=2) {
-    di << "bad number of arguments" <<"\n";
-    return 1;
-  }
-
-  if (Draw::Atoi(a[1])==1) {
-    di << "Activation of debug messages"<<"\n";
-    ShapeUpgrade::SetDebug(Standard_True);
-  }
-  else {
-    di << "Desactivation of debug messages"<<"\n";
-    ShapeUpgrade::SetDebug(Standard_False);
-  }
-  return 0;
-}
-*/
-
-/*static Standard_Integer shellsolid
-  (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
-{
-  if (argc < 4) {
-    di<<"Donner option + nom de SHAPE + nom de RESULTAT"<<"\n";
-    di<<"Options : a all   (sewing sur tous les shells\n"
-      <<  "          c check (sewing sur shells avec bad edges\n"
-       <<"          b bad edges\n          f free edges"<<"\n";
-    return 1 ;
-  }
-  Standard_CString arg1 = argv[1];
-  Standard_CString arg2 = argv[2];
-  Standard_CString arg3 = argv[3];
-
-  TopoDS_Shape Shape = DBRep::Get(arg2);
-  if (Shape.IsNull()) { di<<"Shape unknown : "<<arg2<<"\n"; return 1 ; }
-
-  ShapeAnalysis_Shell STS;
-  char opt = arg1[0];
-  if      (opt == 'a') STS.LoadShells (Shape);
-  else if (opt == 'f') STS.CheckOrientedShells (Shape,Standard_True);
-  else if (opt == 'b' || opt == 'c') STS.CheckOrientedShells (Shape,Standard_False);
-
-  else if (opt == 'o') {
-
-//   Test WireOrder
-    Handle(ShapeExtend_WireData) Frees = new ShapeExtend_WireData;//:sw  Frees.SetPrecision (BRepBuilderAPI::Precision());
-    Standard_Integer nbe = 0;
-    for (TopExp_Explorer edges(Shape,TopAbs_EDGE); edges.More(); edges.Next()) {
-      Frees->Add (TopoDS::Edge(edges.Current()));  nbe ++;
-    }
-    ShapeAnalysis_WireOrder WO (Standard_True,BRepBuilderAPI::Precision());
-    ShapeAnalysis_Wire saw;
-    saw.Load ( Frees );
-    saw.SetPrecision ( BRepBuilderAPI::Precision() );
-    saw.CheckOrder ( WO );
-    
-    Standard_Integer stat = WO.Status();
-    di<<"Wire Order Status = "<<stat<<" on "<<nbe<<" Edges"<<"\n";
-    nbe = WO.NbEdges();
-    for (Standard_Integer ie = 1; ie <= nbe; ie ++) {
-      Standard_Integer io = WO.Ordered (ie);
-      gp_XYZ st3d,en3d;
-      WO.XYZ (io,st3d,en3d);
-      di<<ie<<": Edge."<<io<<" Start:"<<st3d.X()<<" "<<st3d.Y()<<" "<<st3d.Z()
-       <<"  End:"<<en3d.X()<<" "<<en3d.Y()<<" "<<en3d.Z()<<"\n";
-    }
-//    Chainage ?
-    Standard_Real gap = BRepBuilderAPI::Precision();
-    WO.SetChains (gap);
-    Standard_Integer n1,n2,ic, nc = WO.NbChains();
-    for (ic = 1; ic <= nc; ic ++) {
-      WO.Chain(ic,n1,n2);
-      di<<"Chain."<<ic<<" From "<<n1<<" To "<<n2<<"\n";
-    }
-  }
-
-  else { di<<"Option non reconnue : "<<arg1<<"\n"; return 1; }
-
-  TopoDS_Shape res;
-  if (opt == 'a' || opt == 'c') {
-    ShapeUpgrade_ShellSewing sew;
-    res = sew.ApplySewing (Shape);
-    if (res.IsEqual(Shape)) {
-      res.Nullify();
-      di<<"ShellSolid : no sewing done"<<"\n";
-    }
-  } else if (opt == 'b') {
-    if (STS.HasBadEdges()) res = STS.BadEdges();
-    else di<<"ShellSolid : no bad edge"<<"\n";
-  } else if (opt == 'f') {
-    if (STS.HasFreeEdges()) res = STS.FreeEdges();
-    else di<<"ShellSolid : no free edge"<<"\n";
-    if (STS.HasConnectedEdges()) di<<"ShellSolid : connected edges"<<"\n";
-    else di<<"ShellSolid : NO connected edges"<<"\n";
-  }
-
-  if (!res.IsNull()) DBRep::Set (arg3,res);
-
-  return 0; // Done
-}*/
 //---------------gka
 //=======================================================================
 //function : offset2dcurve
index cc74fea02bebfe3f249bfebecf2fb1e188ecbef9..54d9437a95f764d1fcf0fdd08f983122d9c1e810 100644 (file)
@@ -185,8 +185,12 @@ static Standard_Boolean IsBetter(const Standard_Integer first,
 
 void ShapeAnalysis_WireOrder::Perform(const Standard_Boolean /*closed*/) 
 {
-  Standard_Integer i, nb = myXYZ->Length() / 2;
-  myOrd = new TColStd_HArray1OfInteger(1,nb);  myOrd->Init(0);
+  myStat = 0;
+  Standard_Integer i, nb = NbEdges();
+  if(nb == 0)
+    return; // no edges loaded, nothing to do -- return with status OK
+  myOrd = new TColStd_HArray1OfInteger(1,nb);
+  myOrd->Init(0);
 
   Handle(TColStd_HSequenceOfInteger) seq = new TColStd_HSequenceOfInteger;
   TColStd_SequenceOfTransient loops;
diff --git a/tests/bugs/heal/bug25014 b/tests/bugs/heal/bug25014
new file mode 100755 (executable)
index 0000000..492bc7e
--- /dev/null
@@ -0,0 +1,10 @@
+puts "============"
+puts "OCC25014"
+puts "============"
+puts ""
+#######################################################################
+## ShapeAnalysis_WireOrder produces Standard_RangeError on empty wire (debug mode only)
+#######################################################################
+
+shape w w
+stwire w r +r