1 // Created on: 2007-12-08
2 // Created by: Alexander GRIGORIEV
3 // Copyright (c) 2007-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef Poly_CoherentTriPtr_HeaderFile
17 #define Poly_CoherentTriPtr_HeaderFile
19 #include <NCollection_BaseAllocator.hxx>
20 #include <NCollection_DefineAlloc.hxx>
22 class Poly_CoherentTriangle;
25 #pragma warning (push)
26 #pragma warning(disable:4355) //'this' : used in base member initializer list
30 * Implementation of both list node for Poly_CoherentTriangle type and
31 * round double-linked list of these nodes.
34 class Poly_CoherentTriPtr
38 * Iterator class for this list of triangles. Because the list is round,
39 * an iteration can be started from any member and it finishes before taking
40 * this member again. The iteration sense is always forward (Next).
50 inline Iterator (const Poly_CoherentTriPtr& thePtr)
54 //! Query the triangle that started the current iteration.
55 inline const Poly_CoherentTriangle * First () const
56 { return myFirst ? &myFirst->GetTriangle() : 0L; }
57 //! Query if there is available triangle pointer on this iteration
58 inline Standard_Boolean More () const
59 { return myCurrent != 0L; }
60 //! Go to the next iteration.
61 Standard_EXPORT void Next ();
62 //! Get the current iterated triangle
63 inline const Poly_CoherentTriangle& Value () const
64 { return myCurrent->GetTriangle(); }
65 //! Get the current iterated triangle (mutable)
66 inline Poly_CoherentTriangle& ChangeValue () const
67 { return const_cast<Poly_CoherentTriangle&>(myCurrent->GetTriangle()); }
68 //! Get the current iterated pointer to triangle
69 inline const Poly_CoherentTriPtr& PtrValue() const
70 { return * myCurrent; }
72 const Poly_CoherentTriPtr * myFirst;
73 const Poly_CoherentTriPtr * myCurrent;
76 // ---------- PUBLIC METHODS ----------
82 inline Poly_CoherentTriPtr (const Poly_CoherentTriangle& theTri)
83 : mypTriangle (&theTri),
89 * Operator new for dynamic allocations
91 DEFINE_NCOLLECTION_ALLOC
94 * Query the stored pointer to Triangle.
96 inline const Poly_CoherentTriangle&
98 { return * mypTriangle; }
101 * Initialize this instance with a pointer to triangle.
103 inline void SetTriangle (const Poly_CoherentTriangle * pTri)
104 { mypTriangle = pTri; }
107 * Query the next pointer in the list.
109 inline Poly_CoherentTriPtr&
114 * Query the previous pointer in the list.
116 inline Poly_CoherentTriPtr&
118 { return * myPrevious; }
121 * Append a pointer to triangle into the list after the current instance.
123 * Triangle that is to be included in the list after this one.
125 * Allocator where the new pointer instance is created.
127 Standard_EXPORT void Append (const Poly_CoherentTriangle * pTri,
128 const Handle(NCollection_BaseAllocator)& theA);
131 * Prepend a pointer to triangle into the list before the current instance.
133 * Triangle that is to be included in the list before this one.
135 * Allocator where the new pointer instance is created.
137 Standard_EXPORT void Prepend (const Poly_CoherentTriangle * pTri,
138 const Handle(NCollection_BaseAllocator)& theA);
141 * Remove a pointer to triangle from its list.
143 * This class instance that should be removed from its list.
145 * Allocator where the current pointer instance was created.
147 Standard_EXPORT static void
148 Remove (Poly_CoherentTriPtr * thePtr,
149 const Handle(NCollection_BaseAllocator)& theA);
152 * Remove the list containing the given pointer to triangle.
154 Standard_EXPORT static void
155 RemoveList (Poly_CoherentTriPtr * thePtr,
156 const Handle(NCollection_BaseAllocator)&);
159 // ---------- PROTECTED METHODS ----------
164 inline Poly_CoherentTriPtr (const Poly_CoherentTriangle * pTri)
165 : mypTriangle (pTri),
171 // ---------- PRIVATE FIELDS ----------
173 const Poly_CoherentTriangle * mypTriangle;
174 Poly_CoherentTriPtr * myNext;
175 Poly_CoherentTriPtr * myPrevious;
177 friend class Iterator;
181 #pragma warning (pop)