0024252: GCC warnings on breakage of strict-aliasing rules
[occt.git] / src / Visual3d / Visual3d_View.cxx
old mode 100755 (executable)
new mode 100644 (file)
index c93e96d..6872ba6
@@ -1,20 +1,16 @@
 // Copyright (c) 1995-1999 Matra Datavision
-// Copyright (c) 1999-2012 OPEN CASCADE SAS
+// Copyright (c) 1999-2014 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.
+// This file is part of Open CASCADE Technology software library.
 //
-// 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.
+// This library is free software; you can redistribute it and / or modify it
+// under the terms of the GNU Lesser General Public version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
 //
-// 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.
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
 
 /***********************************************************************
 
@@ -48,7 +44,6 @@
       ??-11-97  : CAL ; Retrait de la dependance avec math. Calcul developpe.
       ??-11-97  : CAL ; Ajout de NumberOfDisplayedStructures
       07-08-97  : PCT ; ajout support texture mapping
-      05-01-98  : CAL ; Ajout de AnimationMode
       15-01-98  : FMN ; FRA60019 calcul Ratio pour MyViewMappingReset
       15-01-98  : CAL ; Ajout de la transformation d'une TOS_COMPUTED
       26-01-98  : CAL ; Ajout de la methode HaveTheSameOwner
 #define BUC60572        //GG_03-08-99    Add protection on Zclipping & Zcueing planes
 //              positions.
 
-#define BUC60570        //GG 14-09-99 Don't activates lighting
-//                      when the view shading model is NONE.
-
 #define GER61454        //GG 14-09-99 Activates model clipping planes
 
-#define IMP140100       //GG14-01-00 Add ViewManager( ) method
-
-#define G003            //EUG 30-09-00 Degeneration management
-//                                     Backfacing management
-
 #define RIC120302       //GG Add a NEW SetWindow method which enable
 //                      to connect a graphic widget and context to OGL.
 
-#define  BUC61044    /* 25/10/01 SAV ; added functionality to control gl depth testing
-                        from higher API */
-#define  BUC61045    /* 25/10/01 SAV ; added functionality to control gl lighting
-                        from higher API */
+//BUC61044 25/10/01 SAV ; added functionality to control gl depth testing from higher API
+//BUC61045 25/10/01 SAV ; added functionality to control gl lighting from higher API
 
-#define OCC1188         //SAV Added methods to set background image
+//OCC1188 SAV Added methods to set background image
 
 /*----------------------------------------------------------------------*/
 /*
 #include <Graphic3d_DataStructureManager.hxx>
 
 #include <Graphic3d_GraphicDriver.hxx>
-#include <Graphic3d_GraphicDevice.hxx>
 
 #include <Graphic3d_Vector.hxx>
 #include <Graphic3d_Vertex.hxx>
 #include <Visual3d_HSetOfLight.hxx>
 #include <Visual3d_SetIteratorOfSetOfLight.hxx>
 
-#include <Visual3d_ClipPlane.hxx>
-#include <Visual3d_SetOfClipPlane.hxx>
-#include <Visual3d_HSetOfClipPlane.hxx>
-#include <Visual3d_SetIteratorOfSetOfClipPlane.hxx>
-
 #include <Visual3d_SetIteratorOfSetOfView.hxx>
 
 #include <Graphic3d_TextureEnv.hxx>
 
 #include <TColStd_HArray2OfReal.hxx>
 
-#ifndef WNT
-# include <Xw_Window.hxx>
+#if (defined(_WIN32) || defined(__WIN32__))
+  #include <WNT_Window.hxx>
+#elif (defined(__APPLE__) && !defined(MACOSX_USE_GLX))
+  #include <Cocoa_Window.hxx>
 #else
-# include <WNT_Window.hxx>
-#endif  // WNT
+  #include <Xw_Window.hxx>
+#endif
 
 #include <float.h>
 
@@ -196,25 +177,15 @@ MyDisplayedStructure ()
 {
 Standard_Integer i, j;
 
-#ifdef IMP140100
         MyPtrViewManager        = AManager.operator->();
-#else
-        MyPtrViewManager        = (void *) AManager.operator->();
-#endif
-
-        memset (&MyCView, 0, sizeof(MyCView));
         MyCView.ViewId          = int (AManager->Identification (this));
         MyCView.Active          = 0;
         MyCView.IsDeleted       = 0;
 
-        MyCView.WsId    = -1;
-        MyCView.DefWindow.IsDefined     = 0;
+        MyCView.WsId                  = -1;
+        MyCView.DefWindow.IsDefined   = 0;
 
-        MyCView.Context.NbActiveLight   = 0;
-        MyCView.Context.NbActivePlane   = 0;
-#ifdef GER61454
-        MyCView.Context.ActivePlane = NULL;
-#endif
+        MyCView.Context.NbActiveLight = 0;
 
         for (i=0; i<=3; i++)
                 for (j=0; j<=3; j++)
@@ -282,19 +253,12 @@ Standard_Real um, vm, uM, vM;
 
         MyCView.Context.ZBufferActivity = -1;
 
-        MyMatOfMapIsModified    = Standard_True;
-        MyMatOfOriIsModified    = Standard_True;
         MyMatOfMapIsEvaluated   = Standard_False;
         MyMatOfOriIsEvaluated   = Standard_False;
 
-        DegenerateModeIsActive  = Standard_False;
-        AnimationModeIsActive   = Standard_False;
-#ifdef G003
-        MyCView.IsDegenerates     = 0;
-        MyCView.IsDegeneratesPrev = 0;
+        IsInitialized = Standard_False;
         ComputedModeIsActive      = Standard_False;
         MyCView.Backfacing        = 0;
-#endif  // G003
 
         MyCView.ptrUnderLayer = 0;
         MyCView.ptrOverLayer = 0;
@@ -302,10 +266,7 @@ Standard_Real um, vm, uM, vM;
         MyCView.GDisplayCB = 0;
         MyCView.GClientData = 0;
 
-Handle(Aspect_GraphicDriver) agd =
-        (MyViewManager->GraphicDevice ())->GraphicDriver ();
-
-        MyGraphicDriver = *(Handle(Graphic3d_GraphicDriver) *) &agd;
+        MyGraphicDriver = MyViewManager->GraphicDriver();
 
 }
 
@@ -319,31 +280,21 @@ MyDisplayedStructure ()
 {
 Standard_Integer i, j;
 
-#ifdef IMP140100
         MyPtrViewManager        = AManager.operator->();
-#else
-        MyPtrViewManager        = (void *) AManager.operator->();
-#endif
-
         MyViewOrientation       = VO;
         MyViewMapping           = VM;
         MyContext               = CTX;
         MyViewOrientationReset  = VO;
         MyViewMappingReset      = VM;
 
-        memset (&MyCView, 0, sizeof(MyCView));
         MyCView.ViewId          = int (AManager->Identification (this));
         MyCView.Active          = 0;
         MyCView.IsDeleted       = 0;
 
-        MyCView.WsId    = -1;
-        MyCView.DefWindow.IsDefined     = 0;
+        MyCView.WsId                  = -1;
+        MyCView.DefWindow.IsDefined   = 0;
 
-        MyCView.Context.NbActiveLight   = 0;
-        MyCView.Context.NbActivePlane   = 0;
-#ifdef GER61454
-        MyCView.Context.ActivePlane = NULL;
-#endif
+        MyCView.Context.NbActiveLight = 0;
 
         for (i=0; i<=3; i++)
                 for (j=0; j<=3; j++)
@@ -377,7 +328,8 @@ Standard_Real Sx, Sy, Sz;
           MyCView.Orientation.IsCustomMatrix = 1;
           for ( i = 0; i < 4; i++)
             for ( j = 0; j < 4; j++)
-              MyCView.Orientation.ModelViewMatrix[i][j] = MyViewOrientation.MyModelViewMatrix->Value(i,j);
+              MyCView.Orientation.ModelViewMatrix[i][j] =
+                (Standard_ShortReal)MyViewOrientation.MyModelViewMatrix->Value(i,j);
         }
         else {
           MyCView.Orientation.IsCustomMatrix = 0;
@@ -413,7 +365,8 @@ Standard_Real um, vm, uM, vM;
           MyCView.Mapping.IsCustomMatrix = 1;
           for ( i = 0; i < 4; i++)
             for ( j = 0; j < 4; j++)
-              MyCView.Mapping.ProjectionMatrix[i][j] = MyViewMapping.MyProjectionMatrix->Value(i,j);
+              MyCView.Mapping.ProjectionMatrix[i][j] =
+                (Standard_ShortReal)MyViewMapping.MyProjectionMatrix->Value(i,j);
         }
         else {
           MyCView.Mapping.IsCustomMatrix = 0;
@@ -427,16 +380,11 @@ Standard_Real um, vm, uM, vM;
 
         MyCView.Context.ZBufferActivity = -1;
 
-        MyMatOfMapIsModified    = Standard_True;
-        MyMatOfOriIsModified    = Standard_True;
         MyMatOfMapIsEvaluated   = Standard_False;
         MyMatOfOriIsEvaluated   = Standard_False;
-#ifdef G003
-        AnimationModeIsActive     = Standard_False;
-        MyCView.IsDegenerates     = 0;
-        MyCView.IsDegeneratesPrev = 0;
+
+        IsInitialized = Standard_False;
         ComputedModeIsActive      = Standard_False;
-#endif  // G003
 
         MyCView.ptrUnderLayer = 0;
         MyCView.ptrOverLayer = 0;
@@ -444,10 +392,7 @@ Standard_Real um, vm, uM, vM;
         MyCView.GDisplayCB = 0;
         MyCView.GClientData = 0;
 
-Handle(Aspect_GraphicDriver) agd =
-        (MyViewManager->GraphicDevice ())->GraphicDriver ();
-
-        MyGraphicDriver = *(Handle(Graphic3d_GraphicDriver) *) &agd;
+        MyGraphicDriver = MyViewManager->GraphicDriver();
 
 }
 
@@ -472,36 +417,38 @@ void Visual3d_View::SetWindow (const Handle(Aspect_Window)&      AWindow,
 }
 // RIC120302
 
-void Visual3d_View::SetWindow (const Handle(Aspect_Window)& AWindow) {
+void Visual3d_View::SetWindow (const Handle(Aspect_Window)& theWindow)
+{
 
         if (IsDeleted ()) return;
 
         if (IsDefined ())
                 Visual3d_ViewDefinitionError::Raise ("Window already defined");
 
-        MyWindow        = AWindow;
+        MyWindow        = theWindow;
         MyCView.WsId                    = MyCView.ViewId;
         MyCView.DefWindow.IsDefined     = 1;
-#ifndef WNT
-const Handle(Xw_Window) theWindow = *(Handle(Xw_Window) *) &AWindow;
-        MyCView.DefWindow.XWindow       = theWindow->XWindow ();
-#ifdef RIC120302
-        MyCView.DefWindow.XParentWindow = theWindow->XParentWindow ();
-#endif
+
+#if (defined(_WIN32) || defined(__WIN32__))
+  const Handle(WNT_Window) aWin   = Handle(WNT_Window)::DownCast (theWindow);
+  MyCView.DefWindow.XWindow       = (HWND )(aWin->HWindow());
+  MyCView.DefWindow.XParentWindow = (HWND )(aWin->HParentWindow());
+  WNT_WindowData* aWinData = (WNT_WindowData* )GetWindowLongPtr ((HWND )(aWin->HWindow()), GWLP_USERDATA);
+  aWinData->WNT_WDriver_Ptr = (void* )this;
+  aWinData->WNT_VMgr        = (void* )MyPtrViewManager;
+#elif (defined(__APPLE__) && !defined(MACOSX_USE_GLX))
+  const Handle(Cocoa_Window) aWin = Handle(Cocoa_Window)::DownCast (theWindow);
+  MyCView.DefWindow.XWindow       = (Aspect_Drawable )aWin->HView();
+  MyCView.DefWindow.XParentWindow = NULL;
+  //MyCView.DefWindow.XParentWindow = aWin->HParentWindow();
 #else
-WNT_WindowData* wd;
-const Handle(WNT_Window) theWindow = *(Handle(WNT_Window) *) &AWindow;
-        MyCView.DefWindow.XWindow       = ( HWND )(theWindow->HWindow());
-#ifdef RIC120302
-        MyCView.DefWindow.XParentWindow = ( HWND )(theWindow->HParentWindow());
+  const Handle(Xw_Window) aWin    = Handle(Xw_Window)::DownCast (theWindow);
+  MyCView.DefWindow.XWindow       = aWin->XWindow();
+  //MyCView.DefWindow.XParentWindow = aWin->XParentWindow();
 #endif
-        wd = ( WNT_WindowData* )GetWindowLongPtr (( HWND )(theWindow->HWindow()), GWLP_USERDATA);
-        wd -> WNT_WDriver_Ptr = ( void* )this;
-        wd -> WNT_VMgr        = ( void* )MyPtrViewManager;
-#endif  /* WNT */
 
         Standard_Integer Width, Height;
