Skip to content

Commit

Permalink
Add ofPolyline::removeVertex(...) (#6400)
Browse files Browse the repository at this point in the history
  • Loading branch information
bakercp authored and arturoc committed Oct 25, 2019
1 parent 951d1e0 commit d839812
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@

CORE
----

### Graphics
- ofPolyline::removeVertex( ... ) added.

### utils
- ofXML - provided access to the underlying pugi::xml_node method "getParent()"

Expand Down
9 changes: 9 additions & 0 deletions libs/openFrameworks/graphics/ofPolyline.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@ class ofPolyline_ {
void insertVertex(const T &p, int index);
void insertVertex(float x, float y, float z, int index);


/// \brief Remove a vertex at a given index.
///
/// This function print an error and ignore the input if the index is
/// invalid. When a vertex is removed, the internal caches are cleared.
///
/// \param index The index of the vertex to remove.
void removeVertex(int index);

/// \brief Resize the number of points in the ofPolyline to the value
/// passed in.
void resize(size_t size);
Expand Down
13 changes: 13 additions & 0 deletions libs/openFrameworks/graphics/ofPolyline.inl
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,19 @@ void ofPolyline_<T>::insertVertex(float x, float y, float z, int index) {
}


//----------------------------------------------------------
template<class T>
void ofPolyline_<T>::removeVertex(int index) {
if(index >= points.size()){
ofLogError("ofPolyline") << "removeVertex(): ignoring out of range index " << index << ", number of vertices is" << points.size();
}else{
curveVertices.clear();
points.erase(points.begin()+index);
flagHasChanged();
}
}


//----------------------------------------------------------
template<class T>
size_t ofPolyline_<T>::size() const {
Expand Down

0 comments on commit d839812

Please sign in to comment.