0024271: Provide Boolean operations for NCollection_Map
[occt.git] / src / OpenGl / OpenGl_Structure.cxx
index 4ce7d22..c7c3f49 100644 (file)
-// File:      OpenGl_Structure.cxx
-// Created:   1 August 2011
-// Author:    Sergey ZERCHANINOV
-// Copyright: OPEN CASCADE 2011
+// Created on: 2011-08-01
+// Created by: Sergey ZERCHANINOV
+// Copyright (c) 2011-2012 OPEN CASCADE SAS
+//
+// The content of this file is subject to the Open CASCADE Technology Public
+// License Version 6.5 (the "License"). You may not use the content of this file
+// except in compliance with the License. Please obtain a copy of the License
+// at http://www.opencascade.org and read it completely before using this file.
+//
+// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
+// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
+//
+// The Original Code and all software distributed under the License is
+// distributed on an "AS IS" basis, without warranty of any kind, and the
+// Initial Developer hereby disclaims all such warranties, including without
+// limitation, any warranties of merchantability, fitness for a particular
+// purpose or non-infringement. Please see the License for the specific terms
+// and conditions governing the rights and limitations under the License.
 
 #include <OpenGl_GlCore11.hxx>
 
 #include <OpenGl_Structure.hxx>
 
-#include <OpenGl_Polyline.hxx>
 #include <OpenGl_Workspace.hxx>
+#include <OpenGl_Vec.hxx>
 #include <OpenGl_View.hxx>
-
+#include <OpenGl_CappingAlgo.hxx>
+#include <OpenGl_Context.hxx>
 #include <OpenGl_telem_util.hxx>
 
+#include <Graphic3d_SetOfHClipPlane_Handle.hxx>
+
+//! Auxiliary class for bounding box presentation
+class OpenGl_BndBoxPrs : public OpenGl_Element
+{
+
+public:
+
+  //! Main constructor
+  OpenGl_BndBoxPrs (const CALL_DEF_BOUNDBOX& theBndBox)
+  {
+    const float Xm = theBndBox.Pmin.x;
+    const float Ym = theBndBox.Pmin.y;
+    const float Zm = theBndBox.Pmin.z;
+    const float XM = theBndBox.Pmax.x;
+    const float YM = theBndBox.Pmax.y;
+    const float ZM = theBndBox.Pmax.z;
+    myVerts[0]  = OpenGl_Vec3 (Xm, Ym, Zm);
+    myVerts[1]  = OpenGl_Vec3 (Xm, Ym, ZM);
+    myVerts[2]  = OpenGl_Vec3 (Xm, YM, ZM);
+    myVerts[3]  = OpenGl_Vec3 (Xm, YM, Zm);
+    myVerts[4]  = OpenGl_Vec3 (Xm, Ym, Zm);
+    myVerts[5]  = OpenGl_Vec3 (XM, Ym, Zm);
+    myVerts[6]  = OpenGl_Vec3 (XM, Ym, ZM);
+    myVerts[7]  = OpenGl_Vec3 (XM, YM, ZM);
+    myVerts[8]  = OpenGl_Vec3 (XM, YM, Zm);
+    myVerts[9]  = OpenGl_Vec3 (XM, Ym, Zm);
+    myVerts[10] = OpenGl_Vec3 (XM, YM, Zm);
+    myVerts[11] = OpenGl_Vec3 (Xm, YM, Zm);
+    myVerts[12] = OpenGl_Vec3 (Xm, YM, ZM);
+    myVerts[13] = OpenGl_Vec3 (XM, YM, ZM);
+    myVerts[14] = OpenGl_Vec3 (XM, Ym, ZM);
+    myVerts[15] = OpenGl_Vec3 (Xm, Ym, ZM);
+  }
+
+  //! Render presentation
+  virtual void Render  (const Handle(OpenGl_Workspace)& theWorkspace) const
+  {
+    // Apply line aspect
+    const OpenGl_AspectLine*     anAspectLine = theWorkspace->AspectLine (Standard_True);
+    const Handle(OpenGl_Texture) aPrevTexture = theWorkspace->DisableTexture();
+
+    glDisable (GL_LIGHTING);
+    if ((theWorkspace->NamedStatus & (OPENGL_NS_ADD | OPENGL_NS_IMMEDIATE)) != 0)
+    {
+      glDepthMask (GL_FALSE);
+    }
+
+    // Use highlight colors
+    glColor3fv ((theWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT) ? theWorkspace->HighlightColor->rgb : anAspectLine->Color().rgb);
+
+    glEnableClientState (GL_VERTEX_ARRAY);
+    glVertexPointer (3, GL_FLOAT, 0, (GLfloat* )&myVerts);
+    glDrawArrays (GL_LINE_STRIP, 0, 16);
+    glDisableClientState (GL_VERTEX_ARRAY);
+
+    // restore aspects
+    if (!aPrevTexture.IsNull())
+    {
+      theWorkspace->EnableTexture (aPrevTexture);
+    }
+  }
+
+  //! Release graphical resources
+  virtual void Release (const Handle(OpenGl_Context)& )
+  {
+    //
+  }
+
+protected:
+
+  //! Protected destructor
+  virtual ~OpenGl_BndBoxPrs() {}
+
+private:
+
+  OpenGl_Vec3 myVerts[16]; //!< vertices array
+
+public:
+
+  DEFINE_STANDARD_ALLOC
+
+};
 
 /*----------------------------------------------------------------------*/
 