-        AWindow->Size (Width, Height);
+        theWindow->Size (Width, Height);
 
         MyCView.DefWindow.dx    = float( Width );
         MyCView.DefWindow.dy    = float( Height );
@@ -533,7 +480,7 @@ const Handle(WNT_Window) theWindow = *(Handle(WNT_Window) *) &AWindow;
         // Update planses of model clipping
         UpdatePlanes ();
 
-        // Update light sources 
+        // Update light sources
         UpdateLights ();
 
         /*
@@ -616,11 +563,11 @@ void Visual3d_View::Remove () {
         MyCView.IsDeleted       = 1;
         MyCView.DefWindow.IsDefined     = 0;
 
-        MyMatOfMapIsModified    = Standard_True;
-        MyMatOfOriIsModified    = Standard_True;
         MyMatOfMapIsEvaluated   = Standard_False;
         MyMatOfOriIsEvaluated   = Standard_False;
 
+        IsInitialized = Standard_False;
+
         MyWindow.Nullify ();
 
 }
@@ -752,208 +699,57 @@ Standard_Real Rap;
 
 }
 
-void Visual3d_View::UpdateLights () {
+void Visual3d_View::UpdateLights()
+{
+  if (IsDeleted()
+   || !IsDefined())
+  {
+    return;
+  }
 
-Standard_Integer i, j;
-CALL_DEF_LIGHT *lights=NULL;
+  if (MyContext.Model() == Visual3d_TOM_NONE)
+  {
+    // activate only a white ambient light
+    Graphic3d_CLight aCLight;
+    aCLight.Type        = Visual3d_TOLS_AMBIENT;
+    aCLight.IsHeadlight = Standard_False;
+    aCLight.Color.r() = aCLight.Color.g() = aCLight.Color.b() = 1.0f;
 
-#ifdef BUC60570
-  if( MyContext.Model() == Visual3d_TOM_NONE ) {
-// Activates only a white ambient light
     MyCView.Context.NbActiveLight = 1;
-    lights      = new CALL_DEF_LIGHT [MyCView.Context.NbActiveLight];
-    MyCView.Context.ActiveLight = lights;
-
-    lights[0].WsId              = MyCView.ViewId;
-    lights[0].ViewId    = MyCView.ViewId;
-    lights[0].LightType = int (Visual3d_TOLS_AMBIENT);
-    lights[0].Active    = 1;
-    lights[0].LightId   = 0;
-    lights[0].Headlight = 0;
-    lights[0].Color.r   = lights[0].Color.g = lights[0].Color.b = 1.;
-  } else {
-#endif
-        i       = MyContext.NumberOfActivatedLights ();
-        j       = MyGraphicDriver->InquireLightLimit ();
-        MyCView.Context.NbActiveLight   = (i > j ? j : i);
-
-        if (MyCView.Context.NbActiveLight > 0) {
-
-                // Dynamic Allocation
-                lights  = new CALL_DEF_LIGHT [MyCView.Context.NbActiveLight];
-
-                MyCView.Context.ActiveLight     = lights;
-
-Standard_Real X, Y, Z;
-
-Standard_Real LightConcentration;
-Standard_Real LightAttenuation1;
-Standard_Real LightAttenuation2;
-Standard_Real LightAngle;
-Quantity_Color LightColor;
-Graphic3d_Vertex LightPosition;
-Graphic3d_Vector LightDirection;
-Visual3d_TypeOfLightSource LightType=Visual3d_TOLS_AMBIENT;
-
-                // Parcing of light sources
-                for (j=0; j<MyCView.Context.NbActiveLight; j++) {
-                        LightType       = (MyContext.ActivatedLight (j+1))->LightType ();
-
-                        lights[j].WsId          = MyCView.ViewId;
-                        lights[j].ViewId        = MyCView.ViewId;
-
-                        lights[j].LightType     = int (LightType);
-                        lights[j].Active        = 1;
-                        lights[j].LightId       =
-                                int ((MyContext.ActivatedLight (j+1))->Identification ());
-                        lights[j].Headlight = (MyContext.ActivatedLight (j+1))->Headlight ()? 1:0;
-
-                        switch (LightType) {
-
-                        case Visual3d_TOLS_AMBIENT :
-                                (MyContext.ActivatedLight (j+1))->Values (
-                                                        LightColor
-                                                                );
-                        break;
-
-                        case Visual3d_TOLS_POSITIONAL :
-                                (MyContext.ActivatedLight (j+1))->Values (
-                                                        LightColor,
-                                                        LightPosition,
-                                                        LightAttenuation1,
-                                                        LightAttenuation2
-                                                                );
-                        break;
-
-                        case Visual3d_TOLS_DIRECTIONAL :
-                                (MyContext.ActivatedLight (j+1))->Values (
-                                                        LightColor,
-                                                        LightDirection
-                                                                );
-                        break;
-
-                        case Visual3d_TOLS_SPOT :
-                                (MyContext.ActivatedLight (j+1))->Values (
-                                                        LightColor,
-                                                        LightPosition,
-                                                        LightDirection,
-                                                        LightConcentration,
-                                                        LightAttenuation1,
-                                                        LightAttenuation2,
-                                                        LightAngle
-                                                                );
-                        break;
-
-                        }
-
-                        lights[j].Color.r       = float (LightColor.Red ());
-                        lights[j].Color.g       = float (LightColor.Green ());
-                        lights[j].Color.b       = float (LightColor.Blue ());
-
-                        if ( (LightType == Visual3d_TOLS_POSITIONAL) ||
-                             (LightType == Visual3d_TOLS_SPOT) ) {
-                                LightPosition.Coord (X, Y, Z);
-                                lights[j].Position.x    = float (X);
-                                lights[j].Position.y    = float (Y);
-                                lights[j].Position.z    = float (Z);
-                        }
-
-                        if ( (LightType == Visual3d_TOLS_DIRECTIONAL) ||
-                             (LightType == Visual3d_TOLS_SPOT) ) {
-                                LightDirection.Coord (X, Y, Z);
-                                lights[j].Direction.x   = float (X);
-                                lights[j].Direction.y   = float (Y);
-                                lights[j].Direction.z   = float (Z);
-                        }
-
-                        if ( (LightType == Visual3d_TOLS_POSITIONAL) ||
-                             (LightType == Visual3d_TOLS_SPOT) ) {
-                                lights[j].Attenuation[0] =
-                                        float (LightAttenuation1);
-                                lights[j].Attenuation[1] =
-                                        float (LightAttenuation2);
-                        }
-
-                        if (LightType == Visual3d_TOLS_SPOT) {
-                                lights[j].Concentration =
-                                        float (LightConcentration);
-                                lights[j].Angle         =
-                                        float (LightAngle);
-                        }
-                }
-
-        }
-#ifdef BUC60570
+    MyCView.Context.ActiveLight   = &aCLight;
+    MyGraphicDriver->SetLight (MyCView);
+    MyCView.Context.ActiveLight   = NULL;
+    return;
   }
-#endif
-        // management of light sources
-        if (! IsDeleted ())
-                if (IsDefined ())
-                        MyGraphicDriver->SetLight (MyCView);
 
-        // Dynamic allocation
-        if (MyCView.Context.NbActiveLight > 0) delete [] lights;
+  MyCView.Context.NbActiveLight = Min (MyContext.NumberOfActivatedLights(),
+                                       MyGraphicDriver->InquireLightLimit());
+  if (MyCView.Context.NbActiveLight < 1)
+  {
+    MyGraphicDriver->SetLight (MyCView);
+    return;
+  }
 
+  // parcing of light sources
+  MyCView.Context.ActiveLight = new Graphic3d_CLight[MyCView.Context.NbActiveLight];
+  for (Standard_Integer aLightIter = 0; aLightIter < MyCView.Context.NbActiveLight; ++aLightIter)
+  {
+    MyCView.Context.ActiveLight[aLightIter] = MyContext.ActivatedLight (aLightIter + 1)->CLight();
+  }
+  MyGraphicDriver->SetLight (MyCView);
+  delete[] MyCView.Context.ActiveLight;
+  MyCView.Context.ActiveLight = NULL;
 }
 
-void Visual3d_View::UpdatePlanes () {
-
-Standard_Integer i, j;
-CALL_DEF_PLANE *planes=NULL;
-
-        i       = MyContext.NumberOfActivatedClipPlanes ();
-        j       = MyGraphicDriver->InquirePlaneLimit ();
-        MyCView.Context.NbActivePlane   = (i > j ? j : i);
-
-        if (MyCView.Context.NbActivePlane > 0) {
-
-                // Dynamic Allocation 
-#ifdef GER61454 //Keep the plane address for the next Update !
-                if( !MyCView.Context.ActivePlane )
-                   MyCView.Context.ActivePlane = new CALL_DEF_PLANE [j];
-                planes = MyCView.Context.ActivePlane;
-#else
-                planes  = new CALL_DEF_PLANE [MyCView.Context.NbActivePlane];
-
-                MyCView.Context.ActivePlane     = planes;
-#endif
-Standard_Real A, B, C, D;
-
-                // Parcing of clipping planes
-                for (j=0; j<MyCView.Context.NbActivePlane; j++) {
-
-                        planes[j].WsId          = MyCView.ViewId;
-                        planes[j].ViewId        = MyCView.ViewId;
-
-                        planes[j].Active        = 1;
-                        planes[j].PlaneId       =
-                                int ((MyContext.ActivatedClipPlane (j+1))->Identification ());
-
-                        (MyContext.ActivatedClipPlane (j+1))->Plane (A, B, C, D);
-                        planes[j].CoefA         = float (A);
-                        planes[j].CoefB         = float (B);
-                        planes[j].CoefC         = float (C);
-                        planes[j].CoefD         = float (D);
-                }
-
-        }
-
-        // Management of planes of clipping model
-        if (! IsDeleted ())
-                if (IsDefined ())
-                        MyGraphicDriver->SetPlane (MyCView);
-
-        // Dynamic allocation
-#ifdef GER61454
-        if ( MyCView.Context.ActivePlane && (MyCView.Context.NbActivePlane == 0)
- ) {
-          delete [] MyCView.Context.ActivePlane;
-          MyCView.Context.ActivePlane = NULL;
-        }
-#else
-        if (MyCView.Context.NbActivePlane > 0) delete [] planes;
-#endif
+void Visual3d_View::UpdatePlanes()
+{
+  MyCView.Context.ClipPlanes = MyContext.ClipPlanes();
+  if (IsDeleted() || !IsDefined())
+  {
+    return;
+  }
 
+  MyGraphicDriver->SetClipPlanes (MyCView);
 }
 
 void Visual3d_View::SetBackground (const Aspect_Background& ABack) {
@@ -1005,7 +801,6 @@ void Visual3d_View::SetBackgroundImage( const Standard_CString FileName,
                                         const Aspect_FillMethod FillStyle,
                                         const Standard_Boolean update )
 {
-#ifdef OCC1188
   if ( IsDeleted() )
     return;
   if ( !IsDefined() )
@@ -1017,13 +812,11 @@ void Visual3d_View::SetBackgroundImage( const Standard_CString FileName,
     Update();
   else if ( MyViewManager->UpdateMode() == Aspect_TOU_ASAP )
     Update();
-#endif
 }
 
 void Visual3d_View::SetBgImageStyle( const Aspect_FillMethod FillStyle,
                                      const Standard_Boolean update )
 {
-#ifdef OCC1188
   if ( IsDeleted() )
     return;
   if ( !IsDefined() )
@@ -1035,7 +828,6 @@ void Visual3d_View::SetBgImageStyle( const Aspect_FillMethod FillStyle,
     Update();
   else if ( MyViewManager->UpdateMode() == Aspect_TOU_ASAP )
     Update();
-#endif
 }
 
 Aspect_Background Visual3d_View::Background () const {
@@ -1113,7 +905,6 @@ Visual3d_ViewOrientation NewViewOrientation;
 
         SetViewOrientation (NewViewOrientation);
 
-        MyMatOfOriIsModified    = Standard_True;
         MyMatOfOriIsEvaluated   = Standard_False;
 
 }
@@ -1130,93 +921,89 @@ void Visual3d_View::SetViewOrientation (const Visual3d_ViewOrientation& VO) {
 
         MyViewOrientation       = VO;
 
-Standard_Real X, Y, Z;
-
+        Standard_Real X, Y, Z;
         // Tests on modification of parameters.
-Standard_Boolean VUPIsModified  = Standard_False;
-Standard_Boolean VRPIsModified  = Standard_False;
-Standard_Boolean VRUIsModified  = Standard_False;
-Standard_Boolean ScaleIsModified  = Standard_False;
-Standard_Boolean CustomIsModified = Standard_False;
+        Standard_Boolean VUPIsModified  = Standard_False;
+        Standard_Boolean VRPIsModified  = Standard_False;
+        Standard_Boolean VRUIsModified  = Standard_False;
+        Standard_Boolean ScaleIsModified  = Standard_False;
+        Standard_Boolean CustomIsModified = Standard_False;
 
         (MyViewOrientation.ViewReferencePoint ()).Coord (X, Y, Z);
         VUPIsModified =
-            MyCView.Orientation.ViewReferencePoint.x != float (X)
-         || MyCView.Orientation.ViewReferencePoint.y != float (Y)
-         || MyCView.Orientation.ViewReferencePoint.z != float (Z);
+           MyCView.Orientation.ViewReferencePoint.x != float (X)
+        || MyCView.Orientation.ViewReferencePoint.y != float (Y)
+        || MyCView.Orientation.ViewReferencePoint.z != float (Z);
         MyCView.Orientation.ViewReferencePoint.x        = float (X);
         MyCView.Orientation.ViewReferencePoint.y        = float (Y);
         MyCView.Orientation.ViewReferencePoint.z        = float (Z);
 
         (MyViewOrientation.ViewReferencePlane ()).Coord (X, Y, Z);
         VRPIsModified =
-            MyCView.Orientation.ViewReferencePlane.x != float (X)
-         || MyCView.Orientation.ViewReferencePlane.y != float (Y)
-         || MyCView.Orientation.ViewReferencePlane.z != float (Z);
+           MyCView.Orientation.ViewReferencePlane.x != float (X)
+        || MyCView.Orientation.ViewReferencePlane.y != float (Y)
+        || MyCView.Orientation.ViewReferencePlane.z != float (Z);
         MyCView.Orientation.ViewReferencePlane.x        = float (X);
         MyCView.Orientation.ViewReferencePlane.y        = float (Y);
         MyCView.Orientation.ViewReferencePlane.z        = float (Z);
 
         (MyViewOrientation.ViewReferenceUp ()).Coord (X, Y, Z);
         VRUIsModified =
-            MyCView.Orientation.ViewReferenceUp.x != float (X)
-         || MyCView.Orientation.ViewReferenceUp.y != float (Y)
-         || MyCView.Orientation.ViewReferenceUp.z != float (Z);
+           MyCView.Orientation.ViewReferenceUp.x != float (X)
+        || MyCView.Orientation.ViewReferenceUp.y != float (Y)
+        || MyCView.Orientation.ViewReferenceUp.z != float (Z);
         MyCView.Orientation.ViewReferenceUp.x           = float (X);
         MyCView.Orientation.ViewReferenceUp.y           = float (Y);
         MyCView.Orientation.ViewReferenceUp.z           = float (Z);
 
-Standard_Real Sx, Sy, Sz;
-
-        MyViewOrientation.AxialScale(Sx, Sy, Sz);
-       ScaleIsModified =
-            MyCView.Orientation.ViewScaleX != float (X)
-         || MyCView.Orientation.ViewScaleY != float (Y)
-         || MyCView.Orientation.ViewScaleZ != float (Z);
-        MyCView.Orientation.ViewScaleX                  = float (Sx);
-        MyCView.Orientation.ViewScaleY                  = float (Sy);
-        MyCView.Orientation.ViewScaleZ                  = float (Sz);
+        MyViewOrientation.AxialScale(X, Y, Z);
+        ScaleIsModified =
+           MyCView.Orientation.ViewScaleX != float (X)
+        || MyCView.Orientation.ViewScaleY != float (Y)
+        || MyCView.Orientation.ViewScaleZ != float (Z);
+        MyCView.Orientation.ViewScaleX                  = float (X);
+        MyCView.Orientation.ViewScaleY                  = float (Y);
+        MyCView.Orientation.ViewScaleZ                  = float (Z);
 
         CustomIsModified =
-          MyCView.Orientation.IsCustomMatrix != MyViewOrientation.IsCustomMatrix();
+          (MyCView.Orientation.IsCustomMatrix != MyViewOrientation.IsCustomMatrix());
         MyCView.Orientation.IsCustomMatrix = MyViewOrientation.IsCustomMatrix();
         if ( MyViewOrientation.IsCustomMatrix() ) {
           Standard_Integer i, j;
           for (i = 0; i < 4; i++)
             for (j = 0; j < 4; j++) {
-              if (!CustomIsModified) CustomIsModified =
-                MyCView.Orientation.ModelViewMatrix[i][j] != MyViewOrientation.MyModelViewMatrix->Value(i,j);
-              MyCView.Orientation.ModelViewMatrix[i][j] = MyViewOrientation.MyModelViewMatrix->Value(i,j);
+             if (!CustomIsModified) CustomIsModified =
+               MyCView.Orientation.ModelViewMatrix[i][j] != MyViewOrientation.MyModelViewMatrix->Value(i,j);
             }
         }
 
 #ifdef TRACE_TRSF
-cout << "Visual3d_View::SetViewOrientation\n";
-        if (VUPIsModified || VRPIsModified || VRUIsModified || CustomIsModified)
-                cout <<   "VUPIsModified : " << VUPIsModified
-                     << ", VRPIsModified : " << VRPIsModified
-                     << ", VRUIsModified : " << VRUIsModified
-                     << ", CustomIsModified : " << CustomIsModified << "\n" << flush;
+        cout << "Visual3d_View::SetViewOrientation\n";
+        if (VUPIsModified || VRPIsModified || VRUIsModified || ScaleIsModified || CustomIsModified)
+          cout <<   "VUPIsModified : " << VUPIsModified
+          << ", VRPIsModified : " << VRPIsModified
+          << ", VRUIsModified : " << VRUIsModified
+          << ", CustomIsModified : " << CustomIsModified
+          << ", ScaleIsModified : " << ScaleIsModified << "\n" << flush;
         else
-                cout << "no modification\n" << flush;
+          cout << "no modification\n" << flush;
 #endif
 
         // restart if one of parameters is modified
-        if (VUPIsModified || VRPIsModified || VRUIsModified || ScaleIsModified || CustomIsModified) {
+        if (!IsInitialized || VUPIsModified || VRPIsModified
+            || VRUIsModified || ScaleIsModified || CustomIsModified) {
 
-         if (VUPIsModified || VRPIsModified || VRUIsModified || CustomIsModified) {
-                MyMatOfOriIsModified    = Standard_True;
-                MyMatOfOriIsEvaluated   = Standard_False;
-             }
+        MyMatOfOriIsEvaluated = !VUPIsModified && !VRPIsModified
+                              && !VRUIsModified && !ScaleIsModified;
 
-                if (! IsDefined ()) return;
-
-Standard_Boolean AWait = Standard_False;        // => immediate update
-                MyGraphicDriver->ViewOrientation (MyCView, AWait);
+        if (! IsDefined ()) return;
 
-                Compute ();
+        Standard_Boolean AWait = Standard_False;        // => immediate update
+        MyGraphicDriver->ViewOrientation (MyCView, AWait);
+        IsInitialized = Standard_True;
+        Compute ();
 
-                if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
+        if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
         }
 
 }
@@ -1245,95 +1032,92 @@ void Visual3d_View::ViewOrientationReset () {
 
         MyViewOrientation       = MyViewOrientationReset;
 
-Standard_Real X, Y, Z;
+        Standard_Real X, Y, Z;
 
         // Tests on modification of parameters.
-Standard_Boolean VUPIsModified  = Standard_False;
-Standard_Boolean VRPIsModified  = Standard_False;
-Standard_Boolean VRUIsModified  = Standard_False;
-Standard_Boolean ScaleIsModified  = Standard_False;
-Standard_Boolean CustomIsModified = Standard_False;
+        Standard_Boolean VUPIsModified  = Standard_False;
+        Standard_Boolean VRPIsModified  = Standard_False;
+        Standard_Boolean VRUIsModified  = Standard_False;
+        Standard_Boolean ScaleIsModified  = Standard_False;
+        Standard_Boolean CustomIsModified = Standard_False;
 
         (MyViewOrientation.ViewReferencePoint ()).Coord (X, Y, Z);
         VUPIsModified =
-            MyCView.Orientation.ViewReferencePoint.x != float (X)
-         || MyCView.Orientation.ViewReferencePoint.y != float (Y)
-         || MyCView.Orientation.ViewReferencePoint.z != float (Z);
+           MyCView.Orientation.ViewReferencePoint.x != float (X)
+        || MyCView.Orientation.ViewReferencePoint.y != float (Y)
+        || MyCView.Orientation.ViewReferencePoint.z != float (Z);
         MyCView.Orientation.ViewReferencePoint.x        = float (X);
         MyCView.Orientation.ViewReferencePoint.y        = float (Y);
         MyCView.Orientation.ViewReferencePoint.z        = float (Z);
 
         (MyViewOrientation.ViewReferencePlane ()).Coord (X, Y, Z);
         VRPIsModified =
-            MyCView.Orientation.ViewReferencePlane.x != float (X)
-         || MyCView.Orientation.ViewReferencePlane.y != float (Y)
-         || MyCView.Orientation.ViewReferencePlane.z != float (Z);
+           MyCView.Orientation.ViewReferencePlane.x != float (X)
+        || MyCView.Orientation.ViewReferencePlane.y != float (Y)
+        || MyCView.Orientation.ViewReferencePlane.z != float (Z);
         MyCView.Orientation.ViewReferencePlane.x        = float (X);
         MyCView.Orientation.ViewReferencePlane.y        = float (Y);
         MyCView.Orientation.ViewReferencePlane.z        = float (Z);
 
         (MyViewOrientation.ViewReferenceUp ()).Coord (X, Y, Z);
         VRUIsModified =
-            MyCView.Orientation.ViewReferenceUp.x != float (X)
-         || MyCView.Orientation.ViewReferenceUp.y != float (Y)
-         || MyCView.Orientation.ViewReferenceUp.z != float (Z);
+           MyCView.Orientation.ViewReferenceUp.x != float (X)
+        || MyCView.Orientation.ViewReferenceUp.y != float (Y)
+        || MyCView.Orientation.ViewReferenceUp.z != float (Z);
         MyCView.Orientation.ViewReferenceUp.x           = float (X);
         MyCView.Orientation.ViewReferenceUp.y           = float (Y);
         MyCView.Orientation.ViewReferenceUp.z           = float (Z);
 
-Standard_Real Sx, Sy, Sz;
-
-        MyViewOrientation.AxialScale(Sx, Sy, Sz);
-       ScaleIsModified =
-            MyCView.Orientation.ViewScaleX != float (X)
-         || MyCView.Orientation.ViewScaleY != float (Y)
-         || MyCView.Orientation.ViewScaleZ != float (Z);
-        MyCView.Orientation.ViewScaleX                  = float (Sx);
-        MyCView.Orientation.ViewScaleY                  = float (Sy);
-        MyCView.Orientation.ViewScaleZ                  = float (Sz);
+        MyViewOrientation.AxialScale(X, Y, Z);
+        ScaleIsModified =
+           MyCView.Orientation.ViewScaleX != float (X)
+        || MyCView.Orientation.ViewScaleY != float (Y)
+        || MyCView.Orientation.ViewScaleZ != float (Z);
+        MyCView.Orientation.ViewScaleX                  = float (X);
+        MyCView.Orientation.ViewScaleY                  = float (Y);
+        MyCView.Orientation.ViewScaleZ                  = float (Z);
 
         CustomIsModified =
-          MyCView.Orientation.IsCustomMatrix != MyViewOrientation.IsCustomMatrix();
+        MyCView.Orientation.IsCustomMatrix != MyViewOrientation.IsCustomMatrix();
         MyCView.Orientation.IsCustomMatrix = MyViewOrientation.IsCustomMatrix();
         if ( MyViewOrientation.IsCustomMatrix() ) {
           Standard_Integer i, j;
           for (i = 0; i < 4; i++)
             for (j = 0; j < 4; j++) {
-              if (!CustomIsModified) CustomIsModified =
-                MyCView.Orientation.ModelViewMatrix[i][j] != MyViewOrientation.MyModelViewMatrix->Value(i,j);
-              MyCView.Orientation.ModelViewMatrix[i][j] = MyViewOrientation.MyModelViewMatrix->Value(i,j);
+             if (!CustomIsModified) CustomIsModified =
+               MyCView.Orientation.ModelViewMatrix[i][j] != MyViewOrientation.MyModelViewMatrix->Value(i,j);
             }
         }
 
+
 #ifdef TRACE_TRSF
-cout << "Visual3d_View::ViewOrientationReset\n";
-if (VUPIsModified || VRPIsModified || VRUIsModified || CustomIsModified)
-cout <<   "VUPIsModified : " << VUPIsModified
-     << ", VRPIsModified : " << VRPIsModified
-     << ", VRUIsModified : " << VRUIsModified
-     << ", CustomIsModified : " << CustomIsModified << "\n" << flush;
-else
-cout << "no modification\n" << flush;
+        cout << "Visual3d_View::ViewOrientationReset\n";
+        if (VUPIsModified || VRPIsModified || VRUIsModified || ScaleIsModified || CustomIsModified)
+          cout <<   "VUPIsModified : " << VUPIsModified
+          << ", VRPIsModified : " << VRPIsModified
+          << ", VRUIsModified : " << VRUIsModified
+          << ", CustomIsModified : " << CustomIsModified
+          << ", ScaleIsModified : " << ScaleIsModified << "\n" << flush;
+        else
+          cout << "no modification\n" << flush;
 #endif
 
         // Restart if one of parameters is modified
-        if (VUPIsModified || VRPIsModified || VRUIsModified || CustomIsModified) {
-
-         if (VUPIsModified || VRPIsModified || VRUIsModified || CustomIsModified) {
-                MyMatOfOriIsModified    = Standard_True;
-                MyMatOfOriIsEvaluated   = Standard_False;
-             }
+        if (!IsInitialized || VUPIsModified || VRPIsModified
+            || VRUIsModified || ScaleIsModified || CustomIsModified) {
 
-                if (! IsDefined ()) return;
+        MyMatOfOriIsEvaluated = !VUPIsModified && !VRPIsModified
+                              && !VRUIsModified && !ScaleIsModified;
 
-Standard_Boolean AWait = Standard_False;        // => immediate update
-                MyGraphicDriver->ViewOrientation (MyCView, AWait);
+        if (! IsDefined ()) return;
 
-                Compute ();
+        Standard_Boolean AWait = Standard_False;        // => immediate update
+        MyGraphicDriver->ViewOrientation (MyCView, AWait);
+        IsInitialized = Standard_True;
+        Compute ();
 
-                if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
+        if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
         }
-
 }
 
 void Visual3d_View::SetViewMapping (const Visual3d_ViewMapping& VM) {
@@ -1371,10 +1155,9 @@ Standard_Real um, vm, uM, vM;
           for (i = 0; i < 4; i++)
             for (j = 0; j < 4; j++)
               MyCView.Mapping.ProjectionMatrix[i][j] =
-                MyViewMapping.MyProjectionMatrix->Value(i,j);
+                (Standard_ShortReal)MyViewMapping.MyProjectionMatrix->Value(i,j);
         }
 
-        MyMatOfMapIsModified    = Standard_True;
         MyMatOfMapIsEvaluated   = Standard_False;
 
         if (! IsDefined ()) return;
@@ -1440,10 +1223,9 @@ Standard_Real um, vm, uM, vM;
           for (i = 0; i < 4; i++)
             for (j = 0; j < 4; j++)
               MyCView.Mapping.ProjectionMatrix[i][j] =
-                MyViewMapping.MyProjectionMatrix->Value(i,j);
+                (Standard_ShortReal)MyViewMapping.MyProjectionMatrix->Value(i,j);
         }
 
-        MyMatOfMapIsModified    = Standard_True;
         MyMatOfMapIsEvaluated   = Standard_False;
 
         if (! IsDefined ()) return;
@@ -1462,7 +1244,7 @@ void Visual3d_View::SetContext (const Visual3d_ContextView& CTX) {
 Visual3d_TypeOfVisualization OldVisualMode;
 Visual3d_TypeOfVisualization NewVisualMode;
 
-        // To manage display only in case of 
+        // To manage display only in case of
         // change of visualisation mode.
         OldVisualMode   = MyContext.Visualization ();
         NewVisualMode   = CTX.Visualization ();
@@ -1470,7 +1252,7 @@ Visual3d_TypeOfVisualization NewVisualMode;
 Visual3d_TypeOfModel OldModel;
 Visual3d_TypeOfModel NewModel;
 
-        // To manage change of visualisation only in case 
+        // To manage change of visualisation only in case
         // of change of mode of visualisation or of type of shading.
         OldModel        = MyContext.Model ();
         NewModel        = CTX.Model ();
@@ -1520,22 +1302,11 @@ Standard_Real NewZClippingBackPlane;
         OldZClippingBackPlane   = MyContext.ZClippingBackPlane ();
         NewZClippingBackPlane   = CTX.ZClippingBackPlane ();
 
-Standard_Integer OldTexEnvId;
-Standard_Integer NewTexEnvId;
-Visual3d_TypeOfSurfaceDetail OldSurfaceDetail;
-Visual3d_TypeOfSurfaceDetail NewSurfaceDetail;
-
-        Handle(Graphic3d_TextureEnv)    TempTextureEnv1 = MyContext.TextureEnv();
-        if (! TempTextureEnv1.IsNull()) OldTexEnvId = TempTextureEnv1->TextureId();
-        else                            OldTexEnvId = -1;
+        Handle(Graphic3d_TextureEnv) aTexEnvOld = MyContext.TextureEnv();
+        Handle(Graphic3d_TextureEnv) aTexEnvNew = CTX.TextureEnv();
 
-        Handle(Graphic3d_TextureEnv)    TempTextureEnv2 = CTX.TextureEnv();
-
-        if (! TempTextureEnv2.IsNull()) NewTexEnvId = TempTextureEnv2->TextureId();
-        else                            NewTexEnvId = -1;
-
-        OldSurfaceDetail = MyContext.SurfaceDetail();
-        NewSurfaceDetail = CTX.SurfaceDetail();
+        Visual3d_TypeOfSurfaceDetail OldSurfaceDetail = MyContext.SurfaceDetail();
+        Visual3d_TypeOfSurfaceDetail NewSurfaceDetail = CTX.SurfaceDetail();
 
         MyContext       = CTX;
 
@@ -1580,14 +1351,15 @@ Standard_Boolean AWait = Standard_False;        // => immediate update
                 }
 
                 // management of textures
-                if ( (OldTexEnvId != NewTexEnvId) ||
-                     (OldSurfaceDetail != NewSurfaceDetail) )
+                if ((aTexEnvOld != aTexEnvNew) || (OldSurfaceDetail != NewSurfaceDetail))
+                {
                   MyGraphicDriver->Environment(MyCView);
+                }
 
                 // Update of planes of model clipping
                 UpdatePlanes ();
 
-                // Update of light sources 
+                // Update of light sources
                 UpdateLights ();
         }
 
@@ -1610,7 +1382,7 @@ Graphic3d_SequenceOfStructure FooSequence;
 
                 while (S1Iterator.More ()) {
                         Answer  = AcceptDisplay (S1Iterator.Key ());
-                        // If the structure can't be displayed in the 
+                        // If the structure can't be displayed in the
                         // new context of the view, it is removed.
                         if ((Answer == Visual3d_TOA_NO) ||
                             (Answer == Visual3d_TOA_COMPUTE))
@@ -1629,10 +1401,10 @@ Standard_Integer Length = FooSequence.Length ();
 
                 /*
                  * Change of context =>
-                 * Display structures that can be displayed 
+                 * Display structures that can be displayed
                  * with the new visualisation mode.
-                 * All structures with status Displayed are removed from the ViewManager 
-                 * and displayed in the view directly, if the structure is not already 
+                 * All structures with status Displayed are removed from the ViewManager
+                 * and displayed in the view directly, if the structure is not already
                  * displayed and if the view accepts it in its context.
                  */
 
