Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:47

0001 // Copyright (c) 1995-1999 Matra Datavision
0002 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0003 //
0004 // This file is part of Open CASCADE Technology software library.
0005 //
0006 // This library is free software; you can redistribute it and/or modify it under
0007 // the terms of the GNU Lesser General Public License version 2.1 as published
0008 // by the Free Software Foundation, with special exception defined in the file
0009 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0010 // distribution for complete text of the license and disclaimer of any warranty.
0011 //
0012 // Alternatively, this file may be used under the terms of Open CASCADE
0013 // commercial license or contractual agreement.
0014 
0015 #ifndef _Graphic3d_CStructure_HeaderFile
0016 #define _Graphic3d_CStructure_HeaderFile
0017 
0018 #include <Graphic3d_DisplayPriority.hxx>
0019 #include <Graphic3d_PresentationAttributes.hxx>
0020 #include <Graphic3d_SequenceOfGroup.hxx>
0021 #include <Graphic3d_SequenceOfHClipPlane.hxx>
0022 #include <Graphic3d_ViewAffinity.hxx>
0023 #include <Graphic3d_TransformPers.hxx>
0024 #include <Graphic3d_ZLayerId.hxx>
0025 #include <TopLoc_Datum3D.hxx>
0026 #include <NCollection_IndexedMap.hxx>
0027 
0028 class Graphic3d_GraphicDriver;
0029 class Graphic3d_StructureManager;
0030 
0031 //! Low-level graphic structure interface
0032 class Graphic3d_CStructure : public Standard_Transient
0033 {
0034   DEFINE_STANDARD_RTTIEXT(Graphic3d_CStructure, Standard_Transient)
0035 protected:
0036 
0037   //! Auxiliary wrapper to iterate through structure list.
0038   template<class Struct_t>
0039   class SubclassStructIterator
0040   {
0041   public:
0042     SubclassStructIterator (const NCollection_IndexedMap<const Graphic3d_CStructure*>& theStructs) : myIter (theStructs) {}
0043     Standard_Boolean More() const  { return myIter.More(); }
0044     void Next()                    { myIter.Next(); }
0045     const Struct_t*  Value() const { return (const Struct_t* )(myIter.Value()); }
0046     Struct_t*        ChangeValue() { return (Struct_t* )(myIter.Value()); }
0047   private:
0048     NCollection_IndexedMap<const Graphic3d_CStructure*>::Iterator myIter;
0049   };
0050 
0051   //! Auxiliary wrapper to iterate through group sequence.
0052   template<class Group_t>
0053   class SubclassGroupIterator
0054   {
0055   public:
0056     SubclassGroupIterator (const Graphic3d_SequenceOfGroup& theGroups) : myIter (theGroups) {}
0057     Standard_Boolean More() const  { return myIter.More(); }
0058     void Next()                    { myIter.Next(); }
0059     const Group_t*   Value() const { return (const Group_t* )(myIter.Value().get()); }
0060     Group_t*         ChangeValue() { return (Group_t* )(myIter.ChangeValue().get()); }
0061   private:
0062     Graphic3d_SequenceOfGroup::Iterator myIter;
0063   };
0064 
0065 public:
0066 
0067   //! @return graphic driver created this structure
0068   const Handle(Graphic3d_GraphicDriver)& GraphicDriver() const
0069   {
0070     return myGraphicDriver;
0071   }
0072 
0073   //! @return graphic groups
0074   const Graphic3d_SequenceOfGroup& Groups() const
0075   {
0076     return myGroups;
0077   }
0078 
0079   //! Return transformation.
0080   const Handle(TopLoc_Datum3D)& Transformation() const { return myTrsf; }
0081 
0082   //! Assign transformation.
0083   virtual void SetTransformation (const Handle(TopLoc_Datum3D)& theTrsf) { myTrsf = theTrsf; }
0084 
0085   //! Return transformation persistence.
0086   const Handle(Graphic3d_TransformPers)& TransformPersistence() const { return myTrsfPers; }
0087 
0088   //! Set transformation persistence.
0089   virtual void SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers) { myTrsfPers = theTrsfPers; }
0090 
0091   //! Return TRUE if some groups might have transform persistence; FALSE by default.
0092   bool HasGroupTransformPersistence() const { return myHasGroupTrsf; }
0093 
0094   //! Set if some groups might have transform persistence.
0095   void SetGroupTransformPersistence (bool theValue) { myHasGroupTrsf = theValue; }
0096 
0097   //! @return associated clip planes
0098   const Handle(Graphic3d_SequenceOfHClipPlane)& ClipPlanes() const
0099   {
0100     return myClipPlanes;
0101   }
0102 
0103   //! Pass clip planes to the associated graphic driver structure
0104   void SetClipPlanes (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes) { myClipPlanes = thePlanes; }
0105 
0106   //! @return bounding box of this presentation
0107   const Graphic3d_BndBox3d& BoundingBox() const
0108   {
0109     return myBndBox;
0110   }
0111 
0112   //! @return bounding box of this presentation
0113   //! without transformation matrix applied
0114   Graphic3d_BndBox3d& ChangeBoundingBox()
0115   {
0116     return myBndBox;
0117   }
0118 
0119   //! Return structure visibility flag
0120   bool IsVisible() const { return visible != 0; }
0121 
0122   //! Return structure visibility considering both View Affinity and global visibility state.
0123   bool IsVisible (const Standard_Integer theViewId) const
0124   {
0125     return visible != 0
0126         && (ViewAffinity.IsNull()
0127          || ViewAffinity->IsVisible (theViewId));
0128   }
0129 
0130   //! Set z layer ID to display the structure in specified layer
0131   virtual void SetZLayer (const Graphic3d_ZLayerId theLayerIndex) { myZLayer = theLayerIndex; }
0132 
0133   //! Get z layer ID
0134   Graphic3d_ZLayerId ZLayer() const { return myZLayer; }
0135 
0136   //! Returns valid handle to highlight style of the structure in case if
0137   //! highlight flag is set to true
0138   const Handle(Graphic3d_PresentationAttributes)& HighlightStyle() const { return myHighlightStyle; }
0139 
0140   //! Return structure id (generated by Graphic3d_GraphicDriver::NewIdentification() during structure construction).
0141   Standard_Integer Identification() const { return myId; }
0142 
0143   //! Return structure display priority.
0144   Graphic3d_DisplayPriority Priority() const { return myPriority; }
0145 
0146   //! Set structure display priority.
0147   void SetPriority (Graphic3d_DisplayPriority thePriority) { myPriority = thePriority; }
0148 
0149   //! Return previous structure display priority.
0150   Graphic3d_DisplayPriority PreviousPriority() const { return myPreviousPriority; }
0151 
0152   //! Set previous structure display priority.
0153   void SetPreviousPriority (Graphic3d_DisplayPriority thePriority) { myPreviousPriority = thePriority; }
0154 
0155 public:
0156 
0157   //! Returns FALSE if the structure hits the current view volume, otherwise returns TRUE.
0158   Standard_Boolean IsCulled() const { return myIsCulled; }
0159 
0160   //! Marks structure as culled/not culled - note that IsAlwaysRendered() is ignored here!
0161   void SetCulled (Standard_Boolean theIsCulled) const { myIsCulled = theIsCulled; }
0162 
0163   //! Marks structure as overlapping the current view volume one.
0164   //! The method is called during traverse of BVH tree.
0165   void MarkAsNotCulled() const { myIsCulled = Standard_False; }
0166 
0167   //! Returns whether check of object's bounding box clipping is enabled before drawing of object; TRUE by default.
0168   Standard_Boolean BndBoxClipCheck() const { return myBndBoxClipCheck; }
0169 
0170   //! Enable/disable check of object's bounding box clipping before drawing of object.
0171   void SetBndBoxClipCheck(Standard_Boolean theBndBoxClipCheck) { myBndBoxClipCheck = theBndBoxClipCheck; }
0172 
0173   //! Checks if the structure should be included into BVH tree or not.
0174   Standard_Boolean IsAlwaysRendered() const
0175   {
0176     return IsInfinite
0177         || IsForHighlight
0178         || IsMutable
0179         || Is2dText
0180         || (!myTrsfPers.IsNull() && myTrsfPers->IsTrihedronOr2d());
0181   }
0182 
0183 public:
0184 
0185   //! Update structure visibility state
0186   virtual void OnVisibilityChanged() = 0;
0187 
0188   //! Clear graphic data
0189   virtual void Clear() = 0;
0190 
0191   //! Connect other structure to this one
0192   virtual void Connect    (Graphic3d_CStructure& theStructure) = 0;
0193 
0194   //! Disconnect other structure to this one
0195   virtual void Disconnect (Graphic3d_CStructure& theStructure) = 0;
0196 
0197   //! Highlights structure with the given style
0198   virtual void GraphicHighlight (const Handle(Graphic3d_PresentationAttributes)& theStyle) = 0;
0199 
0200   //! Unhighlights the structure and invalidates pointer to structure's highlight style
0201   virtual void GraphicUnhighlight() = 0;
0202 
0203   //! Create shadow link to this structure
0204   virtual Handle(Graphic3d_CStructure) ShadowLink (const Handle(Graphic3d_StructureManager)& theManager) const = 0;
0205 
0206   //! Create new group within this structure
0207   virtual Handle(Graphic3d_Group) NewGroup (const Handle(Graphic3d_Structure)& theStruct) = 0;
0208 
0209   //! Remove group from this structure
0210   virtual void RemoveGroup (const Handle(Graphic3d_Group)& theGroup) = 0;
0211 
0212   //! Update render transformation matrix.
0213   virtual void updateLayerTransformation() {}
0214 
0215   //! Dumps the content of me into the stream
0216   Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
0217 
0218 public:
0219 
0220   Handle(Graphic3d_ViewAffinity) ViewAffinity; //!< view affinity mask
0221 
0222 protected:
0223 
0224   //! Create empty structure.
0225   Standard_EXPORT Graphic3d_CStructure (const Handle(Graphic3d_StructureManager)& theManager);
0226 
0227 protected:
0228 
0229   Handle(Graphic3d_GraphicDriver) myGraphicDriver;
0230   Graphic3d_SequenceOfGroup       myGroups;
0231   Graphic3d_BndBox3d              myBndBox;
0232   Handle(TopLoc_Datum3D)          myTrsf;
0233   Handle(Graphic3d_TransformPers) myTrsfPers;
0234   Handle(Graphic3d_SequenceOfHClipPlane) myClipPlanes;
0235   Handle(Graphic3d_PresentationAttributes) myHighlightStyle; //! Current highlight style; is set only if highlight flag is true
0236 
0237   Standard_Integer          myId;
0238   Graphic3d_ZLayerId        myZLayer;
0239   Graphic3d_DisplayPriority myPriority;
0240   Graphic3d_DisplayPriority myPreviousPriority;
0241 
0242   mutable Standard_Boolean myIsCulled; //!< A status specifying is structure needs to be rendered after BVH tree traverse
0243   Standard_Boolean myBndBoxClipCheck;  //!< Flag responsible for checking of bounding box clipping before drawing of object
0244 
0245   Standard_Boolean myHasGroupTrsf;     //!< flag specifying that some groups might have transform persistence
0246 
0247 public:
0248 
0249   unsigned IsInfinite     : 1;
0250   unsigned stick          : 1; //!< displaying state - should be set when structure has been added to scene graph (but can be in hidden state)
0251   unsigned highlight      : 1;
0252   unsigned visible        : 1; //!< visibility flag - can be used to suppress structure while leaving it in the scene graph
0253   unsigned HLRValidation  : 1;
0254   unsigned IsForHighlight : 1;
0255   unsigned IsMutable      : 1;
0256   unsigned Is2dText       : 1;
0257 
0258 };
0259 
0260 DEFINE_STANDARD_HANDLE (Graphic3d_CStructure, Standard_Transient)
0261 
0262 #endif // _Graphic3d_CStructure_HeaderFile