+// =======================================================================
+// function : call_util_transpose_mat
+// purpose  :
+// =======================================================================
 static void call_util_transpose_mat (float tmat[16], float mat[4][4])
 {
   int i, j;
@@ -25,12 +127,13 @@ static void call_util_transpose_mat (float tmat[16], float mat[4][4])
       tmat[j*4+i] = mat[i][j];
 }
 
-/*----------------------------------------------------------------------*/
-
+// =======================================================================
+// function : OpenGl_Structure
+// purpose  :
+// =======================================================================
 OpenGl_Structure::OpenGl_Structure ()
 : myTransformation(NULL),
   myTransPers(NULL),
-  myDegenerateModel(NULL),
   myAspectLine(NULL),
   myAspectFace(NULL),
   myAspectMarker(NULL),
@@ -42,62 +145,33 @@ OpenGl_Structure::OpenGl_Structure ()
 {
 }
 
-/*----------------------------------------------------------------------*/
-
-OpenGl_Structure::~OpenGl_Structure ()
+// =======================================================================
+// function : ~OpenGl_Structure
+// purpose  :
+// =======================================================================
+OpenGl_Structure::~OpenGl_Structure()
 {
-  if (myTransformation)
-  {
-    delete myTransformation;
-    myTransformation = NULL;
-  }
-  if (myTransPers)
-  {
-    delete myTransPers;
-    myTransPers = NULL;
-  }
-  if (myDegenerateModel)
-  {
-    delete myDegenerateModel;
-    myDegenerateModel = NULL;
-  }
-  if (myAspectLine)
-  {
-    delete myAspectLine;
-    myAspectLine = NULL;
-  }
-  if (myAspectFace)
-  {
-    delete myAspectFace;
-    myAspectFace = NULL;
-  }
-  if (myAspectMarker)
-  {
-    delete myAspectMarker;
-    myAspectMarker = NULL;
-  }
-  if (myAspectText)
-  {
-    delete myAspectText;
-    myAspectText = NULL;
-  }
-  ClearHighlightColor();
-  // Delete groups
-  Clear();
+  Release (Handle(OpenGl_Context)());
+  delete myTransformation;  myTransformation  = NULL;
+  delete myTransPers;       myTransPers       = NULL;
 }
 
-/*----------------------------------------------------------------------*/
-
+// =======================================================================
+// function : SetTransformation
+// purpose  :
+// =======================================================================
 void OpenGl_Structure::SetTransformation(const float *AMatrix)
 {
   if (!myTransformation)
-    myTransformation = new OpenGl_Matrix;
+    myTransformation = new OpenGl_Matrix();
 
   matcpy( myTransformation->mat, AMatrix );
 }
 
