b311480e |
1 | // Created on: 2007-12-08 |
2 | // Created by: Alexander GRIGORIEV |
973c2be1 |
3 | // Copyright (c) 2007-2014 OPEN CASCADE SAS |
b311480e |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
b311480e |
6 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
7fd59977 |
15 | |
16 | #ifndef Poly_CoherentTriPtr_HeaderFile |
17 | #define Poly_CoherentTriPtr_HeaderFile |
18 | |
19 | #include <NCollection_BaseAllocator.hxx> |
1c35b92f |
20 | #include <NCollection_DefineAlloc.hxx> |
7fd59977 |
21 | |
22 | class Poly_CoherentTriangle; |
23 | |
57c28b61 |
24 | #ifdef _MSC_VER |
7fd59977 |
25 | #pragma warning (push) |
1c35b92f |
26 | #pragma warning(disable:4355) //'this' : used in base member initializer list |
7fd59977 |
27 | #endif |
28 | |
29 | /** |
30 | * Implementation of both list node for Poly_CoherentTriangle type and |
31 | * round double-linked list of these nodes. |
32 | */ |
33 | |
34 | class Poly_CoherentTriPtr |
35 | { |
36 | public: |
37 | /** |
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). |
41 | */ |
42 | class Iterator { |
43 | public: |
44 | //! Empty constructor |
45 | inline Iterator () |
46 | : myFirst (0L), |
47 | myCurrent (0L) |
48 | {} |
49 | //! Constructor |
50 | inline Iterator (const Poly_CoherentTriPtr& thePtr) |
51 | : myFirst (&thePtr), |
52 | myCurrent (&thePtr) |
53 | {} |
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; } |
71 | private: |
72 | const Poly_CoherentTriPtr * myFirst; |
73 | const Poly_CoherentTriPtr * myCurrent; |
74 | }; |
75 | |
76 | // ---------- PUBLIC METHODS ---------- |
77 | |
78 | |
79 | /** |
80 | * Constructor. |
81 | */ |
82 | inline Poly_CoherentTriPtr (const Poly_CoherentTriangle& theTri) |
83 | : mypTriangle (&theTri), |
84 | myNext (this), |
85 | myPrevious (this) |
86 | {} |
87 | |
88 | /** |
89 | * Operator new for dynamic allocations |
90 | */ |
1c35b92f |
91 | DEFINE_NCOLLECTION_ALLOC |
7fd59977 |
92 | |
93 | /** |
94 | * Query the stored pointer to Triangle. |
95 | */ |
96 | inline const Poly_CoherentTriangle& |
97 | GetTriangle () const |
98 | { return * mypTriangle; } |
99 | |
100 | /** |
101 | * Initialize this instance with a pointer to triangle. |
102 | */ |
103 | inline void SetTriangle (const Poly_CoherentTriangle * pTri) |
104 | { mypTriangle = pTri; } |
105 | |
106 | /** |
107 | * Query the next pointer in the list. |
108 | */ |
109 | inline Poly_CoherentTriPtr& |
110 | Next () const |
111 | { return * myNext; } |
112 | |
113 | /** |
114 | * Query the previous pointer in the list. |
115 | */ |
116 | inline Poly_CoherentTriPtr& |
117 | Previous () const |
118 | { return * myPrevious; } |
119 | |
120 | /** |
121 | * Append a pointer to triangle into the list after the current instance. |
122 | * @param pTri |
123 | * Triangle that is to be included in the list after this one. |
124 | * @param theA |
125 | * Allocator where the new pointer instance is created. |
126 | */ |
127 | Standard_EXPORT void Append (const Poly_CoherentTriangle * pTri, |
857ffd5e |
128 | const Handle(NCollection_BaseAllocator)& theA); |
7fd59977 |
129 | |
130 | /** |
131 | * Prepend a pointer to triangle into the list before the current instance. |
132 | * @param pTri |
133 | * Triangle that is to be included in the list before this one. |
134 | * @param theA |
135 | * Allocator where the new pointer instance is created. |
136 | */ |
137 | Standard_EXPORT void Prepend (const Poly_CoherentTriangle * pTri, |
857ffd5e |
138 | const Handle(NCollection_BaseAllocator)& theA); |
7fd59977 |
139 | |
140 | /** |
141 | * Remove a pointer to triangle from its list. |
142 | * @param thePtr |
143 | * This class instance that should be removed from its list. |
144 | * @param theA |
145 | * Allocator where the current pointer instance was created. |
146 | */ |
147 | Standard_EXPORT static void |
148 | Remove (Poly_CoherentTriPtr * thePtr, |
857ffd5e |
149 | const Handle(NCollection_BaseAllocator)& theA); |
7fd59977 |
150 | |
151 | /** |
152 | * Remove the list containing the given pointer to triangle. |
153 | */ |
154 | Standard_EXPORT static void |
155 | RemoveList (Poly_CoherentTriPtr * thePtr, |
857ffd5e |
156 | const Handle(NCollection_BaseAllocator)&); |
7fd59977 |
157 | |
158 | protected: |
159 | // ---------- PROTECTED METHODS ---------- |
160 | |
161 | /** |
162 | * Constructor. |
163 | */ |
164 | inline Poly_CoherentTriPtr (const Poly_CoherentTriangle * pTri) |
165 | : mypTriangle (pTri), |
166 | myNext (this), |
167 | myPrevious (this) |
168 | {} |
169 | |
170 | private: |
171 | // ---------- PRIVATE FIELDS ---------- |
172 | |
173 | const Poly_CoherentTriangle * mypTriangle; |
174 | Poly_CoherentTriPtr * myNext; |
175 | Poly_CoherentTriPtr * myPrevious; |
176 | |
177 | friend class Iterator; |
178 | }; |
179 | |
57c28b61 |
180 | #ifdef _MSC_VER |
7fd59977 |
181 | #pragma warning (pop) |
182 | #endif |
183 | |
184 | #endif |