bringing back the old circulators. marked decrement operator as deprecated. Please use CW/CCW iterators

git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@1230 fdac6126-5c0c-442c-9429-916003d36597
This commit is contained in:
Matthias Möller
2015-03-04 12:59:54 +00:00
parent c7a41edafd
commit 53b9020496
7 changed files with 715 additions and 499 deletions

View File

@@ -397,6 +397,210 @@ class GenericCirculatorT : protected GenericCirculatorBaseT<Mesh> {
mutable value_type pointer_deref_value; mutable value_type pointer_deref_value;
}; };
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////// OLD ///////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// OLD CIRCULATORS
// deprecated circulators, will be removed soon
// if you remove these circulators and go to the old ones, PLEASE ENABLE FOLLOWING UNITTESTS:
//
// OpenMeshTrimeshCirculatorVertexIHalfEdge.VertexIHalfEdgeIterCheckInvalidationAtEnds
// OpenMeshTrimeshCirculatorVertexEdge.VertexEdgeIterCheckInvalidationAtEnds
// OpenMeshTrimeshCirculatorVertexVertex.VertexVertexIterCheckInvalidationAtEnds
// OpenMeshTrimeshCirculatorVertexOHalfEdge.VertexOHalfEdgeIterCheckInvalidationAtEnds
// OpenMeshTrimeshCirculatorVertexFace.VertexFaceIterCheckInvalidationAtEnds
// OpenMeshTrimeshCirculatorVertexFace.VertexFaceIterWithoutHolesDecrement
//
template<class Mesh, class CenterEntityHandle, class ValueHandle>
class GenericCirculator_ValueHandleFnsT_DEPRECATED {
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 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, true>::increment(mesh, heh, start, lap_counter);
}
inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) {
GenericCirculator_CenterEntityFnsT<Mesh, CenterEntityHandle, true>::decrement(mesh, heh, start, lap_counter);
}
};
template<class Mesh, class CenterEntityHandle>
class GenericCirculator_ValueHandleFnsT_DEPRECATED<Mesh, CenterEntityHandle, typename Mesh::FaceHandle> {
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 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, int &lap_counter) {
do {
GenericCirculator_CenterEntityFnsT<Mesh, CenterEntityHandle, true>::increment(mesh, heh, start, lap_counter);
} while (is_valid(heh, start, 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) {
do {
GenericCirculator_CenterEntityFnsT<Mesh, CenterEntityHandle, true>::decrement(mesh, heh, start, lap_counter);
} while (is_valid(heh, start, lap_counter) && !GenericCirculator_DereferenciabilityCheck::isDereferenciable(mesh, heh));
}
};
template<class Mesh, class CenterEntityHandle, class ValueHandle,
ValueHandle (GenericCirculatorBaseT<Mesh>::*Handle2Value)() const>
class GenericCirculatorT_DEPRECATED : protected GenericCirculatorBaseT<Mesh> {
public:
typedef std::ptrdiff_t difference_type;
typedef ValueHandle value_type;
typedef const value_type& reference;
typedef const value_type* pointer;
typedef std::bidirectional_iterator_tag iterator_category;
typedef typename GenericCirculatorBaseT<Mesh>::mesh_ptr mesh_ptr;
typedef typename GenericCirculatorBaseT<Mesh>::mesh_ref mesh_ref;
typedef GenericCirculator_ValueHandleFnsT_DEPRECATED<Mesh, CenterEntityHandle, ValueHandle> GenericCirculator_ValueHandleFns;
public:
GenericCirculatorT_DEPRECATED() {}
GenericCirculatorT_DEPRECATED(mesh_ref mesh, CenterEntityHandle start, bool end = false) :
GenericCirculatorBaseT<Mesh>(mesh, mesh.halfedge_handle(start), end) {
GenericCirculator_ValueHandleFns::init(this->mesh_, this->heh_, this->start_, this->lap_counter_);
}
GenericCirculatorT_DEPRECATED(mesh_ref mesh, HalfedgeHandle heh, bool end = false) :
GenericCirculatorBaseT<Mesh>(mesh, heh, end) {
GenericCirculator_ValueHandleFns::init(this->mesh_, this->heh_, this->start_, this->lap_counter_);
}
GenericCirculatorT_DEPRECATED(const GenericCirculatorT_DEPRECATED &rhs) : GenericCirculatorBaseT<Mesh>(rhs) {}
GenericCirculatorT_DEPRECATED& operator++() {
assert(this->mesh_);
GenericCirculator_ValueHandleFns::increment(this->mesh_, this->heh_, this->start_, this->lap_counter_);
return *this;
}
DEPRECATED("current decrement operator is deprecated. Please use CCW/CW iterators.")
GenericCirculatorT_DEPRECATED& operator--() {
assert(this->mesh_);
GenericCirculator_ValueHandleFns::decrement(this->mesh_, this->heh_, this->start_, this->lap_counter_);
return *this;
}
/// Post-increment
GenericCirculatorT_DEPRECATED operator++(int) {
assert(this->mesh_);
GenericCirculatorT_DEPRECATED cpy(*this);
++(*this);
return cpy;
}
/// Post-decrement
DEPRECATED("current decrement operator is deprecated. Please use CCW/CW iterators.")
GenericCirculatorT_DEPRECATED operator--(int) {
assert(this->mesh_);
GenericCirculatorT_DEPRECATED cpy(*this);
--(*this);
return cpy;
}
/// Standard dereferencing operator.
value_type operator*() const {
#ifndef NDEBUG
assert(this->heh_.is_valid());
value_type res = (this->*Handle2Value)();
assert(res.is_valid());
return res;
#else
return (this->*Handle2Value)();
#endif
}
/**
* @brief Pointer dereferentiation.
*
* This returns a pointer which points to a handle
* that loses its validity once this dereferentiation is
* invoked again. Thus, do not store the result of
* this operation.
*/
pointer operator->() const {
pointer_deref_value = **this;
return &pointer_deref_value;
}
GenericCirculatorT_DEPRECATED &operator=(const GenericCirculatorT_DEPRECATED &rhs) {
GenericCirculatorBaseT<Mesh>::operator=(rhs);
return *this;
};
bool operator==(const GenericCirculatorT_DEPRECATED &rhs) const {
return GenericCirculatorBaseT<Mesh>::operator==(rhs);
}
bool operator!=(const GenericCirculatorT_DEPRECATED &rhs) const {
return GenericCirculatorBaseT<Mesh>::operator!=(rhs);
}
bool is_valid() const {
return GenericCirculator_ValueHandleFns::is_valid(this->heh_,this->start_, this->lap_counter_);
}
DEPRECATED("current_halfedge_handle() is an implementation detail and should not be accessed from outside the iterator class.")
/**
* \deprecated
* current_halfedge_handle() is an implementation detail and should not
* be accessed from outside the iterator class.
*/
const HalfedgeHandle &current_halfedge_handle() const {
return this->heh_;
}
DEPRECATED("Do not use this error prone implicit cast. Compare to end-iterator or use is_valid(), instead.")
/**
* \deprecated
* Do not use this error prone implicit cast. Compare to the
* end-iterator or use is_valid() instead.
*/
operator bool() const {
return is_valid();
}
/**
* \brief Return the handle of the current target.
* \deprecated
* This function clutters your code. Use dereferencing operators -> and * instead.
*/
DEPRECATED("This function clutters your code. Use dereferencing operators -> and * instead.")
value_type handle() const {
return **this;
}
/**
* \brief Cast to the handle of the current target.
* \deprecated
* Implicit casts of iterators are unsafe. Use dereferencing operators
* -> and * instead.
*/
DEPRECATED("Implicit casts of iterators are unsafe. Use dereferencing operators -> and * instead.")
operator value_type() const {
return **this;
}
template<typename STREAM>
friend STREAM &operator<< (STREAM &s, const GenericCirculatorT_DEPRECATED &self) {
return s << self.mesh_ << ", " << self.start_.idx() << ", " << self.heh_.idx() << ", " << self.lap_counter_;
}
private:
mutable value_type pointer_deref_value;
};
} // namespace Iterators } // namespace Iterators
} // namespace OpenMesh } // namespace OpenMesh