-/*----------------------------------------------------------------------*/
-
+// =======================================================================
+// function : SetTransformPersistence
+// purpose  :
+// =======================================================================
 void OpenGl_Structure::SetTransformPersistence(const CALL_DEF_TRANSFORM_PERSISTENCE &ATransPers)
 {
   if (!myTransPers)
@@ -109,116 +183,108 @@ void OpenGl_Structure::SetTransformPersistence(const CALL_DEF_TRANSFORM_PERSISTE
   myTransPers->pointZ = ATransPers.Point.z;
 }
 
-/*----------------------------------------------------------------------*/
-
-void OpenGl_Structure::SetDegenerateModel (const Standard_Integer AMode, const float ASkipRatio)
-{
-  if (!myDegenerateModel)
-    myDegenerateModel = new DEGENERATION;
-
-  myDegenerateModel->mode = AMode;
-  myDegenerateModel->skipRatio = ASkipRatio;
-}
-
-/*----------------------------------------------------------------------*/
-
+// =======================================================================
+// function : SetAspectLine
+// purpose  :
+// =======================================================================
 void OpenGl_Structure::SetAspectLine (const CALL_DEF_CONTEXTLINE &AContext)
 {
   if (!myAspectLine)
-    myAspectLine = new OpenGl_AspectLine;
+    myAspectLine = new OpenGl_AspectLine();
   myAspectLine->SetContext( AContext );
 }
 
-/*----------------------------------------------------------------------*/
-
-void OpenGl_Structure::SetAspectFace (const CALL_DEF_CONTEXTFILLAREA &AContext)
+// =======================================================================
+// function : SetAspectFace
+// purpose  :
+// =======================================================================
+void OpenGl_Structure::SetAspectFace (const Handle(OpenGl_Context)&   theCtx,
+                                      const CALL_DEF_CONTEXTFILLAREA& theAspect)
 {
   if (!myAspectFace)
-    myAspectFace = new OpenGl_AspectFace;
-  myAspectFace->SetContext( AContext );
+  {
+    myAspectFace = new OpenGl_AspectFace();
+  }
+  myAspectFace->Init (theCtx, theAspect);
 }
 
-/*----------------------------------------------------------------------*/
-
-void OpenGl_Structure::SetAspectMarker (const CALL_DEF_CONTEXTMARKER &AContext)
+// =======================================================================
+// function : SetAspectMarker
+// purpose  :
+// =======================================================================
+void OpenGl_Structure::SetAspectMarker (const Handle(OpenGl_Context)& theCtx,
+                                        const CALL_DEF_CONTEXTMARKER& theAspect)
 {
   if (!myAspectMarker)
-    myAspectMarker = new OpenGl_AspectMarker;
-  myAspectMarker->SetContext( AContext );
+  {
+    myAspectMarker = new OpenGl_AspectMarker();
+  }
+  myAspectMarker->Init (theCtx, theAspect);
 }
 
-/*----------------------------------------------------------------------*/
-
+// =======================================================================
+// function : SetAspectText
+// purpose  :
+// =======================================================================
 void OpenGl_Structure::SetAspectText (const CALL_DEF_CONTEXTTEXT &AContext)
 {
   if (!myAspectText)
-    myAspectText = new OpenGl_AspectText;
+    myAspectText = new OpenGl_AspectText();
   myAspectText->SetContext( AContext );
 }
 
-/*----------------------------------------------------------------------*/
-
-void OpenGl_Structure::SetHighlightBox (const CALL_DEF_BOUNDBOX &ABoundBox)
+// =======================================================================
+// function : SetHighlightBox
+// purpose  :
+// =======================================================================
+void OpenGl_Structure::SetHighlightBox (const Handle(OpenGl_Context)& theGlCtx,
+                                        const CALL_DEF_BOUNDBOX&      theBoundBox)
 {
-  if (!myHighlightBox)
-    myHighlightBox = new OpenGl_Group;
+  if (myHighlightBox != NULL)
+  {
+    myHighlightBox->Release (theGlCtx);
+  }
   else
-    myHighlightBox->Clear();
-
-  CALL_DEF_CONTEXTLINE context_line;
-  context_line.Color = ABoundBox.Color;
-  context_line.LineType = Aspect_TOL_SOLID;
-  context_line.Width = 1.0f;
-  myHighlightBox->SetAspectLine( context_line );
-
-#define CALL_MAX_BOUNDBOXSIZE 16
-
-  Graphic3d_Array1OfVertex points(1,CALL_MAX_BOUNDBOXSIZE);
-  const float Xm = ABoundBox.Pmin.x;
-  const float Ym = ABoundBox.Pmin.y;
-  const float Zm = ABoundBox.Pmin.z;
-  const float XM = ABoundBox.Pmax.x;
-  const float YM = ABoundBox.Pmax.y;
-  const float ZM = ABoundBox.Pmax.z;
-  points( 1).SetCoord(Xm,Ym,Zm);
-  points( 2).SetCoord(Xm,Ym,ZM);
-  points( 3).SetCoord(Xm,YM,ZM);
-  points( 4).SetCoord(Xm,YM,Zm);
-  points( 5).SetCoord(Xm,Ym,Zm);
-  points( 6).SetCoord(XM,Ym,Zm);
-  points( 7).SetCoord(XM,Ym,ZM);
-  points( 8).SetCoord(XM,YM,ZM);
-  points( 9).SetCoord(XM,YM,Zm);
-  points(10).SetCoord(XM,Ym,Zm);
-  points(11).SetCoord(XM,YM,Zm);
-  points(12).SetCoord(Xm,YM,Zm);
-  points(13).SetCoord(Xm,YM,ZM);
-  points(14).SetCoord(XM,YM,ZM);
-  points(15).SetCoord(XM,Ym,ZM);
-  points(16).SetCoord(Xm,Ym,ZM);
-
-  OpenGl_Polyline *apolyline = new OpenGl_Polyline(points);
-  myHighlightBox->AddElement( TelPolyline, apolyline );
-}
+  {
+    myHighlightBox = new OpenGl_Group();
+  }
 
-/*----------------------------------------------------------------------*/
+  CALL_DEF_CONTEXTLINE aContextLine;
+  aContextLine.Color    = theBoundBox.Color;
+  aContextLine.LineType = Aspect_TOL_SOLID;
+  aContextLine.Width    = 1.0f;
+  myHighlightBox->SetAspectLine (aContextLine);
+
+  OpenGl_BndBoxPrs* aBndBoxPrs = new OpenGl_BndBoxPrs (theBoundBox);
+  myHighlightBox->AddElement (TelParray, aBndBoxPrs);
+}
 
