Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-31 09:37:05

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