View File

@@ -102,10 +102,11 @@ public:
/** /**
* Enumerates 1-ring vertices in a clockwise fashion. * Enumerates 1-ring vertices in a clockwise fashion.
*/ */
typedef Iterators::GenericCirculatorT<This, This::VertexHandle, This::VertexHandle, typedef Iterators::GenericCirculatorT_DEPRECATED<This, This::VertexHandle, This::VertexHandle,
&Iterators::GenericCirculatorBaseT<This>::toVertexHandle> &Iterators::GenericCirculatorBaseT<This>::toVertexHandle>
VertexVertexIter; VertexVertexIter;
typedef VertexVertexIter VertexVertexCWIter; typedef Iterators::GenericCirculatorT<This, This::VertexHandle, This::VertexHandle,
&Iterators::GenericCirculatorBaseT<This>::toVertexHandle> VertexVertexCWIter;
/** /**
* Enumerates 1-ring vertices in a counter clockwise fashion. * Enumerates 1-ring vertices in a counter clockwise fashion.
@@ -117,10 +118,11 @@ public:
/** /**
* Enumerates outgoing half edges in a clockwise fashion. * Enumerates outgoing half edges in a clockwise fashion.
*/ */
typedef Iterators::GenericCirculatorT<This, This::VertexHandle, This::HalfedgeHandle, typedef Iterators::GenericCirculatorT_DEPRECATED<This, This::VertexHandle, This::HalfedgeHandle,
&Iterators::GenericCirculatorBaseT<This>::toHalfedgeHandle> &Iterators::GenericCirculatorBaseT<This>::toHalfedgeHandle>
VertexOHalfedgeIter; VertexOHalfedgeIter;
typedef VertexOHalfedgeIter VertexOHalfedgeCWIter; typedef Iterators::GenericCirculatorT<This, This::VertexHandle, This::HalfedgeHandle,
&Iterators::GenericCirculatorBaseT<This>::toHalfedgeHandle> VertexOHalfedgeCWIter;
/** /**
* Enumerates outgoing half edges in a counter clockwise fashion. * Enumerates outgoing half edges in a counter clockwise fashion.
@@ -132,10 +134,11 @@ public:
/** /**
* Enumerates incoming half edges in a clockwise fashion. * Enumerates incoming half edges in a clockwise fashion.
*/ */
typedef Iterators::GenericCirculatorT<This, This::VertexHandle, This::HalfedgeHandle, typedef Iterators::GenericCirculatorT_DEPRECATED<This, This::VertexHandle, This::HalfedgeHandle,
&Iterators::GenericCirculatorBaseT<This>::toOppositeHalfedgeHandle> &Iterators::GenericCirculatorBaseT<This>::toOppositeHalfedgeHandle>
VertexIHalfedgeIter; VertexIHalfedgeIter;
typedef VertexIHalfedgeIter VertexIHalfedgeCWIter; typedef Iterators::GenericCirculatorT<This, This::VertexHandle, This::HalfedgeHandle,
&Iterators::GenericCirculatorBaseT<This>::toOppositeHalfedgeHandle> VertexIHalfedgeCWIter;
/** /**
* Enumerates incoming half edges in a counter clockwise fashion. * Enumerates incoming half edges in a counter clockwise fashion.
@@ -147,10 +150,11 @@ public:
/** /**
* Enumerates incident faces in a clockwise fashion. * Enumerates incident faces in a clockwise fashion.
*/ */
typedef Iterators::GenericCirculatorT<This, This::VertexHandle, This::FaceHandle, typedef Iterators::GenericCirculatorT_DEPRECATED<This, This::VertexHandle, This::FaceHandle,
&Iterators::GenericCirculatorBaseT<This>::toFaceHandle> &Iterators::GenericCirculatorBaseT<This>::toFaceHandle>
VertexFaceIter; VertexFaceIter;
typedef VertexFaceIter VertexFaceCWIter; typedef Iterators::GenericCirculatorT<This, This::VertexHandle, This::FaceHandle,
&Iterators::GenericCirculatorBaseT<This>::toFaceHandle> VertexFaceCWIter;
/** /**
* Enumerates incident faces in a counter clockwise fashion. * Enumerates incident faces in a counter clockwise fashion.
@@ -162,10 +166,11 @@ public:
/** /**
* Enumerates incident edges in a clockwise fashion. * Enumerates incident edges in a clockwise fashion.
*/ */
typedef Iterators::GenericCirculatorT<This, This::VertexHandle, This::EdgeHandle, typedef Iterators::GenericCirculatorT_DEPRECATED<This, This::VertexHandle, This::EdgeHandle,
&Iterators::GenericCirculatorBaseT<This>::toEdgeHandle> &Iterators::GenericCirculatorBaseT<This>::toEdgeHandle>
VertexEdgeIter; VertexEdgeIter;
typedef VertexEdgeIter VertexEdgeCWIter; typedef Iterators::GenericCirculatorT<This, This::VertexHandle, This::EdgeHandle,
&Iterators::GenericCirculatorBaseT<This>::toEdgeHandle> VertexEdgeCWIter;
/** /**
* Enumerates incident edges in a counter clockwise fashion. * Enumerates incident edges in a counter clockwise fashion.
*/ */
@@ -176,10 +181,11 @@ public:
/** /**
* Identical to #FaceHalfedgeIter. God knows why this typedef exists. * Identical to #FaceHalfedgeIter. God knows why this typedef exists.
*/ */
typedef Iterators::GenericCirculatorT<This, This::FaceHandle, This::HalfedgeHandle, typedef Iterators::GenericCirculatorT_DEPRECATED<This, This::FaceHandle, This::HalfedgeHandle,
&Iterators::GenericCirculatorBaseT<This>::toHalfedgeHandle> &Iterators::GenericCirculatorBaseT<This>::toHalfedgeHandle>
HalfedgeLoopIter; HalfedgeLoopIter;
typedef HalfedgeLoopIter HalfedgeLoopCWIter; typedef Iterators::GenericCirculatorT<This, This::FaceHandle, This::HalfedgeHandle,
&Iterators::GenericCirculatorBaseT<This>::toHalfedgeHandle> HalfedgeLoopCWIter;
/** /**
* Identical to #FaceHalfedgeIter. God knows why this typedef exists. * Identical to #FaceHalfedgeIter. God knows why this typedef exists.
*/ */