-void OpenGl_Structure::ClearHighlightBox ()
+// =======================================================================
+// function : ClearHighlightBox
+// purpose  :
+// =======================================================================
+void OpenGl_Structure::ClearHighlightBox (const Handle(OpenGl_Context)& theGlCtx)
 {
-  if (myHighlightBox)
+  if (myHighlightBox != NULL)
   {
-    delete myHighlightBox;
-    myHighlightBox = NULL;
+    OpenGl_Element::Destroy (theGlCtx, myHighlightBox);
   }
 }
 
-/*----------------------------------------------------------------------*/
-
-void OpenGl_Structure::SetHighlightColor (const Standard_ShortReal R, const Standard_ShortReal G, const Standard_ShortReal B)
+// =======================================================================
+// function : SetHighlightColor
+// purpose  :
+// =======================================================================
+void OpenGl_Structure::SetHighlightColor (const Handle(OpenGl_Context)& theGlCtx,
+                                          const Standard_ShortReal R,
+                                          const Standard_ShortReal G,
+                                          const Standard_ShortReal B)
 {
-  ClearHighlightBox();
-  if (!myHighlightColor)
-    myHighlightColor = new TEL_COLOUR;
+  ClearHighlightBox (theGlCtx);
+  if (myHighlightColor == NULL)
+  {
+    myHighlightColor = new TEL_COLOUR();
+  }
 
   myHighlightColor->rgb[0] = R;
   myHighlightColor->rgb[1] = G;
@@ -226,28 +292,31 @@ void OpenGl_Structure::SetHighlightColor (const Standard_ShortReal R, const Stan
   myHighlightColor->rgb[3] = 1.F;
 }
 
-/*----------------------------------------------------------------------*/
-
-void OpenGl_Structure::ClearHighlightColor ()
+// =======================================================================
+// function : ClearHighlightColor
+// purpose  :
+// =======================================================================
+void OpenGl_Structure::ClearHighlightColor (const Handle(OpenGl_Context)& theGlCtx)
 {
-  ClearHighlightBox();
-  if (myHighlightColor)
-  {
-    delete myHighlightColor;
-    myHighlightColor = NULL;
-  }
+  ClearHighlightBox(theGlCtx);
+  delete myHighlightColor;
+  myHighlightColor = NULL;
 }
 
-/*----------------------------------------------------------------------*/
-
+// =======================================================================
+// function : Connect
+// purpose  :
+// =======================================================================
 void OpenGl_Structure::Connect (const OpenGl_Structure *AStructure)
 {
   Disconnect (AStructure);
   myConnected.Append(AStructure);
 }
 
-/*----------------------------------------------------------------------*/
-
+// =======================================================================
+// function : Disconnect
+// purpose  :
+// =======================================================================
 void OpenGl_Structure::Disconnect (const OpenGl_Structure *AStructure)
 {
   OpenGl_ListOfStructure::Iterator its(myConnected);
@@ -263,8 +332,10 @@ void OpenGl_Structure::Disconnect (const OpenGl_Structure *AStructure)
   }
 }
 
