ofPolyline, how to remove a vertex

I am using ofpolyline for its getClosestPoint function.

After finding the closest point I want to delete that vertex in the polyline, so that it does not get considered next time.

would it make sense to add something like this to ofPolyline or could there be other issues because of the erasing?

  
void ofPolyline::eraseVertex(int index) {  
	points.erase(points.begin()+index);  
	bHasChanged=true;  
}  

I think for ofPolyline it should be fine and I think it’s a good idea. For ofPath it gets a little bit trickier but still should be ok. I’d say write it up in a patch and submit a pull request on github.

I have update my ofPolyline files with this code and I can’t get it to work.

Has anybody else thought about how a vertex can be removed from an instance of ofPolyline?

this is korea forum. but you can try example code.

1 Like

Thanks!