typedef TriaIterator <TriaAccessor<dim-1, dim, spacedim> > face_iterator;
typedef TriaActiveIterator<TriaAccessor<dim-1, dim, spacedim> > active_face_iterator;
+ typedef typename IteratorSelector::vertex_iterator vertex_iterator;
+ typedef typename IteratorSelector::active_vertex_iterator active_vertex_iterator;
+
typedef typename IteratorSelector::line_iterator line_iterator;
typedef typename IteratorSelector::active_line_iterator active_line_iterator;
*/
face_iterator end_face () const;
+ /*
+ * @}
+ */
+
+ /*---------------------------------------*/
+ /*---------------------------------------*/
+
+ /**
+ * @name Vertex iterator functions
+ * @{
+ */
+
+ /**
+ * Iterator to the first used vertex.
+ */
+ vertex_iterator begin_vertex() const;
+
+ /**
+ * Iterator to the first active vertex. Because all vertices are active,
+ * begin_vertex() and begin_active_vertex() return the same vertex.
+ */
+ active_vertex_iterator begin_active_vertex() const;
+
+ /**
+ * Iterator past the end; this iterator serves for comparisons of iterators
+ * with past-the-end or before-the-beginning states.
+ */
+ vertex_iterator end_vertex() const;
+
/*
* @}
*/
*/
typedef TriaRawIterator <CellAccessor<dim,spacedim> > raw_cell_iterator;
typedef TriaRawIterator <TriaAccessor<dim-1, dim, spacedim> > raw_face_iterator;
+ typedef typename IteratorSelector::raw_vertex_iterator raw_vertex_iterator;
typedef typename IteratorSelector::raw_line_iterator raw_line_iterator;
typedef typename IteratorSelector::raw_quad_iterator raw_quad_iterator;
typedef typename IteratorSelector::raw_hex_iterator raw_hex_iterator;
TriaAccessor (const InvalidAccessor<structdim2,dim2,spacedim2> &);
/**
- * Return the state of the iterator. Since an iterator to points can not be
- * incremented or decremented, its state remains constant, and in particular
- * equal to IteratorState::valid.
+ * Return the state of the iterator.
*/
- static IteratorState::IteratorStates state ();
+ IteratorState::IteratorStates state () const;
/**
* Level of this object. Vertices have no level, so this function always
* @{
*/
/**
- * This operator advances the iterator to the next element. For points, this
- * operation is not defined, so you can't iterate over point iterators.
+ * This operator advances the iterator to the next element.
*/
- void operator ++ () const;
+ void operator ++ ();
/**
- * This operator moves the iterator to the previous element. For points,
- * this operation is not defined, so you can't iterate over point iterators.
+ * This operator moves the iterator to the previous element.
*/
- void operator -- () const;
+ void operator -- ();
/**
* Compare for equality.
*/
template <int dim, int spacedim>
inline
IteratorState::IteratorStates
-TriaAccessor<0, dim, spacedim>::state ()
+TriaAccessor<0, dim, spacedim>::state () const
{
- return IteratorState::valid;
+ if (global_vertex_index != numbers::invalid_unsigned_int)
+ return IteratorState::valid;
+ else
+ return IteratorState::past_the_end;
}
template <int dim, int spacedim>
inline
void
-TriaAccessor<0, dim, spacedim>::operator ++ () const
+TriaAccessor<0, dim, spacedim>::operator ++ ()
{
- Assert (false, ExcNotImplemented());
+ ++global_vertex_index;
+ if (global_vertex_index >= tria->n_vertices())
+ global_vertex_index = numbers::invalid_unsigned_int;
}
template <int dim, int spacedim>
inline
void
-TriaAccessor<0, dim, spacedim>::operator -- () const
+TriaAccessor<0, dim, spacedim>::operator -- ()
{
- Assert (false, ExcNotImplemented());
+ if (global_vertex_index!=numbers::invalid_unsigned_int)
+ --global_vertex_index;
}
template <int spacedim>
struct Iterators<1,spacedim>
{
+ typedef TriaRawIterator <dealii::TriaAccessor<0, 1, spacedim> > raw_vertex_iterator;
typedef TriaIterator <dealii::TriaAccessor<0, 1, spacedim> > vertex_iterator;
+ typedef TriaActiveIterator<dealii::TriaAccessor<0, 1, spacedim> > active_vertex_iterator;
typedef TriaRawIterator <dealii::CellAccessor<1,spacedim> > raw_line_iterator;
typedef TriaIterator <dealii::CellAccessor<1,spacedim> > line_iterator;
template <int spacedim>
struct Iterators<2,spacedim>
{
+ typedef TriaRawIterator <dealii::TriaAccessor<0, 2, spacedim> > raw_vertex_iterator;
typedef TriaIterator <dealii::TriaAccessor<0, 2, spacedim> > vertex_iterator;
+ typedef TriaActiveIterator<dealii::TriaAccessor<0, 2, spacedim> > active_vertex_iterator;
typedef TriaRawIterator <dealii::TriaAccessor<1, 2, spacedim> > raw_line_iterator;
typedef TriaIterator <dealii::TriaAccessor<1, 2, spacedim> > line_iterator;
template <int spacedim>
struct Iterators<3,spacedim>
{
+ typedef TriaRawIterator <dealii::TriaAccessor<0, 3, spacedim> > raw_vertex_iterator;
typedef TriaIterator <dealii::TriaAccessor<0, 3, spacedim> > vertex_iterator;
+ typedef TriaActiveIterator<dealii::TriaAccessor<0, 3, spacedim> > active_vertex_iterator;
typedef TriaRawIterator <dealii::TriaAccessor<1, 3, spacedim> > raw_line_iterator;
typedef TriaIterator <dealii::TriaAccessor<1, 3, spacedim> > line_iterator;
}
+/*------------------------ Vertex iterator functions ------------------------*/
+
+
+template <int dim, int spacedim>
+typename Triangulation<dim,spacedim>::vertex_iterator
+Triangulation<dim,spacedim>::begin_vertex() const
+{
+ if (dim==1)
+ {
+ Assert(false, ExcNotImplemented());
+ return raw_vertex_iterator();
+ }
+ else
+ {
+ vertex_iterator i = raw_vertex_iterator(const_cast<Triangulation<dim, spacedim>*>(this),
+ 0,
+ 0);
+ if (i.state() != IteratorState::valid)
+ return i;
+ while (i->used() == false)
+ if ((++i).state() != IteratorState::valid)
+ return i;
+ return i;
+ }
+}
+
+
+
+template <int dim, int spacedim>
+typename Triangulation<dim,spacedim>::active_vertex_iterator
+Triangulation<dim,spacedim>::begin_active_vertex() const
+{
+ return begin_vertex();
+}
+
+
+
+template <int dim, int spacedim>
+typename Triangulation<dim,spacedim>::vertex_iterator
+Triangulation<dim,spacedim>::end_vertex() const
+{
+ if (dim==1)
+ {
+ Assert(false, ExcNotImplemented());
+ return raw_vertex_iterator();
+ }
+ else
+ return raw_vertex_iterator(const_cast<Triangulation<dim, spacedim>*>(this),
+ -1,
+ numbers::invalid_unsigned_int);
+}
+
+
/*------------------------ Line iterator functions ------------------------*/
GridGenerator::hyper_cube (tria);
tria.refine_global (2);
+ for (typename Triangulation<2>::vertex_iterator
+ vertex_it = tria.begin_vertex(); vertex_it != tria.end_vertex();
+ ++vertex_it)
+ deallog << vertex_it->center() <<std::endl;
+ deallog << std::endl;
+
for (typename Triangulation<2>::active_cell_iterator
cell = tria.begin_active(); cell != tria.end(); ++cell)
{
+DEAL::0.00000 0.00000
+DEAL::1.00000 0.00000
+DEAL::0.00000 1.00000
+DEAL::1.00000 1.00000
+DEAL::0.500000 0.00000
+DEAL::0.00000 0.500000
+DEAL::1.00000 0.500000
+DEAL::0.500000 1.00000
+DEAL::0.500000 0.500000
+DEAL::0.250000 0.00000
+DEAL::0.750000 0.00000
+DEAL::0.00000 0.250000
+DEAL::0.00000 0.750000
+DEAL::1.00000 0.250000
+DEAL::1.00000 0.750000
+DEAL::0.250000 1.00000
+DEAL::0.750000 1.00000
+DEAL::0.500000 0.250000
+DEAL::0.500000 0.750000
+DEAL::0.250000 0.500000
+DEAL::0.750000 0.500000
+DEAL::0.250000 0.250000
+DEAL::0.750000 0.250000
+DEAL::0.250000 0.750000
+DEAL::0.750000 0.750000
+DEAL::
DEAL::0.00000 0.00000
DEAL::0.250000 0.00000
DEAL::0.00000 0.250000