Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:34

0001 // Created on: 2011-08-01
0002 // Created by: Sergey ZERCHANINOV
0003 // Copyright (c) 2011-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef OpenGl_Group_HeaderFile
0017 #define OpenGl_Group_HeaderFile
0018 
0019 #include <Graphic3d_Group.hxx>
0020 #include <Graphic3d_Structure.hxx>
0021 
0022 #include <OpenGl_Aspects.hxx>
0023 #include <OpenGl_Element.hxx>
0024 
0025 class OpenGl_Structure;
0026 
0027 struct OpenGl_ElementNode
0028 {
0029   OpenGl_Element*     elem;
0030   OpenGl_ElementNode* next;
0031   DEFINE_STANDARD_ALLOC
0032 };
0033 
0034 //! Implementation of low-level graphic group.
0035 class OpenGl_Group : public Graphic3d_Group
0036 {
0037 public:
0038 
0039   //! Create empty group.
0040   //! Will throw exception if not created by OpenGl_Structure.
0041   Standard_EXPORT OpenGl_Group (const Handle(Graphic3d_Structure)& theStruct);
0042 
0043   Standard_EXPORT virtual void Clear (const Standard_Boolean theToUpdateStructureMgr) Standard_OVERRIDE;
0044 
0045   //! Return line aspect.
0046   virtual Handle(Graphic3d_Aspects) Aspects() const Standard_OVERRIDE
0047   {
0048     return myAspects != NULL
0049          ? myAspects->Aspect()
0050          : Handle(Graphic3d_Aspects)();
0051   }
0052 
0053   //! Return TRUE if group contains primitives with transform persistence.
0054   bool HasPersistence() const
0055   {
0056     return !myTrsfPers.IsNull()
0057         || (myStructure != NULL && !myStructure->TransformPersistence().IsNull());
0058   }
0059 
0060   //! Update aspect.
0061   Standard_EXPORT virtual void SetGroupPrimitivesAspect (const Handle(Graphic3d_Aspects)& theAspect) Standard_OVERRIDE;
0062 
0063   //! Append aspect as an element.
0064   Standard_EXPORT virtual void SetPrimitivesAspect (const Handle(Graphic3d_Aspects)& theAspect) Standard_OVERRIDE;
0065 
0066   //! Update presentation aspects after their modification.
0067   Standard_EXPORT virtual void SynchronizeAspects() Standard_OVERRIDE;
0068 
0069   //! Replace aspects specified in the replacement map.
0070   Standard_EXPORT virtual void ReplaceAspects (const Graphic3d_MapOfAspectsToAspects& theMap) Standard_OVERRIDE;
0071 
0072   //! Add primitive array element
0073   Standard_EXPORT virtual void AddPrimitiveArray (const Graphic3d_TypeOfPrimitiveArray theType,
0074                                                   const Handle(Graphic3d_IndexBuffer)& theIndices,
0075                                                   const Handle(Graphic3d_Buffer)&      theAttribs,
0076                                                   const Handle(Graphic3d_BoundBuffer)& theBounds,
0077                                                   const Standard_Boolean               theToEvalMinMax) Standard_OVERRIDE;
0078 
0079   //! Adds a text for display
0080   Standard_EXPORT virtual void AddText (const Handle(Graphic3d_Text)& theTextParams,
0081                                         const Standard_Boolean theToEvalMinMax) Standard_OVERRIDE;
0082   //! Add flipping element
0083   Standard_EXPORT virtual void SetFlippingOptions (const Standard_Boolean theIsEnabled,
0084                                                    const gp_Ax2&          theRefPlane) Standard_OVERRIDE;
0085 
0086   //! Add stencil test element
0087   Standard_EXPORT virtual void SetStencilTestOptions (const Standard_Boolean theIsEnabled) Standard_OVERRIDE;
0088 
0089 public:
0090 
0091   OpenGl_Structure* GlStruct() const { return (OpenGl_Structure* )(myStructure->CStructure().operator->()); }
0092 
0093   Standard_EXPORT void AddElement (OpenGl_Element* theElem);
0094 
0095   Standard_EXPORT virtual void Render  (const Handle(OpenGl_Workspace)& theWorkspace) const;
0096   Standard_EXPORT virtual void Release (const Handle(OpenGl_Context)&   theGlCtx);
0097 
0098   //! Returns first OpenGL element node of the group.
0099   const OpenGl_ElementNode* FirstNode() const { return myFirst; }
0100 
0101   //! Returns OpenGL aspect.
0102   const OpenGl_Aspects* GlAspects() const { return myAspects; }
0103 
0104   //! Is the group ray-tracable (contains ray-tracable elements)?
0105   Standard_Boolean IsRaytracable() const { return myIsRaytracable; }
0106 
0107   //! Dumps the content of me into the stream
0108   Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
0109 
0110 protected:
0111 
0112   Standard_EXPORT virtual ~OpenGl_Group();
0113 
0114 private:
0115 
0116   //! Render element if it passes the filtering procedure.
0117   //! This method should be used for elements which can be used in scope of rendering algorithms.
0118   //! E.g. elements of groups during recursive rendering.
0119   //! If render filter is null, pure rendering is performed.
0120   //! @param theWorkspace [in] the rendering workspace
0121   //! @param theFilter    [in] the rendering filter to check whether the element should be rendered or not
0122   //! @return True if element passes the check and renders
0123   Standard_EXPORT bool renderFiltered (const Handle(OpenGl_Workspace)& theWorkspace,
0124                                        OpenGl_Element* theElement) const;
0125 
0126 protected:
0127 
0128   OpenGl_Aspects*     myAspects;
0129   OpenGl_ElementNode* myFirst;
0130   OpenGl_ElementNode* myLast;
0131   Standard_Boolean    myIsRaytracable;
0132 
0133 public:
0134 
0135   DEFINE_STANDARD_RTTIEXT(OpenGl_Group,Graphic3d_Group) // Type definition
0136 
0137 };
0138 
0139 DEFINE_STANDARD_HANDLE(OpenGl_Group, Graphic3d_Group)
0140 
0141 #endif // _OpenGl_Group_Header