From a3f36c2d73755953c463bfb9cbb4f1832e28aa9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Thu, 21 Jun 2012 07:55:12 +0000 Subject: [PATCH] Some documentation and cleanup for the add_face functions. Unittests for add_face on triangle and quad meshes. git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@600 fdac6126-5c0c-442c-9429-916003d36597 --- src/OpenMesh/Core/Mesh/PolyConnectivity.cc | 21 +++++++++++ src/OpenMesh/Core/Mesh/PolyConnectivity.hh | 16 +++------ src/OpenMesh/Core/Mesh/TriConnectivity.cc | 17 +++++++++ src/OpenMesh/Core/Mesh/TriConnectivity.hh | 42 ++++++++++++++++------ src/Unittests/unittests.cc | 1 + src/Unittests/unittests_common.hh | 29 +++++++++++++++ 6 files changed, 103 insertions(+), 23 deletions(-) diff --git a/src/OpenMesh/Core/Mesh/PolyConnectivity.cc b/src/OpenMesh/Core/Mesh/PolyConnectivity.cc index 30a6b64e..3b473e88 100644 --- a/src/OpenMesh/Core/Mesh/PolyConnectivity.cc +++ b/src/OpenMesh/Core/Mesh/PolyConnectivity.cc @@ -51,6 +51,7 @@ const PolyConnectivity::EdgeHandle PolyConnectivity::InvalidEdgeHandle; const PolyConnectivity::FaceHandle PolyConnectivity::InvalidFaceHandle; //----------------------------------------------------------------------------- + PolyConnectivity::HalfedgeHandle PolyConnectivity::find_halfedge(VertexHandle _start_vh, VertexHandle _end_vh ) const { @@ -279,6 +280,26 @@ PolyConnectivity::add_face(const VertexHandle* _vertex_handles, size_t _vhs_size return fh; } +//----------------------------------------------------------------------------- + +FaceHandle PolyConnectivity::add_face(VertexHandle _vh0, VertexHandle _vh1, VertexHandle _vh2, VertexHandle _vh3) +{ + VertexHandle vhs[4] = { _vh0, _vh1, _vh2, _vh3 }; + return add_face(vhs, 4); +} + +//----------------------------------------------------------------------------- + +FaceHandle PolyConnectivity::add_face(VertexHandle _vh0, VertexHandle _vh1, VertexHandle _vh2) +{ + VertexHandle vhs[3] = { _vh0, _vh1, _vh2 }; + return add_face(vhs, 3); +} + +//----------------------------------------------------------------------------- + +FaceHandle PolyConnectivity::add_face(const std::vector& _vhandles) +{ return add_face(&_vhandles.front(), _vhandles.size()); } //----------------------------------------------------------------------------- diff --git a/src/OpenMesh/Core/Mesh/PolyConnectivity.hh b/src/OpenMesh/Core/Mesh/PolyConnectivity.hh index bf951f01..3f4415c1 100644 --- a/src/OpenMesh/Core/Mesh/PolyConnectivity.hh +++ b/src/OpenMesh/Core/Mesh/PolyConnectivity.hh @@ -187,8 +187,7 @@ public: * * @param _vhandles sorted list of vertex handles (also defines order in which the vertices are added to the face) */ - FaceHandle add_face(const std::vector& _vhandles) - { return add_face(&_vhandles.front(), _vhandles.size()); } + FaceHandle add_face(const std::vector& _vhandles); /** \brief Add and connect a new face @@ -200,11 +199,7 @@ public: * @param _vh1 Second vertex handle * @param _vh2 Third vertex handle */ - FaceHandle add_face(VertexHandle _vh0, VertexHandle _vh1, VertexHandle _vh2) - { - VertexHandle vhs[3] = { _vh0, _vh1, _vh2 }; - return add_face(vhs, 3); - } + FaceHandle add_face(VertexHandle _vh0, VertexHandle _vh1, VertexHandle _vh2); /** \brief Add and connect a new face * @@ -216,11 +211,7 @@ public: * @param _vh2 Third vertex handle * @param _vh3 Fourth vertex handle */ - FaceHandle add_face(VertexHandle _vh0, VertexHandle _vh1, VertexHandle _vh2, VertexHandle _vh3) - { - VertexHandle vhs[4] = { _vh0, _vh1, _vh2, _vh3 }; - return add_face(vhs, 4); - } + FaceHandle add_face(VertexHandle _vh0, VertexHandle _vh1, VertexHandle _vh2, VertexHandle _vh3); /** \brief Add and connect a new face * @@ -231,6 +222,7 @@ public: * @param _vhs_size number of vertex handles in the array */ FaceHandle add_face(const VertexHandle* _vhandles, size_t _vhs_size); + //@} /// \name Deleting mesh items and other connectivity/topology modifications diff --git a/src/OpenMesh/Core/Mesh/TriConnectivity.cc b/src/OpenMesh/Core/Mesh/TriConnectivity.cc index c8b24906..1f8a6cc6 100644 --- a/src/OpenMesh/Core/Mesh/TriConnectivity.cc +++ b/src/OpenMesh/Core/Mesh/TriConnectivity.cc @@ -82,6 +82,23 @@ TriConnectivity::add_face(const VertexHandle* _vertex_handles, size_t _vhs_size) } //----------------------------------------------------------------------------- + +FaceHandle TriConnectivity::add_face(const std::vector& _vhandles) +{ + return add_face(&_vhandles.front(), _vhandles.size()); +} + +//----------------------------------------------------------------------------- + + +FaceHandle TriConnectivity::add_face(VertexHandle _vh0, VertexHandle _vh1, VertexHandle _vh2) +{ + VertexHandle vhs[3] = { _vh0, _vh1, _vh2 }; + return PolyConnectivity::add_face(vhs, 3); +} + +//----------------------------------------------------------------------------- + bool TriConnectivity::is_collapse_ok(HalfedgeHandle v0v1) { // is the edge already deleted? diff --git a/src/OpenMesh/Core/Mesh/TriConnectivity.hh b/src/OpenMesh/Core/Mesh/TriConnectivity.hh index 1015b8fd..c1e43fb4 100644 --- a/src/OpenMesh/Core/Mesh/TriConnectivity.hh +++ b/src/OpenMesh/Core/Mesh/TriConnectivity.hh @@ -72,20 +72,40 @@ public: /** \name Addding items to a mesh */ + //@{ - /** Override OpenMesh::Mesh::PolyMeshT::add_face(). Faces that aren't - triangles will be triangulated and added. In this case an - invalid face handle will be returned. */ - FaceHandle add_face(const std::vector& _vhandles) - { return add_face(&_vhandles.front(), _vhandles.size()); } - + + /** \brief Add a face with arbitrary valence to the triangle mesh + * + * Override OpenMesh::Mesh::PolyMeshT::add_face(). Faces that aren't + * triangles will be triangulated and added. In this case an + * invalid face handle will be returned. + * + * + * */ FaceHandle add_face(const VertexHandle* _vhandles, size_t _vhs_size); - FaceHandle add_face(VertexHandle _vh0, VertexHandle _vh1, VertexHandle _vh2) - { - VertexHandle vhs[3] = { _vh0, _vh1, _vh2 }; - return PolyConnectivity::add_face(vhs, 3); - } + /** \brief Add a face with arbitrary valence to the triangle mesh + * + * Override OpenMesh::Mesh::PolyMeshT::add_face(). Faces that aren't + * triangles will be triangulated and added. In this case an + * invalid face handle will be returned. + * + * + * */ + FaceHandle add_face(const std::vector& _vhandles); + + /** \brief Add a face to the mesh (triangle) + * + * This function adds a triangle to the mesh. The triangle is passed directly + * to the underlying PolyConnectivity as we don't explicitly need to triangulate something. + * + * @param _vh0 VertexHandle 1 + * @param _vh1 VertexHandle 2 + * @param _vh2 VertexHandle 3 + * @return FaceHandle of the added face (invalid, if the operation failed) + */ + FaceHandle add_face(VertexHandle _vh0, VertexHandle _vh1, VertexHandle _vh2); //@} diff --git a/src/Unittests/unittests.cc b/src/Unittests/unittests.cc index b4420075..636de273 100644 --- a/src/Unittests/unittests.cc +++ b/src/Unittests/unittests.cc @@ -9,6 +9,7 @@ #include "unittests_decimater.hh" #include "unittests_trimesh_normal_calculations.hh" #include "unittests_trimesh_others.hh" +#include "unittests_add_face.hh" int main(int _argc, char** _argv) { diff --git a/src/Unittests/unittests_common.hh b/src/Unittests/unittests_common.hh index cbf23f67..cbabb9cb 100644 --- a/src/Unittests/unittests_common.hh +++ b/src/Unittests/unittests_common.hh @@ -5,12 +5,15 @@ #include #include +#include struct CustomTraits : public OpenMesh::DefaultTraits { }; typedef OpenMesh::TriMesh_ArrayKernelT Mesh; +typedef OpenMesh::PolyMesh_ArrayKernelT PolyMesh; + /* * Simple test setting. */ @@ -35,4 +38,30 @@ class OpenMeshBase : public testing::Test { Mesh mesh_; }; +/* + * Simple test setting. + */ + +class OpenMeshBasePoly : public testing::Test { + + protected: + + // This function is called before each test is run + virtual void SetUp() { + + // Do some initial stuff with the member data here... + } + + // This function is called after all tests are through + virtual void TearDown() { + + // Do some final stuff with the member data here... + } + + // This member will be accessible in all tests + PolyMesh mesh_; +}; + + + #endif // INCLUDE GUARD