Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-02 09:13:36

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   {
0044   public:
0045     //! Empty constructor
0046     inline Iterator()
0047         : myFirst(nullptr),
0048           myCurrent(nullptr)
0049     {
0050     }
0051 
0052     //! Constructor
0053     inline Iterator(const Poly_CoherentTriPtr& thePtr)
0054         : myFirst(&thePtr),
0055           myCurrent(&thePtr)
0056     {
0057     }
0058 
0059     //! Query the triangle that started the current iteration.
0060     inline const Poly_CoherentTriangle* First() const
0061     {
0062       return myFirst ? &myFirst->GetTriangle() : nullptr;
0063     }
0064 
0065     //! Query if there is available triangle pointer on this iteration
0066     inline bool More() const { return myCurrent != nullptr; }
0067 
0068     //! Go to the next iteration.
0069     Standard_EXPORT void Next();
0070 
0071     //! Get the current iterated triangle
0072     inline const Poly_CoherentTriangle& Value() const { return myCurrent->GetTriangle(); }
0073 
0074     //! Get the current iterated triangle (mutable)
0075     inline Poly_CoherentTriangle& ChangeValue() const
0076     {
0077       return const_cast<Poly_CoherentTriangle&>(myCurrent->GetTriangle());
0078     }
0079 
0080     //! Get the current iterated pointer to triangle
0081     inline const Poly_CoherentTriPtr& PtrValue() const { return *myCurrent; }
0082 
0083   private:
0084     const Poly_CoherentTriPtr* myFirst;
0085     const Poly_CoherentTriPtr* myCurrent;
0086   };
0087 
0088   // ---------- PUBLIC METHODS ----------
0089 
0090   /**
0091    * Constructor.
0092    */
0093   inline Poly_CoherentTriPtr(const Poly_CoherentTriangle& theTri)
0094       : mypTriangle(&theTri),
0095         myNext(this),
0096         myPrevious(this)
0097   {
0098   }
0099 
0100   /**
0101    * Operator new for dynamic allocations
0102    */
0103   DEFINE_NCOLLECTION_ALLOC
0104 
0105   /**
0106    * Query the stored pointer to Triangle.
0107    */
0108   inline const Poly_CoherentTriangle& GetTriangle() const { return *mypTriangle; }
0109 
0110   /**
0111    * Initialize this instance with a pointer to triangle.
0112    */
0113   inline void SetTriangle(const Poly_CoherentTriangle* pTri) { mypTriangle = pTri; }
0114 
0115   /**
0116    * Query the next pointer in the list.
0117    */
0118   inline Poly_CoherentTriPtr& Next() const { return *myNext; }
0119 
0120   /**
0121    * Query the previous pointer in the list.
0122    */
0123   inline Poly_CoherentTriPtr& Previous() const { return *myPrevious; }
0124 
0125   /**
0126    * Append a pointer to triangle into the list after the current instance.
0127    * @param pTri
0128    *   Triangle that is to be included in the list after this one.
0129    * @param theA
0130    *   Allocator where the new pointer instance is created.
0131    */
0132   Standard_EXPORT void Append(const Poly_CoherentTriangle*                  pTri,
0133                               const occ::handle<NCollection_BaseAllocator>& theA);
0134 
0135   /**
0136    * Prepend a pointer to triangle into the list before the current instance.
0137    * @param pTri
0138    *   Triangle that is to be included in the list before this one.
0139    * @param theA
0140    *   Allocator where the new pointer instance is created.
0141    */
0142   Standard_EXPORT void Prepend(const Poly_CoherentTriangle*                  pTri,
0143                                const occ::handle<NCollection_BaseAllocator>& theA);
0144 
0145   /**
0146    * Remove a pointer to triangle from its list.
0147    * @param thePtr
0148    *   This class instance that should be removed from its list.
0149    * @param theA
0150    *   Allocator where the current pointer instance was created.
0151    */
0152   Standard_EXPORT static void Remove(Poly_CoherentTriPtr*                          thePtr,
0153                                      const occ::handle<NCollection_BaseAllocator>& theA);
0154 
0155   /**
0156    * Remove the list containing the given pointer to triangle.
0157    */
0158   Standard_EXPORT static void RemoveList(Poly_CoherentTriPtr* thePtr,
0159                                          const occ::handle<NCollection_BaseAllocator>&);
0160 
0161 protected:
0162   // ---------- PROTECTED METHODS ----------
0163 
0164   /**
0165    * Constructor.
0166    */
0167   inline Poly_CoherentTriPtr(const Poly_CoherentTriangle* pTri)
0168       : mypTriangle(pTri),
0169         myNext(this),
0170         myPrevious(this)
0171   {
0172   }
0173 
0174 private:
0175   // ---------- PRIVATE FIELDS ----------
0176 
0177   const Poly_CoherentTriangle* mypTriangle;
0178   Poly_CoherentTriPtr*         myNext;
0179   Poly_CoherentTriPtr*         myPrevious;
0180 
0181   friend class Iterator;
0182 };
0183 
0184 #ifdef _MSC_VER
0185   #pragma warning(pop)
0186 #endif
0187 
0188 #endif