Commit a3fbdcb9 authored by Max Lyon's avatar Max Lyon
Browse files

let add_vertex and add_face return smart handles

parent e222791c
......@@ -113,7 +113,7 @@ void PolyConnectivity::adjust_outgoing_halfedge(VertexHandle _vh)
//-----------------------------------------------------------------------------
PolyConnectivity::FaceHandle
SmartFaceHandle
PolyConnectivity::add_face(const VertexHandle* _vertex_handles, size_t _vhs_size)
{
VertexHandle vh;
......@@ -142,7 +142,7 @@ PolyConnectivity::add_face(const VertexHandle* _vertex_handles, size_t _vhs_size
if ( !is_boundary(_vertex_handles[i]) )
{
omerr() << "PolyMeshT::add_face: complex vertex\n";
return InvalidFaceHandle;
return make_smart(InvalidFaceHandle, this);
}
// Initialise edge attributes
......@@ -154,7 +154,7 @@ PolyConnectivity::add_face(const VertexHandle* _vertex_handles, size_t _vhs_size
if (!edgeData_[i].is_new && !is_boundary(edgeData_[i].halfedge_handle))
{
omerr() << "PolyMeshT::add_face: complex edge\n";
return InvalidFaceHandle;
return make_smart(InvalidFaceHandle, this);
}
}
......@@ -186,7 +186,7 @@ PolyConnectivity::add_face(const VertexHandle* _vertex_handles, size_t _vhs_size
if (boundary_prev == inner_prev)
{
omerr() << "PolyMeshT::add_face: patch re-linking failed\n";
return InvalidFaceHandle;
return make_smart(InvalidFaceHandle, this);
}
assert(is_boundary(boundary_prev));
......@@ -297,12 +297,12 @@ PolyConnectivity::add_face(const VertexHandle* _vertex_handles, size_t _vhs_size
if (edgeData_[i].needs_adjust)
adjust_outgoing_halfedge(_vertex_handles[i]);
return fh;
return make_smart(fh, this);
}
//-----------------------------------------------------------------------------
FaceHandle PolyConnectivity::add_face(VertexHandle _vh0, VertexHandle _vh1, VertexHandle _vh2, VertexHandle _vh3)
SmartFaceHandle PolyConnectivity::add_face(VertexHandle _vh0, VertexHandle _vh1, VertexHandle _vh2, VertexHandle _vh3)
{
VertexHandle vhs[4] = { _vh0, _vh1, _vh2, _vh3 };
return add_face(vhs, 4);
......@@ -310,7 +310,7 @@ FaceHandle PolyConnectivity::add_face(VertexHandle _vh0, VertexHandle _vh1, Vert
//-----------------------------------------------------------------------------
FaceHandle PolyConnectivity::add_face(VertexHandle _vh0, VertexHandle _vh1, VertexHandle _vh2)
SmartFaceHandle PolyConnectivity::add_face(VertexHandle _vh0, VertexHandle _vh1, VertexHandle _vh2)
{
VertexHandle vhs[3] = { _vh0, _vh1, _vh2 };
return add_face(vhs, 3);
......@@ -318,9 +318,17 @@ FaceHandle PolyConnectivity::add_face(VertexHandle _vh0, VertexHandle _vh1, Vert
//-----------------------------------------------------------------------------
FaceHandle PolyConnectivity::add_face(const std::vector<VertexHandle>& _vhandles)
SmartFaceHandle PolyConnectivity::add_face(const std::vector<VertexHandle>& _vhandles)
{ return add_face(&_vhandles.front(), _vhandles.size()); }
//-----------------------------------------------------------------------------
SmartFaceHandle PolyConnectivity::add_face(const std::vector<SmartVertexHandle>& _vhandles)
{
std::vector<VertexHandle> vhandles(_vhandles.begin(), _vhandles.end());
return add_face(&vhandles.front(), vhandles.size());
}
//-----------------------------------------------------------------------------
bool PolyConnectivity::is_collapse_ok(HalfedgeHandle v0v1)
......
......@@ -481,8 +481,7 @@ public:
//@{
/// Add a new vertex
inline VertexHandle add_vertex()
{ return new_vertex(); }
inline SmartVertexHandle add_vertex();
/** \brief Add and connect a new face
*
......@@ -491,7 +490,16 @@ 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);
SmartFaceHandle add_face(const std::vector<VertexHandle>& _vhandles);
/** \brief Add and connect a new face
*
* Create a new face consisting of the vertices provided by the vertex handle vector.
* (The vertices have to be already added to the mesh by add_vertex)
*
* @param _vhandles sorted list of vertex handles (also defines order in which the vertices are added to the face)
*/
SmartFaceHandle add_face(const std::vector<SmartVertexHandle>& _vhandles);
/** \brief Add and connect a new face
......@@ -503,7 +511,7 @@ public:
* @param _vh1 Second vertex handle
* @param _vh2 Third vertex handle
*/
FaceHandle add_face(VertexHandle _vh0, VertexHandle _vh1, VertexHandle _vh2);
SmartFaceHandle add_face(VertexHandle _vh0, VertexHandle _vh1, VertexHandle _vh2);
/** \brief Add and connect a new face
*
......@@ -515,7 +523,7 @@ public:
* @param _vh2 Third vertex handle
* @param _vh3 Fourth vertex handle
*/
FaceHandle add_face(VertexHandle _vh0, VertexHandle _vh1, VertexHandle _vh2, VertexHandle _vh3);
SmartFaceHandle add_face(VertexHandle _vh0, VertexHandle _vh1, VertexHandle _vh2, VertexHandle _vh3);
/** \brief Add and connect a new face
*
......@@ -525,7 +533,7 @@ public:
* @param _vhandles pointer to a sorted list of vertex handles (also defines order in which the vertices are added to the face)
* @param _vhs_size number of vertex handles in the array
*/
FaceHandle add_face(const VertexHandle* _vhandles, size_t _vhs_size);
SmartFaceHandle add_face(const VertexHandle* _vhandles, size_t _vhs_size);
//@}
......@@ -1526,6 +1534,8 @@ private: // Working storage for add_face()
namespace OpenMesh {
inline SmartVertexHandle PolyConnectivity::add_vertex() { return make_smart(new_vertex(), *this); }
inline SmartHalfedgeHandle PolyConnectivity::next_halfedge_handle(SmartHalfedgeHandle _heh) const { return make_smart(next_halfedge_handle(HalfedgeHandle(_heh)), *this); }
inline SmartHalfedgeHandle PolyConnectivity::prev_halfedge_handle(SmartHalfedgeHandle _heh) const { return make_smart(prev_halfedge_handle(HalfedgeHandle(_heh)), *this); }
inline SmartHalfedgeHandle PolyConnectivity::opposite_halfedge_handle(SmartHalfedgeHandle _heh) const { return make_smart(opposite_halfedge_handle(HalfedgeHandle(_heh)), *this); }
......
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