0024070: OpenGL capped object-level clipping planes
[occt.git] / src / Visual3d / Visual3d_View.cxx
index 93af9d2..960f7f7 100755 (executable)
@@ -48,7 +48,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 GER61454        //GG 14-09-99 Activates model clipping planes
 
-#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>
 
@@ -203,10 +193,6 @@ Standard_Integer i, j;
         MyCView.DefWindow.IsDefined   = 0;
 
         MyCView.Context.NbActiveLight = 0;
-        MyCView.Context.NbActivePlane = 0;
-#ifdef GER61454
-        MyCView.Context.ActivePlane   = NULL;
-#endif
 
         for (i=0; i<=3; i++)
                 for (j=0; j<=3; j++)
@@ -277,16 +263,9 @@ Standard_Real um, vm, uM, vM;
         MyMatOfMapIsEvaluated   = Standard_False;
         MyMatOfOriIsEvaluated   = Standard_False;
 
-        DegenerateModeIsActive  = Standard_False;
-        AnimationModeIsActive   = Standard_False;
-
         IsInitialized = Standard_False;
-#ifdef G003
-        MyCView.IsDegenerates     = 0;
-        MyCView.IsDegeneratesPrev = 0;
         ComputedModeIsActive      = Standard_False;
         MyCView.Backfacing        = 0;
-#endif  // G003
 
         MyCView.ptrUnderLayer = 0;
         MyCView.ptrOverLayer = 0;
@@ -294,10 +273,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();
 
 }
 
@@ -326,10 +302,6 @@ Standard_Integer i, j;
         MyCView.DefWindow.IsDefined   = 0;
 
         MyCView.Context.NbActiveLight = 0;
-        MyCView.Context.NbActivePlane = 0;
-#ifdef GER61454
-        MyCView.Context.ActivePlane = NULL;
-#endif
 
         for (i=0; i<=3; i++)
                 for (j=0; j<=3; j++)
@@ -363,7 +335,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;
@@ -399,7 +372,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;
@@ -417,12 +391,7 @@ Standard_Real um, vm, uM, vM;
         MyMatOfOriIsEvaluated   = Standard_False;
 
         IsInitialized = Standard_False;
-#ifdef G003
-        AnimationModeIsActive     = Standard_False;
-        MyCView.IsDegenerates     = 0;
-        MyCView.IsDegeneratesPrev = 0;
         ComputedModeIsActive      = Standard_False;
-#endif  // G003
 
         MyCView.ptrUnderLayer = 0;
         MyCView.ptrOverLayer = 0;
@@ -430,10 +399,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();
 
 }
 
@@ -458,36 +424,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 );
@@ -772,10 +740,10 @@ CALL_DEF_LIGHT *lights=NULL;
 
 Standard_Real X, Y, Z;
 
-Standard_Real LightConcentration;
-Standard_Real LightAttenuation1;
-Standard_Real LightAttenuation2;
-Standard_Real LightAngle;
+Standard_Real LightConcentration = 0.;
+Standard_Real LightAttenuation1 = 0.;
+Standard_Real LightAttenuation2 = 0.;
+Standard_Real LightAngle = 0.;
 Quantity_Color LightColor;
 Graphic3d_Vertex LightPosition;
 Graphic3d_Vector LightDirection;
@@ -882,64 +850,14 @@ Visual3d_TypeOfLightSource LightType=Visual3d_TOLS_AMBIENT;
 
 }
 
-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.GetClipPlanes();
+  
+  if (IsDeleted() || !IsDefined())
+    return;
 
+  MyGraphicDriver->SetClipPlanes (MyCView);
 }
 
 void Visual3d_View::SetBackground (const Aspect_Background& ABack) {
@@ -991,7 +909,6 @@ void Visual3d_View::SetBackgroundImage( const Standard_CString FileName,
                                         const Aspect_FillMethod FillStyle,
                                         const Standard_Boolean update )
 {
-#ifdef OCC1188
   if ( IsDeleted() )
     return;
   if ( !IsDefined() )
@@ -1003,13 +920,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() )
@@ -1021,7 +936,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 {
@@ -1114,7 +1028,7 @@ void Visual3d_View::SetViewOrientation (const Visual3d_ViewOrientation& VO) {
         if (IsDeleted ()) return;
 
         MyViewOrientation       = VO;
-        
+
         Standard_Real X, Y, Z;
         // Tests on modification of parameters.
         Standard_Boolean VUPIsModified  = Standard_False;
@@ -1160,7 +1074,7 @@ void Visual3d_View::SetViewOrientation (const Visual3d_ViewOrientation& VO) {
         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;
@@ -1189,9 +1103,9 @@ void Visual3d_View::SetViewOrientation (const Visual3d_ViewOrientation& VO) {
 
         MyMatOfOriIsEvaluated = !VUPIsModified && !VRPIsModified
                               && !VRUIsModified && !ScaleIsModified;
-    
+
         if (! IsDefined ()) return;
-        
+
         Standard_Boolean AWait = Standard_False;        // => immediate update
         MyGraphicDriver->ViewOrientation (MyCView, AWait);
         IsInitialized = Standard_True;
@@ -1299,7 +1213,7 @@ void Visual3d_View::ViewOrientationReset () {
         // Restart if one of parameters is modified
         if (!IsInitialized || VUPIsModified || VRPIsModified
             || VRUIsModified || ScaleIsModified || CustomIsModified) {
-              
+
         MyMatOfOriIsEvaluated = !VUPIsModified && !VRPIsModified
                               && !VRUIsModified && !ScaleIsModified;
 
@@ -1349,7 +1263,7 @@ 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);
         }
 
         MyMatOfMapIsEvaluated   = Standard_False;
@@ -1417,7 +1331,7 @@ 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);
         }
 
         MyMatOfMapIsEvaluated   = Standard_False;
@@ -1934,7 +1848,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;
@@ -1942,11 +1856,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 ();
@@ -2127,14 +2037,10 @@ Standard_Integer Index = IsComputed (AStructure);
                 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
@@ -2371,13 +2277,10 @@ Standard_Integer StructId;
         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 (
@@ -2394,12 +2297,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 ();
@@ -3028,12 +2927,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
@@ -3053,10 +2950,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;
@@ -3092,11 +2985,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;
 
@@ -3238,330 +3127,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 {
@@ -3931,20 +3513,20 @@ Handle(Visual3d_ViewManager) Visual3d_View::ViewManager() const
   return MyPtrViewManager;
 }
 
-#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 ()  ) {
 
@@ -4182,22 +3764,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,
@@ -4244,19 +3819,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,