1 // File: Poly_CoherentTriPtr.hxx
2 // Created: 08.12.07 11:52
3 // Author: Alexander GRIGORIEV
4 // Copyright: Open Cascade 2007
7 #ifndef Poly_CoherentTriPtr_HeaderFile
8 #define Poly_CoherentTriPtr_HeaderFile
10 #include <NCollection_BaseAllocator.hxx>
12 class Poly_CoherentTriangle;
15 #pragma warning (push)
16 #pragma warning(disable:4355 4291) //'this' : used in base member initializer list
20 * Implementation of both list node for Poly_CoherentTriangle type and
21 * round double-linked list of these nodes.
24 class Poly_CoherentTriPtr
28 * Iterator class for this list of triangles. Because the list is round,
29 * an iteration can be started from any member and it finishes before taking
30 * this member again. The iteration sense is always forward (Next).
40 inline Iterator (const Poly_CoherentTriPtr& thePtr)
44 //! Query the triangle that started the current iteration.
45 inline const Poly_CoherentTriangle * First () const
46 { return myFirst ? &myFirst->GetTriangle() : 0L; }
47 //! Query if there is available triangle pointer on this iteration
48 inline Standard_Boolean More () const
49 { return myCurrent != 0L; }
50 //! Go to the next iteration.
51 Standard_EXPORT void Next ();
52 //! Get the current iterated triangle
53 inline const Poly_CoherentTriangle& Value () const
54 { return myCurrent->GetTriangle(); }
55 //! Get the current iterated triangle (mutable)
56 inline Poly_CoherentTriangle& ChangeValue () const
57 { return const_cast<Poly_CoherentTriangle&>(myCurrent->GetTriangle()); }
58 //! Get the current iterated pointer to triangle
59 inline const Poly_CoherentTriPtr& PtrValue() const
60 { return * myCurrent; }
62 const Poly_CoherentTriPtr * myFirst;
63 const Poly_CoherentTriPtr * myCurrent;
66 // ---------- PUBLIC METHODS ----------
72 inline Poly_CoherentTriPtr (const Poly_CoherentTriangle& theTri)
73 : mypTriangle (&theTri),
79 * Operator new for dynamic allocations
81 void* operator new (Standard_Size theSize,
82 const Handle(NCollection_BaseAllocator)& theAllocator)
84 return theAllocator->Allocate(theSize);
88 * Query the stored pointer to Triangle.
90 inline const Poly_CoherentTriangle&
92 { return * mypTriangle; }
95 * Initialize this instance with a pointer to triangle.
97 inline void SetTriangle (const Poly_CoherentTriangle * pTri)
98 { mypTriangle = pTri; }
101 * Query the next pointer in the list.
103 inline Poly_CoherentTriPtr&
108 * Query the previous pointer in the list.
110 inline Poly_CoherentTriPtr&
112 { return * myPrevious; }
115 * Append a pointer to triangle into the list after the current instance.
117 * Triangle that is to be included in the list after this one.
119 * Allocator where the new pointer instance is created.
121 Standard_EXPORT void Append (const Poly_CoherentTriangle * pTri,
122 const Handle_NCollection_BaseAllocator& theA);
125 * Prepend a pointer to triangle into the list before the current instance.
127 * Triangle that is to be included in the list before this one.
129 * Allocator where the new pointer instance is created.
131 Standard_EXPORT void Prepend (const Poly_CoherentTriangle * pTri,
132 const Handle_NCollection_BaseAllocator& theA);
135 * Remove a pointer to triangle from its list.
137 * This class instance that should be removed from its list.
139 * Allocator where the current pointer instance was created.
141 Standard_EXPORT static void
142 Remove (Poly_CoherentTriPtr * thePtr,
143 const Handle_NCollection_BaseAllocator& theA);
146 * Remove the list containing the given pointer to triangle.
148 Standard_EXPORT static void
149 RemoveList (Poly_CoherentTriPtr * thePtr,
150 const Handle_NCollection_BaseAllocator&);
153 // ---------- PROTECTED METHODS ----------
158 inline Poly_CoherentTriPtr (const Poly_CoherentTriangle * pTri)
159 : mypTriangle (pTri),
165 // ---------- PRIVATE FIELDS ----------
167 const Poly_CoherentTriangle * mypTriangle;
168 Poly_CoherentTriPtr * myNext;
169 Poly_CoherentTriPtr * myPrevious;
171 friend class Iterator;
175 #pragma warning (pop)