- marked current_halfedge_handle as deprecated

- updated code to fix related warnings
- added some unittests to ensure unchanged behaviour when replacing current_halfedge_handle

git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@917 fdac6126-5c0c-442c-9429-916003d36597
This commit is contained in:
Isaak Lim
2013-08-08 12:47:48 +00:00
parent cb16ac26d6
commit 2eeb756b6a
7 changed files with 346 additions and 31 deletions

View File

@@ -140,7 +140,7 @@ public:
fh_iter != mesh_.fh_end(fh); ++fh_iter) fh_iter != mesh_.fh_end(fh); ++fh_iter)
{ {
//and write the normals to it //and write the normals to it
typename Mesh::HalfedgeHandle heh = fh_iter.current_halfedge_handle(); typename Mesh::HalfedgeHandle heh = *fh_iter;
typename Mesh::VertexHandle vh = mesh_.to_vertex_handle(heh); typename Mesh::VertexHandle vh = mesh_.to_vertex_handle(heh);
typename std::map<VertexHandle,Normal>::iterator it_heNs = halfedgeNormals_.find(vh); typename std::map<VertexHandle,Normal>::iterator it_heNs = halfedgeNormals_.find(vh);
if (it_heNs != halfedgeNormals_.end()) if (it_heNs != halfedgeNormals_.end())

View File

@@ -313,7 +313,7 @@ class GenericCirculatorT : protected GenericCirculatorBaseT<Mesh> {
return GenericCirculator_ValueHandleFns::is_valid(this->heh_, this->start_, this->lap_counter_); 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.")
/** /**
* \deprecated * \deprecated
* current_halfedge_handle() is an implementation detail and should not * current_halfedge_handle() is an implementation detail and should not

View File

@@ -57,9 +57,9 @@ PolyConnectivity::find_halfedge(VertexHandle _start_vh, VertexHandle _end_vh ) c
{ {
assert(_start_vh.is_valid() && _end_vh.is_valid()); assert(_start_vh.is_valid() && _end_vh.is_valid());
for (ConstVertexVertexIter vvIt=cvv_iter(_start_vh); vvIt.is_valid(); ++vvIt) for (ConstVertexOHalfedgeIter voh_it = cvoh_iter(_start_vh); voh_it.is_valid(); ++voh_it)
if (*vvIt == _end_vh) if (to_vertex_handle(*voh_it) == _end_vh)
return vvIt.current_halfedge_handle(); return *voh_it;
return InvalidHalfedgeHandle; return InvalidHalfedgeHandle;
} }

View File

@@ -134,19 +134,20 @@ float ModAspectRatioT<MeshT>::collapse_priority(const CollapseInfo& _ci) {
typename Mesh::FaceHandle fh; typename Mesh::FaceHandle fh;
const typename Mesh::Point *p1(&_ci.p1), *p2, *p3; const typename Mesh::Point *p1(&_ci.p1), *p2, *p3;
typename Mesh::Scalar r0, r1, r0_min(1.0), r1_min(1.0); typename Mesh::Scalar r0, r1, r0_min(1.0), r1_min(1.0);
typename Mesh::CVVIter vv_it(mesh_, _ci.v0); typename Mesh::ConstVertexOHalfedgeIter voh_it(mesh_, _ci.v0);
v3 = *vv_it; v3 = mesh_.to_vertex_handle(*voh_it);
p3 = &mesh_.point(v3); p3 = &mesh_.point(v3);
while (vv_it.is_valid()) { while (voh_it.is_valid()) {
v2 = v3; v2 = v3;
p2 = p3; p2 = p3;
v3 = *(++vv_it); ++voh_it;
v3 = mesh_.to_vertex_handle(*voh_it);
p3 = &mesh_.point(v3); p3 = &mesh_.point(v3);
fh = mesh_.face_handle(vv_it.current_halfedge_handle()); fh = mesh_.face_handle(*voh_it);
// if not boundary // if not boundary
if (fh.is_valid()) { if (fh.is_valid()) {

View File

@@ -98,7 +98,7 @@ JacobiLaplaceSmootherT<Mesh>::
compute_new_positions_C0() compute_new_positions_C0()
{ {
typename Mesh::VertexIter v_it, v_end(Base::mesh_.vertices_end()); typename Mesh::VertexIter v_it, v_end(Base::mesh_.vertices_end());
typename Mesh::CVVIter vv_it; typename Mesh::ConstVertexOHalfedgeIter voh_it;
typename Mesh::Normal u, p, zero(0,0,0); typename Mesh::Normal u, p, zero(0,0,0);
typename Mesh::Scalar w; typename Mesh::Scalar w;
@@ -108,10 +108,9 @@ compute_new_positions_C0()
{ {
// compute umbrella // compute umbrella
u = zero; u = zero;
for (vv_it=Base::mesh_.cvv_iter(*v_it); vv_it.is_valid(); ++vv_it) for (voh_it = Base::mesh_.cvoh_iter(*v_it); voh_it.is_valid(); ++voh_it) {
{ w = this->weight(Base::mesh_.edge_handle(*voh_it));
w = this->weight(Base::mesh_.edge_handle(vv_it.current_halfedge_handle())); u += vector_cast<typename Mesh::Normal>(Base::mesh_.point(Base::mesh_.to_vertex_handle(*voh_it))) * w;
u += vector_cast<typename Mesh::Normal>(Base::mesh_.point(*vv_it)) * w;
} }
u *= this->weight(*v_it); u *= this->weight(*v_it);
u -= vector_cast<typename Mesh::Normal>(Base::mesh_.point(*v_it)); u -= vector_cast<typename Mesh::Normal>(Base::mesh_.point(*v_it));
@@ -137,7 +136,7 @@ JacobiLaplaceSmootherT<Mesh>::
compute_new_positions_C1() compute_new_positions_C1()
{ {
typename Mesh::VertexIter v_it, v_end(Base::mesh_.vertices_end()); typename Mesh::VertexIter v_it, v_end(Base::mesh_.vertices_end());
typename Mesh::CVVIter vv_it; typename Mesh::ConstVertexOHalfedgeIter voh_it;
typename Mesh::Normal u, uu, p, zero(0,0,0); typename Mesh::Normal u, uu, p, zero(0,0,0);
typename Mesh::Scalar w, diag; typename Mesh::Scalar w, diag;
@@ -146,10 +145,9 @@ compute_new_positions_C1()
for (v_it=Base::mesh_.vertices_begin(); v_it!=v_end; ++v_it) for (v_it=Base::mesh_.vertices_begin(); v_it!=v_end; ++v_it)
{ {
u = zero; u = zero;
for (vv_it=Base::mesh_.cvv_iter(*v_it); vv_it.is_valid(); ++vv_it) for (voh_it = Base::mesh_.cvoh_iter(*v_it); voh_it.is_valid(); ++voh_it) {
{ w = this->weight(Base::mesh_.edge_handle(*voh_it));
w = this->weight(Base::mesh_.edge_handle(vv_it.current_halfedge_handle())); u -= vector_cast<typename Mesh::Normal>(Base::mesh_.point(Base::mesh_.to_vertex_handle(*voh_it)))*w;
u -= vector_cast<typename Mesh::Normal>(Base::mesh_.point(*vv_it))*w;
} }
u *= this->weight(*v_it); u *= this->weight(*v_it);
u += vector_cast<typename Mesh::Normal>(Base::mesh_.point(*v_it)); u += vector_cast<typename Mesh::Normal>(Base::mesh_.point(*v_it));
@@ -165,11 +163,10 @@ compute_new_positions_C1()
{ {
uu = zero; uu = zero;
diag = 0.0; diag = 0.0;
for (vv_it=Base::mesh_.cvv_iter(*v_it); vv_it.is_valid(); ++vv_it) for (voh_it = Base::mesh_.cvoh_iter(*v_it); voh_it.is_valid(); ++voh_it) {
{ w = this->weight(Base::mesh_.edge_handle(*voh_it));
w = this->weight(Base::mesh_.edge_handle(vv_it.current_halfedge_handle())); uu -= Base::mesh_.property(umbrellas_, Base::mesh_.to_vertex_handle(*voh_it));
uu -= Base::mesh_.property(umbrellas_, *vv_it); diag += (w * this->weight(Base::mesh_.to_vertex_handle(*voh_it)) + 1.0) * w;
diag += (w * this->weight(*vv_it) + 1.0) * w;
} }
uu *= this->weight(*v_it); uu *= this->weight(*v_it);
diag *= this->weight(*v_it); diag *= this->weight(*v_it);

View File

@@ -36,6 +36,7 @@
#include "unittests_trimesh_circulator_vertex_ihalfedge.hh" #include "unittests_trimesh_circulator_vertex_ihalfedge.hh"
#include "unittests_trimesh_circulator_vertex_ohalfedge.hh" #include "unittests_trimesh_circulator_vertex_ohalfedge.hh"
#include "unittests_trimesh_circulator_vertex_vertex.hh" #include "unittests_trimesh_circulator_vertex_vertex.hh"
#include "unittests_trimesh_circulator_current_halfedge_handle_replacement.hh"
int main(int _argc, char** _argv) { int main(int _argc, char** _argv) {

View File

@@ -0,0 +1,316 @@
#ifndef UNITTESTS_TRIMESH_CIRCULATOR_CURRENT_HANDLE_REPLACEMENT_HH
#define UNITTESTS_TRIMESH_CIRCULATOR_CURRENT_HANDLE_REPLACEMENT_HH
#include <gtest/gtest.h>
#include <Unittests/unittests_common.hh>
#include <iostream>
class OpenMeshTrimeshCirculatorCurrentHalfedgeHandleReplacement : public OpenMeshBase {
protected:
// This function is called before each test is run
virtual void SetUp() {
}
// This function is called after all tests are through
virtual void TearDown() {
// Do some final stuff with the member data here...
}
// Member already defined in OpenMeshBase
//Mesh mesh_;
};
/*
* ====================================================================
* Define tests below
* ====================================================================
*/
/*
* duplicate dereferencing behaviour
*/
TEST_F(OpenMeshTrimeshCirculatorCurrentHalfedgeHandleReplacement, dereference) {
mesh_.clear();
// Add some vertices
Mesh::VertexHandle vhandle[5];
vhandle[0] = mesh_.add_vertex(Mesh::Point(0, 1, 0));
vhandle[1] = mesh_.add_vertex(Mesh::Point(1, 0, 0));
vhandle[2] = mesh_.add_vertex(Mesh::Point(2, 1, 0));
vhandle[3] = mesh_.add_vertex(Mesh::Point(0,-1, 0));
vhandle[4] = mesh_.add_vertex(Mesh::Point(2,-1, 0));
// Add two faces
std::vector<Mesh::VertexHandle> face_vhandles;
face_vhandles.push_back(vhandle[0]);
face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[2]);
mesh_.add_face(face_vhandles);
face_vhandles.clear();
face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[3]);
face_vhandles.push_back(vhandle[4]);
mesh_.add_face(face_vhandles);
face_vhandles.clear();
face_vhandles.push_back(vhandle[0]);
face_vhandles.push_back(vhandle[3]);
face_vhandles.push_back(vhandle[1]);
mesh_.add_face(face_vhandles);
face_vhandles.clear();
face_vhandles.push_back(vhandle[2]);
face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[4]);
mesh_.add_face(face_vhandles);
/* Test setup:
0 ==== 2
|\ 0 /|
| \ / |
|2 1 3|
| / \ |
|/ 1 \|
3 ==== 4 */
// Starting vertex is 1->4
for (Mesh::FaceIter f_it = mesh_.faces_begin(); f_it != mesh_.faces_end(); ++f_it) {
for (Mesh::FaceHalfedgeIter fh_it = mesh_.fh_iter(*f_it); fh_it.is_valid(); ++fh_it) {
EXPECT_EQ(fh_it.current_halfedge_handle(), *fh_it ) << "halfedge handles don't match";
}
}
}
/*
* duplicate vv_iter behaviour
*/
TEST_F(OpenMeshTrimeshCirculatorCurrentHalfedgeHandleReplacement, vv_iter) {
mesh_.clear();
// Add some vertices
Mesh::VertexHandle vhandle[5];
vhandle[0] = mesh_.add_vertex(Mesh::Point(0, 1, 0));
vhandle[1] = mesh_.add_vertex(Mesh::Point(1, 0, 0));
vhandle[2] = mesh_.add_vertex(Mesh::Point(2, 1, 0));
vhandle[3] = mesh_.add_vertex(Mesh::Point(0,-1, 0));
vhandle[4] = mesh_.add_vertex(Mesh::Point(2,-1, 0));
// Add two faces
std::vector<Mesh::VertexHandle> face_vhandles;
face_vhandles.push_back(vhandle[0]);
face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[2]);
mesh_.add_face(face_vhandles);
face_vhandles.clear();
face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[3]);
face_vhandles.push_back(vhandle[4]);
mesh_.add_face(face_vhandles);
face_vhandles.clear();
face_vhandles.push_back(vhandle[0]);
face_vhandles.push_back(vhandle[3]);
face_vhandles.push_back(vhandle[1]);
mesh_.add_face(face_vhandles);
face_vhandles.clear();
face_vhandles.push_back(vhandle[2]);
face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[4]);
mesh_.add_face(face_vhandles);
/* Test setup:
0 ==== 2
|\ 0 /|
| \ / |
|2 1 3|
| / \ |
|/ 1 \|
3 ==== 4 */
// Starting vertex is 1->4
std::vector<Mesh::EdgeHandle> eh0;
std::vector<Mesh::EdgeHandle> eh1;
for (Mesh::VertexIter v_it = mesh_.vertices_begin(); v_it != mesh_.vertices_end(); ++v_it) {
for (Mesh::VertexVertexIter vv_it = mesh_.vv_iter(*v_it); vv_it.is_valid(); ++vv_it)
eh0.push_back(mesh_.edge_handle(vv_it.current_halfedge_handle()));
}
for (Mesh::VertexIter v_it = mesh_.vertices_begin(); v_it != mesh_.vertices_end(); ++v_it) {
for (Mesh::VertexOHalfedgeIter voh_it = mesh_.voh_iter(*v_it); voh_it.is_valid(); ++voh_it)
eh1.push_back(mesh_.edge_handle(*voh_it));
}
EXPECT_EQ(eh0.size(), eh1.size()) << "size of vectors does not match";
for (size_t i = 0; i < eh0.size(); ++i)
EXPECT_EQ(eh0[i], eh1[i]) << "edge handles do not match";
}
/*
* duplicate fe_iter behaviour
*/
TEST_F(OpenMeshTrimeshCirculatorCurrentHalfedgeHandleReplacement, fe_iter) {
mesh_.clear();
// Add some vertices
Mesh::VertexHandle vhandle[5];
vhandle[0] = mesh_.add_vertex(Mesh::Point(0, 1, 0));
vhandle[1] = mesh_.add_vertex(Mesh::Point(1, 0, 0));
vhandle[2] = mesh_.add_vertex(Mesh::Point(2, 1, 0));
vhandle[3] = mesh_.add_vertex(Mesh::Point(0,-1, 0));
vhandle[4] = mesh_.add_vertex(Mesh::Point(2,-1, 0));
// Add two faces
std::vector<Mesh::VertexHandle> face_vhandles;
face_vhandles.push_back(vhandle[0]);
face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[2]);
mesh_.add_face(face_vhandles);
face_vhandles.clear();
face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[3]);
face_vhandles.push_back(vhandle[4]);
mesh_.add_face(face_vhandles);
face_vhandles.clear();
face_vhandles.push_back(vhandle[0]);
face_vhandles.push_back(vhandle[3]);
face_vhandles.push_back(vhandle[1]);
mesh_.add_face(face_vhandles);
face_vhandles.clear();
face_vhandles.push_back(vhandle[2]);
face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[4]);
mesh_.add_face(face_vhandles);
/* Test setup:
0 ==== 2
|\ 0 /|
| \ / |
|2 1 3|
| / \ |
|/ 1 \|
3 ==== 4 */
// Starting vertex is 1->4
std::vector<Mesh::HalfedgeHandle> heh0;
std::vector<Mesh::HalfedgeHandle> heh1;
for (Mesh::FaceIter f_it = mesh_.faces_begin(); f_it != mesh_.faces_end(); ++f_it) {
for (Mesh::FaceEdgeIter fe_it = mesh_.fe_iter(*f_it); fe_it.is_valid(); ++fe_it) {
heh0.push_back(fe_it.current_halfedge_handle());
}
}
for (Mesh::FaceIter f_it = mesh_.faces_begin(); f_it != mesh_.faces_end(); ++f_it) {
for (Mesh::FaceHalfedgeIter fh_it = mesh_.fh_iter(*f_it); fh_it.is_valid(); ++fh_it) {
heh1.push_back(*fh_it);
}
}
EXPECT_EQ(heh0.size(), heh1.size()) << "size of vectors does not match";
for (size_t i = 0; i < heh0.size(); ++i)
EXPECT_EQ(heh0[i], heh1[i]) << "halfedge handles do not match";
}
/*
* duplicate find_halfedge behaviour
*/
TEST_F(OpenMeshTrimeshCirculatorCurrentHalfedgeHandleReplacement, find_halfedge) {
mesh_.clear();
// Add some vertices
Mesh::VertexHandle vhandle[5];
vhandle[0] = mesh_.add_vertex(Mesh::Point(0, 1, 0));
vhandle[1] = mesh_.add_vertex(Mesh::Point(1, 0, 0));
vhandle[2] = mesh_.add_vertex(Mesh::Point(2, 1, 0));
vhandle[3] = mesh_.add_vertex(Mesh::Point(0,-1, 0));
vhandle[4] = mesh_.add_vertex(Mesh::Point(2,-1, 0));
// Add two faces
std::vector<Mesh::VertexHandle> face_vhandles;
face_vhandles.push_back(vhandle[0]);
face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[2]);
mesh_.add_face(face_vhandles);
face_vhandles.clear();
face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[3]);
face_vhandles.push_back(vhandle[4]);
mesh_.add_face(face_vhandles);
face_vhandles.clear();
face_vhandles.push_back(vhandle[0]);
face_vhandles.push_back(vhandle[3]);
face_vhandles.push_back(vhandle[1]);
mesh_.add_face(face_vhandles);
face_vhandles.clear();
face_vhandles.push_back(vhandle[2]);
face_vhandles.push_back(vhandle[1]);
face_vhandles.push_back(vhandle[4]);
mesh_.add_face(face_vhandles);
/* Test setup:
0 ==== 2
|\ 0 /|
| \ / |
|2 1 3|
| / \ |
|/ 1 \|
3 ==== 4 */
// Starting vertex is 1->4
Mesh::HalfedgeHandle hh = mesh_.find_halfedge(vhandle[0], vhandle[1]);
Mesh::HalfedgeHandle hh1;
for (Mesh::VertexOHalfedgeIter voh_it = mesh_.voh_iter(vhandle[0]); voh_it.is_valid(); ++voh_it) {
if (mesh_.to_vertex_handle(*voh_it) == vhandle[1]) {
hh1 = *voh_it;
break;
}
}
EXPECT_EQ(hh, hh1 ) << "halfedge handles don't match";
}
#endif // UNITTESTS_TRIMESH_CIRCULATOR_CURRENT_HANDLE_REPLACEMENT_HH