-/*----------------------------------------------------------------------*/
-
+// =======================================================================
+// function : AddGroup
+// purpose  :
+// =======================================================================
 OpenGl_Group * OpenGl_Structure::AddGroup ()
 {
   // Create new group
@@ -273,41 +344,45 @@ OpenGl_Group * OpenGl_Structure::AddGroup ()
   return g;
 }
 
-/*----------------------------------------------------------------------*/
-
-void OpenGl_Structure::RemoveGroup (const OpenGl_Group *AGroup)
+// =======================================================================
+// function : RemoveGroup
+// purpose  :
+// =======================================================================
+void OpenGl_Structure::RemoveGroup (const Handle(OpenGl_Context)& theGlCtx,
+                                    const OpenGl_Group*           theGroup)
 {
-  OpenGl_ListOfGroup::Iterator itg(myGroups);
-  while (itg.More())
+  for (OpenGl_ListOfGroup::Iterator anIter (myGroups); anIter.More(); anIter.Next())
   {
     // Check for the given group
-    if (itg.Value() == AGroup)
+    if (anIter.Value() == theGroup)
     {
       // Delete object
-      delete AGroup;
-      myGroups.Remove(itg);
+      OpenGl_Element::Destroy (theGlCtx, const_cast<OpenGl_Group*& > (anIter.ChangeValue()));
+      myGroups.Remove (anIter);
       return;
     }
-    itg.Next();
   }
 }
 
-/*----------------------------------------------------------------------*/
-
-void OpenGl_Structure::Clear ()
+// =======================================================================
+// function : Clear
+// purpose  :
+// =======================================================================
+void OpenGl_Structure::Clear (const Handle(OpenGl_Context)& theGlCtx)
 {
-  OpenGl_ListOfGroup::Iterator itg(myGroups);
-  while (itg.More())
+  // Release groups
+  for (OpenGl_ListOfGroup::Iterator anIter (myGroups); anIter.More(); anIter.Next())
   {
     // Delete objects
-    delete itg.Value();
-    itg.Next();
+    OpenGl_Element::Destroy (theGlCtx, const_cast<OpenGl_Group*& > (anIter.ChangeValue()));
   }
   myGroups.Clear();
 }
 
-/*----------------------------------------------------------------------*/
-
+// =======================================================================
+// function : Render
+// purpose  :
+// =======================================================================
 void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &AWorkspace) const
 {
   // Process the structure only if visible
@@ -352,26 +427,6 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &AWorkspace) const
     trans_pers = AWorkspace->ActiveView()->BeginTransformPersistence( myTransPers );
   }
 
-  // Apply degeneration
-  if (myDegenerateModel)
-  {
-    if ( AWorkspace->NamedStatus & OPENGL_NS_DEGENERATION )
-    {
-      AWorkspace->DegenerateModel = myDegenerateModel->mode;
-      switch ( AWorkspace->DegenerateModel )
-      {
-        case 0: break;
-
-        default:
-          glLineWidth ( 1.0 );
-          glDisable   ( GL_LINE_STIPPLE );
-
-        case 1:
-          AWorkspace->SkipRatio = myDegenerateModel->skipRatio;
-      }
-    }
-  }
-
   // Apply aspects
   const OpenGl_AspectLine *aspect_line = AWorkspace->AspectLine(Standard_False);
   const OpenGl_AspectFace *aspect_face = AWorkspace->AspectFace(Standard_False);
@@ -403,6 +458,39 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &AWorkspace) const
     its.Next();
   }
 
