Commit a3f36c2d authored by Jan Möbius's avatar Jan Möbius

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
parent e658918c
......@@ -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<VertexHandle>& _vhandles)
{ return add_face(&_vhandles.front(), _vhandles.size()); }
//-----------------------------------------------------------------------------
......
......@@ -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<VertexHandle>& _vhandles)
{ return add_face(&_vhandles.front(), _vhandles.size()); }
FaceHandle add_face(const std::vector<VertexHandle>& _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
......
......@@ -82,6 +82,23 @@ TriConnectivity::add_face(const VertexHandle* _vertex_handles, size_t _vhs_size)
}
//-----------------------------------------------------------------------------
FaceHandle TriConnectivity::add_face(const std::vector<VertexHandle>& _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?
......
......@@ -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<VertexHandle>& _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<VertexHandle>& _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);
//@}
......
......@@ -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) {
......
......@@ -5,12 +5,15 @@
#include <OpenMesh/Core/IO/MeshIO.hh>
#include <OpenMesh/Core/Mesh/TriMesh_ArrayKernelT.hh>
#include <OpenMesh/Core/Mesh/PolyMesh_ArrayKernelT.hh>
struct CustomTraits : public OpenMesh::DefaultTraits {
};
typedef OpenMesh::TriMesh_ArrayKernelT<CustomTraits> Mesh;
typedef OpenMesh::PolyMesh_ArrayKernelT<CustomTraits> 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
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