diff options
-rw-r--r-- | source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp | 12 | ||||
-rw-r--r-- | source/blender/freestyle/intern/stroke/Stroke.cpp | 9 | ||||
-rw-r--r-- | source/blender/freestyle/intern/stroke/Stroke.h | 4 |
3 files changed, 25 insertions, 0 deletions
diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp b/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp index 8199f5b8021..37a29908469 100644 --- a/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp +++ b/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp @@ -218,6 +218,17 @@ static PyObject *Stroke_remove_vertex( BPy_Stroke *self, PyObject *args, PyObjec Py_RETURN_NONE; } +PyDoc_STRVAR(Stroke_remove_all_vertices_doc, +".. method:: remove_all_vertices()\n" +"\n" +" Removes all vertices from the Stroke."); + +static PyObject *Stroke_remove_all_vertices(BPy_Stroke *self) +{ + self->s->RemoveAllVertices(); + Py_RETURN_NONE; +} + PyDoc_STRVAR(Stroke_update_length_doc, ".. method:: update_length()\n" "\n" @@ -285,6 +296,7 @@ static PyMethodDef BPy_Stroke_methods[] = { {"compute_sampling", (PyCFunction)Stroke_compute_sampling, METH_VARARGS | METH_KEYWORDS, Stroke_compute_sampling_doc}, {"resample", (PyCFunction)Stroke_resample, METH_VARARGS | METH_KEYWORDS, Stroke_resample_doc}, + {"remove_all_vertices", (PyCFunction)Stroke_remove_all_vertices, METH_NOARGS, Stroke_remove_all_vertices_doc}, {"remove_vertex", (PyCFunction)Stroke_remove_vertex, METH_VARARGS | METH_KEYWORDS, Stroke_remove_vertex_doc}, {"insert_vertex", (PyCFunction)Stroke_insert_vertex, METH_VARARGS | METH_KEYWORDS, Stroke_insert_vertex_doc}, {"update_length", (PyCFunction)Stroke_update_length, METH_NOARGS, Stroke_update_length_doc}, diff --git a/source/blender/freestyle/intern/stroke/Stroke.cpp b/source/blender/freestyle/intern/stroke/Stroke.cpp index 79443742573..159e4a39849 100644 --- a/source/blender/freestyle/intern/stroke/Stroke.cpp +++ b/source/blender/freestyle/intern/stroke/Stroke.cpp @@ -644,6 +644,15 @@ void Stroke::Resample(float iSampling) } } +void Stroke::RemoveAllVertices() +{ + vertex_container::iterator it = _Vertices.begin(), itend = _Vertices.end(); + for (; it != itend; ++it) + delete (*it); + _Vertices.clear(); + UpdateLength(); +} + void Stroke::RemoveVertex(StrokeVertex *iVertex) { vertex_container::iterator it = _Vertices.begin(), itend = _Vertices.end(); diff --git a/source/blender/freestyle/intern/stroke/Stroke.h b/source/blender/freestyle/intern/stroke/Stroke.h index deb70c21b2a..5415d003c5e 100644 --- a/source/blender/freestyle/intern/stroke/Stroke.h +++ b/source/blender/freestyle/intern/stroke/Stroke.h @@ -589,6 +589,10 @@ public: */ void Resample(float iSampling); + /*! Removes all vertices from the Stroke. + */ + void RemoveAllVertices(); + /*! Removes the stroke vertex iVertex * from the stroke. * The length and curvilinear abscissa are updated |