View File

@@ -200,85 +200,86 @@ TEST_F(OpenMeshTrimeshCirculatorVertexEdge, VertexEdgeIterBoundaryIncrement) {
/* /*
* Test if the end iterator stays invalid after one lap * Test if the end iterator stays invalid after one lap
* DISABLED as long as the normal iterators using old behavior
*/ */
TEST_F(OpenMeshTrimeshCirculatorVertexEdge, VertexEdgeIterCheckInvalidationAtEnds) { //TEST_F(OpenMeshTrimeshCirculatorVertexEdge, VertexEdgeIterCheckInvalidationAtEnds) {
//
mesh_.clear(); // mesh_.clear();
//
// Add some vertices // // Add some vertices
Mesh::VertexHandle vhandle[5]; // Mesh::VertexHandle vhandle[5];
//
vhandle[0] = mesh_.add_vertex(Mesh::Point(0, 1, 0)); // vhandle[0] = mesh_.add_vertex(Mesh::Point(0, 1, 0));
vhandle[1] = mesh_.add_vertex(Mesh::Point(1, 0, 0)); // vhandle[1] = mesh_.add_vertex(Mesh::Point(1, 0, 0));
vhandle[2] = mesh_.add_vertex(Mesh::Point(2, 1, 0)); // vhandle[2] = mesh_.add_vertex(Mesh::Point(2, 1, 0));
vhandle[3] = mesh_.add_vertex(Mesh::Point(0,-1, 0)); // vhandle[3] = mesh_.add_vertex(Mesh::Point(0,-1, 0));
vhandle[4] = mesh_.add_vertex(Mesh::Point(2,-1, 0)); // vhandle[4] = mesh_.add_vertex(Mesh::Point(2,-1, 0));
//
// Add two faces // // Add two faces
std::vector<Mesh::VertexHandle> face_vhandles; // std::vector<Mesh::VertexHandle> face_vhandles;
//
face_vhandles.push_back(vhandle[0]); // face_vhandles.push_back(vhandle[0]);
face_vhandles.push_back(vhandle[1]); // face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[2]); // face_vhandles.push_back(vhandle[2]);
Mesh::FaceHandle fh0 = mesh_.add_face(face_vhandles); // Mesh::FaceHandle fh0 = mesh_.add_face(face_vhandles);
//
face_vhandles.clear(); // face_vhandles.clear();
//
face_vhandles.push_back(vhandle[1]); // face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[3]); // face_vhandles.push_back(vhandle[3]);
face_vhandles.push_back(vhandle[4]); // face_vhandles.push_back(vhandle[4]);
mesh_.add_face(face_vhandles); // mesh_.add_face(face_vhandles);
//
face_vhandles.clear(); // face_vhandles.clear();
//
face_vhandles.push_back(vhandle[0]); // face_vhandles.push_back(vhandle[0]);
face_vhandles.push_back(vhandle[3]); // face_vhandles.push_back(vhandle[3]);
face_vhandles.push_back(vhandle[1]); // face_vhandles.push_back(vhandle[1]);
mesh_.add_face(face_vhandles); // mesh_.add_face(face_vhandles);
//
face_vhandles.clear(); // face_vhandles.clear();
//
face_vhandles.push_back(vhandle[2]); // face_vhandles.push_back(vhandle[2]);
face_vhandles.push_back(vhandle[1]); // face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[4]); // face_vhandles.push_back(vhandle[4]);
mesh_.add_face(face_vhandles); // mesh_.add_face(face_vhandles);
//
/* Test setup: // /* Test setup:
0 ==== 2 // 0 ==== 2
|\ 0 /| // |\ 0 /|
| \ / | // | \ / |
|2 1 3| // |2 1 3|
| / \ | // | / \ |
|/ 1 \| // |/ 1 \|
3 ==== 4 */ // 3 ==== 4 */
//
//
// Check if the end iterator stays invalid after end // // Check if the end iterator stays invalid after end
Mesh::VertexEdgeIter endIter = mesh_.ve_end(vhandle[1]); // Mesh::VertexEdgeIter endIter = mesh_.ve_end(vhandle[1]);
EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid"; // EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid";
++endIter ; // ++endIter ;
EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid after increment"; // EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid after increment";
//
// Check if the end iterators becomes valid after decrement // // Check if the end iterators becomes valid after decrement
endIter = mesh_.ve_end(vhandle[1]); // endIter = mesh_.ve_end(vhandle[1]);
EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid"; // EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid";
--endIter; // --endIter;
EXPECT_TRUE(endIter.is_valid()) << "EndIter is invalid after decrement"; // EXPECT_TRUE(endIter.is_valid()) << "EndIter is invalid after decrement";
EXPECT_EQ(1,endIter->idx()) << "EndIter points on the wrong element"; // EXPECT_EQ(1,endIter->idx()) << "EndIter points on the wrong element";
//
//
// Check if the start iterator decrement is invalid // // Check if the start iterator decrement is invalid
Mesh::VertexEdgeIter startIter = mesh_.ve_begin(vhandle[1]); // Mesh::VertexEdgeIter startIter = mesh_.ve_begin(vhandle[1]);
EXPECT_TRUE(startIter.is_valid()) << "StartIter is not valid"; // EXPECT_TRUE(startIter.is_valid()) << "StartIter is not valid";
--startIter; // --startIter;
EXPECT_FALSE(startIter.is_valid()) << "StartIter decrement is not invalid"; // EXPECT_FALSE(startIter.is_valid()) << "StartIter decrement is not invalid";
//
// Check if the start iterator becomes valid // // Check if the start iterator becomes valid
++startIter; // ++startIter;
EXPECT_TRUE(startIter.is_valid()) << "StarIter is invalid after re-incrementing"; // 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"; // EXPECT_EQ(startIter->idx(), mesh_.ve_begin(vhandle[1])->idx()) << "StartIter points on the wrong element";
//
} //}
/* /*
* Test CW and CCW iterators * Test CW and CCW iterators

View File

@@ -269,187 +269,189 @@ TEST_F(OpenMeshTrimeshCirculatorVertexFace, VertexFaceIterBoundaryIncrement) {
/* /*
* Test if the end iterator stays invalid after one lap * Test if the end iterator stays invalid after one lap
* DISABLED as long as the normal iterators using old behavior
*/ */
TEST_F(OpenMeshTrimeshCirculatorVertexFace, VertexFaceIterCheckInvalidationAtEnds) { //TEST_F(OpenMeshTrimeshCirculatorVertexFace, VertexFaceIterCheckInvalidationAtEnds) {
//
mesh_.clear(); // mesh_.clear();
//
// Add some vertices // // Add some vertices
Mesh::VertexHandle vhandle[5]; // Mesh::VertexHandle vhandle[5];
//
vhandle[0] = mesh_.add_vertex(Mesh::Point(0, 1, 0)); // vhandle[0] = mesh_.add_vertex(Mesh::Point(0, 1, 0));
vhandle[1] = mesh_.add_vertex(Mesh::Point(1, 0, 0)); // vhandle[1] = mesh_.add_vertex(Mesh::Point(1, 0, 0));
vhandle[2] = mesh_.add_vertex(Mesh::Point(2, 1, 0)); // vhandle[2] = mesh_.add_vertex(Mesh::Point(2, 1, 0));
vhandle[3] = mesh_.add_vertex(Mesh::Point(0,-1, 0)); // vhandle[3] = mesh_.add_vertex(Mesh::Point(0,-1, 0));
vhandle[4] = mesh_.add_vertex(Mesh::Point(2,-1, 0)); // vhandle[4] = mesh_.add_vertex(Mesh::Point(2,-1, 0));
//
// Add two faces // // Add two faces
std::vector<Mesh::VertexHandle> face_vhandles; // std::vector<Mesh::VertexHandle> face_vhandles;
//
face_vhandles.push_back(vhandle[0]); // face_vhandles.push_back(vhandle[0]);
face_vhandles.push_back(vhandle[1]); // face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[2]); // face_vhandles.push_back(vhandle[2]);
Mesh::FaceHandle fh0 = mesh_.add_face(face_vhandles); // Mesh::FaceHandle fh0 = mesh_.add_face(face_vhandles);
//
face_vhandles.clear(); // face_vhandles.clear();
//
face_vhandles.push_back(vhandle[1]); // face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[3]); // face_vhandles.push_back(vhandle[3]);
face_vhandles.push_back(vhandle[4]); // face_vhandles.push_back(vhandle[4]);
mesh_.add_face(face_vhandles); // mesh_.add_face(face_vhandles);
//
face_vhandles.clear(); // face_vhandles.clear();
//
face_vhandles.push_back(vhandle[0]); // face_vhandles.push_back(vhandle[0]);
face_vhandles.push_back(vhandle[3]); // face_vhandles.push_back(vhandle[3]);
face_vhandles.push_back(vhandle[1]); // face_vhandles.push_back(vhandle[1]);
mesh_.add_face(face_vhandles); // mesh_.add_face(face_vhandles);
//
face_vhandles.clear(); // face_vhandles.clear();
//
face_vhandles.push_back(vhandle[2]); // face_vhandles.push_back(vhandle[2]);
face_vhandles.push_back(vhandle[1]); // face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[4]); // face_vhandles.push_back(vhandle[4]);
mesh_.add_face(face_vhandles); // mesh_.add_face(face_vhandles);
//
/* Test setup: // /* Test setup:
0 ==== 2 // 0 ==== 2
|\ 0 /| // |\ 0 /|
| \ / | // | \ / |
|2 1 3| // |2 1 3|
| / \ | // | / \ |
|/ 1 \| // |/ 1 \|
3 ==== 4 */ // 3 ==== 4 */
//
//
// Check if the end iterator stays invalid after end // // Check if the end iterator stays invalid after end
Mesh::VertexFaceIter endIter = mesh_.vf_end(vhandle[1]); // Mesh::VertexFaceIter endIter = mesh_.vf_end(vhandle[1]);
EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid"; // EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid";
++endIter ; // ++endIter ;
EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid after increment"; // EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid after increment";
//
// Check if the end iterators becomes valid after decrement // // Check if the end iterators becomes valid after decrement
endIter = mesh_.vf_end(vhandle[1]); // endIter = mesh_.vf_end(vhandle[1]);
EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid"; // EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid";
--endIter; // --endIter;
EXPECT_TRUE(endIter.is_valid()) << "EndIter is invalid after decrement"; // EXPECT_TRUE(endIter.is_valid()) << "EndIter is invalid after decrement";
EXPECT_EQ(0,endIter->idx()) << "EndIter points on the wrong element"; // EXPECT_EQ(0,endIter->idx()) << "EndIter points on the wrong element";
//
//
// Check if the start iterator decrement is invalid // // Check if the start iterator decrement is invalid
Mesh::VertexFaceIter startIter = mesh_.vf_begin(vhandle[1]); // Mesh::VertexFaceIter startIter = mesh_.vf_begin(vhandle[1]);
EXPECT_TRUE(startIter.is_valid()) << "StartIter is not valid"; // EXPECT_TRUE(startIter.is_valid()) << "StartIter is not valid";
--startIter; // --startIter;
EXPECT_FALSE(startIter.is_valid()) << "StartIter decrement is not invalid"; // EXPECT_FALSE(startIter.is_valid()) << "StartIter decrement is not invalid";
//
// Check if the start iterator becomes valid // // Check if the start iterator becomes valid
++startIter; // ++startIter;
EXPECT_TRUE(startIter.is_valid()) << "StarIter is invalid after re-incrementing"; // 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"; // EXPECT_EQ(startIter->idx(), mesh_.vf_begin(vhandle[1])->idx()) << "StartIter points on the wrong element";
//
} //}
/* /*
* VertexFaceIterator Test without holes testing decrement * VertexFaceIterator Test without holes testing decrement
* DISABLED as long as the normal iterators using old behavior
*/ */
TEST_F(OpenMeshTrimeshCirculatorVertexFace, VertexFaceIterWithoutHolesDecrement) { //TEST_F(OpenMeshTrimeshCirculatorVertexFace, VertexFaceIterWithoutHolesDecrement) {
//
mesh_.clear(); // mesh_.clear();
//
// Add some vertices // // Add some vertices
Mesh::VertexHandle vhandle[5]; // Mesh::VertexHandle vhandle[5];
//
vhandle[0] = mesh_.add_vertex(Mesh::Point(0, 1, 0)); // vhandle[0] = mesh_.add_vertex(Mesh::Point(0, 1, 0));
vhandle[1] = mesh_.add_vertex(Mesh::Point(1, 0, 0)); // vhandle[1] = mesh_.add_vertex(Mesh::Point(1, 0, 0));
vhandle[2] = mesh_.add_vertex(Mesh::Point(2, 1, 0)); // vhandle[2] = mesh_.add_vertex(Mesh::Point(2, 1, 0));
vhandle[3] = mesh_.add_vertex(Mesh::Point(0,-1, 0)); // vhandle[3] = mesh_.add_vertex(Mesh::Point(0,-1, 0));
vhandle[4] = mesh_.add_vertex(Mesh::Point(2,-1, 0)); // vhandle[4] = mesh_.add_vertex(Mesh::Point(2,-1, 0));
//
// Add two faces // // Add two faces
std::vector<Mesh::VertexHandle> face_vhandles; // std::vector<Mesh::VertexHandle> face_vhandles;
//
face_vhandles.push_back(vhandle[0]); // face_vhandles.push_back(vhandle[0]);
face_vhandles.push_back(vhandle[1]); // face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[2]); // face_vhandles.push_back(vhandle[2]);
mesh_.add_face(face_vhandles); // mesh_.add_face(face_vhandles);
//
face_vhandles.clear(); // face_vhandles.clear();
//
face_vhandles.push_back(vhandle[1]); // face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[3]); // face_vhandles.push_back(vhandle[3]);
face_vhandles.push_back(vhandle[4]); // face_vhandles.push_back(vhandle[4]);
mesh_.add_face(face_vhandles); // mesh_.add_face(face_vhandles);
//
face_vhandles.clear(); // face_vhandles.clear();
//
face_vhandles.push_back(vhandle[0]); // face_vhandles.push_back(vhandle[0]);
face_vhandles.push_back(vhandle[3]); // face_vhandles.push_back(vhandle[3]);
face_vhandles.push_back(vhandle[1]); // face_vhandles.push_back(vhandle[1]);
mesh_.add_face(face_vhandles); // mesh_.add_face(face_vhandles);
//
face_vhandles.clear(); // face_vhandles.clear();
//
face_vhandles.push_back(vhandle[2]); // face_vhandles.push_back(vhandle[2]);
face_vhandles.push_back(vhandle[1]); // face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[4]); // face_vhandles.push_back(vhandle[4]);
mesh_.add_face(face_vhandles); // mesh_.add_face(face_vhandles);
//
/* Test setup: // /* Test setup:
0 ==== 2 // 0 ==== 2
|\ 0 /| // |\ 0 /|
| \ / | // | \ / |
|2 1 3| // |2 1 3|
| / \ | // | / \ |
|/ 1 \| // |/ 1 \|
3 ==== 4 */ // 3 ==== 4 */
//
mesh_.vf_begin(vhandle[1]); // mesh_.vf_begin(vhandle[1]);
//
// Iterate around vertex 1 at the middle // // Iterate around vertex 1 at the middle
Mesh::VertexFaceIter vf_it = mesh_.vf_begin(vhandle[1]); // Mesh::VertexFaceIter vf_it = mesh_.vf_begin(vhandle[1]);
std::advance(vf_it,3); // std::advance(vf_it,3);
Mesh::VertexFaceIter vf_end = mesh_.vf_begin(vhandle[1]); // Mesh::VertexFaceIter vf_end = mesh_.vf_begin(vhandle[1]);
--vf_end; // --vf_end;
//
EXPECT_EQ(0, vf_it->idx() ) << "Index wrong in VertexFaceIter at initialization"; // EXPECT_EQ(0, vf_it->idx() ) << "Index wrong in VertexFaceIter at initialization";
EXPECT_TRUE(vf_it.is_valid()) << "Iterator invalid in VertexFaceIter at initialization"; // EXPECT_TRUE(vf_it.is_valid()) << "Iterator invalid in VertexFaceIter at initialization";
--vf_it ; // --vf_it ;
EXPECT_EQ(2, vf_it->idx() ) << "Index wrong in VertexFaceIter at step 1"; // EXPECT_EQ(2, vf_it->idx() ) << "Index wrong in VertexFaceIter at step 1";
EXPECT_TRUE(vf_it.is_valid()) << "Iterator invalid in VertexFaceIter at step 1"; // EXPECT_TRUE(vf_it.is_valid()) << "Iterator invalid in VertexFaceIter at step 1";
--vf_it ; // --vf_it ;
EXPECT_EQ(1, vf_it->idx() ) << "Index wrong in VertexFaceIter at step 2"; // EXPECT_EQ(1, vf_it->idx() ) << "Index wrong in VertexFaceIter at step 2";
EXPECT_TRUE(vf_it.is_valid()) << "Iterator invalid in VertexFaceIter at step 2"; // EXPECT_TRUE(vf_it.is_valid()) << "Iterator invalid in VertexFaceIter at step 2";
--vf_it ; // --vf_it ;
EXPECT_EQ(3, vf_it->idx() ) << "Index wrong in VertexFaceIter at step 3"; // EXPECT_EQ(3, vf_it->idx() ) << "Index wrong in VertexFaceIter at step 3";
EXPECT_TRUE(vf_it.is_valid()) << "Iterator invalid in VertexFaceIter at step 3"; // EXPECT_TRUE(vf_it.is_valid()) << "Iterator invalid in VertexFaceIter at step 3";
--vf_it ; // --vf_it ;
EXPECT_EQ(0, vf_it->idx() ) << "Index wrong in VertexFaceIter at end"; // EXPECT_EQ(0, vf_it->idx() ) << "Index wrong in VertexFaceIter at end";
EXPECT_FALSE(vf_it.is_valid()) << "Iterator invalid in VertexFaceIter at step 2"; // EXPECT_FALSE(vf_it.is_valid()) << "Iterator invalid in VertexFaceIter at step 2";
EXPECT_TRUE( vf_it == vf_end ) << "End iterator for VertexFaceIter not matching"; // EXPECT_TRUE( vf_it == vf_end ) << "End iterator for VertexFaceIter not matching";
//
// Iterate around vertex 1 at the middle with const iterator // // Iterate around vertex 1 at the middle with const iterator
Mesh::ConstVertexFaceIter cvf_it = mesh_.cvf_begin(vhandle[1]); // Mesh::ConstVertexFaceIter cvf_it = mesh_.cvf_begin(vhandle[1]);
std::advance(cvf_it,3); // std::advance(cvf_it,3);
Mesh::ConstVertexFaceIter cvf_end = mesh_.cvf_begin(vhandle[1]); // Mesh::ConstVertexFaceIter cvf_end = mesh_.cvf_begin(vhandle[1]);
--cvf_end; // --cvf_end;
//
EXPECT_EQ(0, cvf_it->idx() ) << "Index wrong in ConstVertexFaceIter at initialization"; // EXPECT_EQ(0, cvf_it->idx() ) << "Index wrong in ConstVertexFaceIter at initialization";
EXPECT_TRUE(cvf_it.is_valid()) << "Iterator invalid in ConstVertexFaceIter at initialization"; // EXPECT_TRUE(cvf_it.is_valid()) << "Iterator invalid in ConstVertexFaceIter at initialization";
--cvf_it ; // --cvf_it ;
EXPECT_EQ(2, cvf_it->idx() ) << "Index wrong in ConstVertexFaceIter at step 1"; // EXPECT_EQ(2, cvf_it->idx() ) << "Index wrong in ConstVertexFaceIter at step 1";
EXPECT_TRUE(cvf_it.is_valid()) << "Iterator invalid in ConstVertexFaceIter at step 1"; // EXPECT_TRUE(cvf_it.is_valid()) << "Iterator invalid in ConstVertexFaceIter at step 1";
--cvf_it ; // --cvf_it ;
EXPECT_EQ(1, cvf_it->idx() ) << "Index wrong in ConstVertexFaceIter at step 2"; // EXPECT_EQ(1, cvf_it->idx() ) << "Index wrong in ConstVertexFaceIter at step 2";
EXPECT_TRUE(cvf_it.is_valid()) << "Iterator invalid in ConstVertexFaceIter at step 2"; // EXPECT_TRUE(cvf_it.is_valid()) << "Iterator invalid in ConstVertexFaceIter at step 2";
--cvf_it ; // --cvf_it ;
EXPECT_EQ(3, cvf_it->idx() ) << "Index wrong in ConstVertexFaceIter at step 3"; // EXPECT_EQ(3, cvf_it->idx() ) << "Index wrong in ConstVertexFaceIter at step 3";
EXPECT_TRUE(cvf_it.is_valid()) << "Iterator invalid in ConstVertexFaceIter at step 3"; // EXPECT_TRUE(cvf_it.is_valid()) << "Iterator invalid in ConstVertexFaceIter at step 3";
--cvf_it ; // --cvf_it ;
EXPECT_EQ(0, cvf_it->idx() ) << "Index wrong in ConstVertexFaceIter at end"; // EXPECT_EQ(0, cvf_it->idx() ) << "Index wrong in ConstVertexFaceIter at end";
EXPECT_FALSE(cvf_it.is_valid()) << "Iterator invalid in VertexFaceIter at step 2"; // EXPECT_FALSE(cvf_it.is_valid()) << "Iterator invalid in VertexFaceIter at step 2";
EXPECT_TRUE( cvf_it == cvf_end ) << "End iterator for ConstVertexFaceIter not matching"; // EXPECT_TRUE( cvf_it == cvf_end ) << "End iterator for ConstVertexFaceIter not matching";
//
} //}
/* /*
* Test CW and CCW iterators * Test CW and CCW iterators

View File

@@ -314,85 +314,86 @@ TEST_F(OpenMeshTrimeshCirculatorVertexIHalfEdge, VertexIncomingHalfedgeDereferen
/* /*
* Test if the end iterator stays invalid after one lap * Test if the end iterator stays invalid after one lap
* DISABLED as long as the normal iterators using old behavior
*/ */
TEST_F(OpenMeshTrimeshCirculatorVertexIHalfEdge, VertexIHalfEdgeIterCheckInvalidationAtEnds) { //TEST_F(OpenMeshTrimeshCirculatorVertexIHalfEdge, VertexIHalfEdgeIterCheckInvalidationAtEnds) {
//
mesh_.clear(); // mesh_.clear();
//
// Add some vertices // // Add some vertices
Mesh::VertexHandle vhandle[5]; // Mesh::VertexHandle vhandle[5];
//
vhandle[0] = mesh_.add_vertex(Mesh::Point(0, 1, 0)); // vhandle[0] = mesh_.add_vertex(Mesh::Point(0, 1, 0));
vhandle[1] = mesh_.add_vertex(Mesh::Point(1, 0, 0)); // vhandle[1] = mesh_.add_vertex(Mesh::Point(1, 0, 0));
vhandle[2] = mesh_.add_vertex(Mesh::Point(2, 1, 0)); // vhandle[2] = mesh_.add_vertex(Mesh::Point(2, 1, 0));
vhandle[3] = mesh_.add_vertex(Mesh::Point(0,-1, 0)); // vhandle[3] = mesh_.add_vertex(Mesh::Point(0,-1, 0));
vhandle[4] = mesh_.add_vertex(Mesh::Point(2,-1, 0)); // vhandle[4] = mesh_.add_vertex(Mesh::Point(2,-1, 0));
//
// Add two faces // // Add two faces
std::vector<Mesh::VertexHandle> face_vhandles; // std::vector<Mesh::VertexHandle> face_vhandles;
//
face_vhandles.push_back(vhandle[0]); // face_vhandles.push_back(vhandle[0]);
face_vhandles.push_back(vhandle[1]); // face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[2]); // face_vhandles.push_back(vhandle[2]);
Mesh::FaceHandle fh0 = mesh_.add_face(face_vhandles); // Mesh::FaceHandle fh0 = mesh_.add_face(face_vhandles);
//
face_vhandles.clear(); // face_vhandles.clear();
//
face_vhandles.push_back(vhandle[1]); // face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[3]); // face_vhandles.push_back(vhandle[3]);
face_vhandles.push_back(vhandle[4]); // face_vhandles.push_back(vhandle[4]);
mesh_.add_face(face_vhandles); // mesh_.add_face(face_vhandles);
//
face_vhandles.clear(); // face_vhandles.clear();
//
face_vhandles.push_back(vhandle[0]); // face_vhandles.push_back(vhandle[0]);
face_vhandles.push_back(vhandle[3]); // face_vhandles.push_back(vhandle[3]);
face_vhandles.push_back(vhandle[1]); // face_vhandles.push_back(vhandle[1]);
mesh_.add_face(face_vhandles); // mesh_.add_face(face_vhandles);
//
face_vhandles.clear(); // face_vhandles.clear();
//
face_vhandles.push_back(vhandle[2]); // face_vhandles.push_back(vhandle[2]);
face_vhandles.push_back(vhandle[1]); // face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[4]); // face_vhandles.push_back(vhandle[4]);
mesh_.add_face(face_vhandles); // mesh_.add_face(face_vhandles);
//
/* Test setup: // /* Test setup:
0 ==== 2 // 0 ==== 2
|\ 0 /| // |\ 0 /|
| \ / | // | \ / |
|2 1 3| // |2 1 3|
| / \ | // | / \ |
|/ 1 \| // |/ 1 \|
3 ==== 4 */ // 3 ==== 4 */
//
//
// Check if the end iterator stays invalid after end // // Check if the end iterator stays invalid after end
Mesh::VertexIHalfedgeIter endIter = mesh_.vih_end(vhandle[1]); // Mesh::VertexIHalfedgeIter endIter = mesh_.vih_end(vhandle[1]);
EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid"; // EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid";
++endIter ; // ++endIter ;
EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid after increment"; // EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid after increment";
//
// Check if the end iterators becomes valid after decrement // // Check if the end iterators becomes valid after decrement
endIter = mesh_.vih_end(vhandle[1]); // endIter = mesh_.vih_end(vhandle[1]);
EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid"; // EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid";
--endIter; // --endIter;
EXPECT_TRUE(endIter.is_valid()) << "EndIter is invalid after decrement"; // EXPECT_TRUE(endIter.is_valid()) << "EndIter is invalid after decrement";
EXPECT_EQ(3,endIter->idx()) << "EndIter points on the wrong element"; // EXPECT_EQ(3,endIter->idx()) << "EndIter points on the wrong element";
//
//
// Check if the start iterator decrement is invalid // // Check if the start iterator decrement is invalid
Mesh::VertexIHalfedgeIter startIter = mesh_.vih_begin(vhandle[1]); // Mesh::VertexIHalfedgeIter startIter = mesh_.vih_begin(vhandle[1]);
EXPECT_TRUE(startIter.is_valid()) << "StartIter is not valid"; // EXPECT_TRUE(startIter.is_valid()) << "StartIter is not valid";
--startIter; // --startIter;
EXPECT_FALSE(startIter.is_valid()) << "StartIter decrement is not invalid"; // EXPECT_FALSE(startIter.is_valid()) << "StartIter decrement is not invalid";
//
// Check if the start iterator becomes valid // // Check if the start iterator becomes valid
++startIter; // ++startIter;
EXPECT_TRUE(startIter.is_valid()) << "StarIter is invalid after re-incrementing"; // 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"; // EXPECT_EQ(startIter->idx(), mesh_.vih_begin(vhandle[1])->idx()) << "StartIter points on the wrong element";
//
} //}
/* /*
* Test CW and CCW iterators * Test CW and CCW iterators

View File

@@ -315,84 +315,85 @@ TEST_F(OpenMeshTrimeshCirculatorVertexOHalfEdge, VertexOutgoingHalfedgeDereferen
/* /*
* Test if the end iterator stays invalid after one lap * Test if the end iterator stays invalid after one lap
* DISABLED as long as the normal iterators using old behavior
*/ */
TEST_F(OpenMeshTrimeshCirculatorVertexOHalfEdge, VertexOHalfEdgeIterCheckInvalidationAtEnds) { //TEST_F(OpenMeshTrimeshCirculatorVertexOHalfEdge, VertexOHalfEdgeIterCheckInvalidationAtEnds) {
//
mesh_.clear(); // mesh_.clear();
//
// Add some vertices // // Add some vertices
Mesh::VertexHandle vhandle[5]; // Mesh::VertexHandle vhandle[5];
//
vhandle[0] = mesh_.add_vertex(Mesh::Point(0, 1, 0)); // vhandle[0] = mesh_.add_vertex(Mesh::Point(0, 1, 0));
vhandle[1] = mesh_.add_vertex(Mesh::Point(1, 0, 0)); // vhandle[1] = mesh_.add_vertex(Mesh::Point(1, 0, 0));
vhandle[2] = mesh_.add_vertex(Mesh::Point(2, 1, 0)); // vhandle[2] = mesh_.add_vertex(Mesh::Point(2, 1, 0));
vhandle[3] = mesh_.add_vertex(Mesh::Point(0,-1, 0)); // vhandle[3] = mesh_.add_vertex(Mesh::Point(0,-1, 0));
vhandle[4] = mesh_.add_vertex(Mesh::Point(2,-1, 0)); // vhandle[4] = mesh_.add_vertex(Mesh::Point(2,-1, 0));
//
// Add two faces // // Add two faces
std::vector<Mesh::VertexHandle> face_vhandles; // std::vector<Mesh::VertexHandle> face_vhandles;
//
face_vhandles.push_back(vhandle[0]); // face_vhandles.push_back(vhandle[0]);
face_vhandles.push_back(vhandle[1]); // face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[2]); // face_vhandles.push_back(vhandle[2]);
Mesh::FaceHandle fh0 = mesh_.add_face(face_vhandles); // Mesh::FaceHandle fh0 = mesh_.add_face(face_vhandles);
//
face_vhandles.clear(); // face_vhandles.clear();
//
face_vhandles.push_back(vhandle[1]); // face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[3]); // face_vhandles.push_back(vhandle[3]);
face_vhandles.push_back(vhandle[4]); // face_vhandles.push_back(vhandle[4]);
mesh_.add_face(face_vhandles); // mesh_.add_face(face_vhandles);
//
face_vhandles.clear(); // face_vhandles.clear();
//
face_vhandles.push_back(vhandle[0]); // face_vhandles.push_back(vhandle[0]);
face_vhandles.push_back(vhandle[3]); // face_vhandles.push_back(vhandle[3]);
face_vhandles.push_back(vhandle[1]); // face_vhandles.push_back(vhandle[1]);
mesh_.add_face(face_vhandles); // mesh_.add_face(face_vhandles);
//
face_vhandles.clear(); // face_vhandles.clear();
//
face_vhandles.push_back(vhandle[2]); // face_vhandles.push_back(vhandle[2]);
face_vhandles.push_back(vhandle[1]); // face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[4]); // face_vhandles.push_back(vhandle[4]);
mesh_.add_face(face_vhandles); // mesh_.add_face(face_vhandles);
//
/* Test setup: // /* Test setup:
0 ==== 2 // 0 ==== 2
|\ 0 /| // |\ 0 /|
| \ / | // | \ / |
|2 1 3| // |2 1 3|
| / \ | // | / \ |
|/ 1 \| // |/ 1 \|
3 ==== 4 */ // 3 ==== 4 */
//
//
// Check if the end iterator stays invalid after end // // Check if the end iterator stays invalid after end
Mesh::VertexOHalfedgeIter endIter = mesh_.voh_end(vhandle[1]); // Mesh::VertexOHalfedgeIter endIter = mesh_.voh_end(vhandle[1]);
EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid"; // EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid";
++endIter ; // ++endIter ;
EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid after increment"; // EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid after increment";
//
endIter = mesh_.voh_end(vhandle[1]); // endIter = mesh_.voh_end(vhandle[1]);
EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid"; // EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid";
--endIter; // --endIter;
EXPECT_TRUE(endIter.is_valid()) << "EndIter is invalid after decrement"; // EXPECT_TRUE(endIter.is_valid()) << "EndIter is invalid after decrement";
EXPECT_EQ(2,endIter->idx()) << "EndIter points on the wrong element"; // EXPECT_EQ(2,endIter->idx()) << "EndIter points on the wrong element";
//
//
// Check if the start iterator decrement is invalid // // Check if the start iterator decrement is invalid
Mesh::VertexOHalfedgeIter startIter = mesh_.voh_begin(vhandle[1]); // Mesh::VertexOHalfedgeIter startIter = mesh_.voh_begin(vhandle[1]);
EXPECT_TRUE(startIter.is_valid()) << "StartIter is not valid"; // EXPECT_TRUE(startIter.is_valid()) << "StartIter is not valid";
--startIter; // --startIter;
EXPECT_FALSE(startIter.is_valid()) << "StartIter decrement is not invalid"; // EXPECT_FALSE(startIter.is_valid()) << "StartIter decrement is not invalid";
//
// Check if the start iterator becomes valid // // Check if the start iterator becomes valid
++startIter; // ++startIter;
EXPECT_TRUE(startIter.is_valid()) << "StartIter is invalid after re-incrementing"; // 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"; // EXPECT_EQ(startIter->idx(), mesh_.voh_begin(vhandle[1])->idx()) << "StartIter points on the wrong element";
//
} //}
/* /*
* Test CW and CCW iterators * Test CW and CCW iterators

View File

@@ -203,85 +203,86 @@ TEST_F(OpenMeshTrimeshCirculatorVertexVertex, VertexVertexBoundaryIncrement) {
/* /*
* Test if the end iterator stays invalid after one lap * Test if the end iterator stays invalid after one lap
* DISABLED as long as the normal iterators using old behavior
*/ */
TEST_F(OpenMeshTrimeshCirculatorVertexVertex, VertexVertexIterCheckInvalidationAtEnds) { //TEST_F(OpenMeshTrimeshCirculatorVertexVertex, VertexVertexIterCheckInvalidationAtEnds) {
//
mesh_.clear(); // mesh_.clear();
//
// Add some vertices // // Add some vertices
Mesh::VertexHandle vhandle[5]; // Mesh::VertexHandle vhandle[5];
//
vhandle[0] = mesh_.add_vertex(Mesh::Point(0, 1, 0)); // vhandle[0] = mesh_.add_vertex(Mesh::Point(0, 1, 0));
vhandle[1] = mesh_.add_vertex(Mesh::Point(1, 0, 0)); // vhandle[1] = mesh_.add_vertex(Mesh::Point(1, 0, 0));
vhandle[2] = mesh_.add_vertex(Mesh::Point(2, 1, 0)); // vhandle[2] = mesh_.add_vertex(Mesh::Point(2, 1, 0));
vhandle[3] = mesh_.add_vertex(Mesh::Point(0,-1, 0)); // vhandle[3] = mesh_.add_vertex(Mesh::Point(0,-1, 0));
vhandle[4] = mesh_.add_vertex(Mesh::Point(2,-1, 0)); // vhandle[4] = mesh_.add_vertex(Mesh::Point(2,-1, 0));
//
// Add two faces // // Add two faces
std::vector<Mesh::VertexHandle> face_vhandles; // std::vector<Mesh::VertexHandle> face_vhandles;
//
face_vhandles.push_back(vhandle[0]); // face_vhandles.push_back(vhandle[0]);
face_vhandles.push_back(vhandle[1]); // face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[2]); // face_vhandles.push_back(vhandle[2]);
Mesh::FaceHandle fh0 = mesh_.add_face(face_vhandles); // Mesh::FaceHandle fh0 = mesh_.add_face(face_vhandles);
//
face_vhandles.clear(); // face_vhandles.clear();
//
face_vhandles.push_back(vhandle[1]); // face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[3]); // face_vhandles.push_back(vhandle[3]);
face_vhandles.push_back(vhandle[4]); // face_vhandles.push_back(vhandle[4]);
mesh_.add_face(face_vhandles); // mesh_.add_face(face_vhandles);
//
face_vhandles.clear(); // face_vhandles.clear();
//
face_vhandles.push_back(vhandle[0]); // face_vhandles.push_back(vhandle[0]);
face_vhandles.push_back(vhandle[3]); // face_vhandles.push_back(vhandle[3]);
face_vhandles.push_back(vhandle[1]); // face_vhandles.push_back(vhandle[1]);
mesh_.add_face(face_vhandles); // mesh_.add_face(face_vhandles);
//
face_vhandles.clear(); // face_vhandles.clear();
//
face_vhandles.push_back(vhandle[2]); // face_vhandles.push_back(vhandle[2]);
face_vhandles.push_back(vhandle[1]); // face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[4]); // face_vhandles.push_back(vhandle[4]);
mesh_.add_face(face_vhandles); // mesh_.add_face(face_vhandles);
//
/* Test setup: // /* Test setup:
0 ==== 2 // 0 ==== 2
|\ 0 /| // |\ 0 /|
| \ / | // | \ / |
|2 1 3| // |2 1 3|
| / \ | // | / \ |
|/ 1 \| // |/ 1 \|
3 ==== 4 */ // 3 ==== 4 */
//
//
// Check if the end iterator stays invalid after end // // Check if the end iterator stays invalid after end
Mesh::VertexVertexIter endIter = mesh_.vv_end(vhandle[1]); // Mesh::VertexVertexIter endIter = mesh_.vv_end(vhandle[1]);
EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid"; // EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid";
++endIter ; // ++endIter ;
EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid after increment"; // EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid after increment";
//
// Check if the end iterators becomes valid after decrement // // Check if the end iterators becomes valid after decrement
endIter = mesh_.vv_end(vhandle[1]); // endIter = mesh_.vv_end(vhandle[1]);
EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid"; // EXPECT_FALSE(endIter.is_valid()) << "EndIter is not invalid";
--endIter; // --endIter;
EXPECT_TRUE(endIter.is_valid()) << "EndIter is invalid after decrement"; // EXPECT_TRUE(endIter.is_valid()) << "EndIter is invalid after decrement";
EXPECT_EQ(2,endIter->idx()) << "EndIter points on the wrong element"; // EXPECT_EQ(2,endIter->idx()) << "EndIter points on the wrong element";
//
//
// Check if the start iterator decrement is invalid // // Check if the start iterator decrement is invalid
Mesh::VertexVertexIter startIter = mesh_.vv_begin(vhandle[1]); // Mesh::VertexVertexIter startIter = mesh_.vv_begin(vhandle[1]);
EXPECT_TRUE(startIter.is_valid()) << "StartIter is not valid"; // EXPECT_TRUE(startIter.is_valid()) << "StartIter is not valid";
--startIter; // --startIter;
EXPECT_FALSE(startIter.is_valid()) << "StartIter decrement is not invalid"; // EXPECT_FALSE(startIter.is_valid()) << "StartIter decrement is not invalid";
//
// Check if the start iterator becomes valid // // Check if the start iterator becomes valid
++startIter; // ++startIter;
EXPECT_TRUE(startIter.is_valid()) << "StartIter is invalid after re-incrementing"; // 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"; // EXPECT_EQ(startIter->idx(), mesh_.vv_begin(vhandle[1])->idx()) << "StartIter points on the wrong element";
//
} //}
/* /*
* Test CW and CCW iterators * Test CW and CCW iterators