0027272: FixMissingSeam function creates G1 seam curves
[occt.git] / src / BRepTest / BRepTest_SurfaceCommands.cxx
index 72ec470..dfe883e 100644 (file)
@@ -180,7 +180,7 @@ static Standard_Integer mksurface(Draw_Interpretor& , Standard_Integer n, const
 // mkplane
 //=======================================================================
 
-static Standard_Integer mkplane(Draw_Interpretor& , Standard_Integer n, const char** a)
+static Standard_Integer mkplane(Draw_Interpretor& theDI, Standard_Integer n, const char** a)
 {
   if (n < 3) return 1;
 
@@ -192,9 +192,30 @@ static Standard_Integer mkplane(Draw_Interpretor& , Standard_Integer n, const ch
     OnlyPlane =  !strcmp(a[3],"1");
   }
 
-  TopoDS_Face F = BRepBuilderAPI_MakeFace(TopoDS::Wire(S), OnlyPlane);
+  BRepBuilderAPI_MakeFace aMF(TopoDS::Wire(S), OnlyPlane);
+
+  switch(aMF.Error())
+  {
+  case BRepBuilderAPI_FaceDone:
+    DBRep::Set(a[1],aMF.Face());
+    break;
+  case BRepLib_NoFace:
+    theDI << "Error. mkplane has been finished with \"No Face\" status.\n";
+    break;
+  case BRepLib_NotPlanar:
+    theDI << "Error. mkplane has been finished with \"Not Planar\" status.\n";
+    break;
+  case BRepLib_CurveProjectionFailed:
+    theDI << "Error. mkplane has been finished with \"Fail in projection curve\" status.\n";
+    break;
+  case BRepLib_ParametersOutOfRange:
+    theDI << "Error. mkplane has been finished with \"Parameters are out of range\" status.\n";
+    break;
+  default:
+    theDI << "Error. Undefined status. Please check the code.\n";
+    break;
+  }
 
-  DBRep::Set(a[1],F);
   return 0;
 }
 
@@ -307,7 +328,7 @@ static Standard_Integer sewing (Draw_Interpretor& theDi,
             }
             else
             {
-              theDi << "Error! min tolerance can't possess the null value" << "\n";
+              theDi << "Error! min tolerance can't possess the null value\n";
               return (1);
             }
           }
@@ -317,7 +338,7 @@ static Standard_Integer sewing (Draw_Interpretor& theDi,
               aMaxTol = Draw::Atof (theArgv[++i]);
             else
             {
-              theDi << "Error! max tolerance can't possess the null value" << "\n";
+              theDi << "Error! max tolerance can't possess the null value\n";
               return (1);
             }
           }
