Commit 8ece0770 authored by Hans-Christian Ebke's avatar Hans-Christian Ebke
Browse files

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

parent 011fdc97
Pipeline #562 passed with stage
......@@ -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); }
......
......@@ -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();
}
......
......@@ -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
......
......@@ -200,6 +200,22 @@ public:
//---------------------------------------------------- synchronize properties
#if (_MSC_VER >= 1900 || __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__)) && !defined(OPENMESH_VECTOR_LEGACY)
void reserve(size_t _n) const {
std::for_each(properties_.begin(), properties_.end(),
[_n](BaseProperty* p) { if (p) p->reserve(_n); });
}
void resize(size_t _n) const {
std::for_each(properties_.begin(), properties_.end(),
[_n](BaseProperty* p) { if (p) p->resize(_n); });
}
void swap(size_t _i0, size_t _i1) const {
std::for_each(properties_.begin(), properties_.end(),
[_i0, _i1](BaseProperty* p) { if (p) p->swap(_i0, _i1); });
}
#else
void reserve(size_t _n) const {
std::for_each(properties_.begin(), properties_.end(), Reserve(_n));
}
......@@ -211,6 +227,7 @@ public:
void swap(size_t _i0, size_t _i1) const {
std::for_each(properties_.begin(), properties_.end(), Swap(_i0, _i1));
}
#endif
......
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