Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Copyright (c) 2013-2014 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef OpenGl_ClippingIterator_Header
0015 #define OpenGl_ClippingIterator_Header
0016 
0017 #include <OpenGl_Clipping.hxx>
0018 
0019 //! The iterator through clipping planes.
0020 class OpenGl_ClippingIterator
0021 {
0022 public:
0023 
0024   //! Main constructor.
0025   OpenGl_ClippingIterator(const OpenGl_Clipping& theClipping)
0026   : myDisabled  (&theClipping.myDisabledPlanes),
0027     myCurrIndex (1)
0028   {
0029     myIter1.Init (theClipping.myPlanesGlobal);
0030     myIter2.Init (theClipping.myPlanesLocal);
0031   }
0032 
0033   //! Return true if iterator points to the valid clipping plane.
0034   bool More() const { return myIter1.More() || myIter2.More(); }
0035 
0036   //! Go to the next clipping plane.
0037   void Next()
0038   {
0039     ++myCurrIndex;
0040     if (myIter1.More())
0041     {
0042       myIter1.Next();
0043     }
0044     else
0045     {
0046       myIter2.Next();
0047     }
0048   }
0049 
0050   //! Return true if plane has been temporarily disabled either by Graphic3d_ClipPlane->IsOn() property or by temporary filter.
0051   //! Beware that this method does NOT handle a Chain filter for Capping algorithm OpenGl_Clipping::CappedChain()!
0052   bool IsDisabled() const { return myDisabled->Value (myCurrIndex) || !Value()->IsOn(); }
0053 
0054   //! Return the plane at current iterator position.
0055   const Handle(Graphic3d_ClipPlane)& Value() const
0056   {
0057     return myIter1.More()
0058          ? myIter1.Value()
0059          : myIter2.Value();
0060   }
0061 
0062   //! Return true if plane from the global (view) list.
0063   bool IsGlobal() const { return myIter1.More(); }
0064 
0065   //! Return the plane index.
0066   Standard_Integer PlaneIndex() const { return myCurrIndex; }
0067 
0068 private:
0069 
0070   Graphic3d_SequenceOfHClipPlane::Iterator myIter1;
0071   Graphic3d_SequenceOfHClipPlane::Iterator myIter2;
0072   const NCollection_Vector<Standard_Boolean>* myDisabled;
0073   Standard_Integer myCurrIndex;
0074 
0075 };
0076 
0077 #endif // OpenGl_ClippingIterator_Header