]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Add three conversion operators for iterators of different type. For example, it is...
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Sat, 20 Feb 1999 13:40:10 +0000 (13:40 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Sat, 20 Feb 1999 13:40:10 +0000 (13:40 +0000)
  Triangulation<dim>::cell_iterator cell = dof_handler.begin();
Previously, this was not possible, since the DoFHandler returned an object of type
  TriaIterator<dim,DoFCellAccessor>
while the left hand side required a
  TriaIterator<dim,TriaCellAccessor>
Since the first accessor is convertible into the second, it is now
possible to convert the first data type into the second.

git-svn-id: https://svn.dealii.org/trunk@856 0785d39b-7218-0410-832d-ea1e28bc413d

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

index 0dc0afe7ae459ae48ecec5ccadd912ff051bfc80..ad5295d026166e161db392f321038c88101ffdee 100644 (file)
@@ -251,6 +251,30 @@ class TriaRawIterator : public bidirectional_iterator<Accessor,int> {
                     const int           index,
                     const typename Accessor::AccessorData *local_data = 0);
 
+                                    /**
+                                     * This is a conversion operator
+                                     * (constructor) which takes another
+                                     * iterator type and copies the data;
+                                     * this conversion works, if there is
+                                     * a conversion path from the
+                                     * #OtherAccessor# class to the #Accessor#
+                                     * class of this object. One such path
+                                     * would be derived class to base class,
+                                     * which for example may be used to get
+                                     * a #Triangulation::raw_cell_iterator# from
+                                     * a #DoFHandler::raw_cell_iterator#, since
+                                     * the #DoFAccessor# class is derived from
+                                     * the #TriaAccessor# class.
+                                     *
+                                     * Since #TriaIterator# and
+                                     * #TriaActiveIterator# are derived classes
+                                     * of this class, this constructor also
+                                     * serves to convert these iterators with
+                                     * other accessor classes.
+                                     */
+    template <typename OtherAccessor>
+    TriaRawIterator (const TriaRawIterator<dim,OtherAccessor> &i);
+    
                                     /**
                                      *  @name Dereferencing
                                      */
@@ -481,6 +505,29 @@ class TriaIterator : public TriaRawIterator<dim,Accessor> {
                  const int           index,
                  const typename Accessor::AccessorData *local_data = 0);
     
+                                    /**
+                                     * This is a conversion operator
+                                     * (constructor) which takes another
+                                     * iterator type and copies the data;
+                                     * this conversion works, if there is
+                                     * a conversion path from the
+                                     * #OtherAccessor# class to the #Accessor#
+                                     * class of this object. One such path
+                                     * would be derived class to base class,
+                                     * which for example may be used to get
+                                     * a #Triangulation::cell_iterator# from
+                                     * a #DoFHandler::cell_iterator#, since
+                                     * the #DoFAccessor# class is derived from
+                                     * the #TriaAccessor# class.
+                                     *
+                                     * Since #TriaActiveIterator# is a derived
+                                     * class of this class, this constructor
+                                     * also serves to convert these iterators 
+                                     * with other accessor classes.
+                                     */
+    template <typename OtherAccessor>
+    TriaIterator (const TriaIterator<dim,OtherAccessor> &i);
+
                                     /**
                                      *  Assignment operator.
                                      */
@@ -612,6 +659,24 @@ class TriaActiveIterator : public TriaIterator<dim,Accessor> {
                        const int           index,
                        const typename Accessor::AccessorData *local_data = 0);
 
+                                    /**
+                                     * This is a conversion operator
+                                     * (constructor) which takes another
+                                     * iterator type and copies the data;
+                                     * this conversion works, if there is
+                                     * a conversion path from the
+                                     * #OtherAccessor# class to the #Accessor#
+                                     * class of this object. One such path
+                                     * would be derived class to base class,
+                                     * which for example may be used to get
+                                     * a #Triangulation::active_cell_iterator# from
+                                     * a #DoFHandler::active_cell_iterator#, since
+                                     * the #DoFAccessor# class is derived from
+                                     * the #TriaAccessor# class.
+                                     */
+    template <typename OtherAccessor>
+    TriaActiveIterator (const TriaActiveIterator<dim,OtherAccessor> &i);
+
                                     /**
                                      *  Assignment operator.
                                      */
@@ -694,6 +759,15 @@ class TriaActiveIterator : public TriaIterator<dim,Accessor> {
 
 
 
+template <int dim, typename Accessor>
+template <typename OtherAccessor>
+inline
+TriaRawIterator<dim,Accessor>::TriaRawIterator (const TriaRawIterator<dim,OtherAccessor> &i)
+               : accessor (i.accessor)
+{};
+
+
+
 template <int dim, typename Accessor>
 inline
 const Accessor &
@@ -790,6 +864,26 @@ void TriaRawIterator<dim,Accessor>::print (ostream &out) const {
 
 
 
+template <int dim, typename Accessor>
+template <typename OtherAccessor>
+inline
+TriaIterator<dim,Accessor>::TriaIterator (const TriaIterator<dim,OtherAccessor> &i)
+               : TriaRawIterator<dim,Accessor> (static_cast<TriaIterator<dim,OtherAccessor> >(i))
+{};
+
+
+
+template <int dim, typename Accessor>
+template <typename OtherAccessor>
+inline
+TriaActiveIterator<dim,Accessor>::TriaActiveIterator (const TriaActiveIterator<dim,OtherAccessor> &i)
+               : TriaIterator<dim,Accessor> (static_cast<TriaIterator<dim,OtherAccessor> >(i))
+{};
+
+
+
+
+
 template <int dim, typename Accessor>
 inline
 ostream & operator << (ostream &out, const TriaRawIterator<dim,Accessor> &i) {

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.