refs #1382
- Fixed the problem that the end iterator could become valid again if it was incremented. - Decrementing the start iterator will return an invalid iterator now (Maybe we can implement reverse iterators) - Removed one check from the iteration, which should result in faster execution of is_valid(). git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@1225 fdac6126-5c0c-442c-9429-916003d36597
This commit is contained in:
@@ -64,19 +64,19 @@ namespace Iterators {
|
||||
template<class Mesh, class CenterEntityHandle>
|
||||
class GenericCirculator_CenterEntityFnsT {
|
||||
public:
|
||||
static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter);
|
||||
static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter);
|
||||
static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, bool &lap_counter);
|
||||
static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, bool &lap_counter);
|
||||
};
|
||||
|
||||
template<class Mesh>
|
||||
class GenericCirculator_CenterEntityFnsT<Mesh, typename Mesh::VertexHandle> {
|
||||
public:
|
||||
inline static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) {
|
||||
inline static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, bool &lap_counter) {
|
||||
heh = mesh->cw_rotated_halfedge_handle(heh);
|
||||
if (heh == start) ++lap_counter;
|
||||
if (heh == start) lap_counter = false;
|
||||
}
|
||||
inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) {
|
||||
if (heh == start) --lap_counter;
|
||||
inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, bool &lap_counter) {
|
||||
if (heh == start) lap_counter = false;
|
||||
heh = mesh->ccw_rotated_halfedge_handle(heh);
|
||||
}
|
||||
};
|
||||
@@ -84,12 +84,12 @@ class GenericCirculator_CenterEntityFnsT<Mesh, typename Mesh::VertexHandle> {
|
||||
template<class Mesh>
|
||||
class GenericCirculator_CenterEntityFnsT<Mesh, typename Mesh::FaceHandle> {
|
||||
public:
|
||||
inline static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) {
|
||||
inline static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, bool &lap_counter) {
|
||||
heh = mesh->next_halfedge_handle(heh);
|
||||
if (heh == start) ++lap_counter;
|
||||
if (heh == start) lap_counter = false;
|
||||
}
|
||||
inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) {
|
||||
if (heh == start) --lap_counter;
|
||||
inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, bool &lap_counter) {
|
||||
if (heh == start) lap_counter = false;
|
||||
heh = mesh->prev_halfedge_handle(heh);
|
||||
}
|
||||
};
|
||||
@@ -119,14 +119,14 @@ class GenericCirculator_DereferenciabilityCheckT<Mesh, typename Mesh::VertexHand
|
||||
template<class Mesh, class CenterEntityHandle, class ValueHandle>
|
||||
class GenericCirculator_ValueHandleFnsT {
|
||||
public:
|
||||
inline static bool is_valid(const typename Mesh::HalfedgeHandle &heh, const typename Mesh::HalfedgeHandle &start, const int &lap_counter) {
|
||||
return heh.is_valid() && ((start != heh) || (lap_counter == 0));
|
||||
inline static bool is_valid(const typename Mesh::HalfedgeHandle &heh, const bool &lap_counter) {
|
||||
return ( heh.is_valid() && lap_counter );
|
||||
}
|
||||
inline static void init(const Mesh*, typename Mesh::HalfedgeHandle&, typename Mesh::HalfedgeHandle&, int&) {};
|
||||
inline static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) {
|
||||
inline static void init(const Mesh*, typename Mesh::HalfedgeHandle&, typename Mesh::HalfedgeHandle&, bool&) {};
|
||||
inline static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, bool &lap_counter) {
|
||||
GenericCirculator_CenterEntityFnsT<Mesh, CenterEntityHandle>::increment(mesh, heh, start, lap_counter);
|
||||
}
|
||||
inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) {
|
||||
inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, bool &lap_counter) {
|
||||
GenericCirculator_CenterEntityFnsT<Mesh, CenterEntityHandle>::decrement(mesh, heh, start, lap_counter);
|
||||
}
|
||||
};
|
||||
@@ -136,22 +136,22 @@ class GenericCirculator_ValueHandleFnsT<Mesh, CenterEntityHandle, typename Mesh:
|
||||
public:
|
||||
typedef GenericCirculator_DereferenciabilityCheckT<Mesh, CenterEntityHandle, typename Mesh::FaceHandle> GenericCirculator_DereferenciabilityCheck;
|
||||
|
||||
inline static bool is_valid(const typename Mesh::HalfedgeHandle &heh, const typename Mesh::HalfedgeHandle &start, const int &lap_counter) {
|
||||
return heh.is_valid() && ((start != heh) || (lap_counter == 0));
|
||||
inline static bool is_valid(const typename Mesh::HalfedgeHandle &heh, const bool &lap_counter) {
|
||||
return ( heh.is_valid() && lap_counter );
|
||||
}
|
||||
inline static void init(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) {
|
||||
if (heh.is_valid() && !GenericCirculator_DereferenciabilityCheck::isDereferenciable(mesh, heh) && lap_counter == 0)
|
||||
inline static void init(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, bool &lap_counter) {
|
||||
if (heh.is_valid() && !GenericCirculator_DereferenciabilityCheck::isDereferenciable(mesh, heh) && lap_counter )
|
||||
increment(mesh, heh, start, lap_counter);
|
||||
};
|
||||
inline static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) {
|
||||
inline static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, bool &lap_counter) {
|
||||
do {
|
||||
GenericCirculator_CenterEntityFnsT<Mesh, CenterEntityHandle>::increment(mesh, heh, start, lap_counter);
|
||||
} while (is_valid(heh, start, lap_counter) && !GenericCirculator_DereferenciabilityCheck::isDereferenciable(mesh, heh));
|
||||
} while (is_valid(heh, lap_counter) && !GenericCirculator_DereferenciabilityCheck::isDereferenciable(mesh, heh));
|
||||
}
|
||||
inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) {
|
||||
inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, bool &lap_counter) {
|
||||
do {
|
||||
GenericCirculator_CenterEntityFnsT<Mesh, CenterEntityHandle>::decrement(mesh, heh, start, lap_counter);
|
||||
} while (is_valid(heh, start, lap_counter) && !GenericCirculator_DereferenciabilityCheck::isDereferenciable(mesh, heh));
|
||||
} while (is_valid(heh, lap_counter) && !GenericCirculator_DereferenciabilityCheck::isDereferenciable(mesh, heh));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -162,10 +162,10 @@ class GenericCirculatorBaseT {
|
||||
typedef const Mesh& mesh_ref;
|
||||
|
||||
public:
|
||||
GenericCirculatorBaseT() : mesh_(0), lap_counter_(0) {}
|
||||
GenericCirculatorBaseT() : mesh_(0), lap_counter_(true) {}
|
||||
|
||||
GenericCirculatorBaseT(mesh_ref mesh, HalfedgeHandle heh, bool end = false) :
|
||||
mesh_(&mesh), start_(heh), heh_(heh), lap_counter_(static_cast<int>(end)) {}
|
||||
mesh_(&mesh), start_(heh), heh_(heh), lap_counter_(!end) {}
|
||||
|
||||
GenericCirculatorBaseT(const GenericCirculatorBaseT &rhs) :
|
||||
mesh_(rhs.mesh_), start_(rhs.start_), heh_(rhs.heh_), lap_counter_(rhs.lap_counter_) {}
|
||||
@@ -213,7 +213,7 @@ class GenericCirculatorBaseT {
|
||||
protected:
|
||||
mesh_ptr mesh_;
|
||||
typename Mesh::HalfedgeHandle start_, heh_;
|
||||
int lap_counter_;
|
||||
bool lap_counter_;
|
||||
};
|
||||
|
||||
template<class Mesh, class CenterEntityHandle, class ValueHandle,
|
||||
@@ -310,7 +310,7 @@ class GenericCirculatorT : protected GenericCirculatorBaseT<Mesh> {
|
||||
}
|
||||
|
||||
bool is_valid() const {
|
||||
return GenericCirculator_ValueHandleFns::is_valid(this->heh_, this->start_, this->lap_counter_);
|
||||
return GenericCirculator_ValueHandleFns::is_valid(this->heh_, this->lap_counter_);
|
||||
}
|
||||
|
||||
DEPRECATED("current_halfedge_handle() is an implementation detail and should not be accessed from outside the iterator class.")
|
||||
|
||||
Reference in New Issue
Block a user