#include <base/config.h>
#include <base/point.h>
#include <base/subscriptor.h>
+#include <base/smartpointer.h>
#include <grid/geometry_info.h>
#include <grid/tria_iterator_selector.h>
unsigned int memory_consumption () const;
};
+//TODO: Replace boundary[255] by a std::vector so we can use constructor of SmartPointer
/**
* Cache class used to store the number of used and active elements
* and can thus never be
* associated with a boundary.
*/
- const Boundary<dim>* boundary[255];
+ SmartPointer<const Boundary<dim> > boundary[255];
/**
* Do some smoothing in the process
// set default boundary for all
// possible components
for (unsigned int i=0;i<255;++i)
- {
- boundary[i] = straight_boundary;
- boundary[i]->subscribe(typeid(*this).name());
- }
+ boundary[i] = straight_boundary;
}
for (unsigned int i=0; i<levels.size(); ++i)
delete levels[i];
levels.clear ();
-
- for (unsigned int i=0;i<255;++i)
- boundary[i]->unsubscribe(typeid(*this).name());
}
// more
Assert (n_subscriptions() == 0, ExcInternalError());
- for (unsigned int i=0; i<levels.size(); ++i)
- delete levels[i];
- levels.clear ();
-
- vertices.clear ();
- vertices_used.clear ();
-
- for (unsigned int i=0; i<255; ++i)
- {
- boundary[i]->unsubscribe(typeid(*this).name());
- boundary[i] = straight_boundary;
- boundary[i]->subscribe(typeid(*this).name());
- };
-
- number_cache = TriaNumberCache<dim>();
+ clear_despite_subscriptions();
}
{
Assert(number<255, ExcIndexRange(number,0,255));
- boundary[number]->unsubscribe(typeid(*this).name());
boundary[number] = &boundary_object;
- boundary_object.subscribe(typeid(*this).name());
}
smooth_grid = old_tria.smooth_grid;
for (unsigned i=0;i<255;++i)
- {
- boundary[i]->unsubscribe(typeid(*this).name());
- boundary[i] = old_tria.boundary[i];
- boundary[i]->subscribe(typeid(*this).name());
- }
+ boundary[i] = old_tria.boundary[i];
levels.reserve (old_tria.levels.size());
for (unsigned int level=0; level<old_tria.levels.size(); ++level)
template<int dim>
void
Triangulation<dim>::clear_despite_subscriptions()
-{
- // disable subscriptions, clear,
- // and then set them again
- const unsigned int n=n_subscriptions();
- for (unsigned int i=0; i<n; ++i)
- unsubscribe(typeid(*this).name());
- clear ();
- for (unsigned int i=0; i<n; ++i)
- subscribe(typeid(*this).name());
+{
+ // This is the former function
+ // clear without the assertion in
+ // the beginning.
+ for (unsigned int i=0; i<levels.size(); ++i)
+ delete levels[i];
+ levels.clear ();
+
+ vertices.clear ();
+ vertices_used.clear ();
+
+ for (unsigned int i=0; i<255; ++i)
+ boundary[i] = straight_boundary;
+
+ number_cache = TriaNumberCache<dim>();
}