From: Guido Kanschat Date: Wed, 26 Sep 2012 16:29:09 +0000 (+0000) Subject: add copy and access functions X-Git-Tag: v8.0.0~2038 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6f289da1e7c401d1aa889b0af25b2286b8bc8be5;p=dealii.git add copy and access functions git-svn-id: https://svn.dealii.org/trunk@26755 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/include/deal.II/grid/tria_iterator.h b/deal.II/include/deal.II/grid/tria_iterator.h index 0c32918742..81144b1185 100644 --- a/deal.II/include/deal.II/grid/tria_iterator.h +++ b/deal.II/include/deal.II/grid/tria_iterator.h @@ -35,6 +35,7 @@ DEAL_II_NAMESPACE_OPEN template class Triangulation; +template class TriaAccessorBase; template class TriaRawIterator; template class TriaIterator; @@ -42,7 +43,6 @@ template class TriaActiveIterator; - // note: in non-debug mode, i.e. with optimizations, the file // tria_iterator.templates.h is included at the end of this file. // this includes a lot of templates and thus makes compilation @@ -312,6 +312,18 @@ class TriaRawIterator : public std::iterator TriaRawIterator (const TriaRawIterator &i); + /** + * Another conversion operator, + * where we use the pointers to + * the Triangulation from a + * TriaAccessorBase object, while + * the additional data is used + * according to the actual type + * of Accessor. + */ + TriaRawIterator (const TriaAccessorBase& tria_accessor, + const typename Accessor::AccessorData *local_data); + /** * Conversion constructor. Same * as above with the difference @@ -359,7 +371,7 @@ class TriaRawIterator : public std::iterator (); + + + /** + * In order be able to assign + * end-iterators for different + * accessors to each other, we + * need an access function which + * returns the accessor + * regardless of its state. + * + * @warning This function should + * not be used in application + * programs. It is only intended + * for limited purposes inside + * the library and it makes + * debugging much harder. + */ + const Accessor& access_any () const; + /*@}*/ /** @@ -661,6 +692,18 @@ class TriaIterator : public TriaRawIterator template TriaIterator (const TriaIterator &i); + /** + * Another conversion operator, + * where we use the pointers to + * the Triangulation from a + * TriaAccessorBase object, while + * the additional data is used + * according to the actual type + * of Accessor. + */ + TriaIterator (const TriaAccessorBase& tria_accessor, + const typename Accessor::AccessorData *local_data); + /** * Similar conversion operator to the above * one, but does a check whether the @@ -850,6 +893,18 @@ class TriaActiveIterator : public TriaIterator template TriaActiveIterator (const TriaActiveIterator &i); + /** + * Another conversion operator, + * where we use the pointers to + * the Triangulation from a + * TriaAccessorBase object, while + * the additional data is used + * according to the actual type + * of Accessor. + */ + TriaActiveIterator (const TriaAccessorBase& tria_accessor, + const typename Accessor::AccessorData *local_data); + /** * Similar conversion operator to the above * one, but does a check whether the @@ -1061,6 +1116,16 @@ TriaRawIterator::operator * () +template +inline +const Accessor & +TriaRawIterator::access_any () const +{ + return accessor; +} + + + template inline const Accessor * diff --git a/deal.II/include/deal.II/grid/tria_iterator.templates.h b/deal.II/include/deal.II/grid/tria_iterator.templates.h index dfa1b5aaad..64211d1ba8 100644 --- a/deal.II/include/deal.II/grid/tria_iterator.templates.h +++ b/deal.II/include/deal.II/grid/tria_iterator.templates.h @@ -58,6 +58,18 @@ TriaRawIterator (const Triangulation +inline +TriaRawIterator::TriaRawIterator ( + const TriaAccessorBase& tria_accessor, + const typename Accessor::AccessorData *local_data) + : + accessor(0, -2, -2, local_data) +{ + accessor.copy_from(tria_accessor); +} + + template inline TriaRawIterator & @@ -209,6 +221,27 @@ TriaIterator::TriaIterator (const Triangulation +inline +TriaIterator::TriaIterator ( + const TriaAccessorBase& tria_accessor, + const typename Accessor::AccessorData *local_data) + : TriaRawIterator (tria_accessor, local_data) +{ +#ifdef DEBUG + // do this like this, because: + // if we write + // "Assert (IteratorState::past_the_end || used)" + // used() is called anyway, even if + // state==IteratorState::past_the_end, and will then + // throw the exception! + if (this->state() != IteratorState::past_the_end) + Assert (this->accessor.used(), + ExcAssignmentOfUnusedObject()); +#endif +} + + template inline TriaIterator & @@ -396,6 +429,27 @@ TriaActiveIterator::TriaActiveIterator (const Triangulation +inline +TriaActiveIterator::TriaActiveIterator ( + const TriaAccessorBase& tria_accessor, + const typename Accessor::AccessorData *local_data) + : TriaIterator (tria_accessor, local_data) +{ +#ifdef DEBUG + // do this like this, because: + // if we write + // "Assert (IteratorState::past_the_end || !has_children())" + // has_children() is called anyway, even if + // state==IteratorState::past_the_end, and will then + // throw the exception! + if (this->state() != IteratorState::past_the_end) + Assert (this->accessor.has_children()==false, + ExcAssignmentOfInactiveObject()); +#endif +} + + template inline TriaActiveIterator &