|
||||
File indexing completed on 2025-01-18 10:04:21
0001 // Created on: 2013-09-05 0002 // Created by: Anton POLETAEV 0003 // Copyright (c) 2013-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_Clipping_HeaderFile 0017 #define OpenGl_Clipping_HeaderFile 0018 0019 #include <Graphic3d_SequenceOfHClipPlane.hxx> 0020 #include <NCollection_Vector.hxx> 0021 #include <Standard_TypeDef.hxx> 0022 0023 class OpenGl_ClippingIterator; 0024 0025 //! This class contains logics related to tracking and modification of clipping plane 0026 //! state for particular OpenGl context. It contains information about enabled 0027 //! clipping planes and provides method to change clippings in context. The methods 0028 //! should be executed within OpenGl context associated with instance of this 0029 //! class. 0030 class OpenGl_Clipping 0031 { 0032 friend class OpenGl_ClippingIterator; 0033 public: //! @name general methods 0034 0035 //! Default constructor. 0036 Standard_EXPORT OpenGl_Clipping(); 0037 0038 //! Initialize. 0039 Standard_EXPORT void Init(); 0040 0041 //! Setup list of global (for entire view) clipping planes 0042 //! and clears local plane list if it was not released before. 0043 Standard_EXPORT void Reset (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes); 0044 0045 //! Setup list of local (for current object) clipping planes. 0046 Standard_EXPORT void SetLocalPlanes (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes); 0047 0048 //! @return true if there are enabled capping planes 0049 Standard_Boolean IsCappingOn() const { return myNbCapping > 0; } 0050 0051 //! @return true if there are enabled clipping or capping planes 0052 Standard_Boolean IsClippingOrCappingOn() const { return NbClippingOrCappingOn() > 0; } 0053 0054 //! @return number of enabled clipping + capping planes 0055 Standard_Integer NbClippingOrCappingOn() const 0056 { 0057 if (IsCappingDisableAllExcept()) 0058 { 0059 return 1; // all Chains are disabled - only single (sub) plane is active 0060 } 0061 return myNbClipping + myNbCapping 0062 + (IsCappingEnableAllExcept() ? -1 : 0); // exclude 1 plane with Capping filter turned ON 0063 } 0064 0065 //! Return TRUE if there are clipping chains in the list (defining more than 1 sub-plane) 0066 Standard_Boolean HasClippingChains() const 0067 { 0068 if (IsCappingDisableAllExcept() // all chains are disabled - only single (sub) plane is active; 0069 || myNbChains == (myNbClipping + myNbCapping)) // no sub-planes 0070 { 0071 return Standard_False; 0072 } 0073 return !IsCappingEnableAllExcept() 0074 || myCappedChain->NbChainNextPlanes() == 1 0075 || myNbChains > 1; // if capping filter ON - chains counter should be decremented 0076 } 0077 0078 public: //! @name advanced method for disabling defined planes 0079 0080 //! Return true if some clipping planes have been temporarily disabled. 0081 Standard_Boolean HasDisabled() const { return myNbDisabled > 0; } 0082 0083 //! Disable plane temporarily. 0084 Standard_EXPORT Standard_Boolean SetEnabled (const OpenGl_ClippingIterator& thePlane, 0085 const Standard_Boolean theIsEnabled); 0086 0087 //! Temporarily disable all planes from the global (view) list, keep only local (object) list. 0088 Standard_EXPORT void DisableGlobal(); 0089 0090 //! Restore all temporarily disabled planes. 0091 //! Does NOT affect constantly disabled planes Graphic3d_ClipPlane::IsOn(). 0092 Standard_EXPORT void RestoreDisabled(); 0093 0094 //! @name capping algorithm filter 0095 public: 0096 0097 //! Chain which is either temporary disabled or the only one enabled for Capping algorithm. 0098 const Handle(Graphic3d_ClipPlane)& CappedChain() const { return myCappedChain; } 0099 0100 //! Sub-plane index within filtered Chain; positive number for DisableAllExcept and negative for EnableAllExcept. 0101 Standard_Integer CappedSubPlane() const { return myCappedSubPlane; } 0102 0103 //! Return TRUE if capping algorithm is in state, when all clipping planes are temporarily disabled except currently processed one. 0104 bool IsCappingFilterOn() const { return !myCappedChain.IsNull(); } 0105 0106 //! Return TRUE if capping algorithm is in state, when all clipping planes are temporarily disabled except currently processed one. 0107 bool IsCappingDisableAllExcept() const { return myCappedSubPlane > 0; } 0108 0109 //! Return TRUE if capping algorithm is in state, when all clipping planes are enabled except currently rendered one. 0110 bool IsCappingEnableAllExcept() const { return myCappedSubPlane < 0; } 0111 0112 //! Temporarily disable all planes except specified one for Capping algorithm. 0113 //! Does not affect already disabled planes. 0114 Standard_EXPORT void DisableAllExcept (const Handle(Graphic3d_ClipPlane)& theChain, 0115 const Standard_Integer theSubPlaneIndex); 0116 0117 //! Enable back planes disabled by ::DisableAllExcept() for Capping algorithm. 0118 //! Keeps only specified plane enabled. 0119 Standard_EXPORT void EnableAllExcept (const Handle(Graphic3d_ClipPlane)& theChain, 0120 const Standard_Integer theSubPlaneIndex); 0121 0122 //! Resets chain filter for Capping algorithm. 0123 Standard_EXPORT void ResetCappingFilter(); 0124 0125 protected: //! @name clipping state modification commands 0126 0127 //! Add planes to the context clipping at the specified system of coordinates. 0128 //! This methods loads appropriate transformation matrix from workspace to 0129 //! to transform equation coordinates. The planes become enabled in the context. 0130 //! If the number of the passed planes exceeds capabilities of OpenGl, the last planes 0131 //! are simply ignored. 0132 //! 0133 //! Within FFP, method also temporarily resets ModelView matrix before calling glClipPlane(). 0134 //! Otherwise the method just redirects to addLazy(). 0135 //! 0136 //! @param thePlanes [in/out] the list of planes to be added 0137 //! The list then provides information on which planes were really added to clipping state. 0138 //! This list then can be used to fall back to previous state. 0139 Standard_EXPORT void add (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes, 0140 const Standard_Integer theStartIndex); 0141 0142 //! Remove the passed set of clipping planes from the context state. 0143 //! @param thePlanes [in] the planes to remove from list. 0144 Standard_EXPORT void remove (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes, 0145 const Standard_Integer theStartIndex); 0146 0147 private: 0148 0149 Handle(Graphic3d_SequenceOfHClipPlane) myPlanesGlobal; //!< global clipping planes 0150 Handle(Graphic3d_SequenceOfHClipPlane) myPlanesLocal; //!< object clipping planes 0151 NCollection_Vector<Standard_Boolean> myDisabledPlanes; //!< ids of disabled planes 0152 0153 Handle(Graphic3d_ClipPlane) myCappedChain; //!< chain which is either temporary disabled or the only one enabled for Capping algorithm 0154 Standard_Integer myCappedSubPlane; //!< sub-plane index within filtered chain; positive number for DisableAllExcept and negative for EnableAllExcept 0155 0156 Standard_Integer myNbClipping; //!< number of enabled clipping-only planes (NOT capping) 0157 Standard_Integer myNbCapping; //!< number of enabled capping planes 0158 Standard_Integer myNbChains; //!< number of enabled chains 0159 Standard_Integer myNbDisabled; //!< number of defined but disabled planes 0160 0161 private: 0162 //! Copying allowed only within Handles 0163 OpenGl_Clipping (const OpenGl_Clipping& ); 0164 OpenGl_Clipping& operator= (const OpenGl_Clipping& ); 0165 }; 0166 0167 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |