0023501: Redundant triangulation cleaning/generation (1) in AIS_Shape.cxx
[occt.git] / src / AIS / AIS_Shape.cxx
index 74376f5..1c4327b 100755 (executable)
@@ -1,28 +1,23 @@
-// File:       AIS_Shape.cxx
-// Created:    Fri Dec 20 17:18:37 1996
-// Author:     Robert COUBLANC
-//             <rob@robox.paris1.matra-dtv.fr>
-// Modified:    Christiane ARMAND: 5/05/97: dans le compute on prend en 
-//              compte le cas des objets infinis     
-//              ROB : introduction des primitives connectees
-//                    Pour le calcul des faces sensibles...
-//   oct-03-97  ROB : en fonction du type de shapes, on change les coeffs de polygonisation...
-//                    (correction du Pb des cercles pas assez discretises...)
+// Created on: 1996-12-20
+// Created by: Robert COUBLANC
+// Copyright (c) 1996-1999 Matra Datavision
+// Copyright (c) 1999-2012 OPEN CASCADE SAS
+//
+// The content of this file is subject to the Open CASCADE Technology Public
+// License Version 6.5 (the "License"). You may not use the content of this file
+// except in compliance with the License. Please obtain a copy of the License
+// at http://www.opencascade.org and read it completely before using this file.
+//
+// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
+// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
+//
+// The Original Code and all software distributed under the License is
+// distributed on an "AS IS" basis, without warranty of any kind, and the
+// Initial Developer hereby disclaims all such warranties, including without
+// limitation, any warranties of merchantability, fitness for a particular
+// purpose or non-infringement. Please see the License for the specific terms
+// and conditions governing the rights and limitations under the License.
 
-#define BUC60577       //GG_191099 Draw correct bounding box and Menage ...
-
-#define BUC60547        //GG_091299 Enable to show a Shape of type COMPOUND
-
-#define GER61351       //GG_171199     Enable to set an object RGB color
-//             instead a restricted object NameOfColor. 
-//             Redefines the Color(),Material(),Transparency() methods .
-//             enable to get separately the shape attributes.
-
-#define IMP040200      //GG Enable to compute selection after transformation
-
-#define BUC60918       //GG 31/05/01 To avoid transparency bug between 
-//                     transparent and non transparent objects, 
-//                     increase display priority for transparent objects
 
 #include <AIS_Shape.ixx>
 
@@ -49,8 +44,7 @@
 #include <Graphic3d_AspectText3d.hxx>
 #include <Graphic3d_AspectMarker3d.hxx>
 #include <Graphic3d_AspectFillArea3d.hxx>
-#include <Graphic3d_Array1OfVertex.hxx>
-#include <Graphic3d_ArrayOfPrimitives.hxx>
+#include <Graphic3d_ArrayOfPolylines.hxx>
 #include <Graphic3d_MaterialAspect.hxx>
 
 #include <Prs3d_Presentation.hxx>
@@ -59,7 +53,6 @@
 #include <Prs3d_Drawer.hxx>
 #include <Prs3d_IsoAspect.hxx>
 
-//#include <StdPrs_WFSectionShape.hxx>
 #include <StdPrs_WFShape.hxx>
 #include <StdPrs_WFDeflectionShape.hxx>
 #include <StdPrs_ShadedShape.hxx>
 #include <Standard_Failure.hxx>
 #include <Standard_ErrorHandler.hxx>
 #include <Select3D_SensitiveBox.hxx>
-#ifdef BUC60547
 #include <TopoDS_Iterator.hxx>
-#endif
 
 static Standard_Boolean myFirstCompute;
 
 Standard_Real AIS_Shape::GetDeflection(const TopoDS_Shape& aShape,
-                                  const Handle(Prs3d_Drawer)& aDrawer)
+                                       const Handle(Prs3d_Drawer)& aDrawer)
 {
   // WARNING: this same piece of code appears several times in Prs3d classes
-  Standard_Real aDeflection;
+  Standard_Real aDeflection = aDrawer->MaximalChordialDeviation();
   if (aDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE) {
     Bnd_Box B;
-    BRepBndLib::Add(aShape, B);
+    BRepBndLib::Add(aShape, B, Standard_False);
     if ( ! B.IsVoid() )
     {
       Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
@@ -104,65 +95,41 @@ Standard_Real AIS_Shape::GetDeflection(const TopoDS_Shape& aShape,
       aDeflection = Max( aXmax-aXmin, Max(aYmax-aYmin, aZmax-aZmin)) *
                     aDrawer->DeviationCoefficient() * 4;
     }
-    else
-      aDeflection = aDrawer->MaximalChordialDeviation();
   }
-  else
-    aDeflection = aDrawer->MaximalChordialDeviation();
   return aDeflection;
 }
 
 void AIS_Shape::DisplayBox(const Handle(Prs3d_Presentation)& aPrs,
-                      const Bnd_Box& B,
-                      const Handle(Prs3d_Drawer)& aDrawer)
+                           const Bnd_Box& B,
+                           const Handle(Prs3d_Drawer)& aDrawer)
 {
-  Standard_Real X[2],Y[2],Z[2];
-  Standard_Integer Indx [16] ;
+  static const Standard_Integer Indx[][3] =
+  { { 0, 0, 0 }, { 1, 0, 0 }, { 1, 0, 1 }, { 0, 0, 1 },
+    { 0, 1, 1 }, { 1, 1, 1 }, { 1, 1, 0 }, { 0, 1, 0 },
+    { 0, 0, 0 }, { 0, 0, 1 }, { 1, 0, 1 }, { 1, 1, 1 },
+    { 0, 1, 1 }, { 0, 1, 0 }, { 1, 1, 0 }, { 1, 0, 0 } };
+
   if ( B.IsVoid() )
     return; // nothing to show
 
-#ifdef BUC60577
-  Indx [0]=1;Indx [1]=2;Indx [2]=4;Indx [3]=3;
-  Indx [4]=5;Indx [5]=6;Indx [6]=8;Indx [7]=7;
-  Indx [8]=1;Indx [9]=3;Indx [10]=7;Indx [11]=5;
-  Indx [12]=2;Indx [13]=4;Indx [14]=8;Indx [15]=6;
+  Standard_Real X[2],Y[2],Z[2];
   B.Get(X[0], Y[0], Z[0], X[1], Y[1], Z[1]);
-#else
-  Indx [0]=1;Indx [1]=2;Indx [2]=3;Indx [3]=4;Indx [4]=5;Indx [5]=6;Indx [6]=7;
-  Indx [7]=8;Indx [8]=1;Indx [9]=2;Indx [10]=6;Indx [10]=5;Indx [10]=3;
-  Indx [10]=4;Indx [10]=8;Indx [10]=7;
-  B.Get(X[1], Y[1], Z[1], X[2], Y[2], Z[2]);
-#endif
 
-  Graphic3d_Array1OfVertex V(1,8);
-  Standard_Integer Rank(0);
-  for(Standard_Integer k=0;k<=1;k++)
-    for(Standard_Integer j=0;j<=1;j++)
-      for(Standard_Integer i=0;i<=1;i++)
-       V(++Rank) = Graphic3d_Vertex(X[i],Y[j],Z[k]);
-  
-  
   Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(aPrs);
   Quantity_Color Q;
   Aspect_TypeOfLine A;
   Standard_Real W;
   aDrawer->LineAspect()->Aspect()->Values(Q,A,W);
-  
 
   G->SetGroupPrimitivesAspect(new Graphic3d_AspectLine3d(Q,Aspect_TOL_DOTDASH,W));
-  
-  G->BeginPrimitives();Standard_Integer I,J;
-  Graphic3d_Array1OfVertex VVV (1,5);
-  for(I=1;I<=4;I++){
-    for(J=1;J<=4;J++){
-      VVV.SetValue(J,V(Indx[J+4*I-5]));
-    }
-    VVV.SetValue(5,VVV(1));
-    G->Polyline(VVV);
-  }
-  G->EndPrimitives();
+
+  Handle(Graphic3d_ArrayOfPolylines) aPolyline = new Graphic3d_ArrayOfPolylines(16);
+  Standard_Integer i(0);
+  for(;i<16;i++)
+    aPolyline->AddVertex(X[Indx[i][0]],Y[Indx[i][1]],Z[Indx[i][2]]);
+  G->AddPrimitiveArray(aPolyline);
 }
