00001 #ifndef SplitData_HEADER 00002 #define SplitData_HEADER 00003 00004 #include <list> 00005 #include "RefineVertex.h" 00006 #include <refine-common/RefineConstants.h> 00007 00008 /* Forward-declaration: ProtectedBall needs to know about SplitData, and 00009 * SplitData needs to know about ProtectedBall. Luckily, both sides need only 00010 * know each others' names. I arbitrarily chose SplitData to be the one that 00011 * forward-declares its partner. */ 00012 template <size_t ambient> class ProtectedBall; 00013 00014 /*************************************************************************** 00015 * This is data that emerges from an insertion: the vertex inserted and the set 00016 * of simplices added and removed; or, if insertion yielded, the set of 00017 * lower-dimensional balls yielded to. 00018 ***************************************************************************/ 00019 template <size_t ambient> 00020 class SplitData : public RefineConstants { 00021 typedef ProtectedBall<ambient> Ball; 00022 typedef RefineVertex<ambient> Vertex; 00023 00024 Vertex *v_; 00025 std::list<Ball*> killed_; 00026 std::list<Ball*> born_; 00027 std::list<Ball*> encroached_; 00028 00029 public: 00030 typedef typename std::list<Ball*>::const_iterator iterator; 00031 00032 SplitData(const RefineConstants& rc): RefineConstants(rc) { } 00033 00034 bool didSplit() { return v_ != 0; } 00035 00036 Vertex *getVertex() const { return v_; } 00037 00040 iterator begin_killed() const { return killed_.begin(); } 00041 iterator end_killed() const { return killed_.end(); } 00042 size_t nkilled() const { return killed_.size(); } 00043 00047 iterator begin_born() const { return born_.begin(); } 00048 iterator end_born() const { return born_.end(); } 00049 size_t nborn() const { return born_.size(); } 00050 00052 iterator begin_encroached() const { return encroached_.begin(); } 00053 iterator end_encroached() const { return encroached_.end(); } 00054 bool encroached() const { return !encroached_.empty(); } 00055 00059 void setVertex(Vertex *v) { v_ = v; } 00060 void insertBorn(Ball *b) { born_.push_front(b); } 00061 void insertKill(Ball *b) { killed_.push_front(b); } 00062 void insertEncroached(Ball *b) { encroached_.push_front(b); } 00063 00065 template <class Mesh, class simplex_iterator> void insertBorn(Mesh *mesh, 00066 simplex_iterator begin, const simplex_iterator& end) { 00067 while (begin != end) { 00068 Ball *b = mesh->toBall(*begin); 00069 insertBorn(b); 00070 ++begin; 00071 } 00072 } 00073 00075 template <class Mesh, class simplex_iterator> void insertKill(Mesh *mesh, 00076 simplex_iterator begin, const simplex_iterator& end) { 00077 while (begin != end) { 00078 Ball *b = mesh->toBall(*begin); 00079 insertKill(b); 00080 ++begin; 00081 } 00082 } 00083 00084 /* No equivalent insertEncroached since those are already balls. */ 00085 }; 00086 00087 #endif
1.4.6