Added a couple of methods to enable more efficient adding of batches of vertices.

This commit is contained in:
Hans-Christian Ebke
2015-12-20 23:07:54 +01:00
parent 011fdc9700
commit 8ece0770a3
4 changed files with 42 additions and 0 deletions

View File

@@ -217,6 +217,14 @@ public:
return handle(vertices_.back());
}
inline VertexHandle new_vertex_dirty()
{
vertices_.push_back(Vertex());
vprops_resize_if_smaller(n_vertices());//TODO:should it be push_back()?
return handle(vertices_.back());
}
inline HalfedgeHandle new_edge(VertexHandle _start_vh, VertexHandle _end_vh)
{
// assert(_start_vh != _end_vh);
@@ -479,6 +487,12 @@ public:
StatusInfo& status(VertexHandle _vh)
{ return property(vertex_status_, _vh); }
void reset_status() {
PropertyT<StatusInfo> &status_prop = property(vertex_status_);
PropertyT<StatusInfo>::vector_type &sprop_v = status_prop.data_vector();
std::fill(sprop_v.begin(), sprop_v.begin() + n_vertices(), StatusInfo());
}
//----------------------------------------------------------- halfedge status
const StatusInfo& status(HalfedgeHandle _hh) const
{ return property(halfedge_status_, _hh); }

View File

@@ -648,6 +648,7 @@ protected: //------------------------------------------- synchronize properties
void vprops_reserve(size_t _n) const { vprops_.reserve(_n); }
void vprops_resize(size_t _n) const { vprops_.resize(_n); }
void vprops_resize_if_smaller(size_t _n) const { if (vprops_.size() < _n) vprops_.resize(_n); }
void vprops_clear() {
vprops_.clear();
}

View File

@@ -203,9 +203,19 @@ public:
return vh;
}
inline VertexHandle new_vertex_dirty(const Point& _p)
{
VertexHandle vh(Kernel::new_vertex_dirty());
this->set_point(vh, _p);
return vh;
}
inline VertexHandle add_vertex(const Point& _p)
{ return new_vertex(_p); }
inline VertexHandle add_vertex_dirty(const Point& _p)
{ return new_vertex_dirty(_p); }
// --- normal vectors ---
/** \name Normal vector computation