-                    
+
 static Standard_Boolean IsInList(const TColStd_ListOfInteger& LL, const Standard_Integer aMode)
 {
   TColStd_ListIteratorOfListOfInteger It(LL);
@@ -216,8 +183,8 @@ Standard_Boolean AIS_Shape::AcceptShapeDecomposition() const
 //purpose  : 
 //=======================================================================
 void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
-                       const Handle(Prs3d_Presentation)& aPrs,
-                       const Standard_Integer aMode)
+                        const Handle(Prs3d_Presentation)& aPrs,
+                        const Standard_Integer aMode)
 {  
   aPrs->Clear();
   if(myshape.IsNull()) return;
@@ -230,18 +197,14 @@ void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentat
   }
   // Shape vide -> Assemblage vide.
   if (myshape.ShapeType() == TopAbs_COMPOUND) {
-#ifdef BUC60547
     TopoDS_Iterator anExplor (myshape);
-#else
-    TopExp_Explorer anExplor (myshape, TopAbs_VERTEX);
-#endif
+
     if (!anExplor.More()) {
       return;
     }
   }
-  
-  
-  if (IsInfinite()) aPrs->SetInfiniteState(Standard_True); //pas de prise en compte lors du FITALL
+
+  if (IsInfinite()) aPrs->SetInfiniteState(Standard_True); //not taken in account duting FITALL
   switch (aMode) {
   case 0:{
     try { OCC_CATCH_SIGNALS  StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer); }
@@ -250,7 +213,7 @@ void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentat
       cout << "AIS_Shape::Compute()  failed"<< endl;
 #endif
       cout << "a Shape should be incorrect : No Compute can be maked on it  "<< endl;     
-// on calcule une presentation de la boite englobante
+// presentation of the bounding box is calculated
 //      Compute(aPresentationManager,aPrs,2);
     }
     break;
@@ -262,70 +225,53 @@ void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentat
       Standard_Real prevcoeff ;
       Standard_Real newcoeff  ; 
       
-      
-      if (OwnDeviationAngle(newangle,prevangle) ||
-         OwnDeviationCoefficient(newcoeff,prevcoeff))
-       if (Abs (newangle - prevangle) > Precision::Angular() ||
-           Abs (newcoeff - prevcoeff) > Precision::Confusion()  ) { 
+      Standard_Boolean isOwnDeviationAngle = OwnDeviationAngle(newangle,prevangle);
+      Standard_Boolean isOwnDeviationCoefficient = OwnDeviationCoefficient(newcoeff,prevcoeff);
+      if (((Abs (newangle - prevangle) > Precision::Angular()) && isOwnDeviationAngle) ||
+          ((Abs (newcoeff - prevcoeff) > Precision::Confusion()) && isOwnDeviationCoefficient)) { 
 #ifdef DEB
-         cout << "AIS_Shape : compute"<<endl;
-         cout << "newangl   : " << newangle << " # de " << "prevangl  : " << prevangle << " OU "<<endl;
-         cout << "newcoeff  : " << newcoeff << " # de " << "prevcoeff : " << prevcoeff << endl;
+        cout << "AIS_Shape : compute"<<endl;
+        cout << "newangl   : " << newangle << " # de " << "prevangl  : " << prevangle << " OU "<<endl;
+        cout << "newcoeff  : " << newcoeff << " # de " << "prevcoeff : " << prevcoeff << endl;
 #endif
-         BRepTools::Clean(myshape);
-       }
+        BRepTools::Clean(myshape);
+      }
       
-      //shading seulement a partir de face...
+      //shading only on face...
       if ((Standard_Integer) myshape.ShapeType()>4)