@@ -1645,7 +1417,7 @@ Standard_Integer Length = FooSequence.Length ();
                   Handle(Graphic3d_Structure) SG = it.Key();
                     if (! IsDisplayed (SG)) {
                       Answer = AcceptDisplay(SG);
-                        // If the structure can be displayed in the 
+                        // If the structure can be displayed in the
                         // new context of the view, it is displayed.
                         if ((Answer == Visual3d_TOA_YES) ||
                             (Answer == Visual3d_TOA_COMPUTE))
@@ -1708,8 +1480,8 @@ void Visual3d_View::Activate () {
                  * Activation of a new view =>
                  * Display structures that can be displayed in this new view.
                  * All structures with status
-                 * Displayed in ViewManager are returned and displayed in 
-                 * the view directly, if the structure is not already 
+                 * Displayed in ViewManager are returned and displayed in
+                 * the view directly, if the structure is not already
                  * displayed and if the view accepts it in its context.
                  */
 
@@ -1777,8 +1549,8 @@ void Visual3d_View::Deactivate () {
                  * Deactivation of a view =>
                  * Removal of structures displayed in this view.
                  * All structures with status
-                 * Displayed in ViewManager are returned and removed from 
-                 * the view directly, if the structure is not already 
+                 * Displayed in ViewManager are returned and removed from
+                 * the view directly, if the structure is not already
                  * displayed and if the view accepts it in its context.
                 */
 
@@ -1897,6 +1669,12 @@ void Visual3d_View::Update (const Handle(Visual3d_Layer)& AnUnderLayer, const Ha
 
         if (! MyWindow->IsMapped ()) return;
 
+        if (MyGraphicDriver->IsDeviceLost())
+        {
+          MyViewManager->ReComputeStructures();
+          MyGraphicDriver->ResetDeviceLostFlag();
+        }
+
         // If activation/desactivation of ZBuffer should be automatic
         // depending on the presence or absence of facets.
         if (MyViewManager->ZBufferAuto ()) {
@@ -1921,9 +1699,6 @@ Aspect_CLayer2d UnderCLayer;
         MyGraphicDriver->Update (MyCView, UnderCLayer, OverCLayer);
         //OSD::SetSignal (Standard_True);
 
-        MyMatOfMapIsModified    = Standard_False;
-        MyMatOfOriIsModified    = Standard_False;
-
 }
 
 Visual3d_TypeOfAnswer Visual3d_View::AcceptDisplay (const Handle(Graphic3d_Structure)& AStructure) const {
@@ -1971,7 +1746,7 @@ Visual3d_TypeOfAnswer Result = Visual3d_TOA_NO;
 
 }
 
-void Visual3d_View::ChangeDisplayPriority (const Handle(Graphic3d_Structure)& AStructure, const Standard_Integer OldPriority, const Standard_Integer NewPriority) {
+void Visual3d_View::ChangeDisplayPriority (const Handle(Graphic3d_Structure)& AStructure, const Standard_Integer /*OldPriority*/, const Standard_Integer NewPriority) {
 
         if (IsDeleted ()) return;
         if (! IsDefined ()) return;
@@ -1979,11 +1754,7 @@ void Visual3d_View::ChangeDisplayPriority (const Handle(Graphic3d_Structure)& AS
         if (! IsDisplayed (AStructure)) return;
 
 Standard_Integer Index = IsComputed (AStructure);
-#ifdef G003
-        if (  Index != 0 && ComputedMode () && !DegenerateModeIsOn ()  )
-#else
-        if ((Index != 0) && (! DegenerateModeIsOn ()))
-#endif  // G003
+        if (Index != 0 && ComputedMode())
         {
 #ifdef TRACE
        Standard_Integer StructId = MyCOMPUTEDSequence.Value (Index)->Identification ();
@@ -2118,7 +1889,7 @@ void Visual3d_View::Display (const Handle(Graphic3d_Structure)& AStructure, cons
         if (! IsActive ()) return;
 
         // If Display on a structure present in the list
-        // of calculated structures while it is not 
+        // of calculated structures while it is not
         // or more, of calculated type =>
         // - removes it as well as the associated old computed
         // THis happens when hlhsr becomes again of type e
@@ -2126,58 +1897,23 @@ void Visual3d_View::Display (const Handle(Graphic3d_Structure)& AStructure, cons
 Standard_Integer Index = IsComputed (AStructure);
 
         if ((Index != 0) && (AStructure->Visual () != Graphic3d_TOS_COMPUTED)) {
-
-#ifdef TRACE_LENGTH
-        if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) {
-                cout << "In Visual3d_View::Display, ";
-                cout << "TOCOMPUTE " << MyTOCOMPUTESequence.Length ()
-                     << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
-                     << "\n" << flush;
-        }
-#endif
                 MyTOCOMPUTESequence.Remove (Index);
                 MyCOMPUTEDSequence.Remove (Index);
-
-#ifdef TRACE_LENGTH
-        if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
-                cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
-                     << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
-                     << "\n" << flush;
-#endif
                 Index = 0;
         }
 
        Visual3d_TypeOfAnswer Answer = AcceptDisplay (AStructure);
 
-#ifdef TRACE_DISPLAY
-       Standard_Integer StructId = AStructure->Identification ();
-        cout << "Visual3d_View" << MyCView.ViewId << "::Display ("
-             << StructId << ");\n";
-        cout << flush;
-#endif
-
         if (Answer == Visual3d_TOA_NO) {
-#ifdef TRACE_DISPLAY
-                cout << "Answer : Visual3d_TOA_NO\n";
-                cout << flush;
-#endif
                 return;
         }
 
-        // Mode degenerated active
-#ifdef G003
-        if (  !ComputedMode () || DegenerateModeIsOn ()  )
-                                        Answer = Visual3d_TOA_YES;
-#else
-        if (DegenerateModeIsOn ()) Answer = Visual3d_TOA_YES;
-;
-#endif  // G003
+        if (!ComputedMode())
+        {
+          Answer = Visual3d_TOA_YES;
+        }
 
         if (Answer == Visual3d_TOA_YES ) {
-#ifdef TRACE_DISPLAY
-                cout << "Answer : Visual3d_TOA_YES\n";
-                cout << flush;
-#endif
                 if (IsDisplayed (AStructure)) return;
                 MyGraphicDriver->DisplayStructure (
                         MyCView,
@@ -2189,32 +1925,8 @@ Standard_Integer Index = IsComputed (AStructure);
         }
 
         if (Answer == Visual3d_TOA_COMPUTE) {
-#ifdef TRACE_DISPLAY
-            cout << "Answer : Visual3d_TOA_COMPUTE\n";
-            cout << "Index : " << Index << "\n" << flush;
-#endif
             if (Index != 0) {
                 // Already computed, is COMPUTED still valid?
-#ifdef TRACE_DISPLAY
-                if (MyCOMPUTEDSequence.Value (Index)->HLRValidation ()) {
-                  cout << "Structure "
-                     << MyTOCOMPUTESequence.Value (Index)->Identification ()
-                     << "already calculated, in the view "
-                     << Identification () << ", par la structure "
-                     << MyCOMPUTEDSequence.Value (Index)->Identification ()
-                     << "\n was not recalculated as HLR is valid\n";
-                  cout << flush;
-                }
-                else {
-                  cout << "Structure "
-                     << MyTOCOMPUTESequence.Value (Index)->Identification ()
-                     << " already calculated, in the view "
-                     << Identification () << ", by the structure "
-                     << MyCOMPUTEDSequence.Value (Index)->Identification ()
-                     << "\n should be recalculated as HLR is invalid\n";
-                  cout << flush;
-                }
-#endif
 Standard_Integer OldStructId =
         MyCOMPUTEDSequence.Value (Index)->Identification ();
 
@@ -2263,7 +1975,7 @@ Standard_Integer OldStructId =
 
                     // Cas COMPUTED invalid, WITHOUT a valid of replacement
                     else {
-                        // COMPUTED is removed if displayed 
+                        // COMPUTED is removed if displayed
                         if (IsDisplayed (AStructure))
                             MyGraphicDriver->EraseStructure (
                                 MyCView,
@@ -2306,37 +2018,16 @@ Standard_Integer ii, jj;
 #endif
             TheStructure->SetHLRValidation (Standard_True);
 
-#ifdef TRACE_LENGTH
-        if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
-                cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
-                     << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
-                     << "\n" << flush;
-#endif
-
             // TOCOMPUTE and COMPUTED associated to sequences are added
             MyTOCOMPUTESequence.Append (AStructure);
             MyCOMPUTEDSequence.Append (TheStructure);
 
-#ifdef TRACE_LENGTH
-        if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
-                cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
-                     << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
-                     << "\n" << flush;
-#endif
-
             // The previous are removed if necessary
             if (Index != 0) {
                 MyTOCOMPUTESequence.Remove (Index);
                 MyCOMPUTEDSequence.Remove (Index);
             }
 
-#ifdef TRACE_LENGTH
-        if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
-                cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
-                     << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
-                     << "\n" << flush;
-#endif
-
 // Return type of visualisation of the view
 Visual3d_TypeOfVisualization ViewType = MyContext.Visualization ();
 
@@ -2362,19 +2053,7 @@ Standard_Boolean ComputeShading = ((ViewType == Visual3d_TOV_SHADING) &&
                 TheStructure->GraphicHighlight (Aspect_TOHM_COLOR);
             }
 
-#ifdef TRACE_DISPLAY
-            cout << "Structure " << StructId
-                 << " in the view " << Identification ()
-                 << " is calculated by the structure "
-                 << TheStructure->Identification ();
-            if (Answer == Visual3d_TOA_YES)
-                cout << " and displayed\n";
-            else
-                cout << " but not displayed\n";
-            cout << flush;
-#endif
-
-            // It is displayed only if the calculated structure 
+            // It is displayed only if the calculated structure
             // has a proper type corresponding to the one of the view.
             if (Answer != Visual3d_TOA_NO) {
                 if (! IsDisplayed (AStructure))
@@ -2403,18 +2082,15 @@ Standard_Integer StructId;
 
         if (IsDeleted ()) return;
 
-        // No test on window as the structure is displayed only if 
+        // No test on window as the structure is displayed only if
         // the window exists, so only one test is enough.
         if (IsDisplayed (AStructure)) {
 Visual3d_TypeOfAnswer Answer = AcceptDisplay (AStructure);
 
-                // Degenerated mode is active
-#ifdef G003
-                if (  !ComputedMode () || DegenerateModeIsOn ()  )
-                                        Answer = Visual3d_TOA_YES;
-#else
-                if (DegenerateModeIsOn ()) Answer = Visual3d_TOA_YES;
-#endif  // G003
+                if (!ComputedMode())
+                {
+                  Answer = Visual3d_TOA_YES;
+                }
 
                 if (Answer != Visual3d_TOA_COMPUTE) {
                         MyGraphicDriver->EraseStructure (
@@ -2431,12 +2107,8 @@ Standard_Integer Index = IsComputed (AStructure);
         cout << "Index : " << Index << "\n";
         cout << flush;
 #endif
-#ifdef G003
-                    if (  Index != 0 && ComputedMode () &&
-                                                !DegenerateModeIsOn ()  )
-#else
-                    if ((Index != 0) && (! DegenerateModeIsOn ()))
-#endif  // G003
+
+                    if (Index != 0 && ComputedMode())
                     {
                         StructId =
                         MyCOMPUTEDSequence.Value (Index)->Identification ();
@@ -2602,7 +2274,7 @@ Graphic3d_MapIteratorOfMapOfStructure Iterator (MyDisplayedStructure);
                 Result  =
                 (((Iterator.Key ())->Visual ()) == Graphic3d_TOS_COMPUTED);
 
-                // Iterator.Next () is located on the 
+                // Iterator.Next () is located on the
                 // next structure
                 Iterator.Next ();
         }
@@ -2671,6 +2343,11 @@ void Visual3d_View::MinMaxValues (const Graphic3d_MapOfStructure& ASet, Standard
         Iterator.More ();
         Iterator.Next ()) {
 
+          if (!Iterator.Key()->IsVisible())
+          {
+            continue;
+          }
+
       if ( (Iterator.Key ())->IsInfinite ()){
         //XMin, YMin .... ZMax are initialized by means of infinite line data
         (Iterator.Key ())->MinMaxValues (Xm, Ym, Zm, XM, YM, ZM);
@@ -2687,7 +2364,7 @@ void Visual3d_View::MinMaxValues (const Graphic3d_MapOfStructure& ASet, Standard
         if ( ZM != RealLast()  && ZM > ZMax )
           ZMax = ZM ;
       }
-      // Only non-empty and non-infinite structures 
+      // Only non-empty and non-infinite structures
       // are taken into account for calculation of MinMax
       if (! (Iterator.Key ())->IsInfinite () &&
           ! (Iterator.Key ())->IsEmpty ()) {
@@ -3053,9 +2730,7 @@ void Visual3d_View::UpdateView () {
         MyCView.Context.Model           = int (MyContext.Model ());
         MyCView.Context.Visualization   = int (MyContext.Visualization ());
 
-        Handle(Graphic3d_TextureEnv)   TempTextureEnv = MyContext.TextureEnv();
-        if (! TempTextureEnv.IsNull()) MyCView.Context.TexEnvId = TempTextureEnv->TextureId();
-        else                           MyCView.Context.TexEnvId = -1;
+        MyCView.Context.TextureEnv    = MyContext.TextureEnv();
         MyCView.Context.SurfaceDetail = MyContext.SurfaceDetail();
 
 }
@@ -3067,12 +2742,10 @@ Standard_Integer Length = MyCOMPUTEDSequence.Length ();
         for (i=1; i<=Length; i++)
             (MyCOMPUTEDSequence.Value (i))->SetHLRValidation (Standard_False);
 
-        // if the degenerated node is active, nothing is recomputed
-#ifdef G003
-        if (  DegenerateModeIsOn () || !ComputedMode ()  ) return;
-#else
-        if (DegenerateModeIsOn ()) return;
-#endif  // G003
+        if (!ComputedMode())
+        {
+          return;
+        }
 
         /*
          * Force HLRValidation to False on all structures
@@ -3092,10 +2765,6 @@ Standard_Integer Length = MyCOMPUTEDSequence.Length ();
          * Remove structures that were calculated for the
          * previous orientation.
          * Recalculation of new structures.
-         * Passage of the degenerated mode ON to OFF =>
-         * Remove structures that were calculated before 
-         * the degenerated mode passed to ON.
-         * Recalculate new structures.
          */
 Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure);
 Visual3d_TypeOfAnswer Answer;
@@ -3131,11 +2800,7 @@ Graphic3d_SequenceOfStructure FooSequence;
 }
 
 void Visual3d_View::ReCompute (const Handle(Graphic3d_Structure)& AStructure) {
-#ifdef G003
-        if ( DegenerateModeIsOn () || !ComputedMode () ) return;
-#else
-        if (DegenerateModeIsOn()) return;
-#endif  // G003
+        if (!ComputedMode()) return;
 
         if (IsDeleted ()) return;
 
@@ -3261,7 +2926,7 @@ Standard_Boolean ComputeShading = ((ViewType == Visual3d_TOV_SHADING) &&
                      << "\n" << flush;
 #endif
 
-                          // hlhsr and the new associated compute are removed 
+                          // hlhsr and the new associated compute are removed
 
                           MyTOCOMPUTESequence.Remove (Index);
                           MyCOMPUTEDSequence.Remove (Index);
@@ -3277,330 +2942,23 @@ Standard_Boolean ComputeShading = ((ViewType == Visual3d_TOV_SHADING) &&
 
 }
 
-void
-#ifdef G003
-Visual3d_View::SetAnimationModeOn ( const Standard_Boolean degenerate ) {
-#else
-Visual3d_View::SetAnimationModeOn () {
-#endif
-
-        if (AnimationModeIsOn ()) return;
-
-        AnimationModeIsActive   = Standard_True;
-#ifdef G003
-        if ( degenerate )
-          SetDegenerateModeOn ();
-        else
-          SetDegenerateModeOff ();
-#endif  // G003
-        MyGraphicDriver->BeginAnimation (MyCView);
-
-}
-
-void Visual3d_View::SetAnimationModeOff () {
-
-        if (! AnimationModeIsOn ()) return;
-
-        AnimationModeIsActive   = Standard_False;
-#ifdef G003
-        SetDegenerateModeOff ();
-#endif  // G003
-        MyGraphicDriver->EndAnimation (MyCView);
-
-}
-
-Standard_Boolean Visual3d_View::AnimationModeIsOn () const {
-
-        return AnimationModeIsActive;
-
-}
-
-void Visual3d_View::SetDegenerateModeOn () {
-
-#ifdef TRACE
-        cout << "Visual3d_View" << MyCView.ViewId
-             << "::SetDegenerateModeOn ();\n";
-        cout << flush;
-#endif
-
-        // If the degenerated mode is already active, nothing is recalculated
-        if (DegenerateModeIsOn ()) return;
-        DegenerateModeIsActive = Standard_True;
-
-#ifdef G003
-        MyCView.IsDegenerates  = 1;
-#else
-        /*
-         * Change of activity of the degenerated mode
-         * Remove structures that were calculated
-         * and displayed when the mode was off.
-         * Display of non-calculated structures.
-         */
-Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure);
-Visual3d_TypeOfAnswer Answer;
-Standard_Integer StructId;
-
-        while (S1Iterator.More ()) {
-
-                Answer  = AcceptDisplay (S1Iterator.Key ());
-                // If the structure was calculated, the previous one is 
-                // removed and the new one is displayed
-                // (This is the role of passage into degenerated mode)
-
-                if (Answer == Visual3d_TOA_COMPUTE) {
-Standard_Integer Index = IsComputed (S1Iterator.Key ());
-                    if (Index != 0) {
-                        StructId =
-                        MyCOMPUTEDSequence.Value (Index)->Identification ();
-#ifdef TRACE_COMP
-        cout << "Structure " << S1Iterator.Key ()->Identification ()
-             << " calculated, in the view "
-             << Identification () << ", by structure "
-             << StructId << " passes in degenerated mode.\n";
-        cout << "Remove" << StructId << " then display "
-             << S1Iterator.Key ()->Identification () << "\n";
-        cout << flush;
-#endif
-                        MyGraphicDriver->EraseStructure
-                                (MyCView, *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure ());
-                        MyGraphicDriver->DisplayStructure (
-                                MyCView,
-                                *(Graphic3d_CStructure *)S1Iterator.Key ()->CStructure (),
-                                int (S1Iterator.Key ()->DisplayPriority ())
-                        );
-                    }
-                    else {
-                        // Else is impossible)
-                        // If the mode was not degenerated previously, the
-                        // calculated structure associated to S1Iterator.Key ()
-                        // really exists and Index != 0
-                    }
-                }
-
-                // S1Iterator.Next () is located on the next structure
-                S1Iterator.Next ();
-        }
-#endif  //G003
-}
-
-void Visual3d_View::SetDegenerateModeOff () {
-
-#ifdef TRACE
-        cout << "Visual3d_View" << MyCView.ViewId
-             << "::SetDegenerateModeOff ();\n";
-        cout << flush;
-#endif
-
-        // If the degenerated mode is already inactive, nothing is recalculated
-        if (! DegenerateModeIsOn ()) return;
-
-        DegenerateModeIsActive  = Standard_False;
-
-#ifdef G003
-        MyCView.IsDegenerates  = 0;
-#else
-        /*
-         * Change of activity of degenerated mode
-         * Remove structures that were displayed
-         * when the mode was on.
-         * Calculation of structures.
-         */
-Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure);
-Visual3d_TypeOfAnswer Answer;
-Standard_Integer StructId;
-
-        Standard_Integer i      = MyDisplayedStructure.Extent ();
-
-        while (S1Iterator.More ()) {
-
-                Answer  = AcceptDisplay (S1Iterator.Key ());
-                // If the structure was calculated, the previous one is 
-                // removed and the new one is displayed
-                // (This is the role of passage into degenerated mode)
-           
-                if (Answer == Visual3d_TOA_COMPUTE) {
-Standard_Integer Index = IsComputed (S1Iterator.Key ());
-                    if (Index != 0) {
-                        StructId =
-                        MyCOMPUTEDSequence.Value (Index)->Identification ();
-#ifdef TRACE_COMP
-        cout << "Structure " << S1Iterator.Key ()->Identification ()
-             << " calculated, in the view "
-             << Identification () << ", by the structure "
-             << StructId << " passes into normal mode.\n";
-        cout << "Remove " << S1Iterator.Key ()->Identification ()
-             << " then display " << StructId << "\n";
-        cout << flush;
-#endif
-                        MyGraphicDriver->EraseStructure
-                                (MyCView,
-                                *(Graphic3d_CStructure *)S1Iterator.Key ()->CStructure ());
-                        MyGraphicDriver->DisplayStructure (
-                                MyCView,
-                                *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure (),
-                                int (S1Iterator.Key ()->DisplayPriority ())
-                        );
-
-                        Display (S1Iterator.Key (), Aspect_TOU_WAIT);
-
-                        if ((S1Iterator.Key ())->IsHighlighted()) {
-                           if (! (MyCOMPUTEDSequence.Value (Index))->IsHighlighted()) {
-                                (MyCOMPUTEDSequence.Value (Index))->SetHighlightColor
-                                        ((S1Iterator.Key ())->HighlightColor ());
-                                (MyCOMPUTEDSequence.Value (Index))->GraphicHighlight (Aspect_TOHM_COLOR);
-                            }
-                        }
-                    }
-                    else {
-                        // Else is impossible 
-                        // Degenerated mode was activated before display of the
-                        // structure. So the structure was displayed in the
-                        // degenerated mode, but the calculated structure didn't exist.
-                        // It is calculated.
-
-        // Compute + Validation
-Handle(Graphic3d_Structure) AStructure = (S1Iterator.Key ());
-#ifdef OLD
-Handle(Graphic3d_Structure) TheStructure = AStructure->Compute (this);
-#else
-Handle(Graphic3d_Structure) TheStructure;
-TColStd_Array2OfReal ATrsf (0, 3, 0, 3);
-        AStructure->Transform (ATrsf);
-        if (Index != 0) {
-TColStd_Array2OfReal Ident (0, 3, 0, 3);
-Standard_Integer ii, jj;
-        for (ii=0; ii<=3; ii++)
-            for (jj=0; jj<=3; jj++)
-                Ident (ii, jj) = (ii == jj ? 1.0 : 0.0);
-            TheStructure = MyCOMPUTEDSequence.Value (Index);
-            TheStructure->SetTransform (Ident, Graphic3d_TOC_REPLACE);
-            if (AStructure->IsTransformed ()) {
-                AStructure->Compute (this, ATrsf, TheStructure);
-            }
-            else {
-                AStructure->Compute (this, TheStructure);
-            }
-        }
-        else {
-            if (AStructure->IsTransformed ()) {
-                TheStructure = AStructure->Compute (this, ATrsf);
-            }
-            else {
-                TheStructure = AStructure->Compute (this);
-            }
-        }
-#endif
-        TheStructure->SetHLRValidation (Standard_True);
-
-// Return type of visualisation of the view
-Visual3d_TypeOfVisualization ViewType = MyContext.Visualization ();
-
-// Of which type will be the computed ?
-Standard_Boolean ComputeWireframe = ((ViewType == Visual3d_TOV_WIREFRAME) &&
-        ((S1Iterator.Key ())->ComputeVisual () != Graphic3d_TOS_SHADING));
-
-Standard_Boolean ComputeShading = ((ViewType == Visual3d_TOV_SHADING) &&
-        ((S1Iterator.Key ())->ComputeVisual () != Graphic3d_TOS_WIREFRAME));
-
-                        if (ComputeWireframe)
-                            TheStructure->SetVisual (Graphic3d_TOS_WIREFRAME);
-                        if (ComputeShading)
-                            TheStructure->SetVisual (Graphic3d_TOS_SHADING);
-
-                        if ((S1Iterator.Key ())->IsHighlighted()) {
-                            TheStructure->SetHighlightColor
-                                ((S1Iterator.Key ())->HighlightColor ());
-                            TheStructure->GraphicHighlight (Aspect_TOHM_COLOR);
-                        }
-
-                        // Make range
-Standard_Integer Result = 0;
-Standard_Integer Length = MyTOCOMPUTESequence.Length ();
-                        // Find structure <S1Iterator.Key ()>
-                        // in the sequence of structures to be calculated
-                        StructId = (S1Iterator.Key ())->Identification ();
-                        for (i=1; i<=Length && Result==0; i++)
-                          if ((MyTOCOMPUTESequence.Value (i))->Identification () ==
-                            StructId) Result    = i;
-                        if (Result != 0)
-                          MyCOMPUTEDSequence.ChangeValue (Result) = TheStructure;
-                        else {
-                          // hlhsr and the associated new compute are added
-#ifdef TRACE_LENGTH
-        if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) {
-                cout << "In Visual3d_View::SetDegenerateModeOff, ";
-                cout << "TOCOMPUTE " << MyTOCOMPUTESequence.Length ()
-                     << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
-                     << "\n" << flush;
-        }
-#endif
-                          MyTOCOMPUTESequence.Append (S1Iterator.Key ());
-                          MyCOMPUTEDSequence.Append (TheStructure);
-#ifdef TRACE_LENGTH
-        if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
-                cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
-                     << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
-                     << "\n" << flush;
-#endif
-                        }
-
-                        // The degenerated is removed and the calculated is displayed
-                        MyGraphicDriver->EraseStructure
-                                (MyCView,
-                                *(Graphic3d_CStructure *)(S1Iterator.Key ()->CStructure ()));
-                        MyGraphicDriver->DisplayStructure (
-                                MyCView,
-                                *(Graphic3d_CStructure *)TheStructure->CStructure (),
-                                int (S1Iterator.Key ()->DisplayPriority ())
-                        );
-                    }
-                }
-
-                // S1Iterator.Next () is located on the next structure
-                S1Iterator.Next ();
-        }
-
-        if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
-#endif  //G003
-}
-
-Standard_Boolean Visual3d_View::DegenerateModeIsOn () const {
-
-        return DegenerateModeIsActive;
-
-}
-
-Handle(Aspect_GraphicDriver) Visual3d_View::GraphicDriver () const {
+const Handle(Graphic3d_GraphicDriver)& Visual3d_View::GraphicDriver () const {
 
         return MyGraphicDriver;
 
 }
 
-void Visual3d_View::Plot (const Handle(Graphic3d_Plotter)& APlotter) const {
-
-Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure);
-
-        while (S1Iterator.More ()) {
-
-                if (DegenerateModeIsOn ())
-                        // As the  mode is degenerated the displayed structure
-                        // is plotted without taking into account if it is calculated or not
-                        (S1Iterator.Key ())->Plot (APlotter);
-                else {
-Standard_Integer Index = IsComputed (S1Iterator.Key ());
-                        // As the  mode is not degenerated the displayed structure
-                        // is plotted as if it was not calculated, otherwise the 
-                        // associated calculated structure is plotted.
-                        if (Index == 0)
-                            (S1Iterator.Key ())->Plot (APlotter);
-                        else
-                            (MyCOMPUTEDSequence.Value (Index))->Plot (APlotter);
-                }
-
-                // S1Iterator.Next () is located on the next structure
-                S1Iterator.Next ();
-        }
-
+void Visual3d_View::Plot (const Handle(Graphic3d_Plotter)& thePlotter) const
+{
+  for (Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure); S1Iterator.More(); S1Iterator.Next())
+  {
+    Standard_Integer Index = IsComputed (S1Iterator.Key ());
+    // displayed structure is plotted as if it was not calculated
+    if (Index == 0)
+      (S1Iterator.Key ())->Plot (thePlotter);
+    else
+      (MyCOMPUTEDSequence.Value (Index))->Plot (thePlotter);
+  }
 }
 
 Standard_Integer Visual3d_View::HaveTheSameOwner (const Handle(Graphic3d_Structure)& AStructure) const {
@@ -3608,7 +2966,7 @@ Standard_Integer Visual3d_View::HaveTheSameOwner (const Handle(Graphic3d_Structu
 Standard_Integer Result = 0;
 Standard_Integer Length = MyTOCOMPUTESequence.Length ();
 
-        // Find in the sequence of already calculated structures 
+        // Find in the sequence of already calculated structures
         // 1/ Structure with the same Owner as <AStructure>
         // 2/ Which is not <AStructure>
         // 3/ COMPUTED which of is valid
@@ -3663,22 +3021,20 @@ void Visual3d_View::TriedronEcho (const Aspect_TypeOfTriedronEcho AType ) {
 
 }
 
-Standard_Boolean checkFloat(const Standard_Real value)
+static Standard_Boolean checkFloat(const Standard_Real value)
 {
     return value > -FLT_MAX && value < FLT_MAX;
 }
 
-void SetMinMaxValuesCallback(void* Visual3dView)
+static void SetMinMaxValuesCallback(Visual3d_View* theView)
 {
     Standard_Real xmin, ymin, zmin, xmax, ymax, zmax;
-
-    Handle(Visual3d_View) view = (Handle(Visual3d_View)&) Visual3dView;
-    view->MinMaxValues(xmin, ymin, zmin, xmax, ymax, zmax);
+    theView->MinMaxValues(xmin, ymin, zmin, xmax, ymax, zmax);
 
     if (checkFloat(xmin) && checkFloat(ymin) && checkFloat(zmin) &&
         checkFloat(xmax) && checkFloat(ymax) && checkFloat(zmax))
     {
-        Handle(Graphic3d_GraphicDriver) driver = Handle(Graphic3d_GraphicDriver)::DownCast(view->GraphicDriver());
+        Handle(Graphic3d_GraphicDriver) driver = Handle(Graphic3d_GraphicDriver)::DownCast(theView->GraphicDriver());
         driver->GraduatedTrihedronMinMaxValues((Standard_ShortReal)xmin, (Standard_ShortReal)ymin, (Standard_ShortReal)zmin,
                                                (Standard_ShortReal)xmax, (Standard_ShortReal)ymax, (Standard_ShortReal)zmax);
     }
@@ -3749,15 +3105,15 @@ Standard_Boolean Visual3d_View::GetGraduatedTrihedron
 
     /* Names of axes */
     xname = MyGTrihedron.xname;
-    yname = MyGTrihedron.yname; 
+    yname = MyGTrihedron.yname;
     zname = MyGTrihedron.zname;
     /* Draw names */
-    xdrawname = MyGTrihedron.xdrawname; 
-    ydrawname = MyGTrihedron.ydrawname; 
+    xdrawname = MyGTrihedron.xdrawname;
+    ydrawname = MyGTrihedron.ydrawname;
     zdrawname = MyGTrihedron.zdrawname;
     /* Draw values */
-    xdrawvalues = MyGTrihedron.xdrawvalues; 
-    ydrawvalues = MyGTrihedron.ydrawvalues; 
+    xdrawvalues = MyGTrihedron.xdrawvalues;
+    ydrawvalues = MyGTrihedron.ydrawvalues;
     zdrawvalues = MyGTrihedron.zdrawvalues;
     /* Draw grid */
     drawgrid = MyGTrihedron.drawgrid;
@@ -3965,27 +3321,25 @@ Standard_Integer Visual3d_View::PlaneLimit() const {
         return maxplane;
 }
 
-#ifdef IMP140100
-Handle(Visual3d_ViewManager) Visual3d_View::ViewManager() const {
-
-        return MyPtrViewManager;
+Handle(Visual3d_ViewManager) Visual3d_View::ViewManager() const
+{
+  return MyPtrViewManager;
 }
-#endif
-
-#ifdef G003
-void Visual3d_View :: SetComputedMode ( const Standard_Boolean aMode ) {
 
- if (  (  (aMode &&  ComputedModeIsActive) ||
-         (!aMode && !ComputedModeIsActive)
-       ) || DegenerateModeIsOn ()
- ) return;
+void Visual3d_View :: SetComputedMode ( const Standard_Boolean aMode )
+{
+  if ((aMode &&  ComputedModeIsActive) ||
+     (!aMode && !ComputedModeIsActive))
+  {
+    return;
+  }
 
  Graphic3d_MapIteratorOfMapOfStructure S1Iterator ( MyDisplayedStructure );
  Visual3d_TypeOfAnswer                 Answer;
  Standard_Integer                      StructId;
  Standard_Integer                      i = MyDisplayedStructure.Extent ();
-
- if (  !( ComputedModeIsActive = aMode )  ) {
+ ComputedModeIsActive = aMode;
+ if (!ComputedModeIsActive) {
 
   while (  S1Iterator.More ()  ) {
 
@@ -4223,22 +3577,15 @@ Visual3d_TypeOfBackfacingModel Visual3d_View :: BackFacingModel () const {
  return Visual3d_TOBM_DISABLE;
 
 }  // end Visual3d_View :: BackFacingModel
-#endif  // G003
 
 void Visual3d_View::EnableDepthTest( const Standard_Boolean enable ) const
 {
-#ifdef BUC61044
   MyGraphicDriver->SetDepthTestEnabled( MyCView, enable );
-#endif
 }
 
 Standard_Boolean Visual3d_View::IsDepthTestEnabled() const
 {
-#ifdef BUC61044
   return MyGraphicDriver->IsDepthTestEnabled( MyCView );
-#else
-  return Standard_True;
-#endif
 }
 
 void Visual3d_View::ReadDepths(const Standard_Integer x,
@@ -4285,19 +3632,13 @@ Standard_Boolean Visual3d_View::BufferDump (Image_PixMap&               theImage
 
 void Visual3d_View::EnableGLLight( const Standard_Boolean enable ) const
 {
-#ifdef BUC61045
   MyGraphicDriver->SetGLLightEnabled( MyCView, enable );
-#endif
 }
 
 
 Standard_Boolean Visual3d_View::IsGLLightEnabled() const
 {
-#ifdef BUC61045
   return MyGraphicDriver->IsGLLightEnabled( MyCView );
-#else
-  return Standard_True;
-#endif
 }
 
 Standard_Boolean Visual3d_View::Export (const Standard_CString       theFileName,
@@ -4339,7 +3680,7 @@ void Visual3d_View::AddZLayer (const Standard_Integer theLayerId)
 
 //=======================================================================
 //function : RemoveZLayer
-//purpose  : 
+//purpose  :
 //=======================================================================
 
 void Visual3d_View::RemoveZLayer (const Standard_Integer theLayerId)
@@ -4349,7 +3690,7 @@ void Visual3d_View::RemoveZLayer (const Standard_Integer theLayerId)
 
 //=======================================================================
 //function : ChangeZLayer
-//purpose  : 
+//purpose  :
 //=======================================================================
 
 void Visual3d_View::ChangeZLayer (const Handle(Graphic3d_Structure)& theStructure,