*/
const Triangulation<dim> *tria;
+ private:
+
+ /**
+ * Dimension of the TriaObject
+ * this accessor gives access to.
+ */
+ static const unsigned int objectdim = dim;
+
template <int anydim, typename Accessor> friend class TriaRawIterator;
template <int anydim, typename Accessor> friend class TriaIterator;
template <int anydim, typename Accessor> friend class TriaActiveIterator;
* <tt>celldim==3</tt>.
*/
void set (const internal::Triangulation::Hexahedron&) const;
+
+ /**
+ * Return the level the element
+ * pointed to belongs to.
+ * This is only valid for cells.
+ */
+ int level () const;
/**
* Index of vertex. The
* previous level is accessed.
*/
void operator -- ();
+
+ private:
+
+ /**
+ * Dimension of the TriaObject
+ * this accessor gives access to.
+ */
+ static const unsigned int objectdim = celldim;
/*@}*/
/**
*/
void set (const internal::Triangulation::Line &l) const;
+ /**
+ * Return the level the element
+ * pointed to belongs to.
+ * This is only valid for cells.
+ */
+ int level () const;
+
/**
* Return the index of vertex
* <tt>i=0,1</tt> of a line.
*/
internal::Triangulation::TriaObjects<internal::Triangulation::Line> & lines() const;
+ private:
+
+ /**
+ * Dimension of the TriaObject
+ * this accessor gives access to.
+ */
+ static const unsigned int objectdim = 1;
+
/*@}*/
/**
* Copy the data of the given quad.
*/
void set (const internal::Triangulation::Quad &q) const;
+
+ /**
+ * Return the level the element
+ * pointed to belongs to.
+ * This is only valid for cells.
+ */
+ int level () const;
/**
* Return index of a vertex of a
* without specialization.
*/
internal::Triangulation::TriaObjects<internal::Triangulation::Quad> & quads() const;
+
+ private:
+
+ /**
+ * Dimension of the TriaObject
+ * this accessor gives access to.
+ */
+ static const unsigned int objectdim = 2;
/*@}*/
/**
* previous level is accessed.
*/
void operator -- ();
+
+ private:
+
+ /**
+ * Dimension of the TriaObject
+ * this accessor gives access to.
+ */
+ static const unsigned int objectdim = 3;
/*@}*/
/**
DeclException0 (ExcCellFlaggedForCoarsening);
private:
+
/**
* Copy operator. This is
* normally used in a context
// $Id$
// Version: $Name$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 by the deal.II authors
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors
//
// This file is subject to QPL and may not be distributed
// without copyright and license information. Please refer
/**@name Exceptions*/
/*@{*/
/**
- * Exception
+ * Exception for TriaObjects with
+ * level, i.e. cells.
*/
- DeclException1 (ExcDereferenceInvalidObject,
+ DeclException1 (ExcDereferenceInvalidCell,
Accessor,
- << "You tried to dereference an iterator for which this "
+ << "You tried to dereference a cell iterator for which this "
<< "is not possible. More information on this iterator: "
<< "level=" << arg1.level()
<< ", index=" << arg1.index()
(arg1.state() == IteratorState::past_the_end ?
"past_the_end" : "invalid")));
+ /**
+ * Exception for
+ * lower-dimensional TriaObjects
+ * without level, i.e. objects
+ * faces are constructed with.
+ */
+ DeclException1 (ExcDereferenceInvalidObject,
+ Accessor,
+ << "You tried to dereference an iterator for which this "
+ << "is not possible. More information on this iterator: "
+ << "index=" << arg1.index()
+ << ", state="
+ << (arg1.state() == IteratorState::valid ? "valid" :
+ (arg1.state() == IteratorState::past_the_end ?
+ "past_the_end" : "invalid")));
+
#ifdef DEAL_II_NESTED_CLASS_FRIEND_BUG
// the above exception class is
// supposed to report information
const Accessor &
TriaRawIterator<dim,Accessor>::operator * () const
{
- Assert (state() == IteratorState::valid,
+ Assert (Accessor::objectdim!=dim ||
+ state() == IteratorState::valid,
+ ExcDereferenceInvalidCell(accessor));
+ Assert (Accessor::objectdim==dim ||
+ state() == IteratorState::valid,
ExcDereferenceInvalidObject(accessor));
+
return accessor;
}
Accessor &
TriaRawIterator<dim,Accessor>::operator * ()
{
- Assert (state() == IteratorState::valid,
+ Assert (Accessor::objectdim!=dim ||
+ state() == IteratorState::valid,
+ ExcDereferenceInvalidCell(accessor));
+ Assert (Accessor::objectdim==dim ||
+ state() == IteratorState::valid,
ExcDereferenceInvalidObject(accessor));
+
return accessor;
}
bool
TriaRawIterator<dim,Accessor>::operator < (const TriaRawIterator &i) const
{
- Assert (state() != IteratorState::invalid,
+ Assert (Accessor::objectdim!=dim ||
+ state() != IteratorState::invalid,
+ ExcDereferenceInvalidCell(accessor));
+ Assert (Accessor::objectdim==dim ||
+ state() != IteratorState::invalid,
ExcDereferenceInvalidObject(accessor));
- Assert (i.state() != IteratorState::invalid,
+
+ Assert (Accessor::objectdim!=dim ||
+ i.state() != IteratorState::invalid,
+ ExcDereferenceInvalidCell(i.accessor));
+ Assert (Accessor::objectdim==dim ||
+ i.state() != IteratorState::invalid,
ExcDereferenceInvalidObject(i.accessor));
+
Assert (&accessor.get_triangulation() == &i.accessor.get_triangulation(),
ExcInvalidComparison());
-
- return ((((accessor.level() < i.accessor.level()) ||
- ((accessor.level() == i.accessor.level()) &&
- (accessor.index() < i.accessor.index())) ) &&
- (state()==IteratorState::valid) &&
- (i.state()==IteratorState::valid) ) ||
- ((state()==IteratorState::valid) &&
- (i.state()==IteratorState::past_the_end)));
+
+ if (Accessor::objectdim==dim)
+ return ((((accessor.level() < i.accessor.level()) ||
+ ((accessor.level() == i.accessor.level()) &&
+ (accessor.index() < i.accessor.index())) ) &&
+ (state()==IteratorState::valid) &&
+ (i.state()==IteratorState::valid) ) ||
+ ((state()==IteratorState::valid) &&
+ (i.state()==IteratorState::past_the_end)));
+ else
+ return ((((accessor.index() < i.accessor.index()) ) &&
+ (state()==IteratorState::valid) &&
+ (i.state()==IteratorState::valid) ) ||
+ ((state()==IteratorState::valid) &&
+ (i.state()==IteratorState::past_the_end)));
}
void
TriaRawIterator<dim,Accessor>::print (std::ostream &out) const
{
- out << accessor.level() << "." << accessor.index();
+ if (Accessor::objectdim==dim)
+ out << accessor.level() << "." << accessor.index();
+ else
+ out << accessor.index();
}