0030346: Modeling Algorithms - BRepPrimAPI_MakeRevol throws "BRepSweep_Translation...
[occt.git] / src / BRepTest / BRepTest_CurveCommands.cxx
index 2b974fe..6bd5a54 100644 (file)
@@ -171,7 +171,7 @@ static Standard_Integer trim(Draw_Interpretor& di, Standard_Integer n, const cha
   }
   else {
     //cout <<"Error creating edge"<<endl;
-    di <<"Error creating edge"<<"\n";
+    di <<"Error creating edge\n";
   }
   return 0;
 }
@@ -224,22 +224,56 @@ static Standard_Integer wire(Draw_Interpretor& di, Standard_Integer n, const cha
   if (n < 3) return 1;
   Standard_Integer i;
   BRepBuilderAPI_MakeWire MW;
-  for (i = 2; i < n; i ++) {
-    TopoDS_Shape S = DBRep::Get(a[i]);
-    if (S.IsNull()) continue;
-    if (S.ShapeType() == TopAbs_EDGE)
-      MW.Add(TopoDS::Edge(S));
-    else if (S.ShapeType() == TopAbs_WIRE)
-      MW.Add(TopoDS::Wire(S));
-    else
-      continue;
+  Standard_Boolean IsUnsorted = !strcmp(a[2], "-unsorted");
+
+  if (!IsUnsorted)
+    for (i = 2; i < n; i ++) {
+      TopoDS_Shape S = DBRep::Get(a[i]);
+      if (S.IsNull()) continue;
+      if (S.ShapeType() == TopAbs_EDGE)
+        MW.Add(TopoDS::Edge(S));
+      else if (S.ShapeType() == TopAbs_WIRE)
+        MW.Add(TopoDS::Wire(S));
+      else
+        continue;
+    }
+  else
+  {
+    TopTools_ListOfShape aLE;
+    for (i = 3; i < n; i ++) 
+    {
+      TopoDS_Shape S = DBRep::Get(a[i]);
+      TopExp_Explorer Exp(S, TopAbs_EDGE);
+      for (;Exp.More();Exp.Next())
+      {
+        const TopoDS_Edge& anE = TopoDS::Edge(Exp.Current()); 
+        if (!anE.IsNull())
+          aLE.Append(anE);
+      }
+    }
+    MW.Add(aLE);
   }
+
   if (!MW.IsDone()) {
     //cout << "Wire not done" << endl;
-    di << "Wire not done" << "\n";
-    return 0;
+    di << "Wire not done with an error:\n";
+    switch (MW.Error()) 
+    {
+    case BRepBuilderAPI_EmptyWire:
+      di << "BRepBuilderAPI_EmptyWire\n";
+      break;
+    case BRepBuilderAPI_DisconnectedWire:
+      di << "BRepBuilderAPI_DisconnectedWire\n";
+      break;
+    case BRepBuilderAPI_NonManifoldWire:
+      di << "BRepBuilderAPI_NonManifoldWire\n";
+      break;
+    default:
+      break;
+    }
   }
-  DBRep::Set(a[1],MW);
+  else   
+    DBRep::Set(a[1],MW);
   return 0;
 }
 
@@ -255,7 +289,7 @@ static Standard_Integer mkedge(Draw_Interpretor& di, Standard_Integer n, const c
   Handle(Geom2d_Curve) C2d = DrawTrSurf::GetCurve2d(a[2]);
   if (C.IsNull() && C2d.IsNull()) {
     //cout << a[2] << " is not a curve" << endl;
-    di << a[2] << " is not a curve" << "\n";
+    di << a[2] << " is not a curve\n";
     return 1;
   }
 
@@ -336,7 +370,7 @@ static Standard_Integer mkcurve(Draw_Interpretor& di, Standard_Integer n, const
   Handle(Geom_Curve) C = BRep_Tool::Curve(TopoDS::Edge(S),L,f,l);
   if (C.IsNull()) {
     //cout << a[2] << " has no 3d curve" << endl;
-    di << a[2] << " has no 3d curve" << "\n";
+    di << a[2] << " has no 3d curve\n";
     return 1;
   }
   C = new Geom_TrimmedCurve(C,f,l);
@@ -965,8 +999,8 @@ static Standard_Integer bsplineprof(Draw_Interpretor& di,
     0.0e0) ;
   gp_Pnt2d first_point(0.0e0,
     0.0e0) ;
-  Standard_Integer i = 2,
-    wait = 1 ;
+  Standard_Integer i = 2;
+  Standard_Boolean wait = Standard_True;
 //  Standard_Real x0 = 0, y0 = 0, x = 0, y = 0, dx = 1, dy = 0;
   Standard_Real x = 0, y = 0, dx = 1, dy = 0;
   BRepBuilderAPI_MakeWire MW;
@@ -1544,7 +1578,7 @@ Standard_Integer mkoffset(Draw_Interpretor& di,
 
     if ( !Paral.IsDone())
     {
-      di << " Error: Offset is not done." << "\n";
+      di << " Error: Offset is not done.\n";
       return 1;
     }
     else
@@ -1604,7 +1638,7 @@ Standard_Integer openoffset(Draw_Interpretor& di,
 
     if ( !Paral.IsDone())
     {
-      di << " Error: Offset is not done." << "\n";
+      di << " Error: Offset is not done.\n";
       return 1;
     }
     else
@@ -1672,7 +1706,7 @@ Standard_Integer edgeintersector(Draw_Interpretor& di,
 
   if (EInter.IsEmpty()) {
     //cout << " No intersection found" << endl;
-    di << " No intersection found" << "\n";
+    di << " No intersection found\n";
     return 0;
   }
 
@@ -1715,10 +1749,10 @@ Standard_Integer edgeintersector(Draw_Interpretor& di,
       di << " Orientation of vertex " << NbV << " on " << a[i+1] << ": ";
       if (OO == TopAbs_FORWARD) {
         //cout << "FORWARD" << endl;
-        di << "FORWARD" << "\n";
+        di << "FORWARD\n";
       } else {
         //cout << "REVERSED" << endl;
-        di << "REVERSED" << "\n";
+        di << "REVERSED\n";
       }
     }
   }
@@ -1787,18 +1821,18 @@ Standard_Integer  build3d(Draw_Interpretor& di,
 
   if ( (n <2) || (n>3) ) {
     //cout << " 1 or 2 arguments expected" << endl;
-    di << " 1 or 2 arguments expected" << "\n";
+    di << " 1 or 2 arguments expected\n";
     return 1;
   }
 
   Standard_Boolean Ok;
-  TopoDS_Shape S = DBRep::Get(a[1],TopAbs_FACE);
+  TopoDS_Shape S = DBRep::Get(a[1]);
   if (S.IsNull()) return 1;
 
   if (n==2) { Ok = BRepLib::BuildCurves3d(S); }
   else      { Ok = BRepLib::BuildCurves3d(S,Draw::Atof(a[2])); }
   //if (!Ok) {cout << " one of the computation failed" << endl;}
-  if (!Ok) {di << " one of the computation failed" << "\n";}
+  if (!Ok) {di << " one of the computation failed\n";}
 
   return 0;
 }
@@ -1819,7 +1853,7 @@ Standard_Integer reducepcurves(Draw_Interpretor& di,
     TopoDS_Shape aShape = DBRep::Get(a[i]);
     if (aShape.IsNull())
       //cout << a[i] << " is not a valid shape" << endl;
-      di << a[i] << " is not a valid shape" << "\n";
+      di << a[i] << " is not a valid shape\n";
     else
       BRepTools::RemoveUnusedPCurves(aShape);
   }
@@ -1864,7 +1898,7 @@ void  BRepTest::CurveCommands(Draw_Interpretor& theCommands)
     polyvertex,g);
 
   theCommands.Add("wire",
-    "wire wirename e1/w1 [e2/w2 ...]",__FILE__,
+    "wire wirename [-unsorted] e1/w1 [e2/w2 ...]",__FILE__,
     wire,g);
 
   theCommands.Add("profile",