Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Created on: 2007-12-08
0002 // Created by: Alexander GRIGORIEV
0003 // Copyright (c) 2007-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 Poly_CoherentTriPtr_HeaderFile
0017 #define Poly_CoherentTriPtr_HeaderFile
0018 
0019 #include <NCollection_BaseAllocator.hxx>
0020 #include <NCollection_DefineAlloc.hxx>
0021 
0022 class Poly_CoherentTriangle;
0023 
0024 #ifdef _MSC_VER
0025 #pragma warning (push)
0026 #pragma warning(disable:4355) //'this' : used in base member initializer list
0027 #endif
0028 
0029 /**
0030  * Implementation of both list node for Poly_CoherentTriangle type and
0031  * round double-linked list of these nodes. 
0032  */
0033 
0034 class Poly_CoherentTriPtr
0035 {
0036  public:
0037   /**
0038    * Iterator class for this list of triangles. Because the list is round,
0039    * an iteration can be started from any member and it finishes before taking
0040    * this member again. The iteration sense is always forward (Next).
0041    */  
0042   class Iterator {
0043   public:
0044     //! Empty constructor
0045     inline Iterator ()
0046       : myFirst         (0L),
0047         myCurrent       (0L)
0048     {}
0049     //! Constructor
0050     inline Iterator (const Poly_CoherentTriPtr& thePtr)
0051       : myFirst         (&thePtr),
0052         myCurrent       (&thePtr)
0053     {}
0054     //! Query the triangle that started the current iteration.
0055     inline const Poly_CoherentTriangle * First  () const
0056     { return myFirst ? &myFirst->GetTriangle() : 0L; }
0057     //! Query if there is available triangle pointer on this iteration
0058     inline Standard_Boolean             More    () const
0059     { return myCurrent != 0L; }
0060     //! Go to the next iteration.
0061     Standard_EXPORT void                Next    ();
0062     //! Get the current iterated triangle
0063     inline const Poly_CoherentTriangle& Value   () const
0064     { return myCurrent->GetTriangle(); }
0065     //! Get the current iterated triangle (mutable)
0066     inline Poly_CoherentTriangle&       ChangeValue   () const
0067     { return const_cast<Poly_CoherentTriangle&>(myCurrent->GetTriangle()); }
0068     //! Get the current iterated pointer to triangle
0069     inline const Poly_CoherentTriPtr&   PtrValue() const
0070     { return * myCurrent; }
0071   private:
0072     const Poly_CoherentTriPtr * myFirst;
0073     const Poly_CoherentTriPtr * myCurrent;
0074   };
0075 
0076   // ---------- PUBLIC METHODS ----------
0077 
0078 
0079   /**
0080    * Constructor.
0081    */
0082   inline Poly_CoherentTriPtr (const Poly_CoherentTriangle& theTri)
0083     : mypTriangle (&theTri),
0084       myNext      (this),
0085       myPrevious  (this)
0086   {}
0087 
0088   /**
0089    * Operator new for dynamic allocations
0090    */
0091   DEFINE_NCOLLECTION_ALLOC
0092 
0093   /**
0094    * Query the stored pointer to Triangle.
0095    */
0096   inline const Poly_CoherentTriangle&
0097                         GetTriangle () const
0098   { return * mypTriangle; }
0099 
0100   /**
0101    * Initialize this instance with a pointer to triangle.
0102    */
0103   inline void          SetTriangle (const Poly_CoherentTriangle * pTri)
0104   { mypTriangle = pTri; }
0105   
0106   /**
0107    * Query the next pointer in the list.
0108    */
0109   inline Poly_CoherentTriPtr&
0110                        Next     () const
0111   { return * myNext; }
0112 
0113   /**
0114    * Query the previous pointer in the list.
0115    */
0116   inline Poly_CoherentTriPtr&
0117                        Previous () const
0118   { return * myPrevious; }
0119 
0120   /**
0121    * Append a pointer to triangle into the list after the current instance.
0122    * @param pTri
0123    *   Triangle that is to be included in the list after this one.
0124    * @param theA
0125    *   Allocator where the new pointer instance is created.
0126    */
0127   Standard_EXPORT void Append   (const Poly_CoherentTriangle *           pTri,
0128                                  const Handle(NCollection_BaseAllocator)& theA);
0129 
0130   /**
0131    * Prepend a pointer to triangle into the list before the current instance.
0132    * @param pTri
0133    *   Triangle that is to be included in the list before this one.
0134    * @param theA
0135    *   Allocator where the new pointer instance is created.
0136    */
0137   Standard_EXPORT void Prepend  (const Poly_CoherentTriangle *           pTri,
0138                                  const Handle(NCollection_BaseAllocator)& theA);
0139 
0140   /**
0141    * Remove a pointer to triangle from its list.
0142    * @param thePtr
0143    *   This class instance that should be removed from its list.
0144    * @param theA
0145    *   Allocator where the current pointer instance was created.
0146    */
0147   Standard_EXPORT static void
0148                        Remove   (Poly_CoherentTriPtr *                   thePtr,
0149                                  const Handle(NCollection_BaseAllocator)& theA);
0150 
0151   /**
0152    * Remove the list containing the given pointer to triangle.
0153    */
0154   Standard_EXPORT static void
0155                        RemoveList (Poly_CoherentTriPtr *                 thePtr,
0156                                    const Handle(NCollection_BaseAllocator)&);
0157 
0158  protected:
0159   // ---------- PROTECTED METHODS ----------
0160 
0161   /**
0162    * Constructor.
0163    */
0164   inline Poly_CoherentTriPtr (const Poly_CoherentTriangle * pTri)
0165     : mypTriangle (pTri),
0166       myNext      (this),
0167       myPrevious  (this)
0168   {}
0169 
0170  private:
0171   // ---------- PRIVATE FIELDS ----------
0172 
0173   const Poly_CoherentTriangle * mypTriangle;
0174   Poly_CoherentTriPtr         * myNext;
0175   Poly_CoherentTriPtr         * myPrevious;
0176 
0177   friend class Iterator;
0178 };
0179 
0180 #ifdef _MSC_VER
0181 #pragma warning (pop)
0182 #endif
0183 
0184 #endif