Commit 0f9b4c23 authored by Matthias Möller's avatar Matthias Möller

- changed lap_counter to int type

- extent circulator unittests for endings testing now the cases: (--endIter).is_valid and (++(--startIter)).is_valid

git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@1226 fdac6126-5c0c-442c-9429-916003d36597
parent 1af153e5
......@@ -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, bool &lap_counter);
static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, bool &lap_counter);
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);
};
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, bool &lap_counter) {
inline static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) {
heh = mesh->cw_rotated_halfedge_handle(heh);
if (heh == start) lap_counter = false;
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;
inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) {
if (heh == start) lap_counter--;
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, bool &lap_counter) {
inline static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) {
heh = mesh->next_halfedge_handle(heh);
if (heh == start) lap_counter = false;
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;
inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) {
if (heh == start) lap_counter--;
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 bool &lap_counter) {
return ( heh.is_valid() && lap_counter );
inline static bool is_valid(const typename Mesh::HalfedgeHandle &heh, const int lap_counter) {
return ( heh.is_valid() && (lap_counter == 0 ) );
}
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) {
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) {
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, bool &lap_counter) {
inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) {
GenericCirculator_CenterEntityFnsT<Mesh, CenterEntityHandle>::decrement(mesh, heh, start, lap_counter);
}
};
......@@ -136,19 +136,19 @@ 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 bool &lap_counter) {
return ( heh.is_valid() && lap_counter );
inline static bool is_valid(const typename Mesh::HalfedgeHandle &heh, const int lap_counter) {
return ( heh.is_valid() && (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 )
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 )
increment(mesh, heh, start, lap_counter);
};
inline static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, bool &lap_counter) {
inline static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) {
do {
GenericCirculator_CenterEntityFnsT<Mesh, CenterEntityHandle>::increment(mesh, heh, start, lap_counter);
} 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, bool &lap_counter) {
inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) {
do {
GenericCirculator_CenterEntityFnsT<Mesh, CenterEntityHandle>::decrement(mesh, heh, start, lap_counter);
} 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_(true) {}
GenericCirculatorBaseT() : mesh_(0), lap_counter_(0) {}
GenericCirculatorBaseT(mesh_ref mesh, HalfedgeHandle heh, bool end = false) :
mesh_(&mesh), start_(heh), heh_(heh), lap_counter_(!end) {}
mesh_(&mesh), start_(heh), heh_(heh), lap_counter_(static_cast<int>(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_;
bool lap_counter_;
int lap_counter_;
};
template<class Mesh, class CenterEntityHandle, class ValueHandle,
......
......@@ -191,6 +191,13 @@ TEST_F(OpenMeshTrimeshCirculatorFaceEdge, FaceEdgeIterCheckInvalidationAtEnds) {
++endIter ;
EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid after increment";
// Check if the end iterators becomes valid after decrement
endIter = mesh_.fe_end(fh0);
EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid";
--endIter;
EXPECT_TRUE(endIter.is_valid()) << "EndIter is invalid after decrement";
EXPECT_EQ(1,endIter->idx()) << "EndIter points on the wrong element";
// Check if the start iterator decrement is invalid
Mesh::FaceEdgeIter startIter = mesh_.fe_begin(fh0);
......@@ -198,9 +205,12 @@ TEST_F(OpenMeshTrimeshCirculatorFaceEdge, FaceEdgeIterCheckInvalidationAtEnds) {
--startIter;
EXPECT_FALSE(startIter.is_valid()) << "StartIter decrement is not invalid";
}
// Check if the start iterator becomes valid
++startIter;
EXPECT_TRUE(startIter.is_valid()) << "StartIter is invalid after re-incrementing";
EXPECT_EQ(startIter->idx(), mesh_.fe_begin(fh0)->idx()) << "StartIter points on the wrong element";
}
/*
......
......@@ -323,6 +323,13 @@ TEST_F(OpenMeshTrimeshCirculatorFaceFace, FaceFaceIterCheckInvalidationAtEnds) {
++endIter ;
EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid after increment";
// Check if the end iterators becomes valid after decrement
endIter = mesh_.ff_end(fh0);
EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid";
--endIter;
EXPECT_TRUE(endIter.is_valid()) << "EndIter is invalid after decrement";
EXPECT_EQ(3,endIter->idx()) << "EndIter points on the wrong element";
// Check if the start iterator decrement is invalid
Mesh::FaceFaceIter startIter = mesh_.ff_begin(fh0);
......@@ -330,6 +337,11 @@ TEST_F(OpenMeshTrimeshCirculatorFaceFace, FaceFaceIterCheckInvalidationAtEnds) {
--startIter;
EXPECT_FALSE(startIter.is_valid()) << "StartIter decrement is not invalid";
// Check if the start iterator becomes valid
++startIter;
EXPECT_TRUE(startIter.is_valid()) << "StartIter is invalid after re-incrementing";
EXPECT_EQ(startIter->idx(), mesh_.ff_begin(fh0)->idx()) << "StartIter points on the wrong element";
}
......
......@@ -189,6 +189,13 @@ TEST_F(OpenMeshTrimeshCirculatorFaceHalfEdge, FaceHalfedgeIterCheckInvalidationA
++endIter ;
EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid after increment";
// Check if the end iterators becomes valid after decrement
endIter = mesh_.fh_end(fh0);
EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid";
--endIter;
EXPECT_TRUE(endIter.is_valid()) << "EndIter is invalid after decrement";
EXPECT_EQ(2,endIter->idx()) << "EndIter points on the wrong element";
// Check if the start iterator decrement is invalid
Mesh::FaceHalfedgeIter startIter = mesh_.fh_begin(fh0);
......@@ -196,6 +203,11 @@ TEST_F(OpenMeshTrimeshCirculatorFaceHalfEdge, FaceHalfedgeIterCheckInvalidationA
--startIter;
EXPECT_FALSE(startIter.is_valid()) << "StartIter decrement is not invalid";
// Check if the start iterator becomes valid
++startIter;
EXPECT_TRUE(startIter.is_valid()) << "StartIter is invalid after re-incrementing";
EXPECT_EQ(startIter->idx(), mesh_.fh_begin(fh0)->idx()) << "StartIter points on the wrong element";
}
}
......@@ -185,6 +185,13 @@ TEST_F(OpenMeshTrimeshCirculatorFaceVertex, FaceVertexIterCheckInvalidationAtEnd
++endIter ;
EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid after increment";
// Check if the end iterators becomes valid after decrement
endIter = mesh_.fv_end(fh0);
EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid";
--endIter;
EXPECT_TRUE(endIter.is_valid()) << "EndIter is invalid after decrement";
EXPECT_EQ(2,endIter->idx()) << "EndIter points on the wrong element";
// Check if the start iterator decrement is invalid
Mesh::FaceVertexIter startIter = mesh_.fv_begin(fh0);
......@@ -192,8 +199,12 @@ TEST_F(OpenMeshTrimeshCirculatorFaceVertex, FaceVertexIterCheckInvalidationAtEnd
--startIter;
EXPECT_FALSE(startIter.is_valid()) << "StartIter decrement is not invalid";
}
// Check if the start iterator becomes valid
++startIter;
EXPECT_TRUE(startIter.is_valid()) << "StartIter is invalid after re-incrementing";
EXPECT_EQ(startIter->idx(), mesh_.fv_begin(fh0)->idx()) << "StartIter points on the wrong element";
}
}
......@@ -259,6 +259,13 @@ TEST_F(OpenMeshTrimeshCirculatorVertexEdge, VertexEdgeIterCheckInvalidationAtEnd
++endIter ;
EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid after increment";
// Check if the end iterators becomes valid after decrement
endIter = mesh_.ve_end(vhandle[1]);
EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid";
--endIter;
EXPECT_TRUE(endIter.is_valid()) << "EndIter is invalid after decrement";
EXPECT_EQ(1,endIter->idx()) << "EndIter points on the wrong element";
// Check if the start iterator decrement is invalid
Mesh::VertexEdgeIter startIter = mesh_.ve_begin(vhandle[1]);
......@@ -266,6 +273,11 @@ TEST_F(OpenMeshTrimeshCirculatorVertexEdge, VertexEdgeIterCheckInvalidationAtEnd
--startIter;
EXPECT_FALSE(startIter.is_valid()) << "StartIter decrement is not invalid";
// Check if the start iterator becomes valid
++startIter;
EXPECT_TRUE(startIter.is_valid()) << "StarIter is invalid after re-incrementing";
EXPECT_EQ(startIter->idx(), mesh_.ve_begin(vhandle[1])->idx()) << "StartIter points on the wrong element";
}
}
......@@ -328,6 +328,13 @@ TEST_F(OpenMeshTrimeshCirculatorVertexFace, VertexFaceIterCheckInvalidationAtEnd
++endIter ;
EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid after increment";
// Check if the end iterators becomes valid after decrement
endIter = mesh_.vf_end(vhandle[1]);
EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid";
--endIter;
EXPECT_TRUE(endIter.is_valid()) << "EndIter is invalid after decrement";
EXPECT_EQ(0,endIter->idx()) << "EndIter points on the wrong element";
// Check if the start iterator decrement is invalid
Mesh::VertexFaceIter startIter = mesh_.vf_begin(vhandle[1]);
......@@ -335,6 +342,11 @@ TEST_F(OpenMeshTrimeshCirculatorVertexFace, VertexFaceIterCheckInvalidationAtEnd
--startIter;
EXPECT_FALSE(startIter.is_valid()) << "StartIter decrement is not invalid";
// Check if the start iterator becomes valid
++startIter;
EXPECT_TRUE(startIter.is_valid()) << "StarIter is invalid after re-incrementing";
EXPECT_EQ(startIter->idx(), mesh_.vf_begin(vhandle[1])->idx()) << "StartIter points on the wrong element";
}
/*
......@@ -439,6 +451,4 @@ TEST_F(OpenMeshTrimeshCirculatorVertexFace, VertexFaceIterWithoutHolesDecrement)
}
}
......@@ -373,6 +373,13 @@ TEST_F(OpenMeshTrimeshCirculatorVertexIHalfEdge, VertexIHalfEdgeIterCheckInvalid
++endIter ;
EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid after increment";
// Check if the end iterators becomes valid after decrement
endIter = mesh_.vih_end(vhandle[1]);
EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid";
--endIter;
EXPECT_TRUE(endIter.is_valid()) << "EndIter is invalid after decrement";
EXPECT_EQ(3,endIter->idx()) << "EndIter points on the wrong element";
// Check if the start iterator decrement is invalid
Mesh::VertexIHalfedgeIter startIter = mesh_.vih_begin(vhandle[1]);
......@@ -380,6 +387,11 @@ TEST_F(OpenMeshTrimeshCirculatorVertexIHalfEdge, VertexIHalfEdgeIterCheckInvalid
--startIter;
EXPECT_FALSE(startIter.is_valid()) << "StartIter decrement is not invalid";
// Check if the start iterator becomes valid
++startIter;
EXPECT_TRUE(startIter.is_valid()) << "StarIter is invalid after re-incrementing";
EXPECT_EQ(startIter->idx(), mesh_.vih_begin(vhandle[1])->idx()) << "StartIter points on the wrong element";
}
......
......@@ -374,6 +374,12 @@ TEST_F(OpenMeshTrimeshCirculatorVertexOHalfEdge, VertexOHalfEdgeIterCheckInvalid
++endIter ;
EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid after increment";
endIter = mesh_.voh_end(vhandle[1]);
EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid";
--endIter;
EXPECT_TRUE(endIter.is_valid()) << "EndIter is invalid after decrement";
EXPECT_EQ(2,endIter->idx()) << "EndIter points on the wrong element";
// Check if the start iterator decrement is invalid
Mesh::VertexOHalfedgeIter startIter = mesh_.voh_begin(vhandle[1]);
......@@ -381,6 +387,11 @@ TEST_F(OpenMeshTrimeshCirculatorVertexOHalfEdge, VertexOHalfEdgeIterCheckInvalid
--startIter;
EXPECT_FALSE(startIter.is_valid()) << "StartIter decrement is not invalid";
// Check if the start iterator becomes valid
++startIter;
EXPECT_TRUE(startIter.is_valid()) << "StartIter is invalid after re-incrementing";
EXPECT_EQ(startIter->idx(), mesh_.voh_begin(vhandle[1])->idx()) << "StartIter points on the wrong element";
}
......
......@@ -262,6 +262,13 @@ TEST_F(OpenMeshTrimeshCirculatorVertexVertex, VertexVertexIterCheckInvalidationA
++endIter ;
EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid after increment";
// Check if the end iterators becomes valid after decrement
endIter = mesh_.vv_end(vhandle[1]);
EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid";
--endIter;
EXPECT_TRUE(endIter.is_valid()) << "EndIter is invalid after decrement";
EXPECT_EQ(2,endIter->idx()) << "EndIter points on the wrong element";
// Check if the start iterator decrement is invalid
Mesh::VertexVertexIter startIter = mesh_.vv_begin(vhandle[1]);
......@@ -269,6 +276,11 @@ TEST_F(OpenMeshTrimeshCirculatorVertexVertex, VertexVertexIterCheckInvalidationA
--startIter;
EXPECT_FALSE(startIter.is_valid()) << "StartIter decrement is not invalid";
// Check if the start iterator becomes valid
++startIter;
EXPECT_TRUE(startIter.is_valid()) << "StartIter is invalid after re-incrementing";
EXPECT_EQ(startIter->idx(), mesh_.vv_begin(vhandle[1])->idx()) << "StartIter points on the wrong element";
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment