1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-06 18:26:22 +03:00

0024590: Crash when processing OpenGl_BndBoxPrs objects

Eliminate TelType enumeration
Cosmetics, warnings
This commit is contained in:
kgv 2014-02-06 11:01:00 +04:00 committed by apn
parent f1a5afa25c
commit 5322131bd1
12 changed files with 65 additions and 133 deletions

View File

@ -68,7 +68,6 @@ OpenGl_PriorityList.hxx
OpenGl_PriorityList.cxx
OpenGl_AVIWriter.hxx
OpenGl_AVIWriter.cxx
OpenGl_tsm.hxx
OpenGl_FrameBuffer.hxx
OpenGl_FrameBuffer.cxx
OpenGl_Texture.cxx

View File

@ -347,7 +347,7 @@ void OpenGl_GraphicDriver::SetStencilTestOptions (const Graphic3d_CGroup& theCGr
{
OpenGl_StencilTest* aStencilTest = new OpenGl_StencilTest();
aStencilTest->SetOptions (theIsEnabled);
((OpenGl_Group* )theCGroup.ptrGroup)->AddElement (TelNil, aStencilTest);
((OpenGl_Group* )theCGroup.ptrGroup)->AddElement (aStencilTest);
}
// =======================================================================
@ -375,7 +375,7 @@ void OpenGl_GraphicDriver::Text (const Graphic3d_CGroup& theCGro
aParams.VAlign = theVta;
const OpenGl_Vec3 aPoint (thePoint.X(), thePoint.Y(), thePoint.Z());
OpenGl_Text* aText = new OpenGl_Text (theText, aPoint, aParams);
((OpenGl_Group* )theCGroup.ptrGroup)->AddElement (TelText, aText);
((OpenGl_Group* )theCGroup.ptrGroup)->AddElement (aText);
}
// =======================================================================
@ -589,5 +589,5 @@ void OpenGl_GraphicDriver::SetFlippingOptions (const Graphic3d_CGroup& theCGroup
{
OpenGl_Flipper* aFlipper = new OpenGl_Flipper (theRefPlane);
aFlipper->SetOptions (theIsEnabled);
((OpenGl_Group* )theCGroup.ptrGroup)->AddElement (TelNil, aFlipper);
((OpenGl_Group* )theCGroup.ptrGroup)->AddElement (aFlipper);
}

View File

@ -69,7 +69,7 @@ void OpenGl_GraphicDriver::PrimitiveArray( const Graphic3d_CGroup& ACGroup,
if ( ACGroup.ptrGroup && parray )
{
OpenGl_PrimitiveArray *aparray = new OpenGl_PrimitiveArray( (CALL_DEF_PARRAY *) parray );
((OpenGl_Group *)ACGroup.ptrGroup)->AddElement( TelParray, aparray );
((OpenGl_Group *)ACGroup.ptrGroup)->AddElement (aparray);
}
}
@ -82,7 +82,7 @@ void OpenGl_GraphicDriver::UserDraw (const Graphic3d_CGroup& theCGroup,
OpenGl_Element* aUserDraw = myUserDrawCallback(&theUserDraw);
if (aUserDraw != NULL)
{
((OpenGl_Group* )theCGroup.ptrGroup)->AddElement (TelUserdraw, aUserDraw);
((OpenGl_Group* )theCGroup.ptrGroup)->AddElement (aUserDraw);
}
}
}

View File

@ -73,7 +73,7 @@ void OpenGl_Group::SetAspectLine (const CALL_DEF_CONTEXTLINE& theAspect,
{
OpenGl_AspectLine* anAspectLine = new OpenGl_AspectLine();
anAspectLine->SetAspect (theAspect);
AddElement (TelNil/*TelAspectLine*/, anAspectLine);
AddElement (anAspectLine);
}
}
@ -96,7 +96,7 @@ void OpenGl_Group::SetAspectFace (const CALL_DEF_CONTEXTFILLAREA& theAspect,
{
OpenGl_AspectFace* anAspectFace = new OpenGl_AspectFace();
anAspectFace->SetAspect (theAspect);
AddElement (TelNil/*TelAspectFace*/, anAspectFace);
AddElement (anAspectFace);
}
#ifdef HAVE_OPENCL
@ -131,7 +131,7 @@ void OpenGl_Group::SetAspectMarker (const CALL_DEF_CONTEXTMARKER& theAspect,
{
OpenGl_AspectMarker* anAspectMarker = new OpenGl_AspectMarker();
anAspectMarker->SetAspect (theAspect);
AddElement (TelNil/*TelAspectMarker*/, anAspectMarker);
AddElement (anAspectMarker);
}
}
@ -154,7 +154,7 @@ void OpenGl_Group::SetAspectText (const CALL_DEF_CONTEXTTEXT& theAspect,
{
OpenGl_AspectText* anAspectText = new OpenGl_AspectText();
anAspectText->SetAspect (theAspect);
AddElement ( TelNil/*TelAspectText*/, anAspectText);
AddElement (anAspectText);
}
}
@ -162,11 +162,10 @@ void OpenGl_Group::SetAspectText (const CALL_DEF_CONTEXTTEXT& theAspect,
// function : AddElement
// purpose :
// =======================================================================
void OpenGl_Group::AddElement (const TelType theType, OpenGl_Element *theElem)
void OpenGl_Group::AddElement (OpenGl_Element* theElem)
{
OpenGl_ElementNode *aNode = new OpenGl_ElementNode();
aNode->type = theType;
aNode->elem = theElem;
aNode->next = NULL;
(myLast? myLast->next : myFirst) = aNode;
@ -194,7 +193,6 @@ void OpenGl_Group::AddElement (const TelType theType, OpenGl_Element *theElem)
void OpenGl_Group::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
{
// Is rendering in ADD or IMMEDIATE mode?
const Standard_Boolean isImmediate = (theWorkspace->NamedStatus & (OPENGL_NS_ADD | OPENGL_NS_IMMEDIATE)) != 0;
const Handle(OpenGl_RenderFilter)& aFilter = theWorkspace->GetRenderFilter();
// Setup aspects
@ -210,27 +208,7 @@ void OpenGl_Group::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
// Render group elements
for (OpenGl_ElementNode* aNodeIter = myFirst; aNodeIter != NULL; aNodeIter = aNodeIter->next)
{
switch (aNodeIter->type)
{
case TelMarker:
case TelMarkerSet:
case TelText:
{
glDisable (GL_LIGHTING);
if (isImmediate)
{
glDepthMask (GL_FALSE);
}
aNodeIter->elem->RenderFiltered (theWorkspace, aFilter);
break;
}
default:
{
aNodeIter->elem->RenderFiltered (theWorkspace, aFilter);
break;
}
}
}
// Restore aspects

View File

@ -26,8 +26,6 @@
#include <OpenGl_AspectMarker.hxx>
#include <OpenGl_AspectText.hxx>
#include <OpenGl_tsm.hxx>
class OpenGl_Group;
class OpenGl_Structure;
@ -35,7 +33,6 @@ typedef NCollection_List<const OpenGl_Group* > OpenGl_ListOfGroup;
struct OpenGl_ElementNode
{
TelType type;
OpenGl_Element* elem;
OpenGl_ElementNode* next;
DEFINE_STANDARD_ALLOC
@ -56,7 +53,7 @@ public:
void SetAspectMarker (const CALL_DEF_CONTEXTMARKER& theAspect, const Standard_Boolean IsGlobal = Standard_True);
void SetAspectText (const CALL_DEF_CONTEXTTEXT& theAspect, const Standard_Boolean IsGlobal = Standard_True);
void AddElement (const TelType, OpenGl_Element * );
void AddElement (OpenGl_Element* theElem);
virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const;
virtual void Release (const Handle(OpenGl_Context)& theGlCtx);

View File

@ -335,13 +335,10 @@ namespace OpenGl_Raytrace
// purpose : Checks to see if the element contains ray-trace geometry
// =======================================================================
Standard_Boolean IsRaytracedElement (const OpenGl_ElementNode* theNode)
{
if (TelParray == theNode->type)
{
OpenGl_PrimitiveArray* anArray = dynamic_cast< OpenGl_PrimitiveArray* > (theNode->elem);
return anArray->PArray()->type >= TelPolygonsArrayType;
}
return Standard_False;
return anArray != NULL
&& anArray->PArray()->type >= TelPolygonsArrayType;
}
// =======================================================================

View File

@ -283,7 +283,7 @@ void OpenGl_Structure::SetHighlightBox (const Handle(OpenGl_Context)& theGlCtx,
myHighlightBox->SetAspectLine (aContextLine);
OpenGl_BndBoxPrs* aBndBoxPrs = new OpenGl_BndBoxPrs (theBoundBox);
myHighlightBox->AddElement (TelParray, aBndBoxPrs);
myHighlightBox->AddElement (aBndBoxPrs);
}
// =======================================================================

View File

@ -709,6 +709,7 @@ void OpenGl_Text::render (const Handle(OpenGl_PrinterContext)& thePrintCtx,
// push enabled flags to the stack
glPushAttrib (GL_ENABLE_BIT);
glDisable (GL_LIGHTING);
// setup depth test
if (!myIs2d

View File

@ -136,20 +136,16 @@ public:
private:
//! Creates new texture format.
OpenGl_TextureFormat (const GLint theChannels, const GLint theInternal)
: myChannels (theChannels),
myInternal (theInternal)
{
//
}
OpenGl_TextureFormat (const GLint theChannels,
const GLint theInternal)
: myInternal (theInternal),
myChannels (theChannels) {}
private:
//! OpenGL internal format of the pixel data.
GLint myInternal;
GLint myInternal; //!< OpenGL internal format of the pixel data
GLint myChannels; //!< Number of channels for each pixel (from 1 to 4)
//! Number of channels for each pixel (from 1 to 4).
GLint myChannels;
};
//! Texture resource.

View File

@ -44,8 +44,6 @@
#include <NCollection_Sequence.hxx>
#include <OpenGl_tsm.hxx>
#include <OpenGl_AspectFace.hxx>
#include <OpenGl_Display.hxx>
#include <OpenGl_Matrix.hxx>

View File

@ -405,11 +405,8 @@ Standard_Boolean OpenGl_Workspace::AddRaytraceStructure (const OpenGl_Structure*
// Add OpenGL elements from group (extract primitives arrays and aspects)
for (const OpenGl_ElementNode* aNode = anItg.Value()->FirstNode(); aNode != NULL; aNode = aNode->next)
{
if (TelNil == aNode->type)
{
OpenGl_AspectFace* anAspect = dynamic_cast<OpenGl_AspectFace*> (aNode->elem);
if (anAspect != NULL)
{
aMatID = static_cast<Standard_Integer> (myRaytraceGeometry.Materials.size());
@ -419,11 +416,9 @@ Standard_Boolean OpenGl_Workspace::AddRaytraceStructure (const OpenGl_Structure*
myRaytraceGeometry.Materials.push_back (aMaterial);
}
}
else if (TelParray == aNode->type)
else
{
OpenGl_PrimitiveArray* aPrimArray = dynamic_cast<OpenGl_PrimitiveArray*> (aNode->elem);
if (aPrimArray != NULL)
{
NCollection_Handle<BVH_Object<Standard_ShortReal, 4> > aSet =

View File

@ -1,29 +0,0 @@
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// 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.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef OPENGL_TSM_H
#define OPENGL_TSM_H
typedef enum
{
TelNil = 0,
TelMarker,
TelMarkerSet,
TelText,
TelParray,
TelUserdraw,
TelLast
} TelType;
#endif