@@ -350,22 +371,22 @@ static Standard_Integer sewing (Draw_Interpretor& theDi,
    
   if (aPar < 2)
   {
-    theDi << "Use: " << theArgv[0] << " result [tolerance] shape1 shape2 ... [min tolerance] [max tolerance] [switches]" << "\n";
-    theDi << "To set user's value of min/max tolerances the following syntax is used: +<parameter> <value>" << "\n";
-    theDi << "- parameters are identified by letters:" << "\n";
-    theDi << "  mint - min tolerance" << "\n";
-    theDi << "  maxt - max tolerance" << "\n";
-    theDi << "Switches allow to tune other parameters of Sewing" << "\n";
-    theDi << "The following syntax is used: <symbol><parameter>" << "\n";
-    theDi << "- symbol may be - to set parameter off, + to set on" << "\n";
-    theDi << "- parameters are identified by letters:" << "\n";
-    theDi << "  s - mode for creating sewed shape" << "\n";
-    theDi << "  a - mode for analysis of input shapes" << "\n";
-    theDi << "  c - mode for cutting of free edges" << "\n";
-    theDi << "  n - mode for non manifold processing" << "\n";
-    theDi << "  p - mode for same parameter processing for edges" << "\n";
-    theDi << "  e - mode for sewing floating edges" << "\n";
-    theDi << "  f - mode for sewing faces" << "\n";
+    theDi << "Use: " << theArgv[0] << " result [tolerance] shape1 shape2 ... [min tolerance] [max tolerance] [switches]\n";
+    theDi << "To set user's value of min/max tolerances the following syntax is used: +<parameter> <value>\n";
+    theDi << "- parameters are identified by letters:\n";
+    theDi << "  mint - min tolerance\n";
+    theDi << "  maxt - max tolerance\n";
+    theDi << "Switches allow to tune other parameters of Sewing\n";
+    theDi << "The following syntax is used: <symbol><parameter>\n";
+    theDi << "- symbol may be - to set parameter off, + to set on\n";
+    theDi << "- parameters are identified by letters:\n";
+    theDi << "  s - mode for creating sewed shape\n";
+    theDi << "  a - mode for analysis of input shapes\n";
+    theDi << "  c - mode for cutting of free edges\n";
+    theDi << "  n - mode for non manifold processing\n";
+    theDi << "  p - mode for same parameter processing for edges\n";
+    theDi << "  e - mode for sewing floating edges\n";
+    theDi << "  f - mode for sewing faces\n";
     return (1);
   }
     
@@ -377,12 +398,12 @@ static Standard_Integer sewing (Draw_Interpretor& theDi,
     aMinTol = Precision::Confusion();
   if (aMinTol > aTol)
   {
-    theDi << "Error! min tolerance can't exceed working tolerance" << "\n";
+    theDi << "Error! min tolerance can't exceed working tolerance\n";
     return (1);
   }
   if (aMaxTol < aTol)
   {
-    theDi << "Error! max tolerance can't be less than working tolerance" << "\n";
+    theDi << "Error! max tolerance can't be less than working tolerance\n";
     return (1);
   }
 
@@ -518,6 +539,41 @@ static Standard_Integer encoderegularity (Draw_Interpretor& ,
   return 0;
 }
 
+static Standard_Integer getedgeregul
+  (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+  if( argc < 3)
+  {
+    cout<<"Invalid number of arguments. Should be: checkedgeregularity edge face1 [face2]"<<endl;
+    return 1;
+  }
+  
+  TopoDS_Shape anEdge =  DBRep::Get(argv[1],TopAbs_EDGE);
+  TopoDS_Shape aFace1 = DBRep::Get(argv[2],TopAbs_FACE);
+  TopoDS_Shape aFace2 = (argc > 3  ? DBRep::Get(argv[3],TopAbs_FACE) : aFace1);
+  if( anEdge.IsNull() || aFace1.IsNull() || aFace2.IsNull())
+  {
+    cout<<"Invalid number of arguments. Should be: getedgeregularity edge face1 [face2]"<<endl;
+    return 1;
+  }
+  GeomAbs_Shape aRegularity = BRep_Tool::Continuity(TopoDS::Edge(anEdge), TopoDS::Face(aFace1),  TopoDS::Face(aFace2));
+  TCollection_AsciiString aStrReg("Regularity of edge : ");
+  switch( aRegularity)
+  {
+    default:
+    case GeomAbs_C0 : aStrReg += "C0"; break;
+    case GeomAbs_G1 : aStrReg += "G1"; break;
+    case GeomAbs_C1 : aStrReg += "C1"; break;
+    case GeomAbs_G2 : aStrReg += "G2"; break;
+    case GeomAbs_C2 : aStrReg += "C2"; break;
+    case GeomAbs_C3 : aStrReg += "C3"; break;
+    case GeomAbs_CN : aStrReg += "CN"; break;
+  };
+
+  di<<aStrReg.ToCString()<<"\n";
+  return 0; // Done
+}
 
 //=======================================================================
 //function : SurfaceCommands
@@ -573,5 +629,6 @@ void  BRepTest::SurfaceCommands(Draw_Interpretor& theCommands)
 
   theCommands.Add ("fastsewing", "fastsewing result [-tol <value>] <list_of_faces>", 
                                                 __FILE__, fastsewing, g);
+  theCommands.Add ("getedgeregularity", "getedgeregularity edge face1 [face2]",  __FILE__,getedgeregul,g);
 }