Reference documentation for deal.II version 8.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
tria_iterator.templates.h
1 // ---------------------------------------------------------------------
2 // @f$Id: tria_iterator.templates.h 30036 2013-07-18 16:55:32Z maier @f$
3 //
4 // Copyright (C) 1998 - 2013 by the deal.II authors
5 //
6 // This file is part of the deal.II library.
7 //
8 // The deal.II library is free software; you can use it, redistribute
9 // it, and/or modify it under the terms of the GNU Lesser General
10 // Public License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
12 // The full text of the license can be found in the file LICENSE at
13 // the top level of the deal.II distribution.
14 //
15 // ---------------------------------------------------------------------
16 
17 #ifndef __deal2__tria_iterator_templates_h
18 #define __deal2__tria_iterator_templates_h
19 
20 
21 #include <deal.II/base/config.h>
22 #include <deal.II/grid/tria.h>
23 #include <deal.II/grid/tria_iterator.h>
24 
25 DEAL_II_NAMESPACE_OPEN
26 
27 
28 /* Note: This file only contains template definitions and will thus
29  not produce an object file. It is rather thought to be included
30  into the *_accessor.cc files.
31 */
32 
33 
34 /*------------------------ Functions: TriaRawIterator ------------------*/
35 
36 
37 template <typename Accessor>
38 inline
40  :
41  accessor (0, -2, -2, 0)
42 {}
43 
44 
45 template <typename Accessor>
46 inline
48  :
49  accessor (i.accessor)
50 {}
51 
52 
53 
54 template <typename Accessor>
55 inline
58  const int level,
59  const int index,
60  const typename Accessor::AccessorData *local_data)
61  :
62  accessor (parent, level, index, local_data)
63 {}
64 
65 
66 template <typename Accessor>
67 inline
70  const typename Accessor::AccessorData *local_data)
71  :
72  accessor(0, -2, -2, local_data)
73 {
74  accessor.copy_from(tria_accessor);
75 }
76 
77 
78 template <typename Accessor>
79 inline
82 {
83  accessor.copy_from (i.accessor);
84 
85  return *this;
86 }
87 
88 
89 // template <typename Accessor>
90 // template <typename OtherAccessor>
91 // inline
92 // TriaRawIterator<Accessor> &
93 // TriaRawIterator<Accessor>::operator = (const TriaRawIterator<OtherAccessor> &i)
94 // {
95 // accessor.copy_from (i.accessor);
96 // return *this;
97 // }
98 
99 
100 // template <typename Accessor>
101 // template <typename OtherAccessor>
102 // inline
103 // TriaRawIterator<Accessor> &
104 // TriaRawIterator<Accessor>::operator = (const TriaIterator<OtherAccessor> &i)
105 // {
106 // accessor.copy_from (i.accessor);
107 // return *this;
108 // }
109 
110 
111 // template <typename Accessor>
112 // template <typename OtherAccessor>
113 // inline
114 // TriaRawIterator<Accessor> &
115 // TriaRawIterator<Accessor>::operator = (const TriaActiveIterator<OtherAccessor> &i)
116 // {
117 // accessor.copy_from (i.accessor);
118 // return *this;
119 // }
120 
121 
122 template <typename Accessor>
123 inline
124 bool
126 {
127  return accessor == i.accessor;
128 }
129 
130 
131 template <typename Accessor>
132 inline
133 bool
135 {
136  // Note that at times, there is a problem
137  // with egcs 1.1 that makes it choose
138  // the global STL operator != (which
139  // does only !(a==b)) over the member
140  // function one, which then results in an
141  // error because the operator == of
142  // the accessor class is
143  // not made public. Strange... don't know
144  // whose fault it is.
145  //
146  // Work around the problem this way:
147  return accessor.operator != (i.accessor);
148 }
149 
150 
151 template <typename Accessor>
152 inline
155 {
156  TriaRawIterator<Accessor> tmp(*this);
157  operator++ ();
158 
159  return tmp;
160 }
161 
162 
163 template <typename Accessor>
164 inline
167 {
168  TriaRawIterator<Accessor> tmp(*this);
169  operator-- ();
170 
171  return tmp;
172 }
173 
174 
175 /*----------------------- functions: TriaIterator ---------------*/
176 
177 
178 template <typename Accessor>
179 inline
181  TriaRawIterator<Accessor> () {}
182 
183 
184 template <typename Accessor>
185 inline
187  :
188  TriaRawIterator<Accessor> (i.accessor) {}
189 
190 
191 template <typename Accessor>
192 inline
194  :
195  TriaRawIterator<Accessor> (i.accessor)
196 {
197 #ifdef DEBUG
198  // do this like this, because:
199  // if we write
200  // "Assert (IteratorState::past_the_end || used)"
201  // used() is called anyway, even if
202  // state==IteratorState::past_the_end, and will then
203  // throw the exception!
204  if (this->state() != IteratorState::past_the_end)
205  Assert (this->accessor.used(),
206  ExcAssignmentOfUnusedObject());
207 #endif
208 }
209 
210 
211 template <typename Accessor>
212 inline
214  const int level,
215  const int index,
216  const typename Accessor::AccessorData *local_data) :
217  TriaRawIterator<Accessor> (parent, level, index, local_data)
218 {
219 #ifdef DEBUG
220  // do this like this, because:
221  // if we write
222  // "Assert (IteratorState::past_the_end || used)"
223  // used() is called anyway, even if
224  // state==IteratorState::past_the_end, and will then
225  // throw the exception!
226  if (this->state() != IteratorState::past_the_end)
227  Assert (this->accessor.used(),
228  ExcAssignmentOfUnusedObject());
229 #endif
230 }
231 
232 
233 template <typename Accessor>
234 inline
237  const typename Accessor::AccessorData *local_data)
238  : TriaRawIterator<Accessor> (tria_accessor, local_data)
239 {
240 #ifdef DEBUG
241  // do this like this, because:
242  // if we write
243  // "Assert (IteratorState::past_the_end || used)"
244  // used() is called anyway, even if
245  // state==IteratorState::past_the_end, and will then
246  // throw the exception!
247  if (this->state() != IteratorState::past_the_end)
248  Assert (this->accessor.used(),
249  ExcAssignmentOfUnusedObject());
250 #endif
251 }
252 
253 
254 template <typename Accessor>
255 inline
258 {
259  this->accessor.copy_from (i.accessor);
260  return *this;
261 }
262 
263 
264 template <typename Accessor>
265 template <typename OtherAccessor>
266 inline
269 {
270  this->accessor.copy_from (i.accessor);
271  return *this;
272 }
273 
274 
275 template <typename Accessor>
276 inline
279 {
280  this->accessor.copy_from (i.accessor);
281 #ifdef DEBUG
282  // do this like this, because:
283  // if we write
284  // "Assert (IteratorState::past_the_end || used)"
285  // used() is called anyway, even if
286  // state==IteratorState::past_the_end, and will then
287  // throw the exception!
288  if (this->state() != IteratorState::past_the_end)
289  Assert (this->accessor.used(),
290  ExcAssignmentOfUnusedObject());
291 #endif
292  return *this;
293 }
294 
295 
296 template <typename Accessor>
297 template <typename OtherAccessor>
298 inline
301 {
302  this->accessor.copy_from (i.accessor);
303 #ifdef DEBUG
304  // do this like this, because:
305  // if we write
306  // "Assert (IteratorState::past_the_end || used)"
307  // used() is called anyway, even if
308  // state==IteratorState::past_the_end, and will then
309  // throw the exception!
310  if (this->state() != IteratorState::past_the_end)
311  Assert (this->accessor.used(),
312  ExcAssignmentOfUnusedObject());
313 #endif
314  return *this;
315 }
316 
317 
318 template <typename Accessor>
319 inline
321 {
323  (this->state() == IteratorState::valid))
324  if (this->accessor.used() == true)
325  return *this;
326  return *this;
327 }
328 
329 
330 template <typename Accessor>
331 inline
333 {
334  TriaIterator<Accessor> tmp(*this);
335  operator++ ();
336 
337  return tmp;
338 }
339 
340 
341 template <typename Accessor>
342 inline
345 {
347  (this->state() == IteratorState::valid))
348  if (this->accessor.used() == true)
349  return *this;
350  return *this;
351 }
352 
353 
354 template <typename Accessor>
355 inline
358 {
359  TriaIterator<Accessor> tmp(*this);
360  operator-- ();
361 
362  return tmp;
363 }
364 
365 
366 /*----------------------- functions: TriaActiveIterator ---------------*/
367 
368 
369 template <typename Accessor>
370 inline
372  TriaIterator<Accessor> () {}
373 
374 
375 template <typename Accessor>
376 inline
378  TriaIterator<Accessor> (static_cast<TriaIterator<Accessor> >(i)) {}
379 
380 
381 template <typename Accessor>
382 inline
384  TriaIterator<Accessor> (i)
385 {
386 #ifdef DEBUG
387  // do this like this, because:
388  // if we write
389  // "Assert (IteratorState::past_the_end || !has_children())"
390  // has_children() is called anyway, even if
391  // state==IteratorState::past_the_end, and will then
392  // throw the exception!
393  if (this->state() != IteratorState::past_the_end)
394  Assert (this->accessor.has_children()==false,
395  ExcAssignmentOfInactiveObject());
396 #endif
397 }
398 
399 
400 template <typename Accessor>
401 inline
403  TriaIterator<Accessor> (i)
404 {
405 #ifdef DEBUG
406  // do this like this, because:
407  // if we write
408  // "Assert (IteratorState::past_the_end || !has_children())"
409  // has_children() is called anyway, even if
410  // state==IteratorState::past_the_end, and will then
411  // throw the exception!
412  if (this->state() != IteratorState::past_the_end)
413  Assert (this->accessor.has_children()==false,
414  ExcAssignmentOfInactiveObject());
415 #endif
416 }
417 
418 
419 template <typename Accessor>
420 inline
422  const int level,
423  const int index,
424  const typename Accessor::AccessorData *local_data) :
425  TriaIterator<Accessor> (parent, level, index, local_data)
426 {
427 #ifdef DEBUG
428  // do this like this, because:
429  // if we write
430  // "Assert (IteratorState::past_the_end || !has_children())"
431  // has_children() is called anyway, even if
432  // state==IteratorState::past_the_end, and will then
433  // throw the exception!
434  if (this->state() != IteratorState::past_the_end)
435  Assert (this->accessor.has_children()==false,
436  ExcAssignmentOfInactiveObject());
437 #endif
438 }
439 
440 
441 template <typename Accessor>
442 inline
445  const typename Accessor::AccessorData *local_data)
446  : TriaIterator<Accessor> (tria_accessor, local_data)
447 {
448 #ifdef DEBUG
449  // do this like this, because:
450  // if we write
451  // "Assert (IteratorState::past_the_end || !has_children())"
452  // has_children() is called anyway, even if
453  // state==IteratorState::past_the_end, and will then
454  // throw the exception!
455  if (this->state() != IteratorState::past_the_end)
456  Assert (this->accessor.has_children()==false,
457  ExcAssignmentOfInactiveObject());
458 #endif
459 }
460 
461 
462 template <typename Accessor>
463 inline
466 {
467  this->accessor.copy_from (i.accessor);
468  return *this;
469 }
470 
471 
472 template <typename Accessor>
473 template <class OtherAccessor>
474 inline
477 {
478  this->accessor.copy_from (i.accessor);
479  return *this;
480 }
481 
482 
483 template <typename Accessor>
484 inline
487 {
488  this->accessor.copy_from (i.accessor);
489 #ifdef DEBUG
490  // do this like this, because:
491  // if we write
492  // "Assert (IteratorState::past_the_end || !has_children())"
493  // has_chidlren() is called anyway, even if
494  // state==IteratorState::past_the_end, and will then
495  // throw the exception!
496  if (this->state() != IteratorState::past_the_end)
497  Assert (this->accessor.used() && this->accessor.has_children()==false,
498  ExcAssignmentOfInactiveObject());
499 #endif
500  return *this;
501 }
502 
503 
504 template <typename Accessor>
505 template <class OtherAccessor>
506 inline
509 {
510  this->accessor.copy_from (i.accessor);
511 #ifdef DEBUG
512  // do this like this, because:
513  // if we write
514  // "Assert (IteratorState::past_the_end || !has_children())"
515  // has_chidlren() is called anyway, even if
516  // state==IteratorState::past_the_end, and will then
517  // throw the exception!
518  if (this->state() != IteratorState::past_the_end)
519  Assert (this->accessor.used() && this->accessor.has_children()==false,
520  ExcAssignmentOfInactiveObject());
521 #endif
522  return *this;
523 }
524 
525 
526 template <typename Accessor>
527 template <class OtherAccessor>
528 inline
531 {
532  this->accessor.copy_from (i.accessor);
533 #ifdef DEBUG
534  // do this like this, because:
535  // if we write
536  // "Assert (IteratorState::past_the_end || !has_children())"
537  // has_children() is called anyway, even if
538  // state==IteratorState::past_the_end, and will then
539  // throw the exception!
540  if (this->state() != IteratorState::past_the_end)
541  Assert (this->accessor.has_children()==false,
542  ExcAssignmentOfInactiveObject());
543 #endif
544  return *this;
545 }
546 
547 
548 template <typename Accessor>
549 inline
552 {
553  this->accessor.copy_from (i.accessor);
554 #ifdef DEBUG
555  // do this like this, because:
556  // if we write
557  // "Assert (IteratorState::past_the_end || !has_children())"
558  // has_children() is called anyway, even if
559  // state==IteratorState::past_the_end, and will then
560  // throw the exception!
561  if (this->state() != IteratorState::past_the_end)
562  Assert (this->accessor.has_children()==false,
563  ExcAssignmentOfInactiveObject());
564 #endif
565  return *this;
566 }
567 
568 
569 template <typename Accessor>
570 inline
573 {
575  (this->state() == IteratorState::valid))
576  if (this->accessor.has_children() == false)
577  return *this;
578  return *this;
579 }
580 
581 
582 template <typename Accessor>
583 inline
586 {
587  TriaActiveIterator<Accessor> tmp(*this);
588  operator++ ();
589 
590  return tmp;
591 }
592 
593 
594 template <typename Accessor>
595 inline
598 {
600  (this->state() == IteratorState::valid))
601  if (this->accessor.has_children() == false)
602  return *this;
603  return *this;
604 }
605 
606 
607 template <typename Accessor>
608 inline
610 {
611  TriaActiveIterator<Accessor> tmp(*this);
612  operator-- ();
613 
614  return tmp;
615 }
616 
617 DEAL_II_NAMESPACE_CLOSE
618 
619 #endif
TriaIterator< Accessor > & operator++()
TriaActiveIterator< Accessor > & operator++()
TriaActiveIterator< Accessor > & operator--()
#define Assert(cond, exc)
Definition: exceptions.h:299
TriaRawIterator & operator++()
TriaActiveIterator< Accessor > & operator=(const TriaActiveIterator< Accessor > &)
IteratorState::IteratorStates state() const
TriaRawIterator & operator--()
TriaIterator< Accessor > & operator=(const TriaIterator< Accessor > &)
TriaIterator< Accessor > & operator--()
TriaRawIterator & operator=(const TriaRawIterator &)
bool operator!=(const TriaRawIterator &) const
Iterator reached end of container.
Iterator points to a valid object.
bool operator==(const TriaRawIterator &) const