-       StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer);
+        StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer);
       else {
-       myDrawer->SetShadingAspectGlobal(Standard_False);
-       if (IsInfinite()) StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer);
-       else    {
-         {
-           try {
-             OCC_CATCH_SIGNALS
-             StdPrs_ShadedShape::Add(aPrs,myshape,myDrawer);
-           }
-           catch (Standard_Failure) {
+        myDrawer->SetShadingAspectGlobal(Standard_False);
+        if (IsInfinite()) StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer);
+        else {
+          {
+            try {
+              OCC_CATCH_SIGNALS
+              StdPrs_ShadedShape::Add(aPrs,myshape,myDrawer);
+            }
+            catch (Standard_Failure) {
 #ifdef DEB
-             cout << "AIS_Shape::Compute() in ShadingMode failed"<< endl;
+              cout << "AIS_Shape::Compute() in ShadingMode failed"<< endl;
 #endif
-             StdPrs_WFShape::Add(aPrs,myshape,myDrawer);
-           }
-         }
-       }
+              StdPrs_WFShape::Add(aPrs,myshape,myDrawer);
+            }
+          }
+        }
       }
-#ifdef BUC60918
       Standard_Real value = Transparency() ;
       if( value > 0. ) {
-       SetTransparency( value );
+        SetTransparency( value );
       }
-#endif
       break;
     }
   case 2:
     {
-      // boite englobante
+      // bounding box
       if (IsInfinite()) StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer);
       else DisplayBox(aPrs,BoundingBox(),myDrawer);
     }
-
-
   } // end switch
   aPrs->ReCompute(); // for hidden line recomputation if necessary...
-  
-}
-
-//=======================================================================
-//function : Compute
-//purpose  : 
-//=======================================================================
-
-void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager2d)& /*aPresentationManager*/,
-                       const Handle(Graphic2d_GraphicObject)& /*aGRO*/,
-                       const Standard_Integer /*aMode*/)
-{
 }
 
 //=======================================================================
