]> https://gitweb.dealii.org/ - dealii.git/commitdiff
add copy and access functions
authorGuido Kanschat <dr.guido.kanschat@gmail.com>
Wed, 26 Sep 2012 16:29:09 +0000 (16:29 +0000)
committerGuido Kanschat <dr.guido.kanschat@gmail.com>
Wed, 26 Sep 2012 16:29:09 +0000 (16:29 +0000)
git-svn-id: https://svn.dealii.org/trunk@26755 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/grid/tria_iterator.h
deal.II/include/deal.II/grid/tria_iterator.templates.h

index 0c32918742a7d34f14f2707cfe23b044013ddfec..81144b118540eae981d42ce564effe3ba368adad 100644 (file)
@@ -35,6 +35,7 @@
 DEAL_II_NAMESPACE_OPEN
 
 template <int dim, int spacedim> class Triangulation;
+template <int, int, int> class TriaAccessorBase;
 
 template <typename> class TriaRawIterator;
 template <typename> class TriaIterator;
@@ -42,7 +43,6 @@ template <typename> 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<std::bidirectional_iterator_tag,Acc
     template <typename OtherAccessor>
     TriaRawIterator (const TriaRawIterator<OtherAccessor> &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<Accessor::structure_dimension,Accessor::dimension,Accessor::space_dimension>& 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<std::bidirectional_iterator_tag,Acc
                                       *  version.
                                       */
     Accessor & operator * ();
-
+    
                                      /**
                                       *  Dereferencing operator, returns a
                                       *  reference of the cell pointed to.
@@ -375,6 +387,25 @@ class TriaRawIterator : public std::iterator<std::bidirectional_iterator_tag,Acc
                                       *  version.
                                       */
     Accessor * operator -> ();
+
+        
+                                    /**
+                                     * 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<Accessor>
     template <typename OtherAccessor>
     TriaIterator (const TriaIterator<OtherAccessor> &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<Accessor::structure_dimension,Accessor::dimension,Accessor::space_dimension>& 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<Accessor>
     template <typename OtherAccessor>
     TriaActiveIterator (const TriaActiveIterator<OtherAccessor> &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<Accessor::structure_dimension,Accessor::dimension,Accessor::space_dimension>& 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<Accessor>::operator * ()
 
 
 
+template <typename Accessor>
+inline
+const Accessor &
+TriaRawIterator<Accessor>::access_any () const
+{
+  return accessor;
+}
+
+
+
 template <typename Accessor>
 inline
 const Accessor *
index dfa1b5aaad5f29281c41892a1aac11696032dc59..64211d1ba811f89aa716804d5831235597b943b2 100644 (file)
@@ -58,6 +58,18 @@ TriaRawIterator (const Triangulation<Accessor::dimension,Accessor::space_dimensi
 {}
 
 
+template <typename Accessor>
+inline
+TriaRawIterator<Accessor>::TriaRawIterator (
+  const TriaAccessorBase<Accessor::structure_dimension,Accessor::dimension,Accessor::space_dimension>& tria_accessor,
+  const typename Accessor::AccessorData *local_data)
+               :
+               accessor(0, -2, -2, local_data)
+{
+  accessor.copy_from(tria_accessor);
+}
+
+
 template <typename Accessor>
 inline
 TriaRawIterator<Accessor> &
@@ -209,6 +221,27 @@ TriaIterator<Accessor>::TriaIterator (const Triangulation<Accessor::dimension,Ac
 }
 
 
+template <typename Accessor>
+inline
+TriaIterator<Accessor>::TriaIterator (
+  const TriaAccessorBase<Accessor::structure_dimension,Accessor::dimension,Accessor::space_dimension>& tria_accessor,
+  const typename Accessor::AccessorData *local_data)
+               : TriaRawIterator<Accessor> (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 <typename Accessor>
 inline
 TriaIterator<Accessor> &
@@ -396,6 +429,27 @@ TriaActiveIterator<Accessor>::TriaActiveIterator (const Triangulation<Accessor::
 }
 
 
+template <typename Accessor>
+inline
+TriaActiveIterator<Accessor>::TriaActiveIterator (
+  const TriaAccessorBase<Accessor::structure_dimension,Accessor::dimension,Accessor::space_dimension>& tria_accessor,
+  const typename Accessor::AccessorData *local_data)
+               : TriaIterator<Accessor> (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 <typename Accessor>
 inline
 TriaActiveIterator<Accessor> &

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.