+  // Set up plane equations for non-structure transformed global model-view matrix
+  const Handle(OpenGl_Context)& aContext = AWorkspace->GetGlContext();
+
+  // List of planes to be applied to context state
+  Handle(Graphic3d_SetOfHClipPlane) aUserPlanes;
+
+  // Collect clipping planes of structure scope
+  if (!myClipPlanes.IsEmpty())
+  {
+    Graphic3d_SetOfHClipPlane::Iterator aClippingIt (myClipPlanes);
+    for (; aClippingIt.More(); aClippingIt.Next())
+    {
+      const Handle(Graphic3d_ClipPlane)& aClipPlane = aClippingIt.Value();
+      if (!aClipPlane->IsOn())
+      {
+        continue;
+      }
+
+      if (aUserPlanes.IsNull())
+      {
+        aUserPlanes = new Graphic3d_SetOfHClipPlane();
+      }
+
+      aUserPlanes->Add (aClipPlane);
+    }
+  }
+
+  if (!aUserPlanes.IsNull() && !aUserPlanes->IsEmpty())
+  {
+    // add planes at loaded view matrix state
+    aContext->ChangeClipping().AddWorld (*aUserPlanes, AWorkspace);
+  }
+
   // Render groups
   OpenGl_ListOfGroup::Iterator itg(myGroups);
   while (itg.More())
@@ -411,6 +499,18 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &AWorkspace) const
     itg.Next();
   }
 
+  // Render capping for structure groups
+  if (!aContext->Clipping().Planes().IsEmpty())
+  {
+    OpenGl_CappingAlgo::RenderCapping (AWorkspace, myGroups);
+  }
+
+  // Revert structure clippings
+  if (!aUserPlanes.IsNull() && !aUserPlanes->IsEmpty())
+  {
+    aContext->ChangeClipping().Remove (*aUserPlanes);
+  }
+
   // Restore highlight color
   AWorkspace->HighlightColor = highlight_color;
 
@@ -447,11 +547,61 @@ void OpenGl_Structure::Render (const Handle(OpenGl_Workspace) &AWorkspace) const
   AWorkspace->NamedStatus = named_status;
 }
 
+// =======================================================================
+// function : Release
+// purpose  :
+// =======================================================================
+void OpenGl_Structure::Release (const Handle(OpenGl_Context)& theGlCtx)
+{
+  // Release groups
+  Clear (theGlCtx);
+  OpenGl_Element::Destroy (theGlCtx, myAspectLine);
+  OpenGl_Element::Destroy (theGlCtx, myAspectFace);
+  OpenGl_Element::Destroy (theGlCtx, myAspectMarker);
+  OpenGl_Element::Destroy (theGlCtx, myAspectText);
+  ClearHighlightColor (theGlCtx);
+}
+
+// =======================================================================
+// function : ReleaseGlResources
+// purpose  :
+// =======================================================================
+void OpenGl_Structure::ReleaseGlResources (const Handle(OpenGl_Context)& theGlCtx)
+{
+  for (OpenGl_ListOfGroup::Iterator anIter (myGroups); anIter.More(); anIter.Next())
+  {
+    OpenGl_Group* aGroup = const_cast<OpenGl_Group*& > (anIter.ChangeValue());
+    if (aGroup != NULL)
+    {
+      aGroup->Release (theGlCtx);
+    }
+  }
+  if (myAspectLine != NULL)
+  {
+    myAspectLine->Release (theGlCtx);
+  }
+  if (myAspectFace != NULL)
+  {
+    myAspectFace->Release (theGlCtx);
+  }
+  if (myAspectMarker != NULL)
+  {
+    myAspectMarker->Release (theGlCtx);
+  }
+  if (myAspectText != NULL)
+  {
+    myAspectText->Release (theGlCtx);
+  }
+  if (myHighlightBox != NULL)
+  {
+    myHighlightBox->Release (theGlCtx);
+  }
+}
+
 //=======================================================================
 //function : SetZLayer
-//purpose  : 
+//purpose  :
 //=======================================================================
-
 void OpenGl_Structure::SetZLayer (const Standard_Integer theLayerIndex)
 {
   myZLayer = theLayerIndex;
@@ -459,9 +609,8 @@ void OpenGl_Structure::SetZLayer (const Standard_Integer theLayerIndex)
 
 //=======================================================================
 //function : GetZLayer
-//purpose  : 
+//purpose  :
 //=======================================================================
-
 Standard_Integer OpenGl_Structure::GetZLayer () const
 {
   return myZLayer;