Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-04 08:46:03

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   //! Create empty group.
0039   //! Will throw exception if not created by OpenGl_Structure.
0040   Standard_EXPORT OpenGl_Group(const Handle(Graphic3d_Structure)& theStruct);
0041 
0042   Standard_EXPORT virtual void Clear(const Standard_Boolean theToUpdateStructureMgr)
0043     Standard_OVERRIDE;
0044 
0045   //! Return line aspect.
0046   virtual Handle(Graphic3d_Aspects) Aspects() const Standard_OVERRIDE
0047   {
0048     return myAspects != NULL ? myAspects->Aspect() : Handle(Graphic3d_Aspects)();
0049   }
0050 
0051   //! Return TRUE if group contains primitives with transform persistence.
0052   bool HasPersistence() const
0053   {
0054     return !myTrsfPers.IsNull()
0055            || (myStructure != NULL && !myStructure->TransformPersistence().IsNull());
0056   }
0057 
0058   //! Update aspect.
0059   Standard_EXPORT virtual void SetGroupPrimitivesAspect(const Handle(Graphic3d_Aspects)& theAspect)
0060     Standard_OVERRIDE;
0061 
0062   //! Append aspect as an element.
0063   Standard_EXPORT virtual void SetPrimitivesAspect(const Handle(Graphic3d_Aspects)& theAspect)
0064     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)
0071     Standard_OVERRIDE;
0072 
0073   //! Add primitive array element
0074   Standard_EXPORT virtual void AddPrimitiveArray(const Graphic3d_TypeOfPrimitiveArray theType,
0075                                                  const Handle(Graphic3d_IndexBuffer)& theIndices,
0076                                                  const Handle(Graphic3d_Buffer)&      theAttribs,
0077                                                  const Handle(Graphic3d_BoundBuffer)& theBounds,
0078                                                  const Standard_Boolean theToEvalMinMax)
0079     Standard_OVERRIDE;
0080 
0081   //! Adds a text for display
0082   Standard_EXPORT virtual void AddText(const Handle(Graphic3d_Text)& theTextParams,
0083                                        const Standard_Boolean theToEvalMinMax) Standard_OVERRIDE;
0084   //! Add flipping element
0085   Standard_EXPORT virtual void SetFlippingOptions(const Standard_Boolean theIsEnabled,
0086                                                   const gp_Ax2& theRefPlane) Standard_OVERRIDE;
0087 
0088   //! Add stencil test element
0089   Standard_EXPORT virtual void SetStencilTestOptions(const Standard_Boolean theIsEnabled)
0090     Standard_OVERRIDE;
0091 
0092 public:
0093   OpenGl_Structure* GlStruct() const
0094   {
0095     return (OpenGl_Structure*)(myStructure->CStructure().operator->());
0096   }
0097 
0098   Standard_EXPORT void AddElement(OpenGl_Element* theElem);
0099 
0100   Standard_EXPORT virtual void Render(const Handle(OpenGl_Workspace)& theWorkspace) const;
0101   Standard_EXPORT virtual void Release(const Handle(OpenGl_Context)& theGlCtx);
0102 
0103   //! Returns first OpenGL element node of the group.
0104   const OpenGl_ElementNode* FirstNode() const { return myFirst; }
0105 
0106   //! Returns OpenGL aspect.
0107   const OpenGl_Aspects* GlAspects() const { return myAspects; }
0108 
0109   //! Is the group ray-tracable (contains ray-tracable elements)?
0110   Standard_Boolean IsRaytracable() const { return myIsRaytracable; }
0111 
0112   //! Dumps the content of me into the stream
0113   Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
0114                                         Standard_Integer  theDepth = -1) const Standard_OVERRIDE;
0115 
0116 protected:
0117   Standard_EXPORT virtual ~OpenGl_Group();
0118 
0119 private:
0120   //! Render element if it passes the filtering procedure.
0121   //! This method should be used for elements which can be used in scope of rendering algorithms.
0122   //! E.g. elements of groups during recursive rendering.
0123   //! If render filter is null, pure rendering is performed.
0124   //! @param[in] theWorkspace  the rendering workspace
0125   //! @param[in] theFilter     the rendering filter to check whether the element should be rendered
0126   //! or not
0127   //! @return True if element passes the check and renders
0128   Standard_EXPORT bool renderFiltered(const Handle(OpenGl_Workspace)& theWorkspace,
0129                                       OpenGl_Element*                 theElement) const;
0130 
0131 protected:
0132   OpenGl_Aspects*     myAspects;
0133   OpenGl_ElementNode* myFirst;
0134   OpenGl_ElementNode* myLast;
0135   Standard_Boolean    myIsRaytracable;
0136 
0137 public:
0138   DEFINE_STANDARD_RTTIEXT(OpenGl_Group, Graphic3d_Group) // Type definition
0139 };
0140 
0141 DEFINE_STANDARD_HANDLE(OpenGl_Group, Graphic3d_Group)
0142 
0143 #endif // _OpenGl_Group_Header