From f0ada3e8d443fd00d0f6d663868abcd8fb443d4a Mon Sep 17 00:00:00 2001
From: ifv <ifv@opencascade.com>
Date: Fri, 27 Mar 2020 14:45:28 +0300
Subject: [PATCH] 0031469: BRepFeat_MakePrism failed

BRepFeat_Form.cxx: methods IsDeleted, Modified, Generated are corrected
BRepTest_FeatureCommands.cxx: history treatment is added in methods DEFIN and PERF
bugs/modalg_7/bug31469: test case added
---
 src/BRepFeat/BRepFeat_Form.cxx            |   38 +-
 src/BRepTest/BRepTest_FeatureCommands.cxx | 1738 +++++++++++----------
 tests/bugs/modalg_7/bug31469              |   43 +
 3 files changed, 964 insertions(+), 855 deletions(-)
 create mode 100644 tests/bugs/modalg_7/bug31469

diff --git a/src/BRepFeat/BRepFeat_Form.cxx b/src/BRepFeat/BRepFeat_Form.cxx
index b30dc8d0f7..e749670164 100644
--- a/src/BRepFeat/BRepFeat_Form.cxx
+++ b/src/BRepFeat/BRepFeat_Form.cxx
@@ -1015,7 +1015,11 @@ static void Descendants(const TopoDS_Shape&,
 
 Standard_Boolean BRepFeat_Form::IsDeleted(const TopoDS_Shape& F)
 {
-  return (myMap(F).IsEmpty());
+  if (myMap.IsBound(F))
+  {
+    return (myMap(F).IsEmpty());
+  }
+  return Standard_False;
 }
 
 //=======================================================================
@@ -1026,16 +1030,23 @@ Standard_Boolean BRepFeat_Form::IsDeleted(const TopoDS_Shape& F)
 const TopTools_ListOfShape& BRepFeat_Form::Modified
    (const TopoDS_Shape& F)
 {
+  myGenerated.Clear();
+  if (!IsDone())
+    return myGenerated;
+
+  if (mySbase.IsEqual(F))
+  {
+    myGenerated.Append(myShape);
+    return myGenerated;
+  }
+
   if (myMap.IsBound(F)) {
-    static TopTools_ListOfShape list;
-    list.Clear(); // For the second passage DPF
     TopTools_ListIteratorOfListOfShape ite(myMap(F));
     for(; ite.More(); ite.Next()) {
       const TopoDS_Shape& sh = ite.Value();
-      if(!sh.IsSame(F)) 
-        list.Append(sh);
+      if(!sh.IsSame(F) && sh.ShapeType() == F.ShapeType()) 
+        myGenerated.Append(sh);
     }
-    return list;
   }
   return myGenerated; // empty list
 }
@@ -1048,19 +1059,20 @@ const TopTools_ListOfShape& BRepFeat_Form::Modified
 const TopTools_ListOfShape& BRepFeat_Form::Generated
    (const TopoDS_Shape& S)
 {
-  if (myMap.IsBound(S) && 
-      S.ShapeType() != TopAbs_FACE) { // check if filter on face or not
-    static TopTools_ListOfShape list;
-    list.Clear(); // For the second passage DPF
+  myGenerated.Clear();
+  if (!IsDone())
+    return myGenerated;
+  if (myMap.IsBound(S) &&
+    S.ShapeType() != TopAbs_FACE) { // check if filter on face or not
     TopTools_ListIteratorOfListOfShape ite(myMap(S));
     for(; ite.More(); ite.Next()) {
       const TopoDS_Shape& sh = ite.Value();
       if(!sh.IsSame(S)) 
-        list.Append(sh);
+        myGenerated.Append(sh);
     }
-    return list;
+    return myGenerated;
   }
-  else return myGenerated;
+  return myGenerated;
 }
 
 
diff --git a/src/BRepTest/BRepTest_FeatureCommands.cxx b/src/BRepTest/BRepTest_FeatureCommands.cxx
index 568bc68db9..1cf6dbcdc1 100644
--- a/src/BRepTest/BRepTest_FeatureCommands.cxx
+++ b/src/BRepTest/BRepTest_FeatureCommands.cxx
@@ -85,6 +85,10 @@ static BRepFeat_MakePipe  thePipe;
 static BRepFeat_MakeLinearForm  theLF;
 static BRepFeat_MakeRevolutionForm  theRF;
 
+//Input shapes for Prism, DPrism, Revol, Pipe
+static TopoDS_Shape theSbase, thePbase;
+static TopoDS_Face theSkface;
+
 static Standard_Boolean dprdef = Standard_False;
 static Standard_Boolean prdef = Standard_False;
 static Standard_Boolean rvdef = Standard_False;
@@ -94,8 +98,8 @@ static Standard_Boolean rfdef = Standard_False;
 
 static Standard_Real t3d = 1.e-4;
 static Standard_Real t2d = 1.e-5;
-static Standard_Real ta  = 1.e-2;
-static Standard_Real fl  = 1.e-3;
+static Standard_Real ta = 1.e-2;
+static Standard_Real fl = 1.e-3;
 static Standard_Real tapp_angle = 1.e-2;
 static GeomAbs_Shape blend_cont = GeomAbs_C1;
 static BRepFilletAPI_MakeFillet* Rakk = 0;
@@ -103,7 +107,7 @@ static BRepFilletAPI_MakeFillet* Rakk = 0;
 
 
 static void Print(Draw_Interpretor& di,
-		  const BRepFeat_Status St)
+  const BRepFeat_Status St)
 {
   di << "  Error Status : ";
   switch (St) {
@@ -122,17 +126,17 @@ static void Print(Draw_Interpretor& di,
 }
 
 static Standard_Integer Loc(Draw_Interpretor& theCommands,
-			    Standard_Integer narg, const char** a)
+  Standard_Integer narg, const char** a)
 {
-  if (narg<6) return 1;
+  if (narg < 6) return 1;
   TopoDS_Shape S = DBRep::Get(a[2]);
   TopoDS_Shape T = DBRep::Get(a[3]);
 
   Standard_Boolean Fuse;
-  if (!strcasecmp("F",a[4])) {
+  if (!strcasecmp("F", a[4])) {
     Fuse = Standard_True;
   }
-  else if (!strcasecmp("C",a[4])) {
+  else if (!strcasecmp("C", a[4])) {
     Fuse = Standard_False;
   }
   else {
@@ -140,10 +144,10 @@ static Standard_Integer Loc(Draw_Interpretor& theCommands,
   }
 
   TopTools_ListOfShape LF;
-  for (Standard_Integer i=0; i<= narg-6; i++) {
-    TopoDS_Shape aLocalShape(DBRep::Get(a[i+5],TopAbs_FACE));
+  for (Standard_Integer i = 0; i <= narg - 6; i++) {
+    TopoDS_Shape aLocalShape(DBRep::Get(a[i + 5], TopAbs_FACE));
     LF.Append(aLocalShape);
-//    LF.Append(TopoDS::Face(DBRep::Get(a[i+5],TopAbs_FACE)));
+    //    LF.Append(TopoDS::Face(DBRep::Get(a[i+5],TopAbs_FACE)));
   }
 
   //BRepFeat_LocalOperation BLoc(S);
@@ -151,7 +155,7 @@ static Standard_Integer Loc(Draw_Interpretor& theCommands,
   //BLoc.BuildPartsOfTool();
   TopTools_ListOfShape parts;
   BRepFeat_Builder BLoc;
-  BLoc.Init(S,T);
+  BLoc.Init(S, T);
   BLoc.SetOperation(Fuse);
   //BRepFeat_LocalOperation BLoc;
   //BLoc.Init(S,T,Fuse);
@@ -160,7 +164,7 @@ static Standard_Integer Loc(Draw_Interpretor& theCommands,
 
 #if 0
   char newname[1024];
-  strcpy(newname,a[1]);
+  strcpy(newname, a[1]);
   char* p = newname;
   while (*p != '\0') p++;
   *p = '_';
@@ -170,20 +174,20 @@ static Standard_Integer Loc(Draw_Interpretor& theCommands,
   i = 0;
   for (; its.More(); its.Next()) {
     i++;
-    Sprintf(p,"%d",i);
-    DBRep::Set(newname,its.Value());
+    Sprintf(p, "%d", i);
+    DBRep::Set(newname, its.Value());
   }
   if (i >= 2) {
     dout.Flush();
-    Standard_Integer qq,ww,ee,button;
+    Standard_Integer qq, ww, ee, button;
     TopoDS_Shell S;
     do {
-      TopoDS_Shape aLocalShape(DBRep::Get(".",TopAbs_SHELL));
+      TopoDS_Shape aLocalShape(DBRep::Get(".", TopAbs_SHELL));
       S = TopoDS::Shell(aLocalShape);
-//      S = TopoDS::Shell(DBRep::Get(".",TopAbs_SHELL));
-      Draw::LastPick(qq,ww,ee,button);
+      //      S = TopoDS::Shell(DBRep::Get(".",TopAbs_SHELL));
+      Draw::LastPick(qq, ww, ee, button);
       if (!S.IsNull()) {
-        
+
         switch (button) {
         case 1:
           //BLoc.RemovePart(S);
@@ -192,7 +196,7 @@ static Standard_Integer Loc(Draw_Interpretor& theCommands,
           BLoc.KeepPart(S);
           break;
         default:
-          {}
+        {}
         }
       }
       else {
@@ -204,131 +208,131 @@ static Standard_Integer Loc(Draw_Interpretor& theCommands,
 #endif
   BLoc.PerformResult();
   if (!BLoc.HasErrors()) {
-//    dout.Clear();
-    DBRep::Set(a[1],BLoc.Shape());
+    //    dout.Clear();
+    DBRep::Set(a[1], BLoc.Shape());
     dout.Flush();
     return 0;
   }
-  theCommands << "Local operation not done" ;
+  theCommands << "Local operation not done";
   return 1;
 }
 
 
 
 static Standard_Integer HOLE1(Draw_Interpretor& theCommands,
-			      Standard_Integer narg, const char** a)
+  Standard_Integer narg, const char** a)
 {
-  if (narg<10 || narg == 11) return 1;
+  if (narg < 10 || narg == 11) return 1;
   TopoDS_Shape S = DBRep::Get(a[2]);
 
-  gp_Pnt Or(Draw::Atof(a[3]),Draw::Atof(a[4]),Draw::Atof(a[5]));
-  gp_Dir Di(Draw::Atof(a[6]),Draw::Atof(a[7]),Draw::Atof(a[8]));
+  gp_Pnt Or(Draw::Atof(a[3]), Draw::Atof(a[4]), Draw::Atof(a[5]));
+  gp_Dir Di(Draw::Atof(a[6]), Draw::Atof(a[7]), Draw::Atof(a[8]));
 
   Standard_Real Radius = Draw::Atof(a[9]);
 
-  theHole.Init(S,gp_Ax1(Or,Di));
+  theHole.Init(S, gp_Ax1(Or, Di));
 
   if (narg <= 10) {
     theHole.Perform(Radius);
   }
   else {
     Standard_Real pfrom = Draw::Atof(a[10]);
-    Standard_Real pto   = Draw::Atof(a[11]);
-    theHole.Perform(Radius,pfrom,pto,WithControl);
+    Standard_Real pto = Draw::Atof(a[11]);
+    theHole.Perform(Radius, pfrom, pto, WithControl);
   }
 
   theHole.Build();
   if (!theHole.HasErrors()) {
-//    dout.Clear();
-    DBRep::Set(a[1],theHole.Shape());
+    //    dout.Clear();
+    DBRep::Set(a[1], theHole.Shape());
     dout.Flush();
     return 0;
   }
   theCommands << "Echec de MakeCylindricalHole";
-  Print(theCommands,theHole.Status());
+  Print(theCommands, theHole.Status());
   return 1;
 }
 
 static Standard_Integer HOLE2(Draw_Interpretor& theCommands,
-			      Standard_Integer narg, const char** a)
+  Standard_Integer narg, const char** a)
 {
-  if (narg<10) return 1;
+  if (narg < 10) return 1;
   TopoDS_Shape S = DBRep::Get(a[2]);
 
-  gp_Pnt Or(Draw::Atof(a[3]),Draw::Atof(a[4]),Draw::Atof(a[5]));
-  gp_Dir Di(Draw::Atof(a[6]),Draw::Atof(a[7]),Draw::Atof(a[8]));
+  gp_Pnt Or(Draw::Atof(a[3]), Draw::Atof(a[4]), Draw::Atof(a[5]));
+  gp_Dir Di(Draw::Atof(a[6]), Draw::Atof(a[7]), Draw::Atof(a[8]));
 
   Standard_Real Radius = Draw::Atof(a[9]);
 
-  theHole.Init(S,gp_Ax1(Or,Di));
-  theHole.PerformThruNext(Radius,WithControl);
+  theHole.Init(S, gp_Ax1(Or, Di));
+  theHole.PerformThruNext(Radius, WithControl);
 
   theHole.Build();
   if (!theHole.HasErrors()) {
-//    dout.Clear();
-    DBRep::Set(a[1],theHole.Shape());
+    //    dout.Clear();
+    DBRep::Set(a[1], theHole.Shape());
     dout.Flush();
     return 0;
   }
   theCommands << "Echec de MakeCylindricalHole";
-  Print(theCommands,theHole.Status());
+  Print(theCommands, theHole.Status());
   return 1;
 }
 
 static Standard_Integer HOLE3(Draw_Interpretor& theCommands,
-			      Standard_Integer narg, const char** a)
+  Standard_Integer narg, const char** a)
 {
-  if (narg<10) return 1;
+  if (narg < 10) return 1;
   TopoDS_Shape S = DBRep::Get(a[2]);
 
-  gp_Pnt Or(Draw::Atof(a[3]),Draw::Atof(a[4]),Draw::Atof(a[5]));
-  gp_Dir Di(Draw::Atof(a[6]),Draw::Atof(a[7]),Draw::Atof(a[8]));
+  gp_Pnt Or(Draw::Atof(a[3]), Draw::Atof(a[4]), Draw::Atof(a[5]));
+  gp_Dir Di(Draw::Atof(a[6]), Draw::Atof(a[7]), Draw::Atof(a[8]));
 
   Standard_Real Radius = Draw::Atof(a[9]);
 
-  theHole.Init(S,gp_Ax1(Or,Di));
-  theHole.PerformUntilEnd(Radius,WithControl);
+  theHole.Init(S, gp_Ax1(Or, Di));
+  theHole.PerformUntilEnd(Radius, WithControl);
   theHole.Build();
   if (!theHole.HasErrors()) {
-//    dout.Clear();
-    DBRep::Set(a[1],theHole.Shape());
+    //    dout.Clear();
+    DBRep::Set(a[1], theHole.Shape());
     dout.Flush();
     return 0;
   }
   theCommands << "Echec de MakeCylindricalHole";
-  Print(theCommands,theHole.Status());
+  Print(theCommands, theHole.Status());
   return 1;
 }
 
 
 static Standard_Integer HOLE4(Draw_Interpretor& theCommands,
-			      Standard_Integer narg, const char** a)
+  Standard_Integer narg, const char** a)
 {
-  if (narg<11) return 1;
+  if (narg < 11) return 1;
   TopoDS_Shape S = DBRep::Get(a[2]);
 
-  gp_Pnt Or(Draw::Atof(a[3]),Draw::Atof(a[4]),Draw::Atof(a[5]));
-  gp_Dir Di(Draw::Atof(a[6]),Draw::Atof(a[7]),Draw::Atof(a[8]));
+  gp_Pnt Or(Draw::Atof(a[3]), Draw::Atof(a[4]), Draw::Atof(a[5]));
+  gp_Dir Di(Draw::Atof(a[6]), Draw::Atof(a[7]), Draw::Atof(a[8]));
 
   Standard_Real Radius = Draw::Atof(a[9]);
   Standard_Real Length = Draw::Atof(a[10]);
 
-  theHole.Init(S,gp_Ax1(Or,Di));
-  theHole.PerformBlind(Radius,Length,WithControl);
+  theHole.Init(S, gp_Ax1(Or, Di));
+  theHole.PerformBlind(Radius, Length, WithControl);
   theHole.Build();
   if (!theHole.HasErrors()) {
-//    dout.Clear();
-    DBRep::Set(a[1],theHole.Shape());
+    //    dout.Clear();
+    DBRep::Set(a[1], theHole.Shape());
     dout.Flush();
     return 0;
   }
   theCommands << "Echec de MakeCylindricalHole";
-  Print(theCommands,theHole.Status());
+  Print(theCommands, theHole.Status());
   return 1;
 }
 
 static Standard_Integer CONTROL(Draw_Interpretor& theCommands,
-				Standard_Integer narg, const char** a)
+  Standard_Integer narg, const char** a)
 {
   if (narg >= 2) {
     WithControl = strcmp("0", a[1]) != 0;
@@ -347,40 +351,40 @@ static Standard_Integer CONTROL(Draw_Interpretor& theCommands,
 //purpose  : Print state of offset operation by error code.
 //=======================================================================
 static void reportOffsetState(Draw_Interpretor& theCommands,
-                              const BRepOffset_Error theErrorCode)
+  const BRepOffset_Error theErrorCode)
 {
-  switch(theErrorCode)
+  switch (theErrorCode)
   {
   case BRepOffset_NoError:
-    {
-      theCommands << "OK. Offset performed succesfully.";
-      break;
-    }
+  {
+    theCommands << "OK. Offset performed succesfully.";
+    break;
+  }
   case BRepOffset_BadNormalsOnGeometry:
-    {
-      theCommands << "ERROR. Degenerated normal on input data.";
-      break;
-    }
+  {
+    theCommands << "ERROR. Degenerated normal on input data.";
+    break;
+  }
   case BRepOffset_C0Geometry:
-    {
-      theCommands << "ERROR. C0 continuity of input data.";
-      break;
-    }
+  {
+    theCommands << "ERROR. C0 continuity of input data.";
+    break;
+  }
   case BRepOffset_NullOffset:
-    {
-      theCommands << "ERROR. Null offset of all faces.";
-      break;
-    }
+  {
+    theCommands << "ERROR. Null offset of all faces.";
+    break;
+  }
   case BRepOffset_NotConnectedShell:
-    {
-      theCommands << "ERROR. Incorrect set of faces to remove, the remaining shell is not connected.";
-      break;
-    }
+  {
+    theCommands << "ERROR. Incorrect set of faces to remove, the remaining shell is not connected.";
+    break;
+  }
   default:
-    {
-      theCommands << "ERROR. offsetperform operation not done.";
-      break;
-    }
+  {
+    theCommands << "ERROR. offsetperform operation not done.";
+    break;
+  }
   }
 }
 
@@ -390,13 +394,13 @@ static void reportOffsetState(Draw_Interpretor& theCommands,
 //=======================================================================
 
 static Standard_Integer PRW(Draw_Interpretor& theCommands,
-			    Standard_Integer narg, const char** a)
+  Standard_Integer narg, const char** a)
 {
-  if (narg<9) return 1;
+  if (narg < 9) return 1;
   TopoDS_Shape S = DBRep::Get(a[3]);
   BRepFeat_MakePrism thePFace;
   gp_Vec V;
-  TopoDS_Shape FFrom,FUntil;
+  TopoDS_Shape FFrom, FUntil;
   Standard_Integer borne;
   Standard_Boolean fuse;
   if (a[1][0] == 'f' || a[1][0] == 'F') {
@@ -415,21 +419,21 @@ static Standard_Integer PRW(Draw_Interpretor& theCommands,
     }
     if (a[5][0] == '.' || IsAlphabetic(a[5][0])) {
       if (narg < 11) {
-	return 1;
+        return 1;
       }
-      V.SetCoord(Draw::Atof(a[6]),Draw::Atof(a[7]),Draw::Atof(a[8]));
-      FFrom   = DBRep::Get(a[4],TopAbs_SHAPE);
-      FUntil  = DBRep::Get(a[5],TopAbs_SHAPE);
+      V.SetCoord(Draw::Atof(a[6]), Draw::Atof(a[7]), Draw::Atof(a[8]));
+      FFrom = DBRep::Get(a[4], TopAbs_SHAPE);
+      FUntil = DBRep::Get(a[5], TopAbs_SHAPE);
       borne = 9;
     }
     else {
-      V.SetCoord(Draw::Atof(a[5]),Draw::Atof(a[6]),Draw::Atof(a[7]));
-      FUntil  = DBRep::Get(a[4],TopAbs_SHAPE);
+      V.SetCoord(Draw::Atof(a[5]), Draw::Atof(a[6]), Draw::Atof(a[7]));
+      FUntil = DBRep::Get(a[4], TopAbs_SHAPE);
       borne = 8;
     }
   }
   else {
-    V.SetCoord(Draw::Atof(a[4]),Draw::Atof(a[5]),Draw::Atof(a[6]));
+    V.SetCoord(Draw::Atof(a[4]), Draw::Atof(a[5]), Draw::Atof(a[6]));
     borne = 7;
   }
   Standard_Real Length = V.Magnitude();
@@ -437,34 +441,34 @@ static Standard_Integer PRW(Draw_Interpretor& theCommands,
     return 1;
   }
 
-  TopoDS_Shape aLocalShape(DBRep::Get(a[borne],TopAbs_FACE));
-  TopoDS_Face F  = TopoDS::Face(aLocalShape);
-//  TopoDS_Face F  = TopoDS::Face(DBRep::Get(a[borne],TopAbs_FACE));
+  TopoDS_Shape aLocalShape(DBRep::Get(a[borne], TopAbs_FACE));
+  TopoDS_Face F = TopoDS::Face(aLocalShape);
+  //  TopoDS_Face F  = TopoDS::Face(DBRep::Get(a[borne],TopAbs_FACE));
   BRepFeat_SplitShape Spls(F);
-  for (Standard_Integer i = borne+1; i<narg; i++) {
+  for (Standard_Integer i = borne + 1; i < narg; i++) {
     TopoDS_Wire wir;
-    if (a[i][0] !='-') {
-      aLocalShape = DBRep::Get(a[i],TopAbs_WIRE);
+    if (a[i][0] != '-') {
+      aLocalShape = DBRep::Get(a[i], TopAbs_WIRE);
       wir = TopoDS::Wire(aLocalShape);
-//      wir = TopoDS::Wire(DBRep::Get(a[i],TopAbs_WIRE));
+      //      wir = TopoDS::Wire(DBRep::Get(a[i],TopAbs_WIRE));
     }
     else {
       if (a[i][1] == '\0')
-	return 1;
-      const char* Temp = a[i]+1;
-      aLocalShape = DBRep::Get(Temp,TopAbs_WIRE);
+        return 1;
+      const char* Temp = a[i] + 1;
+      aLocalShape = DBRep::Get(Temp, TopAbs_WIRE);
       wir = TopoDS::Wire(aLocalShape);
-//      wir = TopoDS::Wire(DBRep::Get(Temp,TopAbs_WIRE));
+      //      wir = TopoDS::Wire(DBRep::Get(Temp,TopAbs_WIRE));
       wir.Reverse();
     }
-    Spls.Add(wir,F);
+    Spls.Add(wir, F);
   }
   Spls.Build();
 
   TopoDS_Shape ToPrism;
   const TopTools_ListOfShape& lleft = Spls.DirectLeft();
   if (lleft.Extent() == 1) {
-    thePFace.Init(S,lleft.First(),F,V,fuse,Standard_True);
+    thePFace.Init(S, lleft.First(), F, V, fuse, Standard_True);
     ToPrism = lleft.First();
   }
   else {
@@ -472,11 +476,11 @@ static Standard_Integer PRW(Draw_Interpretor& theCommands,
     TopoDS_Shell Sh;
     B.MakeShell(Sh);
     TopTools_ListIteratorOfListOfShape it;
-    for (it.Initialize(lleft);it.More();it.Next()) {
-      B.Add(Sh,TopoDS::Face(it.Value()));
+    for (it.Initialize(lleft); it.More(); it.Next()) {
+      B.Add(Sh, TopoDS::Face(it.Value()));
     }
-    Sh.Closed (BRep_Tool::IsClosed (Sh));
-    thePFace.Init(S,Sh,F,V,fuse,Standard_True);
+    Sh.Closed(BRep_Tool::IsClosed(Sh));
+    thePFace.Init(S, Sh, F, V, fuse, Standard_True);
     ToPrism = Sh;
   }
 
@@ -484,8 +488,8 @@ static Standard_Integer PRW(Draw_Interpretor& theCommands,
   // du shape de depart
 
 //  for (TopExp_Explorer exp(S,TopAbs_FACE);exp.More();exp.Next()) {
-  TopExp_Explorer exp(S,TopAbs_FACE) ;
-  for ( ;exp.More();exp.Next()) {
+  TopExp_Explorer exp(S, TopAbs_FACE);
+  for (; exp.More(); exp.Next()) {
     if (exp.Current().IsSame(F)) {
       break;
     }
@@ -493,33 +497,33 @@ static Standard_Integer PRW(Draw_Interpretor& theCommands,
 
   if (!exp.More()) {
     LocOpe_FindEdgesInFace FEIF;
-    for (exp.Init(S,TopAbs_FACE);exp.More();exp.Next()) {
+    for (exp.Init(S, TopAbs_FACE); exp.More(); exp.Next()) {
       const TopoDS_Face& fac = TopoDS::Face(exp.Current());
       Handle(Geom_Surface) Su = BRep_Tool::Surface(fac);
       if (Su->DynamicType() == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
-	Su = Handle(Geom_RectangularTrimmedSurface)::
-	DownCast(Su)->BasisSurface();
+        Su = Handle(Geom_RectangularTrimmedSurface)::
+          DownCast(Su)->BasisSurface();
       }
       if (Su->DynamicType() == STANDARD_TYPE(Geom_Plane)) {
-	gp_Pln pl = Handle(Geom_Plane)::DownCast(Su)->Pln();
-	if (pl.Contains(gp_Lin(pl.Location(),V),
-			Precision::Confusion(),
-			Precision::Angular())) {
-	  FEIF.Set(ToPrism,fac);
-	  for (FEIF.Init();FEIF.More();FEIF.Next()) {
-	    thePFace.Add(FEIF.Edge(),fac);
-	  }
-	}
+        gp_Pln pl = Handle(Geom_Plane)::DownCast(Su)->Pln();
+        if (pl.Contains(gp_Lin(pl.Location(), V),
+          Precision::Confusion(),
+          Precision::Angular())) {
+          FEIF.Set(ToPrism, fac);
+          for (FEIF.Init(); FEIF.More(); FEIF.Next()) {
+            thePFace.Add(FEIF.Edge(), fac);
+          }
+        }
       }
       else if (Su->DynamicType() == STANDARD_TYPE(Geom_CylindricalSurface)) {
-	gp_Cylinder cy = 
-	  Handle(Geom_CylindricalSurface)::DownCast(Su)->Cylinder();
-	if (V.IsParallel(cy.Axis().Direction(),Precision::Angular())) {
-	  FEIF.Set(ToPrism,fac);
-	  for (FEIF.Init();FEIF.More();FEIF.Next()) {
-	    thePFace.Add(FEIF.Edge(),fac);
-	  }
-	}
+        gp_Cylinder cy =
+          Handle(Geom_CylindricalSurface)::DownCast(Su)->Cylinder();
+        if (V.IsParallel(cy.Axis().Direction(), Precision::Angular())) {
+          FEIF.Set(ToPrism, fac);
+          for (FEIF.Init(); FEIF.More(); FEIF.Next()) {
+            thePFace.Add(FEIF.Edge(), fac);
+          }
+        }
       }
     }
   }
@@ -532,14 +536,14 @@ static Standard_Integer PRW(Draw_Interpretor& theCommands,
   }
   else if (borne == 9) {
     if (!(FFrom.IsNull() || FUntil.IsNull())) {
-      thePFace.Perform(FFrom,FUntil);
+      thePFace.Perform(FFrom, FUntil);
     }
     else if (FFrom.IsNull()) {
       if (!FUntil.IsNull()) {
-	thePFace.PerformFromEnd(FUntil);
+        thePFace.PerformFromEnd(FUntil);
       }
       else {
-	thePFace.PerformThruAll();
+        thePFace.PerformThruAll();
       }
     }
     else {
@@ -553,7 +557,7 @@ static Standard_Integer PRW(Draw_Interpretor& theCommands,
     return 1;
   }
 
-  DBRep::Set(a[2],thePFace);
+  DBRep::Set(a[2], thePFace);
   dout.Flush();
   return 0;
 }
@@ -565,14 +569,14 @@ static Standard_Integer PRW(Draw_Interpretor& theCommands,
 //=======================================================================
 
 static Standard_Integer PRF(Draw_Interpretor& theCommands,
-			    Standard_Integer narg, const char** a)
+  Standard_Integer narg, const char** a)
 {
-  if (narg<8) return 1;
+  if (narg < 8) return 1;
   TopoDS_Shape S = DBRep::Get(a[3]);
   BRepFeat_MakePrism thePFace;
   Standard_Integer borne;
   gp_Vec V;
-  TopoDS_Shape FFrom,FUntil;
+  TopoDS_Shape FFrom, FUntil;
   Standard_Boolean fuse;
   if (a[1][0] == 'f' || a[1][0] == 'F') {
     fuse = Standard_True;
@@ -591,22 +595,22 @@ static Standard_Integer PRF(Draw_Interpretor& theCommands,
     }
     if (a[5][0] == '.' || IsAlphabetic(a[5][0])) {
       if (narg < 10) {
-	return 1;
+        return 1;
       }
       borne = 9;
-      V.SetCoord(Draw::Atof(a[6]),Draw::Atof(a[7]),Draw::Atof(a[8]));
-      FFrom  = DBRep::Get(a[4],TopAbs_SHAPE);
-      FUntil  = DBRep::Get(a[5],TopAbs_SHAPE);
+      V.SetCoord(Draw::Atof(a[6]), Draw::Atof(a[7]), Draw::Atof(a[8]));
+      FFrom = DBRep::Get(a[4], TopAbs_SHAPE);
+      FUntil = DBRep::Get(a[5], TopAbs_SHAPE);
     }
     else {
       borne = 8;
-      V.SetCoord(Draw::Atof(a[5]),Draw::Atof(a[6]),Draw::Atof(a[7]));
-      FUntil  = DBRep::Get(a[4],TopAbs_SHAPE);
+      V.SetCoord(Draw::Atof(a[5]), Draw::Atof(a[6]), Draw::Atof(a[7]));
+      FUntil = DBRep::Get(a[4], TopAbs_SHAPE);
     }
   }
   else {
     borne = 7;
-    V.SetCoord(Draw::Atof(a[4]),Draw::Atof(a[5]),Draw::Atof(a[6]));
+    V.SetCoord(Draw::Atof(a[4]), Draw::Atof(a[5]), Draw::Atof(a[6]));
   }
   Standard_Real Length = V.Magnitude();
   if (Length < Precision::Confusion()) {
@@ -614,41 +618,41 @@ static Standard_Integer PRF(Draw_Interpretor& theCommands,
   }
 
   TopoDS_Shape ToPrism;
-  if (narg == borne+1) {
-    TopoDS_Shape aLocalShape(DBRep::Get(a[borne],TopAbs_FACE));
-    TopoDS_Face F  = TopoDS::Face(aLocalShape);
-//    TopoDS_Face F  = TopoDS::Face(DBRep::Get(a[borne],TopAbs_FACE));
-    thePFace.Init(S,F,F,V,fuse,Standard_True);
+  if (narg == borne + 1) {
+    TopoDS_Shape aLocalShape(DBRep::Get(a[borne], TopAbs_FACE));
+    TopoDS_Face F = TopoDS::Face(aLocalShape);
+    //    TopoDS_Face F  = TopoDS::Face(DBRep::Get(a[borne],TopAbs_FACE));
+    thePFace.Init(S, F, F, V, fuse, Standard_True);
     ToPrism = F;
   }
   else {
     TopoDS_Shell She;
     BRep_Builder B;
     B.MakeShell(She);
-    for (Standard_Integer i=borne; i<narg; i++) {
-      TopoDS_Shape aLocalShape(DBRep::Get(a[i],TopAbs_FACE));
-      TopoDS_Face F  = TopoDS::Face(aLocalShape);
-//      TopoDS_Face F  = TopoDS::Face(DBRep::Get(a[i],TopAbs_FACE));
+    for (Standard_Integer i = borne; i < narg; i++) {
+      TopoDS_Shape aLocalShape(DBRep::Get(a[i], TopAbs_FACE));
+      TopoDS_Face F = TopoDS::Face(aLocalShape);
+      //      TopoDS_Face F  = TopoDS::Face(DBRep::Get(a[i],TopAbs_FACE));
       if (!F.IsNull()) {
-	B.Add(She,F);
+        B.Add(She, F);
       }
     }
-    She.Closed (BRep_Tool::IsClosed (She));
-    thePFace.Init(S,She,TopoDS_Face(),V,fuse,Standard_False);
+    She.Closed(BRep_Tool::IsClosed(She));
+    thePFace.Init(S, She, TopoDS_Face(), V, fuse, Standard_False);
     ToPrism = She;
   }
-  
+
   // Recherche des faces de glissement, on ne prisme pas une face
   // du shape de depart
 
 //  for (TopExp_Explorer exp(ToPrism,TopAbs_FACE);exp.More();exp.Next()) {
-  TopExp_Explorer exp(ToPrism,TopAbs_FACE) ;
-  for ( ;exp.More();exp.Next()) {
-//    for (TopExp_Explorer exp2(S,TopAbs_FACE);exp2.More();exp2.Next()) {
-    TopExp_Explorer exp2(S,TopAbs_FACE) ;
-    for ( ;exp2.More();exp2.Next()) {
+  TopExp_Explorer exp(ToPrism, TopAbs_FACE);
+  for (; exp.More(); exp.Next()) {
+    //    for (TopExp_Explorer exp2(S,TopAbs_FACE);exp2.More();exp2.Next()) {
+    TopExp_Explorer exp2(S, TopAbs_FACE);
+    for (; exp2.More(); exp2.Next()) {
       if (exp2.Current().IsSame(exp.Current())) {
-	break;
+        break;
       }
     }
     if (exp2.More()) {
@@ -658,33 +662,33 @@ static Standard_Integer PRF(Draw_Interpretor& theCommands,
 
   if (!exp.More()) {
     LocOpe_FindEdgesInFace FEIF;
-    for (exp.Init(S,TopAbs_FACE);exp.More();exp.Next()) {
+    for (exp.Init(S, TopAbs_FACE); exp.More(); exp.Next()) {
       const TopoDS_Face& fac = TopoDS::Face(exp.Current());
       Handle(Geom_Surface) Su = BRep_Tool::Surface(fac);
       if (Su->DynamicType() == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
-	Su = Handle(Geom_RectangularTrimmedSurface)::
-        DownCast(Su)->BasisSurface();
+        Su = Handle(Geom_RectangularTrimmedSurface)::
+          DownCast(Su)->BasisSurface();
       }
       if (Su->DynamicType() == STANDARD_TYPE(Geom_Plane)) {
-	gp_Pln pl = Handle(Geom_Plane)::DownCast(Su)->Pln();
-	if (pl.Contains(gp_Lin(pl.Location(),V),
-			Precision::Confusion(),
-			Precision::Angular())) {
-	  FEIF.Set(ToPrism,fac);
-	  for (FEIF.Init();FEIF.More();FEIF.Next()) {
-	    thePFace.Add(FEIF.Edge(),fac);
-	  }
-	}
+        gp_Pln pl = Handle(Geom_Plane)::DownCast(Su)->Pln();
+        if (pl.Contains(gp_Lin(pl.Location(), V),
+          Precision::Confusion(),
+          Precision::Angular())) {
+          FEIF.Set(ToPrism, fac);
+          for (FEIF.Init(); FEIF.More(); FEIF.Next()) {
+            thePFace.Add(FEIF.Edge(), fac);
+          }
+        }
       }
       else if (Su->DynamicType() == STANDARD_TYPE(Geom_CylindricalSurface)) {
-	gp_Cylinder cy = 
-	  Handle(Geom_CylindricalSurface)::DownCast(Su)->Cylinder();
-	if (V.IsParallel(cy.Axis().Direction(),Precision::Angular())) {
-	  FEIF.Set(ToPrism,fac);
-	  for (FEIF.Init();FEIF.More();FEIF.Next()) {
-	    thePFace.Add(FEIF.Edge(),fac);
-	  }
-	}
+        gp_Cylinder cy =
+          Handle(Geom_CylindricalSurface)::DownCast(Su)->Cylinder();
+        if (V.IsParallel(cy.Axis().Direction(), Precision::Angular())) {
+          FEIF.Set(ToPrism, fac);
+          for (FEIF.Init(); FEIF.More(); FEIF.Next()) {
+            thePFace.Add(FEIF.Edge(), fac);
+          }
+        }
       }
     }
   }
@@ -697,14 +701,14 @@ static Standard_Integer PRF(Draw_Interpretor& theCommands,
   }
   else if (borne == 9) {
     if (!(FFrom.IsNull() || FUntil.IsNull())) {
-      thePFace.Perform(FFrom,FUntil);
+      thePFace.Perform(FFrom, FUntil);
     }
     else if (FFrom.IsNull()) {
       if (!FUntil.IsNull()) {
-	thePFace.PerformFromEnd(FUntil);
+        thePFace.PerformFromEnd(FUntil);
       }
       else {
-	thePFace.PerformThruAll();
+        thePFace.PerformThruAll();
       }
     }
     else { //FUntil.IsNull()
@@ -718,7 +722,7 @@ static Standard_Integer PRF(Draw_Interpretor& theCommands,
     return 1;
   }
 
-  DBRep::Set(a[2],thePFace);
+  DBRep::Set(a[2], thePFace);
   dout.Flush();
   return 0;
 }
@@ -730,8 +734,8 @@ static Standard_Integer PRF(Draw_Interpretor& theCommands,
 //purpose  : 
 //=======================================================================
 
-static Standard_Integer SPLS(Draw_Interpretor& ,
-			     Standard_Integer narg, const char** a)
+static Standard_Integer SPLS(Draw_Interpretor&,
+  Standard_Integer narg, const char** a)
 {
   Standard_Integer newnarg;
 
@@ -746,34 +750,34 @@ static Standard_Integer SPLS(Draw_Interpretor& ,
   TopoDS_Shape S = DBRep::Get(a[2]);
   if (S.IsNull())
   {
-    std::cout << "Invalid input shape " << a[2]<<std::endl;
+    std::cout << "Invalid input shape " << a[2] << std::endl;
     return 1;
   }
   BRepFeat_SplitShape Spls(S);
   Standard_Boolean pick = Standard_False;
   TopoDS_Shape EF;
-  Standard_Real u,v;
+  Standard_Real u, v;
   Standard_Integer i = 3;
 
-  for ( newnarg=3; newnarg<narg; newnarg++) {
+  for (newnarg = 3; newnarg < narg; newnarg++) {
     if (a[newnarg][0] == '@') {
       break;
     }
   }
 
-  if (newnarg == 3 || 
-      (newnarg !=narg && ((narg-newnarg)<=2 || (narg-newnarg)%2 != 1))) {
+  if (newnarg == 3 ||
+    (newnarg != narg && ((narg - newnarg) <= 2 || (narg - newnarg) % 2 != 1))) {
     return 1;
   }
   Standard_Boolean isSplittingEdges = Standard_False;
   TopTools_SequenceOfShape aSplitEdges;
   if (i < newnarg) {
     pick = (a[i][0] == '.');
-   
+
     TopoDS_Shape aSh = DBRep::Get(a[i]);
     if (aSh.IsNull())
     {
-      std::cout << "Invalid input shape " <<a[i]<<std::endl;
+      std::cout << "Invalid input shape " << a[i] << std::endl;
       return 1;
     }
 
@@ -796,53 +800,53 @@ static Standard_Integer SPLS(Draw_Interpretor& ,
   i++;
   while (i < newnarg) {
     if (pick) {
-      DBRep_DrawableShape::LastPick(EF,u,v);
+      DBRep_DrawableShape::LastPick(EF, u, v);
     }
-    if (!isSplittingEdges  && !EF.IsNull() && EF.ShapeType() == TopAbs_FACE) {
+    if (!isSplittingEdges && !EF.IsNull() && EF.ShapeType() == TopAbs_FACE) {
       // face wire/edge ...
-     
+
       while (i < newnarg) {
-	TopoDS_Shape W;
-	Standard_Boolean rever = Standard_False;
-	if (a[i][0] == '-') {
-	  if (a[i][1] == '\0')
-	    return 1;
-	  pick = (a[i][1] == '.');
-	  const char* Temp = a[i]+1;
-	  W = DBRep::Get(Temp,TopAbs_SHAPE,Standard_False);
-	  rever = Standard_True;
-	}
-	else {
-	  pick = (a[i][0] == '.');
-	  W = DBRep::Get(a[i],TopAbs_SHAPE,Standard_False);
-	}
-	if (W.IsNull()) {
-	  return 1; // on n`a rien recupere
-	}
-	TopAbs_ShapeEnum wtyp = W.ShapeType();
-	if (wtyp != TopAbs_WIRE && wtyp != TopAbs_EDGE && wtyp != TopAbs_COMPOUND && pick) {
-	  DBRep_DrawableShape::LastPick(W,u,v);
-	  wtyp = W.ShapeType();
-	}
-	if (wtyp != TopAbs_WIRE && wtyp != TopAbs_EDGE && wtyp != TopAbs_COMPOUND) {
-	  EF = DBRep::Get(a[i]);
-	  break;
-	}
-	else {
-	  if (rever) {
-	    W.Reverse();
-	  }
-	  if (wtyp == TopAbs_WIRE) {
-	    Spls.Add(TopoDS::Wire(W),TopoDS::Face(EF));
-	  }
-	  else if (wtyp == TopAbs_EDGE) {
-	    Spls.Add(TopoDS::Edge(W),TopoDS::Face(EF));
-	  }
-          else {
-	    Spls.Add(TopoDS::Compound(W),TopoDS::Face(EF));
+        TopoDS_Shape W;
+        Standard_Boolean rever = Standard_False;
+        if (a[i][0] == '-') {
+          if (a[i][1] == '\0')
+            return 1;
+          pick = (a[i][1] == '.');
+          const char* Temp = a[i] + 1;
+          W = DBRep::Get(Temp, TopAbs_SHAPE, Standard_False);
+          rever = Standard_True;
+        }
+        else {
+          pick = (a[i][0] == '.');
+          W = DBRep::Get(a[i], TopAbs_SHAPE, Standard_False);
+        }
+        if (W.IsNull()) {
+          return 1; // on n`a rien recupere
+        }
+        TopAbs_ShapeEnum wtyp = W.ShapeType();
+        if (wtyp != TopAbs_WIRE && wtyp != TopAbs_EDGE && wtyp != TopAbs_COMPOUND && pick) {
+          DBRep_DrawableShape::LastPick(W, u, v);
+          wtyp = W.ShapeType();
+        }
+        if (wtyp != TopAbs_WIRE && wtyp != TopAbs_EDGE && wtyp != TopAbs_COMPOUND) {
+          EF = DBRep::Get(a[i]);
+          break;
+        }
+        else {
+          if (rever) {
+            W.Reverse();
           }
-	}
-	i++;
+          if (wtyp == TopAbs_WIRE) {
+            Spls.Add(TopoDS::Wire(W), TopoDS::Face(EF));
+          }
+          else if (wtyp == TopAbs_EDGE) {
+            Spls.Add(TopoDS::Edge(W), TopoDS::Face(EF));
+          }
+          else {
+            Spls.Add(TopoDS::Compound(W), TopoDS::Face(EF));
+          }
+        }
+        i++;
       }
     }
     else
@@ -852,7 +856,7 @@ static Standard_Integer SPLS(Draw_Interpretor& ,
         TopoDS_Shape aSh = DBRep::Get(a[i]);
         if (aSh.IsNull())
         {
-          std::cout << "Invalid input shape " <<a[i]<< std::endl;
+          std::cout << "Invalid input shape " << a[i] << std::endl;
           return 1;
         }
         TopExp_Explorer aExpE(aSh, TopAbs_EDGE, TopAbs_FACE);
@@ -861,40 +865,40 @@ static Standard_Integer SPLS(Draw_Interpretor& ,
       }
       else
       {
-         std::cout << "Invalid input arguments. Should be : splitshape result shape [splitedges] \
+        std::cout << "Invalid input arguments. Should be : splitshape result shape [splitedges] \
             [face wire/edge/compound [wire/edge/compound ...] \
             [face wire/edge/compound [wire/edge/compound...] ...] \
-            [@ edgeonshape edgeonwire [edgeonshape edgeonwire...]]"<<std::endl;
+            [@ edgeonshape edgeonwire [edgeonshape edgeonwire...]]" << std::endl;
         return 1;
       }
     }
     i++;
   }
-  
+
   if (isSplittingEdges)
     Spls.Add(aSplitEdges);
 
   // ici, i vaut newnarg
   for (; i < narg; i += 2) {
-    TopoDS_Shape Ew,Es;
-    TopoDS_Shape aLocalShape(DBRep::Get(a[i],TopAbs_EDGE));
+    TopoDS_Shape Ew, Es;
+    TopoDS_Shape aLocalShape(DBRep::Get(a[i], TopAbs_EDGE));
     Es = TopoDS::Edge(aLocalShape);
-//    Es = TopoDS::Edge(DBRep::Get(a[i],TopAbs_EDGE));
+    //    Es = TopoDS::Edge(DBRep::Get(a[i],TopAbs_EDGE));
     if (Es.IsNull()) {
       return 1;
     }
-    aLocalShape = DBRep::Get(a[i+1],TopAbs_EDGE);
+    aLocalShape = DBRep::Get(a[i + 1], TopAbs_EDGE);
     Ew = TopoDS::Edge(aLocalShape);
-//    Ew = TopoDS::Edge(DBRep::Get(a[i+1],TopAbs_EDGE));
+    //    Ew = TopoDS::Edge(DBRep::Get(a[i+1],TopAbs_EDGE));
     if (Ew.IsNull()) {
-      std::cout << "Invalid input shape " <<a[i+1]<< std::endl;
+      std::cout << "Invalid input shape " << a[i + 1] << std::endl;
       return 1;
     }
-    Spls.Add(TopoDS::Edge(Ew),TopoDS::Edge(Es));
+    Spls.Add(TopoDS::Edge(Ew), TopoDS::Edge(Es));
   }
 
 
-  DBRep::Set(a[1],Spls);
+  DBRep::Set(a[1], Spls);
   return 0;
 }
 
@@ -905,18 +909,18 @@ static Standard_Integer SPLS(Draw_Interpretor& ,
 Standard_Integer thickshell(Draw_Interpretor& theCommands,
   Standard_Integer n, const char** a)
 {
-  if ( n < 4) return 1;
-  TopoDS_Shape  S  = DBRep::Get(a[2]);
+  if (n < 4) return 1;
+  TopoDS_Shape  S = DBRep::Get(a[2]);
   if (S.IsNull()) return 1;
 
-  Standard_Real    Of    = Draw::Atof(a[3]);
+  Standard_Real    Of = Draw::Atof(a[3]);
 
-  GeomAbs_JoinType JT= GeomAbs_Arc;
+  GeomAbs_JoinType JT = GeomAbs_Arc;
   if (n > 4)
   {
-    if (!strcmp(a[4],"i"))
+    if (!strcmp(a[4], "i"))
       JT = GeomAbs_Intersection;
-    if (!strcmp(a[4],"t"))
+    if (!strcmp(a[4], "t"))
       JT = GeomAbs_Tangent;
   }
 
@@ -926,14 +930,14 @@ Standard_Integer thickshell(Draw_Interpretor& theCommands,
     Tol = Draw::Atof(a[5]);
 
   BRepOffset_MakeOffset B;
-  B.Initialize(S,Of,Tol,BRepOffset_Skin,Inter,0,JT,Standard_True);
+  B.Initialize(S, Of, Tol, BRepOffset_Skin, Inter, 0, JT, Standard_True);
 
   B.MakeOffsetShape();
 
   const BRepOffset_Error aRetCode = B.Error();
   reportOffsetState(theCommands, aRetCode);
 
-  DBRep::Set(a[1],B.Shape());
+  DBRep::Set(a[1], B.Shape());
   return 0;
 }
 
@@ -943,42 +947,42 @@ Standard_Integer thickshell(Draw_Interpretor& theCommands,
 //=======================================================================
 
 Standard_Integer offsetshape(Draw_Interpretor& theCommands,
-                             Standard_Integer n, const char** a)
+  Standard_Integer n, const char** a)
 {
-  if ( n < 4) return 1;
-  TopoDS_Shape  S  = DBRep::Get(a[2]);
+  if (n < 4) return 1;
+  TopoDS_Shape  S = DBRep::Get(a[2]);
   if (S.IsNull()) return 1;
 
-  Standard_Real    Of    = Draw::Atof(a[3]);
-  Standard_Boolean Inter = (!strcmp(a[0],"offsetcompshape"));
-  GeomAbs_JoinType JT= GeomAbs_Arc;
-  if (!strcmp(a[0],"offsetinter"))
+  Standard_Real    Of = Draw::Atof(a[3]);
+  Standard_Boolean Inter = (!strcmp(a[0], "offsetcompshape"));
+  GeomAbs_JoinType JT = GeomAbs_Arc;
+  if (!strcmp(a[0], "offsetinter"))
   {
-    JT    = GeomAbs_Intersection;
+    JT = GeomAbs_Intersection;
     Inter = Standard_True;
   }
-  
+
   BRepOffset_MakeOffset B;
-  Standard_Integer      IB  = 4;
+  Standard_Integer      IB = 4;
   Standard_Real         Tol = Precision::Confusion();
   if (n > 4)
   {
-    TopoDS_Shape  SF  = DBRep::Get(a[4],TopAbs_FACE);
+    TopoDS_Shape  SF = DBRep::Get(a[4], TopAbs_FACE);
     if (SF.IsNull())
     {
-      IB  = 5;
+      IB = 5;
       Tol = Draw::Atof(a[4]);
     }
   }
-  B.Initialize(S,Of,Tol,BRepOffset_Skin,Inter,0,JT);
+  B.Initialize(S, Of, Tol, BRepOffset_Skin, Inter, 0, JT);
   //------------------------------------------
   // recuperation et chargement des bouchons.
   //----------------------------------------
   Standard_Boolean YaBouchon = Standard_False;
 
-  for (Standard_Integer i = IB ; i < n; i++)
+  for (Standard_Integer i = IB; i < n; i++)
   {
-    TopoDS_Shape  SF  = DBRep::Get(a[i],TopAbs_FACE);
+    TopoDS_Shape  SF = DBRep::Get(a[i], TopAbs_FACE);
     if (!SF.IsNull())
     {
       YaBouchon = Standard_True;
@@ -987,12 +991,12 @@ Standard_Integer offsetshape(Draw_Interpretor& theCommands,
   }
 
   if (!YaBouchon)  B.MakeOffsetShape();
-  else             B.MakeThickSolid ();
+  else             B.MakeThickSolid();
 
   const BRepOffset_Error aRetCode = B.Error();
   reportOffsetState(theCommands, aRetCode);
 
-  DBRep::Set(a[1],B.Shape());
+  DBRep::Set(a[1], B.Shape());
 
   return 0;
 }
@@ -1001,30 +1005,31 @@ static BRepOffset_MakeOffset TheOffset;
 static Standard_Real         TheRadius;
 static Standard_Boolean      theYaBouchon;
 static Standard_Real         TheTolerance = Precision::Confusion();
-static Standard_Boolean      TheInter     = Standard_False;
-static GeomAbs_JoinType      TheJoin      = GeomAbs_Arc;
+static Standard_Boolean      TheInter = Standard_False;
+static GeomAbs_JoinType      TheJoin = GeomAbs_Arc;
 static Standard_Boolean      RemoveIntEdges = Standard_False;
 
 Standard_Integer offsetparameter(Draw_Interpretor& di,
-                                 Standard_Integer n, const char** a)
+  Standard_Integer n, const char** a)
 {
-  if ( n == 1 ) { 
+  if (n == 1) {
     di << " offsetparameter Tol Inter(c/p) JoinType(a/i/t) [RemoveInternalEdges(r/k)]\n";
     di << " Current Values\n";
     di << "   --> Tolerance : " << TheTolerance << "\n";
     di << "   --> TheInter  : ";
-    if ( TheInter) {
-      di << "Complet" ;
-    } else {
+    if (TheInter) {
+      di << "Complet";
+    }
+    else {
       di << "Partial";
     }
     di << "\n   --> TheJoin   : ";
-    
+
     switch (TheJoin) {
     case GeomAbs_Arc:          di << "Arc";          break;
     case GeomAbs_Intersection: di << "Intersection"; break;
     default:
-      break ;
+      break;
     }
     //
     di << "\n   --> Internal Edges : ";
@@ -1039,14 +1044,14 @@ Standard_Integer offsetparameter(Draw_Interpretor& di,
     return 0;
   }
 
-  if ( n < 4 ) return 1;
+  if (n < 4) return 1;
   //
   TheTolerance = Draw::Atof(a[1]);
-  TheInter     = strcmp(a[2],"p") != 0;
+  TheInter = strcmp(a[2], "p") != 0;
   //
-  if      ( !strcmp(a[3],"a")) TheJoin = GeomAbs_Arc;
-  else if ( !strcmp(a[3],"i")) TheJoin = GeomAbs_Intersection;
-  else if ( !strcmp(a[3],"t")) TheJoin = GeomAbs_Tangent;
+  if (!strcmp(a[3], "a")) TheJoin = GeomAbs_Arc;
+  else if (!strcmp(a[3], "i")) TheJoin = GeomAbs_Intersection;
+  else if (!strcmp(a[3], "t")) TheJoin = GeomAbs_Tangent;
   //
   RemoveIntEdges = (n >= 5) ? !strcmp(a[4], "r") : Standard_False;
   //
@@ -1058,24 +1063,24 @@ Standard_Integer offsetparameter(Draw_Interpretor& di,
 //purpose  : 
 //=======================================================================
 
-Standard_Integer offsetload(Draw_Interpretor& ,
+Standard_Integer offsetload(Draw_Interpretor&,
   Standard_Integer n, const char** a)
 {
-  if ( n < 2) return 1;
-  TopoDS_Shape  S  = DBRep::Get(a[1]);
+  if (n < 2) return 1;
+  TopoDS_Shape  S = DBRep::Get(a[1]);
   if (S.IsNull()) return 1;
 
-  Standard_Real    Of    = Draw::Atof(a[2]);
+  Standard_Real    Of = Draw::Atof(a[2]);
   TheRadius = Of;
-//  Standard_Boolean Inter = Standard_True;
-  
-  TheOffset.Initialize(S,Of,TheTolerance,BRepOffset_Skin,TheInter,0,TheJoin,
-                       Standard_False, RemoveIntEdges);
+  //  Standard_Boolean Inter = Standard_True;
+
+  TheOffset.Initialize(S, Of, TheTolerance, BRepOffset_Skin, TheInter, 0, TheJoin,
+    Standard_False, RemoveIntEdges);
   //------------------------------------------
   // recuperation et chargement des bouchons.
   //----------------------------------------
-  for (Standard_Integer i = 3 ; i < n; i++) {
-    TopoDS_Shape  SF  = DBRep::Get(a[i],TopAbs_FACE);
+  for (Standard_Integer i = 3; i < n; i++) {
+    TopoDS_Shape  SF = DBRep::Get(a[i], TopAbs_FACE);
     if (!SF.IsNull()) {
       TheOffset.AddFace(TopoDS::Face(SF));
     }
@@ -1094,16 +1099,16 @@ Standard_Integer offsetload(Draw_Interpretor& ,
 
 Standard_Integer offsetonface(Draw_Interpretor&, Standard_Integer n, const char** a)
 {
-  if ( n < 3) return 1;
+  if (n < 3) return 1;
 
-  for (Standard_Integer i = 1 ; i < n; i+=2) {
-    TopoDS_Shape  SF  = DBRep::Get(a[i],TopAbs_FACE);
+  for (Standard_Integer i = 1; i < n; i += 2) {
+    TopoDS_Shape  SF = DBRep::Get(a[i], TopAbs_FACE);
     if (!SF.IsNull()) {
-      Standard_Real Of = Draw::Atof(a[i+1]);
-      TheOffset.SetOffsetOnFace(TopoDS::Face(SF),Of);
+      Standard_Real Of = Draw::Atof(a[i + 1]);
+      TheOffset.SetOffsetOnFace(TopoDS::Face(SF), Of);
     }
   }
-  
+
   return 0;
 }
 
@@ -1113,35 +1118,35 @@ Standard_Integer offsetonface(Draw_Interpretor&, Standard_Integer n, const char*
 //=======================================================================
 
 Standard_Integer offsetperform(Draw_Interpretor& theCommands,
-                               Standard_Integer theNArg, const char** a)
-  {
-  if ( theNArg < 2) return 1;
+  Standard_Integer theNArg, const char** a)
+{
+  if (theNArg < 2) return 1;
 
   if (theYaBouchon)
-    TheOffset.MakeThickSolid ();
+    TheOffset.MakeThickSolid();
   else
     TheOffset.MakeOffsetShape();
 
-  if(TheOffset.IsDone())
-    {
-    DBRep::Set(a[1],TheOffset.Shape());
-    }
+  if (TheOffset.IsDone())
+  {
+    DBRep::Set(a[1], TheOffset.Shape());
+  }
   else
-    {
-      const BRepOffset_Error aRetCode = TheOffset.Error();
-      reportOffsetState(theCommands, aRetCode);
-    }
+  {
+    const BRepOffset_Error aRetCode = TheOffset.Error();
+    reportOffsetState(theCommands, aRetCode);
+  }
 
   // Store the history of Boolean operation into the session
   if (BRepTest_Objects::IsHistoryNeeded())
   {
     TopTools_ListOfShape aLA;
-    aLA.Append (TheOffset.InitShape());
+    aLA.Append(TheOffset.InitShape());
     BRepTest_Objects::SetHistory<BRepOffset_MakeOffset>(aLA, TheOffset);
   }
 
   return 0;
-  }
+}
 
 
 //=======================================================================
@@ -1150,16 +1155,16 @@ Standard_Integer offsetperform(Draw_Interpretor& theCommands,
 //=======================================================================
 
 static Standard_Integer ROW(Draw_Interpretor& theCommands,
-			    Standard_Integer narg, const char** a)
+  Standard_Integer narg, const char** a)
 {
-  if (narg<13) return 1;
+  if (narg < 13) return 1;
   TopoDS_Shape S = DBRep::Get(a[3]);
   BRepFeat_MakeRevol theRFace;
   gp_Dir D;
   gp_Pnt Or;
-  Standard_Real Angle=0;
-  TopoDS_Shape FFrom,FUntil;
-  Standard_Integer i,borne;
+  Standard_Real Angle = 0;
+  TopoDS_Shape FFrom, FUntil;
+  Standard_Integer i, borne;
   Standard_Boolean fuse;
 
   if (a[1][0] == 'f' || a[1][0] == 'F') {
@@ -1172,61 +1177,61 @@ static Standard_Integer ROW(Draw_Interpretor& theCommands,
     return 1;
   }
 
-  FFrom   = DBRep::Get(a[4],TopAbs_SHAPE);
+  FFrom = DBRep::Get(a[4], TopAbs_SHAPE);
   if (FFrom.IsNull()) {
     Angle = Draw::Atof(a[4]);
-    Angle *=M_PI/180.;
+    Angle *= M_PI / 180.;
     i = 5;
   }
   else {
-    FUntil = DBRep::Get(a[5],TopAbs_SHAPE);
+    FUntil = DBRep::Get(a[5], TopAbs_SHAPE);
     if (FUntil.IsNull()) {
       i = 5;
       FUntil = FFrom;
       FFrom.Nullify();
-      
+
     }
     else {
       if (narg < 14) {
-	return 1;
+        return 1;
       }
       i = 6;
     }
   }
-  borne = i+6;
+  borne = i + 6;
 
-  Or.SetCoord(Draw::Atof(a[i]),Draw::Atof(a[i+1]),Draw::Atof(a[i+2]));
-  D.SetCoord(Draw::Atof(a[i+3]),Draw::Atof(a[i+4]),Draw::Atof(a[i+5]));
-  gp_Ax1 theAxis(Or,D);
+  Or.SetCoord(Draw::Atof(a[i]), Draw::Atof(a[i + 1]), Draw::Atof(a[i + 2]));
+  D.SetCoord(Draw::Atof(a[i + 3]), Draw::Atof(a[i + 4]), Draw::Atof(a[i + 5]));
+  gp_Ax1 theAxis(Or, D);
 
-  TopoDS_Shape aLocalShape(DBRep::Get(a[borne],TopAbs_FACE));
-  TopoDS_Face F  = TopoDS::Face(aLocalShape);
-//  TopoDS_Face F  = TopoDS::Face(DBRep::Get(a[borne],TopAbs_FACE));
+  TopoDS_Shape aLocalShape(DBRep::Get(a[borne], TopAbs_FACE));
+  TopoDS_Face F = TopoDS::Face(aLocalShape);
+  //  TopoDS_Face F  = TopoDS::Face(DBRep::Get(a[borne],TopAbs_FACE));
   BRepFeat_SplitShape Spls(F);
-  for (i = borne+1; i<narg; i++) {
+  for (i = borne + 1; i < narg; i++) {
     TopoDS_Wire wir;
-    if (a[i][0] !='-') {
-      aLocalShape = DBRep::Get(a[i],TopAbs_WIRE);
+    if (a[i][0] != '-') {
+      aLocalShape = DBRep::Get(a[i], TopAbs_WIRE);
       wir = TopoDS::Wire(aLocalShape);
-//      wir = TopoDS::Wire(DBRep::Get(a[i],TopAbs_WIRE));
+      //      wir = TopoDS::Wire(DBRep::Get(a[i],TopAbs_WIRE));
     }
     else {
       if (a[i][1] == '\0')
-	return 1;
-      const char* Temp = a[i]+1;
-      aLocalShape = DBRep::Get(Temp,TopAbs_WIRE);
+        return 1;
+      const char* Temp = a[i] + 1;
+      aLocalShape = DBRep::Get(Temp, TopAbs_WIRE);
       wir = TopoDS::Wire(aLocalShape);
-//      wir = TopoDS::Wire(DBRep::Get(Temp,TopAbs_WIRE));
+      //      wir = TopoDS::Wire(DBRep::Get(Temp,TopAbs_WIRE));
       wir.Reverse();
     }
-    Spls.Add(wir,F);
+    Spls.Add(wir, F);
   }
   Spls.Build();
 
   TopoDS_Shape ToRotate;
   const TopTools_ListOfShape& lleft = Spls.DirectLeft();
   if (lleft.Extent() == 1) {
-    theRFace.Init(S,lleft.First(),F,theAxis,fuse,Standard_True);
+    theRFace.Init(S, lleft.First(), F, theAxis, fuse, Standard_True);
     ToRotate = lleft.First();
   }
   else {
@@ -1234,18 +1239,18 @@ static Standard_Integer ROW(Draw_Interpretor& theCommands,
     TopoDS_Shell Sh;
     B.MakeShell(Sh);
     TopTools_ListIteratorOfListOfShape it;
-    for (it.Initialize(lleft);it.More();it.Next()) {
-      B.Add(Sh,TopoDS::Face(it.Value()));
+    for (it.Initialize(lleft); it.More(); it.Next()) {
+      B.Add(Sh, TopoDS::Face(it.Value()));
     }
-    Sh.Closed (BRep_Tool::IsClosed (Sh));
-    theRFace.Init(S,Sh,F,theAxis,fuse,Standard_True);
+    Sh.Closed(BRep_Tool::IsClosed(Sh));
+    theRFace.Init(S, Sh, F, theAxis, fuse, Standard_True);
     ToRotate = Sh;
   }
 
   // Recherche des faces de glissement
 //  for (TopExp_Explorer exp(S,TopAbs_FACE);exp.More();exp.Next()) {
-  TopExp_Explorer exp(S,TopAbs_FACE) ;
-  for ( ;exp.More();exp.Next()) {
+  TopExp_Explorer exp(S, TopAbs_FACE);
+  for (; exp.More(); exp.Next()) {
     if (exp.Current().IsSame(F)) {
       break;
     }
@@ -1253,32 +1258,32 @@ static Standard_Integer ROW(Draw_Interpretor& theCommands,
 
   if (!exp.More()) {
     LocOpe_FindEdgesInFace FEIF;
-    for (exp.Init(S,TopAbs_FACE);exp.More();exp.Next()) {
+    for (exp.Init(S, TopAbs_FACE); exp.More(); exp.Next()) {
       const TopoDS_Face& fac = TopoDS::Face(exp.Current());
       Handle(Geom_Surface) Su = BRep_Tool::Surface(fac);
       if (Su->DynamicType() == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
-	Su = Handle(Geom_RectangularTrimmedSurface)::
-	  DownCast(Su)->BasisSurface();
+        Su = Handle(Geom_RectangularTrimmedSurface)::
+          DownCast(Su)->BasisSurface();
       }
       if (Su->DynamicType() == STANDARD_TYPE(Geom_Plane)) {
-	gp_Pln pl = Handle(Geom_Plane)::DownCast(Su)->Pln();
-	if (pl.Axis().IsParallel(theAxis,Precision::Angular())) {
-	  FEIF.Set(ToRotate,fac);
-	  for (FEIF.Init();FEIF.More();FEIF.Next()) {
-	    theRFace.Add(FEIF.Edge(),fac);
-	  }
-	}
+        gp_Pln pl = Handle(Geom_Plane)::DownCast(Su)->Pln();
+        if (pl.Axis().IsParallel(theAxis, Precision::Angular())) {
+          FEIF.Set(ToRotate, fac);
+          for (FEIF.Init(); FEIF.More(); FEIF.Next()) {
+            theRFace.Add(FEIF.Edge(), fac);
+          }
+        }
       }
       else if (Su->DynamicType() == STANDARD_TYPE(Geom_CylindricalSurface)) {
-	gp_Cylinder cy = 
-	  Handle(Geom_CylindricalSurface)::DownCast(Su)->Cylinder();
-	if (cy.Axis().IsCoaxial(theAxis,
-				Precision::Angular(),Precision::Confusion())) {
-	  FEIF.Set(ToRotate,fac);
-	  for (FEIF.Init();FEIF.More();FEIF.Next()) {
-	    theRFace.Add(FEIF.Edge(),fac);
-	  }
-	}
+        gp_Cylinder cy =
+          Handle(Geom_CylindricalSurface)::DownCast(Su)->Cylinder();
+        if (cy.Axis().IsCoaxial(theAxis,
+          Precision::Angular(), Precision::Confusion())) {
+          FEIF.Set(ToRotate, fac);
+          for (FEIF.Init(); FEIF.More(); FEIF.Next()) {
+            theRFace.Add(FEIF.Edge(), fac);
+          }
+        }
       }
     }
   }
@@ -1292,7 +1297,7 @@ static Standard_Integer ROW(Draw_Interpretor& theCommands,
     }
   }
   else { // borne == 12
-    theRFace.Perform(FFrom,FUntil);
+    theRFace.Perform(FFrom, FUntil);
   }
 
   if (!theRFace.IsDone()) {
@@ -1300,7 +1305,7 @@ static Standard_Integer ROW(Draw_Interpretor& theCommands,
     return 1;
   }
 
-  DBRep::Set(a[2],theRFace);
+  DBRep::Set(a[2], theRFace);
   dout.Flush();
   return 0;
 }
@@ -1312,16 +1317,16 @@ static Standard_Integer ROW(Draw_Interpretor& theCommands,
 //=======================================================================
 
 static Standard_Integer ROF(Draw_Interpretor& theCommands,
-			    Standard_Integer narg, const char** a)
+  Standard_Integer narg, const char** a)
 {
-  if (narg<12) return 1;
+  if (narg < 12) return 1;
   TopoDS_Shape S = DBRep::Get(a[3]);
   BRepFeat_MakeRevol theRFace;
   gp_Dir D;
   gp_Pnt Or;
-  Standard_Real Angle=0;
-  TopoDS_Shape FFrom,FUntil;
-  Standard_Integer i,borne;
+  Standard_Real Angle = 0;
+  TopoDS_Shape FFrom, FUntil;
+  Standard_Integer i, borne;
   Standard_Boolean fuse;
 
   if (a[1][0] == 'f' || a[1][0] == 'F') {
@@ -1334,67 +1339,67 @@ static Standard_Integer ROF(Draw_Interpretor& theCommands,
     return 1;
   }
 
-  FFrom   = DBRep::Get(a[4],TopAbs_SHAPE);
+  FFrom = DBRep::Get(a[4], TopAbs_SHAPE);
   if (FFrom.IsNull()) {
     Angle = Draw::Atof(a[4]);
-    Angle *=M_PI/180.;
+    Angle *= M_PI / 180.;
     i = 5;
   }
   else {
-    FUntil = DBRep::Get(a[5],TopAbs_SHAPE);
+    FUntil = DBRep::Get(a[5], TopAbs_SHAPE);
     if (FUntil.IsNull()) {
       i = 5;
       FUntil = FFrom;
       FFrom.Nullify();
-      
+
     }
     else {
       if (narg < 13) {
-	return 1;
+        return 1;
       }
       i = 6;
     }
   }
 
-  borne = i+6;
-  Or.SetCoord(Draw::Atof(a[i]),Draw::Atof(a[i+1]),Draw::Atof(a[i+2]));
-  D.SetCoord(Draw::Atof(a[i+3]),Draw::Atof(a[i+4]),Draw::Atof(a[i+5]));
-  gp_Ax1 theAxis(Or,D);
+  borne = i + 6;
+  Or.SetCoord(Draw::Atof(a[i]), Draw::Atof(a[i + 1]), Draw::Atof(a[i + 2]));
+  D.SetCoord(Draw::Atof(a[i + 3]), Draw::Atof(a[i + 4]), Draw::Atof(a[i + 5]));
+  gp_Ax1 theAxis(Or, D);
 
   TopoDS_Shape ToRotate;
-  if (narg == borne+1) {
-    TopoDS_Shape aLocalShape(DBRep::Get(a[borne],TopAbs_FACE));
-    TopoDS_Face F  = TopoDS::Face(aLocalShape);
-//    TopoDS_Face F  = TopoDS::Face(DBRep::Get(a[borne],TopAbs_FACE));
-    theRFace.Init(S,F,F,theAxis,fuse,Standard_True);
+  if (narg == borne + 1) {
+    TopoDS_Shape aLocalShape(DBRep::Get(a[borne], TopAbs_FACE));
+    TopoDS_Face F = TopoDS::Face(aLocalShape);
+    //    TopoDS_Face F  = TopoDS::Face(DBRep::Get(a[borne],TopAbs_FACE));
+    theRFace.Init(S, F, F, theAxis, fuse, Standard_True);
     ToRotate = F;
   }
   else {
     TopoDS_Shell She;
     BRep_Builder B;
     B.MakeShell(She);
-    
-    for (i=borne; i<narg; i++) {
-      TopoDS_Shape aLocalShape(DBRep::Get(a[i],TopAbs_FACE));
-      TopoDS_Face F  = TopoDS::Face(aLocalShape);
-//      TopoDS_Face F  = TopoDS::Face(DBRep::Get(a[i],TopAbs_FACE));
+
+    for (i = borne; i < narg; i++) {
+      TopoDS_Shape aLocalShape(DBRep::Get(a[i], TopAbs_FACE));
+      TopoDS_Face F = TopoDS::Face(aLocalShape);
+      //      TopoDS_Face F  = TopoDS::Face(DBRep::Get(a[i],TopAbs_FACE));
       if (!F.IsNull()) {
-	B.Add(She,F);
+        B.Add(She, F);
       }
     }
-    She.Closed (BRep_Tool::IsClosed (She));
-    theRFace.Init(S,She,TopoDS_Face(),theAxis,fuse,Standard_False);
+    She.Closed(BRep_Tool::IsClosed(She));
+    theRFace.Init(S, She, TopoDS_Face(), theAxis, fuse, Standard_False);
     ToRotate = She;
   }
 
-//  for (TopExp_Explorer exp(ToRotate,TopAbs_FACE);exp.More();exp.Next()) {
-  TopExp_Explorer exp(ToRotate,TopAbs_FACE) ;
-  for ( ;exp.More();exp.Next()) {
-//    for (TopExp_Explorer exp2(S,TopAbs_FACE);exp2.More();exp2.Next()) {
-    TopExp_Explorer exp2(S,TopAbs_FACE) ;
-    for ( ;exp2.More();exp2.Next()) {
+  //  for (TopExp_Explorer exp(ToRotate,TopAbs_FACE);exp.More();exp.Next()) {
+  TopExp_Explorer exp(ToRotate, TopAbs_FACE);
+  for (; exp.More(); exp.Next()) {
+    //    for (TopExp_Explorer exp2(S,TopAbs_FACE);exp2.More();exp2.Next()) {
+    TopExp_Explorer exp2(S, TopAbs_FACE);
+    for (; exp2.More(); exp2.Next()) {
       if (exp2.Current().IsSame(exp.Current())) {
-	break;
+        break;
       }
     }
     if (exp2.More()) {
@@ -1404,32 +1409,32 @@ static Standard_Integer ROF(Draw_Interpretor& theCommands,
 
   if (!exp.More()) {
     LocOpe_FindEdgesInFace FEIF;
-    for (exp.Init(S,TopAbs_FACE);exp.More();exp.Next()) {
+    for (exp.Init(S, TopAbs_FACE); exp.More(); exp.Next()) {
       const TopoDS_Face& fac = TopoDS::Face(exp.Current());
       Handle(Geom_Surface) Su = BRep_Tool::Surface(fac);
       if (Su->DynamicType() == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
-	Su = Handle(Geom_RectangularTrimmedSurface)::
-	  DownCast(Su)->BasisSurface();
+        Su = Handle(Geom_RectangularTrimmedSurface)::
+          DownCast(Su)->BasisSurface();
       }
       if (Su->DynamicType() == STANDARD_TYPE(Geom_Plane)) {
-	gp_Pln pl = Handle(Geom_Plane)::DownCast(Su)->Pln();
-	if (pl.Axis().IsParallel(theAxis,Precision::Angular())) {
-	  FEIF.Set(ToRotate,fac);
-	  for (FEIF.Init();FEIF.More();FEIF.Next()) {
-	    theRFace.Add(FEIF.Edge(),fac);
-	  }
-	}
+        gp_Pln pl = Handle(Geom_Plane)::DownCast(Su)->Pln();
+        if (pl.Axis().IsParallel(theAxis, Precision::Angular())) {
+          FEIF.Set(ToRotate, fac);
+          for (FEIF.Init(); FEIF.More(); FEIF.Next()) {
+            theRFace.Add(FEIF.Edge(), fac);
+          }
+        }
       }
       else if (Su->DynamicType() == STANDARD_TYPE(Geom_CylindricalSurface)) {
-	gp_Cylinder cy = 
-	  Handle(Geom_CylindricalSurface)::DownCast(Su)->Cylinder();
-	if (cy.Axis().IsCoaxial(theAxis,
-				Precision::Angular(),Precision::Confusion())) {
-	  FEIF.Set(ToRotate,fac);
-	  for (FEIF.Init();FEIF.More();FEIF.Next()) {
-	    theRFace.Add(FEIF.Edge(),fac);
-	  }
-	}
+        gp_Cylinder cy =
+          Handle(Geom_CylindricalSurface)::DownCast(Su)->Cylinder();
+        if (cy.Axis().IsCoaxial(theAxis,
+          Precision::Angular(), Precision::Confusion())) {
+          FEIF.Set(ToRotate, fac);
+          for (FEIF.Init(); FEIF.More(); FEIF.Next()) {
+            theRFace.Add(FEIF.Edge(), fac);
+          }
+        }
       }
     }
   }
@@ -1443,7 +1448,7 @@ static Standard_Integer ROF(Draw_Interpretor& theCommands,
     }
   }
   else { // borne == 12
-    theRFace.Perform(FFrom,FUntil);
+    theRFace.Perform(FFrom, FUntil);
   }
 
   if (!theRFace.IsDone()) {
@@ -1451,7 +1456,7 @@ static Standard_Integer ROF(Draw_Interpretor& theCommands,
     return 1;
   }
 
-  DBRep::Set(a[2],theRFace);
+  DBRep::Set(a[2], theRFace);
   dout.Flush();
   return 0;
 }
@@ -1462,23 +1467,23 @@ static Standard_Integer ROF(Draw_Interpretor& theCommands,
 //purpose  : Commande glue
 //=======================================================================
 
-static Standard_Integer GLU(Draw_Interpretor& ,
-			    Standard_Integer narg, const char** a)
+static Standard_Integer GLU(Draw_Interpretor&,
+  Standard_Integer narg, const char** a)
 {
-  if (narg<6 || narg%2 != 0) return 1;
+  if (narg < 6 || narg % 2 != 0) return 1;
   TopoDS_Shape Sne = DBRep::Get(a[2]);
   TopoDS_Shape Sba = DBRep::Get(a[3]);
-  
+
   Standard_Boolean pick;
-  
-  BRepFeat_Gluer theGl(Sne,Sba);
-  TopoDS_Shape Fne,Fba;
-  
+
+  BRepFeat_Gluer theGl(Sne, Sba);
+  TopoDS_Shape Fne, Fba;
+
   LocOpe_FindEdges fined;
 
   Standard_Integer i = 4;
   Standard_Boolean first = Standard_True;
-  while (i<narg) {
+  while (i < narg) {
     pick = (a[i][0] == '.');
     Fne = DBRep::Get(a[i]);
     if (Fne.IsNull()) {
@@ -1486,22 +1491,22 @@ static Standard_Integer GLU(Draw_Interpretor& ,
     }
     TopAbs_ShapeEnum sht = Fne.ShapeType();
     if (pick && sht != TopAbs_FACE && sht != TopAbs_EDGE) {
-      Standard_Real u,v;
-      DBRep_DrawableShape::LastPick(Fne,u,v);
+      Standard_Real u, v;
+      DBRep_DrawableShape::LastPick(Fne, u, v);
       sht = Fne.ShapeType();
     }
     if (first && sht != TopAbs_FACE) {
       return 1;
     }
     first = Standard_False;
-    pick = (a[i+1][0] == '.');
-    Fba = DBRep::Get(a[i+1]);
+    pick = (a[i + 1][0] == '.');
+    Fba = DBRep::Get(a[i + 1]);
     if (Fba.IsNull()) {
       return 1;
     }
     if (pick && Fba.ShapeType() != sht) {
-      Standard_Real u,v;
-      DBRep_DrawableShape::LastPick(Fba,u,v);
+      Standard_Real u, v;
+      DBRep_DrawableShape::LastPick(Fba, u, v);
     }
     if (Fba.ShapeType() != sht) {
       return 1;
@@ -1509,42 +1514,42 @@ static Standard_Integer GLU(Draw_Interpretor& ,
     if (sht == TopAbs_FACE) {
       const TopoDS_Face& f1 = TopoDS::Face(Fne);
       const TopoDS_Face& f2 = TopoDS::Face(Fba);
-      theGl.Bind(f1,f2);
-      fined.Set(Fne,Fba);
+      theGl.Bind(f1, f2);
+      fined.Set(Fne, Fba);
       for (fined.InitIterator(); fined.More(); fined.Next()) {
-	theGl.Bind(fined.EdgeFrom(),fined.EdgeTo());
+        theGl.Bind(fined.EdgeFrom(), fined.EdgeTo());
       }
     }
     else {
-      theGl.Bind(TopoDS::Edge(Fne),TopoDS::Edge(Fba));
+      theGl.Bind(TopoDS::Edge(Fne), TopoDS::Edge(Fba));
     }
-    i +=2;
+    i += 2;
   }
-  
-  DBRep::Set(a[1],theGl);
+
+  DBRep::Set(a[1], theGl);
   dout.Flush();
   return 0;
 }
 
 static Standard_Integer DEFIN(Draw_Interpretor& theCommands,
-			      Standard_Integer narg, const char** a)
+  Standard_Integer narg, const char** a)
 {
 
-  if (strcasecmp(a[0],"FEATPRISM") &&
-      strcasecmp(a[0],"FEATDPRISM") &&
-      strcasecmp(a[0],"FEATREVOL") &&
-      strcasecmp(a[0],"FEATPIPE") &&
-      strcasecmp(a[0],"FEATLF")  &&
-      strcasecmp(a[0],"FEATRF")) {
+  if (strcasecmp(a[0], "FEATPRISM") &&
+    strcasecmp(a[0], "FEATDPRISM") &&
+    strcasecmp(a[0], "FEATREVOL") &&
+    strcasecmp(a[0], "FEATPIPE") &&
+    strcasecmp(a[0], "FEATLF") &&
+    strcasecmp(a[0], "FEATRF")) {
     return 1;
   }
 
-  if ((!strcasecmp(a[0],"FEATPRISM") && narg !=9) ||
-      (!strcasecmp(a[0],"FEATREVOL") && narg != 12) ||
-      (!strcasecmp(a[0],"FEATDPRISM") && narg != 7) ||
-      (!strcasecmp(a[0],"FEATPIPE") && narg != 7) ||
-      (!strcasecmp(a[0],"FEATLF") && narg != 12) ||
-      (!strcasecmp(a[0],"FEATRF") && narg != 14)) {
+  if ((!strcasecmp(a[0], "FEATPRISM") && narg != 9) ||
+    (!strcasecmp(a[0], "FEATREVOL") && narg != 12) ||
+    (!strcasecmp(a[0], "FEATDPRISM") && narg != 7) ||
+    (!strcasecmp(a[0], "FEATPIPE") && narg != 7) ||
+    (!strcasecmp(a[0], "FEATLF") && narg != 12) ||
+    (!strcasecmp(a[0], "FEATRF") && narg != 14)) {
     theCommands << "invalid number of arguments";
     return 1;
   }
@@ -1554,11 +1559,11 @@ static Standard_Integer DEFIN(Draw_Interpretor& theCommands,
     theCommands << "null basis shape";
     return 1;
   }
-  Standard_Integer Ifuse  = Draw::Atoi(a[narg-2]);
-  Standard_Integer Imodif = Draw::Atoi(a[narg-1]);
-  
+  Standard_Integer Ifuse = Draw::Atoi(a[narg - 2]);
+  Standard_Integer Imodif = Draw::Atoi(a[narg - 1]);
+
   Standard_Integer Fuse = Ifuse;
-  Standard_Boolean Modify = (Imodif!=0);
+  Standard_Boolean Modify = (Imodif != 0);
 
   TopoDS_Shape Pbase;
   TopoDS_Face Skface;
@@ -1568,15 +1573,15 @@ static Standard_Integer DEFIN(Draw_Interpretor& theCommands,
 
   BRepFeat_StatusError se;
 
-  if (strcasecmp(a[0],"FEATLF") && strcasecmp(a[0],"FEATRF")) {
+  if (strcasecmp(a[0], "FEATLF") && strcasecmp(a[0], "FEATRF")) {
     Pbase = DBRep::Get(a[2]);
     if (Pbase.IsNull()) {
       theCommands << "null shape to transform";
       return 1;
     }
-    TopoDS_Shape aLocalShape(DBRep::Get(a[3],TopAbs_FACE));
+    TopoDS_Shape aLocalShape(DBRep::Get(a[3], TopAbs_FACE));
     Skface = TopoDS::Face(aLocalShape);
-//    Skface = TopoDS::Face(DBRep::Get(a[3],TopAbs_FACE));
+    //    Skface = TopoDS::Face(DBRep::Get(a[3],TopAbs_FACE));
     if (Skface.IsNull()) {
       theCommands << "null face of Sketch";
       return 1;
@@ -1585,30 +1590,33 @@ static Standard_Integer DEFIN(Draw_Interpretor& theCommands,
   else {
     TopoDS_Shape aLocalShape(DBRep::Get(a[2], TopAbs_WIRE));
     W = TopoDS::Wire(aLocalShape);
-//    W = TopoDS::Wire(DBRep::Get(a[2], TopAbs_WIRE));
-    if(W.IsNull()) {
+    //    W = TopoDS::Wire(DBRep::Get(a[2], TopAbs_WIRE));
+    if (W.IsNull()) {
       theCommands << "null profile for rib or slot";
       return 1;
     }
     Handle(Geom_Surface) s = DrawTrSurf::GetSurface(a[3]);
     P = Handle(Geom_Plane)::DownCast(s);
-    if(P.IsNull()) {
+    if (P.IsNull()) {
       theCommands << "null plane to transform";
       return 1;
     }
   }
   if (narg == 9 || narg == 12 || narg == 14) {
-//    Standard_Real X,Y,Z,X1,Y1,Z1;
-    Standard_Real X,Y,Z;
+    //    Standard_Real X,Y,Z,X1,Y1,Z1;
+    Standard_Real X, Y, Z;
     X = Draw::Atof(a[4]);
     Y = Draw::Atof(a[5]);
     Z = Draw::Atof(a[6]);
-    
+
     if (narg == 9) { // prism
-      prdef = Standard_True;      
-      thePrism.Init(Sbase,Pbase,Skface,gp_Dir(X,Y,Z),Fuse,Modify);
+      prdef = Standard_True;
+      theSbase = Sbase;
+      thePbase = Pbase;
+      theSkface = Skface;
+      thePrism.Init(Sbase, Pbase, Skface, gp_Dir(X, Y, Z), Fuse, Modify);
     }
-    else if(narg == 14) {
+    else if (narg == 14) {
       rfdef = Standard_True;
       gp_Pnt Or(X, Y, Z);
       X = Draw::Atof(a[7]);
@@ -1619,66 +1627,75 @@ static Standard_Integer DEFIN(Draw_Interpretor& theCommands,
       gp_Ax1 ax1(Or, gp_Dir(X, Y, Z));
       theRF.Init(Sbase, W, P, ax1, H1, H2, Fuse, Modify);
       if (!theRF.IsDone()) {
-	se = theRF.CurrentStatusError();
-	//BRepFeat::Print(se,std::cout) << std::endl;
-	Standard_SStream aSStream;
-	BRepFeat::Print(se,aSStream);
-	theCommands << aSStream << "\n";
-	return 1;
+        se = theRF.CurrentStatusError();
+        //BRepFeat::Print(se,std::cout) << std::endl;
+        Standard_SStream aSStream;
+        BRepFeat::Print(se, aSStream);
+        theCommands << aSStream << "\n";
+        return 1;
       }
     }
-    else if(narg == 12 && strcasecmp(a[0],"FEATLF")) {
+    else if (narg == 12 && strcasecmp(a[0], "FEATLF")) {
       rvdef = Standard_True;
-      gp_Pnt Or(X,Y,Z);
+      gp_Pnt Or(X, Y, Z);
       X = Draw::Atof(a[7]);
       Y = Draw::Atof(a[8]);
       Z = Draw::Atof(a[9]);
-      theRevol.Init(Sbase,Pbase,Skface,gp_Ax1(Or,gp_Dir(X,Y,Z)),
-		    Fuse,Modify);
+      theSbase = Sbase;
+      thePbase = Pbase;
+      theSkface = Skface;
+      theRevol.Init(Sbase, Pbase, Skface, gp_Ax1(Or, gp_Dir(X, Y, Z)),
+        Fuse, Modify);
     }
     else {
       lfdef = Standard_True;
-      gp_Vec Direct(X,Y,Z);
+      gp_Vec Direct(X, Y, Z);
       X = Draw::Atof(a[7]);
       Y = Draw::Atof(a[8]);
       Z = Draw::Atof(a[9]);
-      theLF.Init(Sbase, W, P, Direct, gp_Vec(X,Y,Z), Fuse,Modify);
+      theLF.Init(Sbase, W, P, Direct, gp_Vec(X, Y, Z), Fuse, Modify);
       if (!theLF.IsDone()) {
-	se = theLF.CurrentStatusError();
-	//BRepFeat::Print(se,std::cout) << std::endl;
-	Standard_SStream aSStream;
-	BRepFeat::Print(se,aSStream);
-	theCommands << aSStream << "\n";
-	return 1;
+        se = theLF.CurrentStatusError();
+        //BRepFeat::Print(se,std::cout) << std::endl;
+        Standard_SStream aSStream;
+        BRepFeat::Print(se, aSStream);
+        theCommands << aSStream << "\n";
+        return 1;
       }
     }
   }
   else if (narg == 7) {
-    if (!strcasecmp(a[0],"FEATDPRISM")) {
+    if (!strcasecmp(a[0], "FEATDPRISM")) {
       if (Pbase.ShapeType() != TopAbs_FACE) {
-	theCommands << "Invalid DPrism base";
-	return 1;
+        theCommands << "Invalid DPrism base";
+        return 1;
       }
-      Standard_Real Angle = Draw::Atof(a[4])*M_PI/360; 
+      Standard_Real Angle = Draw::Atof(a[4])*M_PI / 360;
       dprdef = Standard_True;
-      theDPrism.Init(Sbase,TopoDS::Face(Pbase),Skface,Angle,Fuse,Modify);
+      theSbase = Sbase;
+      thePbase = Pbase;
+      theSkface = Skface;
+      theDPrism.Init(Sbase, TopoDS::Face(Pbase), Skface, Angle, Fuse, Modify);
     }
     else { // FEATPIPE
-      TopoDS_Shape aLocalShape(DBRep::Get(a[4],TopAbs_WIRE));
+      TopoDS_Shape aLocalShape(DBRep::Get(a[4], TopAbs_WIRE));
       TopoDS_Wire Spine = TopoDS::Wire(aLocalShape);
-//      TopoDS_Wire Spine = TopoDS::Wire(DBRep::Get(a[4],TopAbs_WIRE));
+      //      TopoDS_Wire Spine = TopoDS::Wire(DBRep::Get(a[4],TopAbs_WIRE));
       if (Spine.IsNull()) {
-	TopoDS_Shape Edspine =DBRep::Get(a[4],TopAbs_EDGE);
-	if (Edspine.IsNull()) {
-	  theCommands << "null spine";
-	  return 1;
-	}
-	BRep_Builder B;
-	B.MakeWire(Spine);
-	B.Add(Spine,Edspine);
+        TopoDS_Shape Edspine = DBRep::Get(a[4], TopAbs_EDGE);
+        if (Edspine.IsNull()) {
+          theCommands << "null spine";
+          return 1;
+        }
+        BRep_Builder B;
+        B.MakeWire(Spine);
+        B.Add(Spine, Edspine);
       }
       pidef = Standard_True;
-      thePipe.Init(Sbase,Pbase,Skface,Spine,Fuse,Modify);
+      theSbase = Sbase;
+      thePbase = Pbase;
+      theSkface = Skface;
+      thePipe.Init(Sbase, Pbase, Skface, Spine, Fuse, Modify);
     }
   }
   return 0;
@@ -1686,71 +1703,71 @@ static Standard_Integer DEFIN(Draw_Interpretor& theCommands,
 
 
 
-static Standard_Integer ADD(Draw_Interpretor& ,
-			    Standard_Integer narg, const char** a)
+static Standard_Integer ADD(Draw_Interpretor&,
+  Standard_Integer narg, const char** a)
 {
-  Standard_Integer i ;
-  if (narg < 4 || narg%2 != 0) {
+  Standard_Integer i;
+  if (narg < 4 || narg % 2 != 0) {
     return 1;
   }
-  if (!strcasecmp("PRISM",a[1])) {
+  if (!strcasecmp("PRISM", a[1])) {
     if (!prdef) {
       return 1;
     }
-    for ( i=2; i<narg; i+=2) {
-      TopoDS_Shape aLocalShape(DBRep::Get(a[i],TopAbs_EDGE));
+    for (i = 2; i < narg; i += 2) {
+      TopoDS_Shape aLocalShape(DBRep::Get(a[i], TopAbs_EDGE));
       TopoDS_Edge edg = TopoDS::Edge(aLocalShape);
-//      TopoDS_Edge edg = TopoDS::Edge(DBRep::Get(a[i],TopAbs_EDGE));
+      //      TopoDS_Edge edg = TopoDS::Edge(DBRep::Get(a[i],TopAbs_EDGE));
       if (edg.IsNull()) {
-	return 1;
+        return 1;
       }
-      aLocalShape = DBRep::Get(a[i+1],TopAbs_FACE);
+      aLocalShape = DBRep::Get(a[i + 1], TopAbs_FACE);
       TopoDS_Face fac = TopoDS::Face(aLocalShape);
-//      TopoDS_Face fac = TopoDS::Face(DBRep::Get(a[i+1],TopAbs_FACE));
+      //      TopoDS_Face fac = TopoDS::Face(DBRep::Get(a[i+1],TopAbs_FACE));
       if (fac.IsNull()) {
-	return 1;
+        return 1;
       }
-      thePrism.Add(edg,fac);
+      thePrism.Add(edg, fac);
     }
   }
-  else if (!strcasecmp("REVOL",a[1])) {
+  else if (!strcasecmp("REVOL", a[1])) {
     if (!rvdef) {
       return 1;
     }
-    for ( i=2; i<narg; i+=2) {
-      TopoDS_Shape aLocalShape(DBRep::Get(a[i],TopAbs_EDGE));
+    for (i = 2; i < narg; i += 2) {
+      TopoDS_Shape aLocalShape(DBRep::Get(a[i], TopAbs_EDGE));
       TopoDS_Edge edg = TopoDS::Edge(aLocalShape);
-//      TopoDS_Edge edg = TopoDS::Edge(DBRep::Get(a[i],TopAbs_EDGE));
+      //      TopoDS_Edge edg = TopoDS::Edge(DBRep::Get(a[i],TopAbs_EDGE));
       if (edg.IsNull()) {
-	return 1;
+        return 1;
       }
-      aLocalShape = DBRep::Get(a[i+1],TopAbs_FACE);
+      aLocalShape = DBRep::Get(a[i + 1], TopAbs_FACE);
       TopoDS_Face fac = TopoDS::Face(aLocalShape);
-//      TopoDS_Face fac = TopoDS::Face(DBRep::Get(a[i+1],TopAbs_FACE));
+      //      TopoDS_Face fac = TopoDS::Face(DBRep::Get(a[i+1],TopAbs_FACE));
       if (fac.IsNull()) {
-	return 1;
+        return 1;
       }
-      theRevol.Add(edg,fac);
+      theRevol.Add(edg, fac);
     }
   }
-  else if (!strcasecmp("PIPE",a[1])) {
+  else if (!strcasecmp("PIPE", a[1])) {
     if (!pidef) {
       return 1;
     }
-    for ( i=2; i<narg; i+=2) {
-      TopoDS_Shape aLocalShape(DBRep::Get(a[i],TopAbs_EDGE));
+    for (i = 2; i < narg; i += 2) {
+      TopoDS_Shape aLocalShape(DBRep::Get(a[i], TopAbs_EDGE));
       TopoDS_Edge edg = TopoDS::Edge(aLocalShape);
-//      TopoDS_Edge edg = TopoDS::Edge(DBRep::Get(a[i],TopAbs_EDGE));
+      //      TopoDS_Edge edg = TopoDS::Edge(DBRep::Get(a[i],TopAbs_EDGE));
       if (edg.IsNull()) {
-	return 1;
+        return 1;
       }
-      aLocalShape = DBRep::Get(a[i+1],TopAbs_FACE);
+      aLocalShape = DBRep::Get(a[i + 1], TopAbs_FACE);
       TopoDS_Face fac = TopoDS::Face(aLocalShape);
-//      TopoDS_Face fac = TopoDS::Face(DBRep::Get(a[i+1],TopAbs_FACE));
+      //      TopoDS_Face fac = TopoDS::Face(DBRep::Get(a[i+1],TopAbs_FACE));
       if (fac.IsNull()) {
-	return 1;
+        return 1;
       }
-      thePipe.Add(edg,fac);
+      thePipe.Add(edg, fac);
     }
   }
   else {
@@ -1762,67 +1779,68 @@ static Standard_Integer ADD(Draw_Interpretor& ,
 
 
 static Standard_Integer PERF(Draw_Interpretor& theCommands,
-			    Standard_Integer narg, const char** a)
+  Standard_Integer narg, const char** a)
 {
   if (narg < 3) {
     return 1;
   }
-  if (strcasecmp(a[0],"FEATPERFORM") &&
-      strcasecmp(a[0],"FEATPERFORMVAL")) {
+  if (strcasecmp(a[0], "FEATPERFORM") &&
+    strcasecmp(a[0], "FEATPERFORMVAL")) {
     return 1;
   }
 
+  TopTools_ListOfShape anArgs;
   Standard_Integer Kas;
-  if (!strcasecmp("PRISM",a[1])) {
+  if (!strcasecmp("PRISM", a[1])) {
     Kas = 1;
     if (!prdef) {
       theCommands << "prism not defined";
       return 1;
     }
   }
-  else if (!strcasecmp("REVOL",a[1])) {
+  else if (!strcasecmp("REVOL", a[1])) {
     Kas = 2;
     if (!rvdef) {
       theCommands << "revol not defined";
       return 1;
     }
   }
-  else if (!strcasecmp("PIPE",a[1])) {
+  else if (!strcasecmp("PIPE", a[1])) {
     Kas = 3;
     if (!pidef) {
       theCommands << "pipe not defined";
       return 1;
     }
-    if (!strcasecmp(a[0],"FEATPERFORMVAL")) {
+    if (!strcasecmp(a[0], "FEATPERFORMVAL")) {
       theCommands << "invalid command for pipe";
       return 1;
     }
   }
-  else if (!strcasecmp("DPRISM",a[1])) {
+  else if (!strcasecmp("DPRISM", a[1])) {
     Kas = 4;
     if (!dprdef) {
       theCommands << "dprism not defined";
       return 1;
     }
   }
-  else if (!strcasecmp("LF",a[1])) {
+  else if (!strcasecmp("LF", a[1])) {
     Kas = 5;
     if (!lfdef) {
       theCommands << "lf not defined";
       return 1;
     }
-    if (!strcasecmp(a[0],"FEATPERFORMVAL")) {
+    if (!strcasecmp(a[0], "FEATPERFORMVAL")) {
       theCommands << "invalid command for lf";
       return 1;
     }
   }
-  else if (!strcasecmp("RF",a[1])) {
+  else if (!strcasecmp("RF", a[1])) {
     Kas = 6;
     if (!rfdef) {
       theCommands << "rf not defined";
       return 1;
     }
-    if (!strcasecmp(a[0],"FEATPERFORMVAL")) {
+    if (!strcasecmp(a[0], "FEATPERFORMVAL")) {
       theCommands << "invalid command for rf";
       return 1;
     }
@@ -1832,183 +1850,183 @@ static Standard_Integer PERF(Draw_Interpretor& theCommands,
     return 1;
   }
 
-  if (!strcasecmp(a[0],"FEATPERFORMVAL")) {
-    if (narg !=4 && narg != 5) {
+  if (!strcasecmp(a[0], "FEATPERFORMVAL")) {
+    if (narg != 4 && narg != 5) {
       theCommands << "invalid number of arguments";
       return 1;
     }
     if (narg == 4) {
       Standard_Real Val = Draw::Atof(a[3]);
       if (Kas == 1) {
-	thePrism.Perform(Val);
+        thePrism.Perform(Val);
       }
       else if (Kas == 2) {
-	Val *=(M_PI/180.);
-	theRevol.Perform(Val);
+        Val *= (M_PI / 180.);
+        theRevol.Perform(Val);
       }
       else if (Kas == 4) {
-	theDPrism.Perform(Val);
+        theDPrism.Perform(Val);
       }
       else if (Kas == 5) {
-	theCommands << "invalid command for lf";
-	return 1;
+        theCommands << "invalid command for lf";
+        return 1;
       }
       else if (Kas == 6) {
-	theCommands << "invalid command for rf";
-	return 1;
+        theCommands << "invalid command for rf";
+        return 1;
       }
     }
-    else if(narg == 5) {
+    else if (narg == 5) {
       Standard_Real Val = Draw::Atof(a[3]);
-      TopoDS_Shape FUntil = DBRep::Get(a[4],TopAbs_SHAPE);
+      TopoDS_Shape FUntil = DBRep::Get(a[4], TopAbs_SHAPE);
       if (Kas == 1) {
-	thePrism.PerformUntilHeight(FUntil, Val);
+        thePrism.PerformUntilHeight(FUntil, Val);
       }
       else if (Kas == 2) {
-	Val *=(M_PI/180.);
-	theRevol.PerformUntilAngle(FUntil, Val);
+        Val *= (M_PI / 180.);
+        theRevol.PerformUntilAngle(FUntil, Val);
       }
       else if (Kas == 4) {
-	theDPrism.PerformUntilHeight(FUntil, Val);
-      } 
+        theDPrism.PerformUntilHeight(FUntil, Val);
+      }
       else {
-	theCommands << "invalid command for ribs or slots";
-	return 1;
+        theCommands << "invalid command for ribs or slots";
+        return 1;
       }
     }
   }
-  else if (!strcasecmp(a[0],"FEATPERFORM")) {
+  else if (!strcasecmp(a[0], "FEATPERFORM")) {
     if (narg == 3) { // Thru all
       switch (Kas) {
       case 1:
-	thePrism.PerformThruAll();
-	break;
+        thePrism.PerformThruAll();
+        break;
       case 2:
-	theRevol.PerformThruAll();
-	break;
+        theRevol.PerformThruAll();
+        break;
       case 3:
-	thePipe.Perform();
-	break;
+        thePipe.Perform();
+        break;
       case 4:
         theDPrism.PerformThruAll();
         break;
       case 5:
-	theLF.Perform();
+        theLF.Perform();
         break;
       case 6:
-	theRF.Perform();
+        theRF.Perform();
         break;
       default:
 
-	return 1;
+        return 1;
       }
     }
     else if (narg == 4) { // Until
-      TopoDS_Shape Funtil = DBRep::Get(a[3],TopAbs_SHAPE);
+      TopoDS_Shape Funtil = DBRep::Get(a[3], TopAbs_SHAPE);
       switch (Kas) {
       case 1:
-	{
-	  if (Funtil.IsNull()) {
-	    thePrism.PerformUntilEnd();
-	  }
-	  else {
-	    thePrism.Perform(Funtil);
-	  }
-	}
-	break;
+      {
+        if (Funtil.IsNull()) {
+          thePrism.PerformUntilEnd();
+        }
+        else {
+          thePrism.Perform(Funtil);
+        }
+      }
+      break;
       case 2:
-	{
-	  if (!Funtil.IsNull()) {
-	    theRevol.Perform(Funtil);
-	  }
-	  else {
-	    return 1;
-	  }
-	}
-	break;
+      {
+        if (!Funtil.IsNull()) {
+          theRevol.Perform(Funtil);
+        }
+        else {
+          return 1;
+        }
+      }
+      break;
       case 3:
-	{
-	  if (!Funtil.IsNull()) {
-	    thePipe.Perform(Funtil);
-	  }
-	  else {
-	    theCommands << "invalid command for ribs pipe";
-	    return 1;
-	  }
-	}
-	break;
+      {
+        if (!Funtil.IsNull()) {
+          thePipe.Perform(Funtil);
+        }
+        else {
+          theCommands << "invalid command for ribs pipe";
+          return 1;
+        }
+      }
+      break;
       case 4:
-        {
-	  if (!Funtil.IsNull()) {
-	    theDPrism.Perform(Funtil);
-	  }
-	  else {
-	    theDPrism.PerformUntilEnd();
-	  }
-	}
-        break;
+      {
+        if (!Funtil.IsNull()) {
+          theDPrism.Perform(Funtil);
+        }
+        else {
+          theDPrism.PerformUntilEnd();
+        }
+      }
+      break;
       case 5:
-        {  
-	  theCommands << "invalid command for lf";
-	  return 1;
-	}
-        break;
+      {
+        theCommands << "invalid command for lf";
+        return 1;
+      }
+      break;
       case 6:
-        {  
-	  theCommands << "invalid command for rf";
-	  return 1;
-	}
-        break;
+      {
+        theCommands << "invalid command for rf";
+        return 1;
+      }
+      break;
       default:
-	return 1;
+        return 1;
       }
     }
     else if (narg == 5) {
-      TopoDS_Shape Ffrom = DBRep::Get(a[3],TopAbs_SHAPE);
-      TopoDS_Shape Funtil = DBRep::Get(a[4],TopAbs_SHAPE);
+      TopoDS_Shape Ffrom = DBRep::Get(a[3], TopAbs_SHAPE);
+      TopoDS_Shape Funtil = DBRep::Get(a[4], TopAbs_SHAPE);
       if (Funtil.IsNull()) {
-	return 1;
+        return 1;
       }
       switch (Kas) {
       case 1:
-	{
-	  if (Ffrom.IsNull()) {
-	    thePrism.PerformFromEnd(Funtil);
-	  }
-	  else {
-	    thePrism.Perform(Ffrom,Funtil);
-	  }
-	}
-	break;
+      {
+        if (Ffrom.IsNull()) {
+          thePrism.PerformFromEnd(Funtil);
+        }
+        else {
+          thePrism.Perform(Ffrom, Funtil);
+        }
+      }
+      break;
       case 2:
-	{
-	  if (Ffrom.IsNull()) {
-	    return 1;
-	  }
-	  theRevol.Perform(Ffrom,Funtil);
-	}
-	break;
+      {
+        if (Ffrom.IsNull()) {
+          return 1;
+        }
+        theRevol.Perform(Ffrom, Funtil);
+      }
+      break;
       case 3:
-	{
-	  if (Ffrom.IsNull()) {
-	    return 1;
-	  }
-	  thePipe.Perform(Ffrom,Funtil);
-	}
-	break;
+      {
+        if (Ffrom.IsNull()) {
+          return 1;
+        }
+        thePipe.Perform(Ffrom, Funtil);
+      }
+      break;
       case 4:
-	{
-	  if (Ffrom.IsNull()) {
-	    theDPrism.PerformFromEnd(Funtil);
-	  }
-	  else {
-            theDPrism.Perform(Ffrom,Funtil);
-          }
-	}
-	break;
+      {
+        if (Ffrom.IsNull()) {
+          theDPrism.PerformFromEnd(Funtil);
+        }
+        else {
+          theDPrism.Perform(Ffrom, Funtil);
+        }
+      }
+      break;
 
       default:
-	return 1;
+        return 1;
       }
     }
   }
@@ -2020,23 +2038,41 @@ static Standard_Integer PERF(Draw_Interpretor& theCommands,
       se = thePrism.CurrentStatusError();
       //BRepFeat::Print(se,std::cout) << std::endl;
       Standard_SStream aSStream;
-      BRepFeat::Print(se,aSStream);
+      BRepFeat::Print(se, aSStream);
       theCommands << aSStream << "\n";
       return 1;
     }
-    DBRep::Set(a[2],thePrism);
+    DBRep::Set(a[2], thePrism);
     dout.Flush();
+    //History 
+    if (BRepTest_Objects::IsHistoryNeeded())
+    {
+      anArgs.Clear();
+      anArgs.Append(theSbase);
+      anArgs.Append(thePbase);
+      anArgs.Append(theSkface);
+      BRepTest_Objects::SetHistory(anArgs, thePrism);
+    }
     return 0;
   case 2:
     if (!theRevol.IsDone()) {
       se = theRevol.CurrentStatusError();
       //BRepFeat::Print(se,std::cout) << std::endl;
       Standard_SStream aSStream;
-      BRepFeat::Print(se,aSStream);
+      BRepFeat::Print(se, aSStream);
       theCommands << aSStream << "\n";
       return 1;
     }
-    DBRep::Set(a[2],theRevol);
+    //History 
+    if (BRepTest_Objects::IsHistoryNeeded())
+    {
+      anArgs.Clear();
+      anArgs.Append(theSbase);
+      anArgs.Append(thePbase);
+      anArgs.Append(theSkface);
+      BRepTest_Objects::SetHistory(anArgs, theRevol);
+    }
+    DBRep::Set(a[2], theRevol);
     dout.Flush();
     return 0;
   case 3:
@@ -2044,11 +2080,20 @@ static Standard_Integer PERF(Draw_Interpretor& theCommands,
       se = thePipe.CurrentStatusError();
       //BRepFeat::Print(se,std::cout) << std::endl;
       Standard_SStream aSStream;
-      BRepFeat::Print(se,aSStream);
+      BRepFeat::Print(se, aSStream);
       theCommands << aSStream << "\n";
       return 1;
     }
-    DBRep::Set(a[2],thePipe);
+    //History 
+    if (BRepTest_Objects::IsHistoryNeeded())
+    {
+      anArgs.Clear();
+      anArgs.Append(theSbase);
+      anArgs.Append(thePbase);
+      anArgs.Append(theSkface);
+      BRepTest_Objects::SetHistory(anArgs, thePipe);
+    }
+    DBRep::Set(a[2], thePipe);
     dout.Flush();
     return 0;
   case 4:
@@ -2056,11 +2101,20 @@ static Standard_Integer PERF(Draw_Interpretor& theCommands,
       se = theDPrism.CurrentStatusError();
       //BRepFeat::Print(se,std::cout) << std::endl;
       Standard_SStream aSStream;
-      BRepFeat::Print(se,aSStream);
+      BRepFeat::Print(se, aSStream);
       theCommands << aSStream << "\n";
       return 1;
     }
-    DBRep::Set(a[2],theDPrism);
+    //History 
+    if (BRepTest_Objects::IsHistoryNeeded())
+    {
+      anArgs.Clear();
+      anArgs.Append(theSbase);
+      anArgs.Append(thePbase);
+      anArgs.Append(theSkface);
+      BRepTest_Objects::SetHistory(anArgs, theDPrism);
+    }
+    DBRep::Set(a[2], theDPrism);
     dout.Flush();
     return 0;
   case 5:
@@ -2068,11 +2122,11 @@ static Standard_Integer PERF(Draw_Interpretor& theCommands,
       se = theLF.CurrentStatusError();
       //BRepFeat::Print(se,std::cout) << std::endl;
       Standard_SStream aSStream;
-      BRepFeat::Print(se,aSStream);
+      BRepFeat::Print(se, aSStream);
       theCommands << aSStream << "\n";
       return 1;
     }
-    DBRep::Set(a[2],theLF);
+    DBRep::Set(a[2], theLF);
     dout.Flush();
     return 0;
   case 6:
@@ -2080,11 +2134,11 @@ static Standard_Integer PERF(Draw_Interpretor& theCommands,
       se = theRF.CurrentStatusError();
       //BRepFeat::Print(se,std::cout) << std::endl;
       Standard_SStream aSStream;
-      BRepFeat::Print(se,aSStream);
+      BRepFeat::Print(se, aSStream);
       theCommands << aSStream << "\n";
       return 1;
     }
-    DBRep::Set(a[2],theRF);
+    DBRep::Set(a[2], theRF);
     dout.Flush();
     return 0;
   default:
@@ -2094,42 +2148,42 @@ static Standard_Integer PERF(Draw_Interpretor& theCommands,
 
 
 static Standard_Integer BOSS(Draw_Interpretor& theCommands,
-			     Standard_Integer narg, const char** a)
+  Standard_Integer narg, const char** a)
 {
-  if (strcasecmp(a[0],"ENDEDGES") && strcasecmp(a[0],"FILLET")
-      && strcasecmp(a[0],"BOSSAGE")) {
+  if (strcasecmp(a[0], "ENDEDGES") && strcasecmp(a[0], "FILLET")
+    && strcasecmp(a[0], "BOSSAGE")) {
     return 1;
   }
 
-  if ((!strcasecmp(a[0],"ENDEDGES") && narg !=5) ||
-      (!strcasecmp(a[0],"FILLET") && (narg < 5 || narg%2 != 1)) ||
-      (!strcasecmp(a[0],"BOSSAGE") && narg != 6)) {
+  if ((!strcasecmp(a[0], "ENDEDGES") && narg != 5) ||
+    (!strcasecmp(a[0], "FILLET") && (narg < 5 || narg % 2 != 1)) ||
+    (!strcasecmp(a[0], "BOSSAGE") && narg != 6)) {
     theCommands.PrintHelp(a[0]);
     return 1;
   }
 
-  Standard_Integer Kas=0;
-  Standard_Integer dprsig=0;
-  if (!strcasecmp("ENDEDGES",a[0])) {
+  Standard_Integer Kas = 0;
+  Standard_Integer dprsig = 0;
+  if (!strcasecmp("ENDEDGES", a[0])) {
     Kas = 1;
     dprsig = Draw::Atoi(a[4]);
   }
-  else if (!strcasecmp("FILLET",a[0])) {
+  else if (!strcasecmp("FILLET", a[0])) {
     Kas = 2;
   }
-  else if (!strcasecmp("BOSSAGE",a[0])) {
+  else if (!strcasecmp("BOSSAGE", a[0])) {
     Kas = 3;
     dprsig = Draw::Atoi(a[5]);
   }
- 
-  TopoDS_Shape theShapeTop; 
+
+  TopoDS_Shape theShapeTop;
   TopoDS_Shape theShapeBottom;
 
   if (Kas == 1 || Kas == 3) {
-    if (!strcasecmp("DPRISM",a[1])) {
+    if (!strcasecmp("DPRISM", a[1])) {
       if (!dprdef) {
-	theCommands << "dprism not defined";
-	return 1;
+        theCommands << "dprism not defined";
+        return 1;
       }
     }
     else {
@@ -2138,7 +2192,7 @@ static Standard_Integer BOSS(Draw_Interpretor& theCommands,
     }
 
     theDPrism.BossEdges(dprsig);
-   
+
     TopTools_ListOfShape theTopEdges, theLatEdges;
     theTopEdges = theDPrism.TopEdges();
     theLatEdges = theDPrism.LatEdges();
@@ -2148,42 +2202,42 @@ static Standard_Integer BOSS(Draw_Interpretor& theCommands,
 
     B.MakeCompound(TopoDS::Compound(theShapeTop));
     it.Initialize(theTopEdges);
-    for(; it.More(); it.Next()) {
+    for (; it.More(); it.Next()) {
       TopExp_Explorer exp;
-      for (exp.Init(it.Value(),TopAbs_EDGE); exp.More(); exp.Next()) {
-	B.Add(theShapeTop,exp.Current());
+      for (exp.Init(it.Value(), TopAbs_EDGE); exp.More(); exp.Next()) {
+        B.Add(theShapeTop, exp.Current());
       }
     }
-    DBRep::Set(a[2],theShapeTop);
+    DBRep::Set(a[2], theShapeTop);
     dout.Flush();
 
     B.MakeCompound(TopoDS::Compound(theShapeBottom));
     it.Initialize(theLatEdges);
-    for(; it.More(); it.Next()) {
-      B.Add(theShapeBottom,it.Value());
+    for (; it.More(); it.Next()) {
+      B.Add(theShapeBottom, it.Value());
     }
-    DBRep::Set(a[3],theShapeBottom);
+    DBRep::Set(a[3], theShapeBottom);
     dout.Flush();
     if (Kas == 1) return 0;
   }
 
   if (Kas == 2 || Kas == 3) {
-    
-//    Standard_Integer nrad;
+
+    //    Standard_Integer nrad;
     TopoDS_Shape V;
     if (Kas == 2) {
-      V = DBRep::Get(a[2],TopAbs_SHAPE);
+      V = DBRep::Get(a[2], TopAbs_SHAPE);
     }
     else if (Kas == 3) {
       V = theDPrism;
     }
 
-    if(V.IsNull()) return 1;
+    if (V.IsNull()) return 1;
     ChFi3d_FilletShape FSh = ChFi3d_Rational;
     if (Rakk)
       delete Rakk;
-    Rakk = new BRepFilletAPI_MakeFillet(V,FSh);
-    Rakk->SetParams(ta,t3d,t2d,t3d,t2d,fl);
+    Rakk = new BRepFilletAPI_MakeFillet(V, FSh);
+    Rakk->SetParams(ta, t3d, t2d, t3d, t2d, fl);
     Rakk->SetContinuity(blend_cont, tapp_angle);
     Standard_Real Rad;
     TopoDS_Shape S;
@@ -2191,57 +2245,57 @@ static Standard_Integer BOSS(Draw_Interpretor& theCommands,
     Standard_Integer nbedge = 0;
 
     if (Kas == 2) {
-      for (Standard_Integer ii = 1; ii < (narg-1)/2; ii++){
-	Rad = Draw::Atof(a[2*ii + 1]);
-	if (Rad == 0.) continue;
-	S = DBRep::Get(a[(2*ii+2)],TopAbs_SHAPE);
-	TopExp_Explorer exp;
-	for (exp.Init(S,TopAbs_EDGE); exp.More(); exp.Next()) {
-	  E = TopoDS::Edge(exp.Current());
-	  if(!E.IsNull()){
-	    Rakk->Add(Rad,E);
-	    nbedge++;
-	  }
-	}
+      for (Standard_Integer ii = 1; ii < (narg - 1) / 2; ii++) {
+        Rad = Draw::Atof(a[2 * ii + 1]);
+        if (Rad == 0.) continue;
+        S = DBRep::Get(a[(2 * ii + 2)], TopAbs_SHAPE);
+        TopExp_Explorer exp;
+        for (exp.Init(S, TopAbs_EDGE); exp.More(); exp.Next()) {
+          E = TopoDS::Edge(exp.Current());
+          if (!E.IsNull()) {
+            Rakk->Add(Rad, E);
+            nbedge++;
+          }
+        }
       }
     }
     else if (Kas == 3) {
       Rad = Draw::Atof(a[3]);
       if (Rad != 0.) {
-	S = theShapeTop;
-	TopExp_Explorer exp;
-	for (exp.Init(S,TopAbs_EDGE); exp.More(); exp.Next()) {
-	  E = TopoDS::Edge(exp.Current());
-	  if(!E.IsNull()){
-	    Rakk->Add(Rad,E);
-	    nbedge++;
-	  }
-	} 
+        S = theShapeTop;
+        TopExp_Explorer exp;
+        for (exp.Init(S, TopAbs_EDGE); exp.More(); exp.Next()) {
+          E = TopoDS::Edge(exp.Current());
+          if (!E.IsNull()) {
+            Rakk->Add(Rad, E);
+            nbedge++;
+          }
+        }
       }
       Rad = Draw::Atof(a[4]);
       if (Rad != 0.) {
-	S = theShapeBottom;
-	TopExp_Explorer exp;
-	for (exp.Init(S,TopAbs_EDGE); exp.More(); exp.Next()) {
-	  E = TopoDS::Edge(exp.Current());
-	  if(!E.IsNull()){
-	    Rakk->Add(Rad,E);
-	    nbedge++;
-	  }
-	} 
+        S = theShapeBottom;
+        TopExp_Explorer exp;
+        for (exp.Init(S, TopAbs_EDGE); exp.More(); exp.Next()) {
+          E = TopoDS::Edge(exp.Current());
+          if (!E.IsNull()) {
+            Rakk->Add(Rad, E);
+            nbedge++;
+          }
+        }
       }
     }
-    
-    if(!nbedge) return 1;
+
+    if (!nbedge) return 1;
     Rakk->Build();
-    if(!Rakk->IsDone()) return 1;
+    if (!Rakk->IsDone()) return 1;
     TopoDS_Shape res = Rakk->Shape();
 
     if (Kas == 2) {
-      DBRep::Set(a[1],res);
-    } 
+      DBRep::Set(a[1], res);
+    }
     else if (Kas == 3) {
-      DBRep::Set(a[2],res);
+      DBRep::Set(a[2], res);
     }
     dout.Flush();
 
@@ -2264,8 +2318,8 @@ static Standard_Integer BOSS(Draw_Interpretor& theCommands,
 //purpose  : Computes simple offset.
 //=============================================================================
 static Standard_Integer ComputeSimpleOffset(Draw_Interpretor& theCommands,
-                                            Standard_Integer narg, 
-                                            const char** a)
+  Standard_Integer narg,
+  const char** a)
 {
   if (narg < 4)
   {
@@ -2287,12 +2341,12 @@ static Standard_Integer ComputeSimpleOffset(Draw_Interpretor& theCommands,
     return 0;
   }
 
-  Standard_Boolean makeSolid = (narg > 4 && !strcasecmp(a[4],"solid"));
+  Standard_Boolean makeSolid = (narg > 4 && !strcasecmp(a[4], "solid"));
   int iTolArg = (makeSolid ? 5 : 4);
   Standard_Real aTol = (narg > iTolArg ? Draw::Atof(a[iTolArg]) : Precision::Confusion());
 
   BRepOffset_MakeSimpleOffset aMaker(aShape, anOffsetValue);
-  aMaker.SetTolerance (aTol);
+  aMaker.SetTolerance(aTol);
   aMaker.SetBuildSolidFlag(makeSolid);
   aMaker.Perform();
 
@@ -2312,7 +2366,7 @@ static Standard_Integer ComputeSimpleOffset(Draw_Interpretor& theCommands,
 //purpose  : 
 //=======================================================================
 
-void BRepTest::FeatureCommands (Draw_Interpretor& theCommands)
+void BRepTest::FeatureCommands(Draw_Interpretor& theCommands)
 {
   static Standard_Boolean done = Standard_False;
   if (done) return;
@@ -2322,48 +2376,48 @@ void BRepTest::FeatureCommands (Draw_Interpretor& theCommands)
 
   const char* g = "TOPOLOGY Feature commands";
 
-  theCommands.Add("localope", 
-		  " Performs a local top. operation : localope result shape tool F/C (fuse/cut) face [face...]",
-		  __FILE__,Loc,g);
+  theCommands.Add("localope",
+    " Performs a local top. operation : localope result shape tool F/C (fuse/cut) face [face...]",
+    __FILE__, Loc, g);
 
   theCommands.Add("hole",
-		  " Performs a hole : hole result shape Or.X Or.Y Or.Z Dir.X Dir.Y Dir.Z Radius [Pfrom Pto]",
-		  __FILE__,HOLE1,g);
+    " Performs a hole : hole result shape Or.X Or.Y Or.Z Dir.X Dir.Y Dir.Z Radius [Pfrom Pto]",
+    __FILE__, HOLE1, g);
 
   theCommands.Add("firsthole",
-		  " Performs the first hole : firsthole result shape Or.X Or.Y Or.Z Dir.X Dir.Y Dir.Z Radius",
-		  __FILE__,HOLE2,g);
+    " Performs the first hole : firsthole result shape Or.X Or.Y Or.Z Dir.X Dir.Y Dir.Z Radius",
+    __FILE__, HOLE2, g);
 
   theCommands.Add("holend",
-		  " Performs the hole til end : holend result shape Or.X Or.Y Or.Z Dir.X Dir.Y Dir.Z Radius",
-		  __FILE__,HOLE3,g);
+    " Performs the hole til end : holend result shape Or.X Or.Y Or.Z Dir.X Dir.Y Dir.Z Radius",
+    __FILE__, HOLE3, g);
 
-  theCommands.Add("blindhole", 
-		  " Performs the blind hole : blindhole result shape Or.X Or.Y Or.Z Dir.X Dir.Y Dir.Z Radius Length",
-		  __FILE__,HOLE4,g);
+  theCommands.Add("blindhole",
+    " Performs the blind hole : blindhole result shape Or.X Or.Y Or.Z Dir.X Dir.Y Dir.Z Radius Length",
+    __FILE__, HOLE4, g);
 
   theCommands.Add("holecontrol",
-		  "Sets/Unsets or display controls on holes : holecontrol [0/1]",
-		  __FILE__,CONTROL,g);
+    "Sets/Unsets or display controls on holes : holecontrol [0/1]",
+    __FILE__, CONTROL, g);
 
   theCommands.Add("wprism",
-		  "Prisms wires on a face : wprism f[use]/c[ut] result shape [[FaceFrom] FaceUntil] VecX VecY VecZ  SkecthFace wire1 [wire2 ....]",
-		  __FILE__,PRW,g);
+    "Prisms wires on a face : wprism f[use]/c[ut] result shape [[FaceFrom] FaceUntil] VecX VecY VecZ  SkecthFace wire1 [wire2 ....]",
+    __FILE__, PRW, g);
 
 
-  theCommands.Add("fprism", 
-		  "Prisms a set of faces of a shape : fprism f[use]/c[ut] result shape [[FaceFrom] FaceUntil] VecX VecY VecZ face1 [face2...]",
-		  __FILE__,PRF,g);
+  theCommands.Add("fprism",
+    "Prisms a set of faces of a shape : fprism f[use]/c[ut] result shape [[FaceFrom] FaceUntil] VecX VecY VecZ face1 [face2...]",
+    __FILE__, PRF, g);
 
 
   theCommands.Add("wrotate",
-		  "Rotates wires on a face : wrotate f[use]/c[ut] result shape Angle/[FFrom] FUntil OX OY OZ DX DY DZ SkecthFace wire1 [wire2 ....]",
-		  __FILE__,ROW,g);
+    "Rotates wires on a face : wrotate f[use]/c[ut] result shape Angle/[FFrom] FUntil OX OY OZ DX DY DZ SkecthFace wire1 [wire2 ....]",
+    __FILE__, ROW, g);
 
 
-  theCommands.Add("frotate", 
-		  "Rotates a set of faces of a shape : frotate f[use]/c[ut] result shape Angle/[FaceFrom] FaceUntil OX OY OZ DX DY DZ face1 [face2...]",
-		  __FILE__,ROF,g);
+  theCommands.Add("frotate",
+    "Rotates a set of faces of a shape : frotate f[use]/c[ut] result shape Angle/[FaceFrom] FaceUntil OX OY OZ DX DY DZ face1 [face2...]",
+    __FILE__, ROF, g);
 
 
   theCommands.Add("splitshape",
@@ -2372,87 +2426,87 @@ void BRepTest::FeatureCommands (Draw_Interpretor& theCommands)
 
 
   theCommands.Add("thickshell",
-		  "thickshell r shape offset [jointype [tol] ]",
-		  __FILE__,thickshell,g);
-  
+    "thickshell r shape offset [jointype [tol] ]",
+    __FILE__, thickshell, g);
+
   theCommands.Add("offsetshape",
-		  "offsetshape r shape offset [tol] [face ...]",
-		  __FILE__,offsetshape,g);
-  
+    "offsetshape r shape offset [tol] [face ...]",
+    __FILE__, offsetshape, g);
+
   theCommands.Add("offsetcompshape",
-		  "offsetcompshape r shape offset [face ...]",
-		  __FILE__,offsetshape,g);
+    "offsetcompshape r shape offset [face ...]",
+    __FILE__, offsetshape, g);
 
   theCommands.Add("offsetparameter",
-		  "offsetparameter Tol Inter(c/p) JoinType(a/i/t) [RemoveInternalEdges(r/k)]",
-		  __FILE__,offsetparameter);
+    "offsetparameter Tol Inter(c/p) JoinType(a/i/t) [RemoveInternalEdges(r/k)]",
+    __FILE__, offsetparameter);
 
   theCommands.Add("offsetload",
-		  "offsetload shape offset bouchon1 bouchon2 ...",
-		  __FILE__,offsetload,g);
+    "offsetload shape offset bouchon1 bouchon2 ...",
+    __FILE__, offsetload, g);
 
   theCommands.Add("offsetonface",
-		  "offsetonface face1 offset1 face2 offset2 ...",
-		  __FILE__,offsetonface,g);
+    "offsetonface face1 offset1 face2 offset2 ...",
+    __FILE__, offsetonface, g);
 
   theCommands.Add("offsetperform",
-		  "offsetperform result",
-		  __FILE__,offsetperform,g);
+    "offsetperform result",
+    __FILE__, offsetperform, g);
 
-  theCommands.Add("glue", 
-		  "glue result shapenew shapebase facenew facebase [facenew facebase...] [edgenew edgebase [edgenew edgebase...]]",
-		  __FILE__,GLU,g);
+  theCommands.Add("glue",
+    "glue result shapenew shapebase facenew facebase [facenew facebase...] [edgenew edgebase [edgenew edgebase...]]",
+    __FILE__, GLU, g);
 
 
-  theCommands.Add("featprism", 
-		  "Defines the arguments for a prism : featprism shape element skface  Dirx Diry Dirz Fuse(0/1/2) Modify(0/1)",
-		  __FILE__,DEFIN);
+  theCommands.Add("featprism",
+    "Defines the arguments for a prism : featprism shape element skface  Dirx Diry Dirz Fuse(0/1/2) Modify(0/1)",
+    __FILE__, DEFIN);
 
-  theCommands.Add("featrevol", 
-		  "Defines the arguments for a revol : featrevol shape element skface  Ox Oy Oz Dx Dy Dz Fuse(0/1/2) Modify(0/1)",
-		  __FILE__,DEFIN);
+  theCommands.Add("featrevol",
+    "Defines the arguments for a revol : featrevol shape element skface  Ox Oy Oz Dx Dy Dz Fuse(0/1/2) Modify(0/1)",
+    __FILE__, DEFIN);
 
-  theCommands.Add("featpipe", 
-		  "Defines the arguments for a pipe : featpipe shape element skface  spine Fuse(0/1/2) Modify(0/1)",
-		  __FILE__,DEFIN);
+  theCommands.Add("featpipe",
+    "Defines the arguments for a pipe : featpipe shape element skface  spine Fuse(0/1/2) Modify(0/1)",
+    __FILE__, DEFIN);
 
-  theCommands.Add("featdprism", 
-		  "Defines the arguments for a drafted prism : featdprism shape face skface angle Fuse(0/1/2) Modify(0/1)",
-		  __FILE__,DEFIN);
+  theCommands.Add("featdprism",
+    "Defines the arguments for a drafted prism : featdprism shape face skface angle Fuse(0/1/2) Modify(0/1)",
+    __FILE__, DEFIN);
 
-  theCommands.Add("featlf", 
-		  "Defines the arguments for a linear rib or slot : featlf shape wire plane DirX DirY DirZ DirX DirY DirZ Fuse(0/1/2) Modify(0/1)",
-		  __FILE__,DEFIN);
+  theCommands.Add("featlf",
+    "Defines the arguments for a linear rib or slot : featlf shape wire plane DirX DirY DirZ DirX DirY DirZ Fuse(0/1/2) Modify(0/1)",
+    __FILE__, DEFIN);
 
-  theCommands.Add("featrf", 
-		  "Defines the arguments for a rib or slot of revolution : featrf shape wire plane X Y Z DirX DirY DirZ Size Size Fuse(0/1/2) Modify(0/1)",
-		  __FILE__,DEFIN);
+  theCommands.Add("featrf",
+    "Defines the arguments for a rib or slot of revolution : featrf shape wire plane X Y Z DirX DirY DirZ Size Size Fuse(0/1/2) Modify(0/1)",
+    __FILE__, DEFIN);
 
-  theCommands.Add("addslide", 
-		  " Adds sliding elements : addslide prism/revol/pipe edge face [edge face...]",
-		  __FILE__,ADD);
+  theCommands.Add("addslide",
+    " Adds sliding elements : addslide prism/revol/pipe edge face [edge face...]",
+    __FILE__, ADD);
 
-  theCommands.Add("featperform", 
-		  " Performs the prism revol dprism linform or pipe :featperform prism/revol/pipe/dprism/lf result [[Ffrom] Funtil]",
-		  __FILE__,PERF);
+  theCommands.Add("featperform",
+    " Performs the prism revol dprism linform or pipe :featperform prism/revol/pipe/dprism/lf result [[Ffrom] Funtil]",
+    __FILE__, PERF);
 
-  theCommands.Add("featperformval", 
-		  " Performs the prism revol dprism or linform with a value :featperformval prism/revol/dprism/lf result value",
-		  __FILE__,PERF);
+  theCommands.Add("featperformval",
+    " Performs the prism revol dprism or linform with a value :featperformval prism/revol/dprism/lf result value",
+    __FILE__, PERF);
 
-  theCommands.Add("endedges", 
-		  " Return top and bottom edges of dprism :endedges dprism shapetop shapebottom First/LastShape (1/2)",
-		  __FILE__,BOSS);
+  theCommands.Add("endedges",
+    " Return top and bottom edges of dprism :endedges dprism shapetop shapebottom First/LastShape (1/2)",
+    __FILE__, BOSS);
 
-  theCommands.Add("fillet", 
-		  " Perform fillet on compounds of edges :fillet result object rad1 comp1 rad2 comp2 ...",
-		  __FILE__,BOSS);
+  theCommands.Add("fillet",
+    " Perform fillet on compounds of edges :fillet result object rad1 comp1 rad2 comp2 ...",
+    __FILE__, BOSS);
 
-  theCommands.Add("bossage", 
-		  " Perform fillet on top and bottom edges of dprism :bossage dprism result radtop radbottom First/LastShape (1/2)",
-		  __FILE__,BOSS);
+  theCommands.Add("bossage",
+    " Perform fillet on top and bottom edges of dprism :bossage dprism result radtop radbottom First/LastShape (1/2)",
+    __FILE__, BOSS);
 
-  theCommands.Add("offsetshapesimple", 
-                  "offsetshapesimple result shape offsetvalue [solid] [tolerance=1e-7]",
-                  __FILE__, ComputeSimpleOffset);
+  theCommands.Add("offsetshapesimple",
+    "offsetshapesimple result shape offsetvalue [solid] [tolerance=1e-7]",
+    __FILE__, ComputeSimpleOffset);
 }
diff --git a/tests/bugs/modalg_7/bug31469 b/tests/bugs/modalg_7/bug31469
new file mode 100644
index 0000000000..26713e964c
--- /dev/null
+++ b/tests/bugs/modalg_7/bug31469
@@ -0,0 +1,43 @@
+puts "========"
+puts "0031469: Modeling Algorithms - 0031469: BRepFeat_MakePrism has problem with method IsDeleted(...)"
+puts "========"
+puts ""
+
+box S 400 250 300
+
+explode S face 
+mksurface pl2 S_2
+trim pl2 pl2 100 200 -200 -100
+mkface pbase pl2
+featprism S pbase S_2 -1 0 0 0 1
+featperformval prism pp 200
+checkshape pp
+checknbshapes pp -vertex 12 -edge 20 -face 11 -solid 1
+savehistory ph
+if { ![regexp "Not deleted" [isdeleted ph S]] } {
+  puts "Error: S has wrong delete status"
+}
+
+if { ![regexp "Not deleted" [isdeleted ph S_2]] } {
+  puts "Error: S_2 has wrong delete status"
+}
+
+if {![regexp "The shape has not been modified." [modified m1 ph S]] } {
+   checknbshapes m1 -vertex 12 -edge 20 -face 11 -solid 1
+} else {
+  puts "Error: S has wrong modified list"
+}
+
+if {![regexp "The shape has not been modified." [modified m2 ph S_2]] } {
+   checknbshapes m2 -vertex 8 -edge 8 -wire 2 -face 1
+} else {
+  puts "Error: S_2 has wrong modified list"
+}
+
+explode pbase e
+if {![regexp "No shapes were generated from the shape." [generated g1 ph pbase_1]] } {
+   checknbshapes g1 -vertex 2 -edge 3 -wire 1 -face 1
+   checkprops g1 -s 20000
+} else {
+  puts "Error: pbase_1 has wrong generated list"
+}