@@ -333,7 +279,7 @@ void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager2d)& /*aPresentat
 //purpose  : Hidden Line Removal
 //=======================================================================
 void AIS_Shape::Compute(const Handle(Prs3d_Projector)& aProjector,
-                       const Handle(Prs3d_Presentation)& aPresentation)
+                        const Handle(Prs3d_Presentation)& aPresentation)
 {
   Compute(aProjector,aPresentation,myshape);
 }
@@ -344,8 +290,8 @@ void AIS_Shape::Compute(const Handle(Prs3d_Projector)& aProjector,
 //=======================================================================
 
 void AIS_Shape::Compute(const Handle(Prs3d_Projector)&     aProjector,
-                       const Handle(Geom_Transformation)& TheTrsf,
-                       const Handle(Prs3d_Presentation)&  aPresentation)
+                        const Handle(Geom_Transformation)& TheTrsf,
+                        const Handle(Prs3d_Presentation)&  aPresentation)
 {
   const TopLoc_Location& loc = myshape.Location();
   TopoDS_Shape shbis = myshape.Located(TopLoc_Location(TheTrsf->Trsf())*loc);
@@ -358,34 +304,31 @@ void AIS_Shape::Compute(const Handle(Prs3d_Projector)&     aProjector,
 //=======================================================================
 
 void AIS_Shape::Compute(const Handle(Prs3d_Projector)& aProjector,
-                       const Handle(Prs3d_Presentation)& aPresentation,
-                       const TopoDS_Shape& SH)
+                        const Handle(Prs3d_Presentation)& aPresentation,
+                        const TopoDS_Shape& SH)
 {
   if (SH.ShapeType() == TopAbs_COMPOUND) {
-#ifdef BUC60547
     TopoDS_Iterator anExplor (SH);
-#else
-    TopExp_Explorer anExplor (SH, TopAbs_VERTEX);
-#endif
+
     if (!anExplor.More()) // Shape vide -> Assemblage vide.
       return;
   }
-  
+
   Handle (Prs3d_Drawer) defdrawer = GetContext()->DefaultDrawer();
   if (defdrawer->DrawHiddenLine()) 
     {myDrawer->EnableDrawHiddenLine();}
   else {myDrawer->DisableDrawHiddenLine();}
-  
+
   Aspect_TypeOfDeflection prevdef = defdrawer->TypeOfDeflection();
   defdrawer->SetTypeOfDeflection(Aspect_TOD_RELATIVE);
 
-// coefficients pour le calcul
+// coefficients for calculation
 
   Standard_Real prevangle, newangle ,prevcoeff,newcoeff ; 
-  if (OwnHLRDeviationAngle(newangle,prevangle) || OwnHLRDeviationCoefficient(newcoeff, prevcoeff))
-      
-    if (Abs (newangle - prevangle) > Precision::Angular() ||
-       Abs (newcoeff - prevcoeff) > Precision::Confusion()  ) { 
+  Standard_Boolean isOwnHLRDeviationAngle = OwnHLRDeviationAngle(newangle,prevangle);
+  Standard_Boolean isOwnHLRDeviationCoefficient = OwnHLRDeviationCoefficient(newcoeff,prevcoeff);
+  if (((Abs (newangle - prevangle) > Precision::Angular()) && isOwnHLRDeviationAngle) ||
+      ((Abs (newcoeff - prevcoeff) > Precision::Confusion()) && isOwnHLRDeviationCoefficient)) {
 #ifdef DEB
       cout << "AIS_Shape : compute"<<endl;
       cout << "newangle  : " << newangle << " # de " << "prevangl  : " << prevangle << " OU "<<endl;
@@ -397,7 +340,15 @@ void AIS_Shape::Compute(const Handle(Prs3d_Projector)& aProjector,
   {
     try {
       OCC_CATCH_SIGNALS
-      StdPrs_HLRPolyShape::Add(aPresentation,SH,myDrawer,aProjector);
+      switch (TypeOfHLR()) {
+        case Prs3d_TOH_Algo:
+          StdPrs_HLRShape::Add (aPresentation, SH, myDrawer, aProjector);
+          break;
+        case Prs3d_TOH_PolyAlgo:
+        default:
+          StdPrs_HLRPolyShape::Add (aPresentation, SH, myDrawer, aProjector);
+          break;
+      }
     }
     catch (Standard_Failure) {
 #ifdef DEB
@@ -407,7 +358,6 @@ void AIS_Shape::Compute(const Handle(Prs3d_Projector)& aProjector,
     }
   }
 
-  
   defdrawer->SetTypeOfDeflection (prevdef);
 }
 
@@ -477,45 +427,27 @@ Standard_Integer AIS_Shape::SelectionMode(const TopAbs_ShapeEnum aType)
 //=======================================================================
 
 void AIS_Shape::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
-                const Standard_Integer aMode)
+                                              const Standard_Integer aMode)
 {
   if(myshape.IsNull()) return;
   if (myshape.ShapeType() == TopAbs_COMPOUND) {
-#ifdef BUC60547
     TopoDS_Iterator anExplor (myshape);
-#else
-    TopExp_Explorer anExplor (myshape, TopAbs_VERTEX);
-#endif
-    if (!anExplor.More()) // Shape vide -> Assemblage vide.
+
+    if (!anExplor.More()) // empty Shape -> empty Assembly.
       return;
   }
 
   static TopAbs_ShapeEnum TypOfSel;
   TypOfSel = AIS_Shape::SelectionType(aMode);
   TopoDS_Shape shape = myshape;
-#ifdef IMP040200
   if( HasTransformation() ) {
     Handle(Geom_Transformation) trsf = Transformation();
     shape = shape.Located(TopLoc_Location(trsf->Trsf())*shape.Location());
   }
-#endif
 
-// POP on protege contre un plantage dans les couches basses
-
-  Standard_Real aDeflection = myDrawer->MaximalChordialDeviation();
-  if (myDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE)
-  {
-    // On calcule la fleche en fonction des min max globaux de la piece:
-    Bnd_Box aBndBox; //= BoundingBox(); ?
-    BRepBndLib::Add (shape, aBndBox);
-    if (!aBndBox.IsVoid())
-    {
-      Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
-      aBndBox.Get (aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
-      aDeflection = Max (aXmax - aXmin, Max (aYmax - aYmin, aZmax - aZmin)) * myDrawer->DeviationCoefficient();
-    }
-  }
+// POP protection against crash in low layers
 
+  Standard_Real aDeflection = GetDeflection(shape, myDrawer);
   Standard_Boolean autoTriangulation = Standard_True;
   try {  
     OCC_CATCH_SIGNALS
@@ -524,7 +456,7 @@ void AIS_Shape::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
                                       shape,
                                       TypOfSel,
                                       aDeflection,
-                                      myDrawer->DeviationAngle(),
+                                      myDrawer->HLRAngle(),
                                       autoTriangulation); 
   } catch ( Standard_Failure ) {
 //    cout << "a Shape should be incorrect : A Selection on the Bnd  is activated   "<<endl;
@@ -540,7 +472,6 @@ void AIS_Shape::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
   StdSelect::SetDrawerForBRepOwner(aSelection,myDrawer);
 }
 
-#ifdef GER61351
 Quantity_NameOfColor AIS_Shape::Color() const {
 Quantity_Color aColor;
   Color(aColor);
@@ -558,7 +489,6 @@ Graphic3d_NameOfMaterial AIS_Shape::Material() const {
 Standard_Real AIS_Shape::Transparency() const {
   return myDrawer->ShadingAspect()->Transparency(myCurrentFacingModel);
 }
-#endif
 
 //=======================================================================
 //function : SetColor
@@ -566,44 +496,28 @@ Standard_Real AIS_Shape::Transparency() const {
 //=======================================================================
 
 void AIS_Shape::SetColor(const Quantity_NameOfColor aCol)
-#ifdef GER61351
 {
   SetColor(Quantity_Color(aCol));
 }
 
+//=======================================================================
+//function : SetColor
+//purpose  : 
+//=======================================================================
+
 void AIS_Shape::SetColor(const Quantity_Color &aCol)
-#endif
 {
-  hasOwnColor = Standard_True;
-#ifdef GER61351
   if( !HasColor() && !IsTransparent() && !HasMaterial() ) {
-       myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
+    myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
   }
-#else
-  myOwnColor  = aCol; 
-  if(!myDrawer->HasShadingAspect()){
-    Handle(Prs3d_ShadingAspect) asp = new Prs3d_ShadingAspect();
-// recuperons le materiau reference...
-    if(myDrawer->HasLink()){
-      const Handle(Prs3d_Drawer)& refdr = myDrawer->Link();
-      Graphic3d_MaterialAspect theRefMat = 
-       refdr->ShadingAspect()->Aspect()->FrontMaterial();
-      theRefMat.SetTransparency(myTransparency);
-      asp->SetMaterial(theRefMat);
-    }   
-    
-    myDrawer->SetShadingAspect(asp);
-  } 
-#endif
+  hasOwnColor = Standard_True;
 
-#ifdef GER61351
   myDrawer->ShadingAspect()->SetColor(aCol,myCurrentFacingModel);
-#else
-  myDrawer->ShadingAspect()->SetColor(aCol);
-#endif
+  myDrawer->ShadingAspect()->SetTransparency(myTransparency,myCurrentFacingModel);
   myDrawer->SetShadingAspectGlobal(Standard_False);
-    
-  Standard_Real WW = HasWidth()? Width():AIS_GraphicTool::GetLineWidth(myDrawer->Link(),AIS_TOA_Line);
+
+
+  const Standard_Real WW = HasWidth()? Width():AIS_GraphicTool::GetLineWidth(myDrawer->Link(),AIS_TOA_Line);
 
   myDrawer->SetLineAspect(new Prs3d_LineAspect(aCol,Aspect_TOL_SOLID,WW));
   myDrawer->SetWireAspect(new Prs3d_LineAspect(aCol,Aspect_TOL_SOLID,WW));
@@ -611,34 +525,32 @@ void AIS_Shape::SetColor(const Quantity_Color &aCol)
   myDrawer->SetUnFreeBoundaryAspect(new Prs3d_LineAspect(aCol,Aspect_TOL_SOLID,WW));
   myDrawer->SetSeenLineAspect(new Prs3d_LineAspect(aCol,Aspect_TOL_SOLID,WW));
 
-  // modif du shading rapide...
+  // fast shading modification...
   if(!GetContext().IsNull()){
     if( GetContext()->MainPrsMgr()->HasPresentation(this,1)){
-      Handle(Prs3d_Presentation) P = GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation();
-      Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(P);
-      Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect();
-#ifdef BUC60577
-      P->SetPrimitivesAspect(a4bis);
-      G->SetGroupPrimitivesAspect(a4bis);
-#else
-      a4bis->SetInteriorColor(Quantity_Color(aCol)); // Already done above in SetColor(...)    
-
-//***test rob : pour avoir la vraie couleur demandee en shading ***
-// mais du coup, le shading est "plat" ...****
-//      Graphic3d_MaterialAspect FMAT = a4bis->FrontMaterial();
-//      FMAT.SetColor(Quantity_Color(aCol));
-//      a4bis->SetFrontMaterial(FMAT);
-//******
-
-      P->SetPrimitivesAspect(myDrawer->ShadingAspect()->Aspect());
-      G->SetGroupPrimitivesAspect(myDrawer->ShadingAspect()->Aspect());
-#endif
-    }  
+      Handle(Prs3d_Presentation) aPresentation = 
+        GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation();
+      Handle(Graphic3d_Group) aCurGroup = Prs3d_Root::CurrentGroup(aPresentation);
+      Handle(Graphic3d_AspectFillArea3d) anAreaAspect = myDrawer->ShadingAspect()->Aspect();
+      Handle(Graphic3d_AspectLine3d) aLineAspect = myDrawer->LineAspect()->Aspect();
+
+      // Set aspects for presentation and for group
+      aPresentation->SetPrimitivesAspect(anAreaAspect);
+      aPresentation->SetPrimitivesAspect(aLineAspect);
+      // Check if aspect of given type is set for the group, 
+      // because setting aspect for group with no already set aspect
+      // can lead to loss of presentation data
+      if (aCurGroup->IsGroupPrimitivesAspectSet(Graphic3d_ASPECT_FILL_AREA))
+        aCurGroup->SetGroupPrimitivesAspect(anAreaAspect);
+      if (aCurGroup->IsGroupPrimitivesAspectSet(Graphic3d_ASPECT_LINE))
+        aCurGroup->SetGroupPrimitivesAspect(aLineAspect);
+    }
   }
 
   LoadRecomputable(0);
-  LoadRecomputable(2); 
+  LoadRecomputable(2);
 }
+
 //=======================================================================
 //function : UnsetColor
 //purpose  : 
@@ -646,24 +558,24 @@ void AIS_Shape::SetColor(const Quantity_Color &aCol)
 
 void AIS_Shape::UnsetColor()
 {
-  // Evitons les stupidites...
-  if(!HasColor() ){  myToRecomputeModes.Clear();
-                    return;}
-  
+  if ( !HasColor() )
+  {
+    myToRecomputeModes.Clear();
+    return;
+  }
   hasOwnColor = Standard_False;
 
   Handle(Prs3d_LineAspect) NullAsp;
   Handle(Prs3d_ShadingAspect) NullShA;
   
-  if(!HasWidth()){
+  if(!HasWidth()) {
     myDrawer->SetLineAspect(NullAsp);
     myDrawer->SetWireAspect(NullAsp);
     myDrawer->SetFreeBoundaryAspect(NullAsp);
     myDrawer->SetUnFreeBoundaryAspect(NullAsp);
     myDrawer->SetSeenLineAspect(NullAsp);
   }
-  else{
-#ifdef GER61351
+  else {
     Quantity_Color CC;
     AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line,CC);
     myDrawer->LineAspect()->SetColor(CC);
@@ -675,43 +587,50 @@ void AIS_Shape::UnsetColor()
     myDrawer->UnFreeBoundaryAspect()->SetColor(CC);
     AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Seen,CC);
     myDrawer->SeenLineAspect()->SetColor(CC);
-#else
-    myDrawer->LineAspect()->SetColor(AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line));
-    myDrawer->WireAspect()->SetColor(AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Wire));
-    myDrawer->FreeBoundaryAspect()->SetColor(AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Free));
-    myDrawer->UnFreeBoundaryAspect()->SetColor(AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_UnFree));
-    myDrawer->SeenLineAspect()->SetColor(AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Seen));
-#endif
   }
-  
-  if(myDrawer->HasShadingAspect()){
+
+  if( HasMaterial() || IsTransparent()) {
+    Graphic3d_MaterialAspect mat = AIS_GraphicTool::GetMaterial(HasMaterial()? myDrawer : myDrawer->Link());
+    if( HasMaterial() ) {
+      Quantity_Color color = myDrawer->Link()->ShadingAspect()->Color(myCurrentFacingModel);
+      mat.SetColor(color);
+    }
+    if( IsTransparent() ) {
+      Standard_Real trans = myDrawer->ShadingAspect()->Transparency(myCurrentFacingModel);
+      mat.SetTransparency(trans);
+    }
+    myDrawer->ShadingAspect()->SetMaterial(mat,myCurrentFacingModel);
+  }
+  else {
     myDrawer->SetShadingAspect(NullShA);
-  }    
-  
+  }
+
   if(!GetContext().IsNull()){
     if(GetContext()->MainPrsMgr()->HasPresentation(this,1)){
-      Handle(Prs3d_Presentation) P = GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation();
-      Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(P);
-      
-      Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->Link()->ShadingAspect()->Aspect();
-#ifdef GER61351
+      Handle(Prs3d_Presentation) aPresentation = 
+        GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation();
+      Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(aPresentation);
+
+      Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->Link()->ShadingAspect()->Aspect();
+      Handle(Graphic3d_AspectLine3d) aLineAsp = myDrawer->Link()->LineAspect()->Aspect();
       Quantity_Color CC;
       AIS_GraphicTool::GetInteriorColor(myDrawer->Link(),CC);
-      a4bis->SetInteriorColor(CC);
-#else
-      Quantity_NameOfColor KOL = AIS_GraphicTool::GetInteriorColor(myDrawer->Link());
-      a4bis->SetInteriorColor(Quantity_Color(KOL));
-#endif
-      P->SetPrimitivesAspect(a4bis);
-      G->SetGroupPrimitivesAspect(a4bis);
+      anAreaAsp->SetInteriorColor(CC);
+      aPresentation->SetPrimitivesAspect(anAreaAsp);
+      aPresentation->SetPrimitivesAspect(aLineAsp);
+      // Check if aspect of given type is set for the group, 
+      // because setting aspect for group with no already set aspect
+      // can lead to loss of presentation data
+      if (aGroup->IsGroupPrimitivesAspectSet(Graphic3d_ASPECT_FILL_AREA))
+        aGroup->SetGroupPrimitivesAspect(anAreaAsp);
+      if (aGroup->IsGroupPrimitivesAspectSet(Graphic3d_ASPECT_LINE))
+        aGroup->SetGroupPrimitivesAspect(aLineAsp);
     }
-}
+  }
   LoadRecomputable(0);
   LoadRecomputable(2);
-  
 }
 
-
 //=======================================================================
 //function : SetWidth
 //purpose  : 
@@ -719,7 +638,7 @@ void AIS_Shape::UnsetColor()
 
 void AIS_Shape::SetWidth(const Standard_Real W)
 {
-  if(HasColor() || HasWidth()){ 
+  if(HasColor() || HasWidth()){
     myDrawer->LineAspect()->SetWidth(W);
     myDrawer->WireAspect()->SetWidth(W);
     myDrawer->FreeBoundaryAspect()->SetWidth(W);
@@ -727,7 +646,6 @@ void AIS_Shape::SetWidth(const Standard_Real W)
     myDrawer->SeenLineAspect()->SetWidth(W);
   }
   else{
-#ifdef GER61351
     Quantity_Color CC;
     AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line,CC);
     myDrawer->SetLineAspect(new Prs3d_LineAspect(CC,Aspect_TOL_SOLID,W));
@@ -739,27 +657,10 @@ void AIS_Shape::SetWidth(const Standard_Real W)
     myDrawer->SetUnFreeBoundaryAspect(new Prs3d_LineAspect(CC,Aspect_TOL_SOLID,W));
     AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Seen,CC);
     myDrawer->SetSeenLineAspect(new Prs3d_LineAspect(CC,Aspect_TOL_SOLID,W));
-#else
-    Quantity_NameOfColor KOL = AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line);
-    myDrawer->SetLineAspect(new Prs3d_LineAspect(KOL,Aspect_TOL_SOLID,W));
-
-    KOL = AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Wire);
-    myDrawer->SetWireAspect(new Prs3d_LineAspect(KOL,Aspect_TOL_SOLID,W));
-
-    KOL = AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Free);
-    myDrawer->SetFreeBoundaryAspect(new Prs3d_LineAspect(KOL,Aspect_TOL_SOLID,W));
-
-    KOL = AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_UnFree);
-    myDrawer->SetUnFreeBoundaryAspect(new Prs3d_LineAspect(KOL,Aspect_TOL_SOLID,W));
-
-    KOL = AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Seen);
-    myDrawer->SetSeenLineAspect(new Prs3d_LineAspect(KOL,Aspect_TOL_SOLID,W));
-#endif    
   }
   myOwnWidth = W;
-  LoadRecomputable(0); // signifier qu'il faut recalculer uniquement le wireframe....
-  LoadRecomputable(2); // et la boite englobante...
-  
+  LoadRecomputable(0); // means that it is necessary to recompute only the wireframe....
+  LoadRecomputable(2); // and the bounding box...
 }
 
 //=======================================================================
@@ -769,11 +670,15 @@ void AIS_Shape::SetWidth(const Standard_Real W)
 
 void AIS_Shape::UnsetWidth()
 {
-  if(myOwnWidth== 0.0){  myToRecomputeModes.Clear();
-                     return;}
+  if(myOwnWidth == 0.0)
+  {
+    myToRecomputeModes.Clear();
+    return;
+  }
   myOwnWidth=0.0;
+
   Handle(Prs3d_LineAspect) NullAsp;
-  
+
   if(!HasColor()){
     myDrawer->SetLineAspect(NullAsp);
     myDrawer->SetWireAspect(NullAsp);
@@ -791,80 +696,66 @@ void AIS_Shape::UnsetWidth()
   LoadRecomputable(0);
 }
 
-
 //=======================================================================
 //function : SetMaterial
 //purpose  : 
 //=======================================================================
+
 void AIS_Shape::SetMaterial(const Graphic3d_NameOfMaterial aMat)
 {
-#ifdef GER61351
-  if( !HasColor() && !IsTransparent() && !HasMaterial() ) {
-       myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
-  }
-  myDrawer->ShadingAspect()->SetMaterial(aMat,myCurrentFacingModel);
-  hasOwnMaterial = Standard_True;
-#else
-  AIS_InteractiveObject::SetMaterial(aMat);
-#endif
-  if(!GetContext().IsNull()){
-    if(GetContext()->MainPrsMgr()->HasPresentation(this,1)){
-      Handle(Prs3d_Presentation) P = GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation();
-      Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(P);
-      
-      Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect();
-      P->SetPrimitivesAspect(a4bis);
-      G->SetGroupPrimitivesAspect(a4bis);
-    }
-  }
-  myRecomputeEveryPrs =Standard_False; // aucun mode a recalculer :uniquement update viewer
-  myToRecomputeModes.Clear();  
+  SetMaterial(Graphic3d_MaterialAspect(aMat));
 }
+
 //=======================================================================
 //function : SetMaterial
 //purpose  : 
 //=======================================================================
+
 void AIS_Shape::SetMaterial(const Graphic3d_MaterialAspect& aMat)
 {
-#ifdef GER61351
   if( !HasColor() && !IsTransparent() && !HasMaterial() ) {
-       myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
+    myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
   }
-  myDrawer->ShadingAspect()->SetMaterial(aMat,myCurrentFacingModel);
   hasOwnMaterial = Standard_True;
-#else
-  AIS_InteractiveObject::SetMaterial(aMat);
-#endif  
+
+  myDrawer->ShadingAspect()->SetMaterial(aMat,myCurrentFacingModel);
+  myDrawer->ShadingAspect()->SetTransparency(myTransparency,myCurrentFacingModel);
+
   if(!GetContext().IsNull()){
-  if(GetContext()->MainPrsMgr()->HasPresentation(this,1)){
-    Handle(Prs3d_Presentation) P = GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation();
-    Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(P);
+    if(GetContext()->MainPrsMgr()->HasPresentation(this,1)){
+      Handle(Prs3d_Presentation) aPresentation = 
+        GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation();
+      Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(aPresentation);
     
-    Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect();
-    P->SetPrimitivesAspect(a4bis);
-    G->SetGroupPrimitivesAspect(a4bis);
+      Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->ShadingAspect()->Aspect();
+      aPresentation->SetPrimitivesAspect(anAreaAsp);
+      // Check if aspect of given type is set for the group, 
+      // because setting aspect for group with no already set aspect
+      // can lead to loss of presentation data
+      if (aGroup->IsGroupPrimitivesAspectSet(Graphic3d_ASPECT_FILL_AREA))
+        aGroup->SetGroupPrimitivesAspect(anAreaAsp);
+    }
+    myRecomputeEveryPrs =Standard_False; // no mode to recalculate  :only viewer update
+    myToRecomputeModes.Clear();
   }
 }
-  myRecomputeEveryPrs =Standard_False; // aucun mode a recalculer :uniquement update viewer
-  myToRecomputeModes.Clear();  
-}
-
 //=======================================================================
 //function : UnsetMaterial
 //purpose  : 
 //=======================================================================
+
 void AIS_Shape::UnsetMaterial()
 {
-#ifdef GER61351
   if( !HasMaterial() ) return;
+
   if( HasColor() || IsTransparent()) {
     Graphic3d_MaterialAspect mat = AIS_GraphicTool::GetMaterial(myDrawer->Link()); 
     if( HasColor() ) {
-       Quantity_Color color = myDrawer->ShadingAspect()->Color(myCurrentFacingModel);
+      Quantity_Color color = myDrawer->ShadingAspect()->Color(myCurrentFacingModel);
       mat.SetColor(color);
     }
     if( IsTransparent() ) {
-       Standard_Real trans = myDrawer->ShadingAspect()->Transparency(myCurrentFacingModel);
+      Standard_Real trans = myDrawer->ShadingAspect()->Transparency(myCurrentFacingModel);
       mat.SetTransparency(trans);
     }
     myDrawer->ShadingAspect()->SetMaterial(mat,myCurrentFacingModel);
@@ -873,24 +764,24 @@ void AIS_Shape::UnsetMaterial()
     myDrawer->SetShadingAspect(SA);
   }
   hasOwnMaterial = Standard_False;
-#else
-  AIS_InteractiveObject::UnsetMaterial();
-#endif
   if(!GetContext().IsNull()){
-
     if(GetContext()->MainPrsMgr()->HasPresentation(this,1)){
-      Handle(Prs3d_Presentation) P = GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation();
-      Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(P);
-      
-      Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect();
-      P->SetPrimitivesAspect(a4bis);
-      G->SetGroupPrimitivesAspect(a4bis);
+      Handle(Prs3d_Presentation) aPresentation = 
+        GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation();
+      Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(aPresentation);
+      Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->ShadingAspect()->Aspect();
+      aPresentation->SetPrimitivesAspect(anAreaAsp);
+      // Check if aspect of given type is set for the group, 
+      // because setting aspect for group with no already set aspect
+      // can lead to loss of presentation data
+      if (aGroup->IsGroupPrimitivesAspectSet(Graphic3d_ASPECT_FILL_AREA))
+        aGroup->SetGroupPrimitivesAspect(anAreaAsp);
     }
   }
-  myRecomputeEveryPrs =Standard_False; // aucun mode a recalculer :uniquement update viewer
+  myRecomputeEveryPrs =Standard_False; // no mode to recalculate :only viewer update
   myToRecomputeModes.Clear();  
-  
 }
+
 //=======================================================================
 //function : SetTransparency
 //purpose  : 
@@ -898,78 +789,80 @@ void AIS_Shape::UnsetMaterial()
 
 void AIS_Shape::SetTransparency(const Standard_Real AValue)
 {
-#ifdef GER61351
-  if(!HasColor() && !HasMaterial() ) {
-        myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
+  if ( !HasColor() && !HasMaterial() ) {
+    myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
   }
   myDrawer->ShadingAspect()->SetTransparency(AValue,myCurrentFacingModel);
   myTransparency = AValue;
-#else
-  AIS_InteractiveObject::SetTransparency(AValue);
-#endif  
+
   if(!GetContext().IsNull()){
     if(GetContext()->MainPrsMgr()->HasPresentation(this,1)){
-      Handle(Prs3d_Presentation) P = GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation();
-      Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(P);
-      
-      Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect();
-      P->SetPrimitivesAspect(a4bis);
-#ifdef BUC60918        //force highest priority for transparent objects
-      P->SetDisplayPriority(10);       
-#endif
-      G->SetGroupPrimitivesAspect(a4bis);
+      Handle(Prs3d_Presentation) aPresentation = 
+        GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation();
+      Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(aPresentation);
+      Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->ShadingAspect()->Aspect();
+      aPresentation->SetPrimitivesAspect(anAreaAsp);
+      //force highest priority for transparent objects
+      aPresentation->SetDisplayPriority(10);
+      // Check if aspect of given type is set for the group, 
+      // because setting aspect for group with no already set aspect
+      // can lead to loss of presentation data
+      if (aGroup->IsGroupPrimitivesAspectSet(Graphic3d_ASPECT_FILL_AREA))
+        aGroup->SetGroupPrimitivesAspect(anAreaAsp);
     }
   }
-  myRecomputeEveryPrs =Standard_False; // aucun mode a recalculer :uniquement update viewer
-  myToRecomputeModes.Clear();  
-  
+  myRecomputeEveryPrs =Standard_False; // no mode to recalculate :only viewer update
+  myToRecomputeModes.Clear();
 }
 
 //=======================================================================
 //function : UnsetTransparency
 //purpose  : 
 //=======================================================================
+
 void AIS_Shape::UnsetTransparency()
 {
-#ifdef GER61351
-  if(HasColor() || HasMaterial() ) {
+  if( HasColor() || HasMaterial() ) {
     myDrawer->ShadingAspect()->SetTransparency(0.0,myCurrentFacingModel);
   } else {
     Handle(Prs3d_ShadingAspect) SA;
     myDrawer->SetShadingAspect(SA);
   }
+
   myTransparency = 0.0;
-#else
-  AIS_InteractiveObject::UnsetTransparency();
-#endif
+
   if(!GetContext().IsNull()){
-    
     if(GetContext()->MainPrsMgr()->HasPresentation(this,1)){
-      Handle(Prs3d_Presentation) P = GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation();
-      Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(P);
-      
-      Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect();
-      P->SetPrimitivesAspect(a4bis);
-      G->SetGroupPrimitivesAspect(a4bis);
-#ifdef BUC60918        
-      P->ResetDisplayPriority();
-#endif
+      Handle(Prs3d_Presentation) aPresentation = 
+        GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation();
+      Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(aPresentation);
+      Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->ShadingAspect()->Aspect();
+      aPresentation->SetPrimitivesAspect(anAreaAsp);
+      // Check if aspect of given type is set for the group, 
+      // because setting aspect for group with no already set aspect
+      // can lead to loss of presentation data
+      if (aGroup->IsGroupPrimitivesAspectSet(Graphic3d_ASPECT_FILL_AREA))
+        aGroup->SetGroupPrimitivesAspect(anAreaAsp);
+
+      aPresentation->ResetDisplayPriority();
     }
   }
-  myRecomputeEveryPrs =Standard_False; // aucun mode a recalculer :uniquement update viewer
-  myToRecomputeModes.Clear();  
+  myRecomputeEveryPrs =Standard_False; // no mode to recalculate :only viewer update
+  myToRecomputeModes.Clear();
 }
 
+//=======================================================================
+//function : LoadRecomputable
+//purpose  : 
+//=======================================================================
 
 void AIS_Shape::LoadRecomputable(const Standard_Integer TheMode)
 {
-  myRecomputeEveryPrs =Standard_False;
+  myRecomputeEveryPrs = Standard_False;
   if(!IsInList(myToRecomputeModes,TheMode))
     myToRecomputeModes.Append(TheMode);
 }
 
-
-
 //=======================================================================
 //function : BoundingBox
 //purpose  : 
@@ -978,20 +871,17 @@ void AIS_Shape::LoadRecomputable(const Standard_Integer TheMode)
 const Bnd_Box& AIS_Shape::BoundingBox()  
 {
   if (myshape.ShapeType() == TopAbs_COMPOUND) {
-#ifdef BUC60547
     TopoDS_Iterator anExplor (myshape);
-#else
-    TopExp_Explorer anExplor (myshape, TopAbs_VERTEX);
-#endif
-    if (!anExplor.More()) { // Shape vide -> Assemblage vide.
-      myBB.SetVoid();      
+
+    if (!anExplor.More()) { // empty Shape  -> empty Assembly.
+      myBB.SetVoid();
       return myBB;
     }
   }
 
   if(myCompBB) {
     BRepBndLib::AddClose(myshape, myBB);
-    myCompBB = Standard_False;    
+    myCompBB = Standard_False;
   }
   return myBB;
 }
@@ -1009,10 +899,8 @@ Standard_Boolean AIS_Shape::SetOwnDeviationCoefficient ()
   Standard_Boolean itSet = myDrawer->IsOwnDeviationCoefficient();
   if(itSet)  myDrawer->SetDeviationCoefficient();
   return itSet;
-
 }
 
-
 //=======================================================================
 //function : SetHLROwnDeviationCoefficient
 //purpose  : resets myhasOwnHLRDeviationCoefficient to Standard_False and
@@ -1099,7 +987,6 @@ void AIS_Shape::SetAngleAndDeviation ( const Standard_Real  anAngle )
   Standard_Real OutAngl,OutDefl;
   HLRBRep::PolyHLRAngleAndDeflection(anAngle,OutAngl,OutDefl);
   SetOwnDeviationAngle(anAngle) ;
-//  SetOwnDeviationAngle(OutAngl) ;
   SetOwnDeviationCoefficient(OutDefl) ;
   myInitAng = anAngle;
   SetToUpdate(0);
@@ -1147,7 +1034,7 @@ void AIS_Shape::SetOwnHLRDeviationAngle ( const Standard_Real  anAngle )
 //=======================================================================
 
 Standard_Boolean AIS_Shape::OwnDeviationCoefficient ( Standard_Real &  aCoefficient,
-                                                     Standard_Real & aPreviousCoefficient ) const
+                                                      Standard_Real & aPreviousCoefficient ) const
 {
   aCoefficient = myDrawer->DeviationCoefficient();
   aPreviousCoefficient = myDrawer->PreviousDeviationCoefficient ();
@@ -1160,7 +1047,7 @@ Standard_Boolean AIS_Shape::OwnDeviationCoefficient ( Standard_Real &  aCoeffici
 //=======================================================================
 
 Standard_Boolean AIS_Shape::OwnHLRDeviationCoefficient ( Standard_Real & aCoefficient,
-                                                        Standard_Real & aPreviousCoefficient ) const
+                                                         Standard_Real & aPreviousCoefficient ) const
 {
   aCoefficient = myDrawer->HLRDeviationCoefficient();
   aPreviousCoefficient = myDrawer->PreviousHLRDeviationCoefficient ();
@@ -1174,7 +1061,7 @@ Standard_Boolean AIS_Shape::OwnHLRDeviationCoefficient ( Standard_Real & aCoeffi
 //=======================================================================
 
 Standard_Boolean AIS_Shape::OwnDeviationAngle ( Standard_Real &  anAngle,
-                                               Standard_Real & aPreviousAngle ) const
+                                                Standard_Real & aPreviousAngle ) const
 {
   anAngle = myDrawer->DeviationAngle();
   aPreviousAngle = myDrawer->PreviousDeviationAngle (); 
@@ -1187,10 +1074,9 @@ Standard_Boolean AIS_Shape::OwnDeviationAngle ( Standard_Real &  anAngle,
 //=======================================================================
 
 Standard_Boolean AIS_Shape::OwnHLRDeviationAngle ( Standard_Real &  anAngle,
-                                                  Standard_Real & aPreviousAngle ) const
+                                                   Standard_Real & aPreviousAngle ) const
 {
   anAngle = myDrawer->HLRAngle();
   aPreviousAngle = myDrawer->PreviousHLRDeviationAngle (); 
   return myDrawer->IsOwnHLRDeviationAngle();
-
 }