From b4cf25a94e0626c7821d7b0d74b4600ed0818701 Mon Sep 17 00:00:00 2001 From: Timo Heister Date: Wed, 17 Jul 2013 20:58:49 +0000 Subject: [PATCH] make the conversion from from Accessor to TriaIterators explicit git-svn-id: https://svn.dealii.org/trunk@30027 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/include/deal.II/grid/tria_iterator.h | 30 ++++++++++-- deal.II/source/dofs/dof_renumbering.cc | 48 +++++++++++++------- 2 files changed, 59 insertions(+), 19 deletions(-) diff --git a/deal.II/include/deal.II/grid/tria_iterator.h b/deal.II/include/deal.II/grid/tria_iterator.h index eb97f7f5ee..05cf132def 100644 --- a/deal.II/include/deal.II/grid/tria_iterator.h +++ b/deal.II/include/deal.II/grid/tria_iterator.h @@ -264,7 +264,7 @@ public: * = accessor; * @endcode */ - TriaRawIterator (const Accessor &a); + explicit TriaRawIterator (const Accessor &a); /** * Constructor. Assumes that the @@ -273,7 +273,7 @@ public: * one. */ template - TriaRawIterator (const OtherAccessor &a); + explicit TriaRawIterator (const OtherAccessor &a); /** * Proper constructor, initialized @@ -685,6 +685,13 @@ public: const int index, const typename Accessor::AccessorData *local_data = 0); + /** + * Construct from an accessor of type OtherAccessor that is convertible + * to the type Accessor. + */ + template + explicit TriaIterator (const OtherAccessor &a); + /** * This is a conversion operator * (constructor) which takes another @@ -1278,7 +1285,24 @@ TriaIterator::TriaIterator (const TriaRawIterator &i) #endif } - +template +template +TriaIterator::TriaIterator (const OtherAccessor &a) +: +TriaRawIterator (a) +{ +#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 template diff --git a/deal.II/source/dofs/dof_renumbering.cc b/deal.II/source/dofs/dof_renumbering.cc index 9b89bd4466..755104f0aa 100644 --- a/deal.II/source/dofs/dof_renumbering.cc +++ b/deal.II/source/dofs/dof_renumbering.cc @@ -1552,14 +1552,18 @@ namespace DoFRenumbering { if (dof_wise_renumbering == false) { - std::vector - ordered_cells(dof.get_tria().n_active_cells()); + std::vector ordered_cells; + ordered_cells.reserve(dof.get_tria().n_active_cells()); const CompareDownstream comparator(direction); - typename DH::active_cell_iterator begin = dof.begin_active(); + typename DH::active_cell_iterator p = dof.begin_active(); typename DH::active_cell_iterator end = dof.end(); - std::copy (begin, end, ordered_cells.begin()); + while (p!=end) + { + ordered_cells.push_back(p); + ++p; + } std::sort (ordered_cells.begin(), ordered_cells.end(), comparator); compute_cell_wise(new_indices, reverse, dof, ordered_cells); @@ -1655,14 +1659,18 @@ namespace DoFRenumbering { if (dof_wise_renumbering == false) { - std::vector - ordered_cells(dof.get_tria().n_cells(level)); + std::vector ordered_cells; + ordered_cells.reserve (dof.get_tria().n_cells(level)); const CompareDownstream comparator(direction); - typename DH::level_cell_iterator begin = dof.begin(level); + typename DH::level_cell_iterator p = dof.begin(level); typename DH::level_cell_iterator end = dof.end(level); - std::copy (begin, end, ordered_cells.begin()); + while (p!=end) + { + ordered_cells.push_back(p); + ++p; + } std::sort (ordered_cells.begin(), ordered_cells.end(), comparator); compute_cell_wise(new_indices, reverse, dof, level, ordered_cells); @@ -1808,14 +1816,18 @@ namespace DoFRenumbering const Point ¢er, const bool counter) { - std::vector - ordered_cells(dof.get_tria().n_active_cells()); + std::vector ordered_cells; + ordered_cells.reserve (dof.get_tria().n_active_cells()); internal::ClockCells comparator(center, counter); - typename DH::active_cell_iterator begin = dof.begin_active(); + typename DH::active_cell_iterator p = dof.begin_active(); typename DH::active_cell_iterator end = dof.end(); - std::copy (begin, end, ordered_cells.begin()); + while (p!=end) + { + ordered_cells.push_back(p); + ++p; + } std::sort (ordered_cells.begin(), ordered_cells.end(), comparator); std::vector reverse(new_indices.size()); @@ -1830,14 +1842,18 @@ namespace DoFRenumbering const Point ¢er, const bool counter) { - std::vector - ordered_cells(dof.get_tria().n_cells(level)); + std::vector ordered_cells; + ordered_cells.reserve(dof.get_tria().n_active_cells()); internal::ClockCells comparator(center, counter); - typename DH::level_cell_iterator begin = dof.begin(level); + typename DH::level_cell_iterator p = dof.begin(level); typename DH::level_cell_iterator end = dof.end(level); - std::copy (begin, end, ordered_cells.begin()); + while (p!=end) + { + ordered_cells.push_back(p); + ++p; + } std::sort (ordered_cells.begin(), ordered_cells.end(), comparator); cell_wise(dof, level, ordered_cells); -- 2.39.5