I am trying to implement a tool with polyline selections, but I came across some issues. The tool should allow users to:
Draw a closed polyline. (Done, using the PolyLineWidget)
Highlight all the actors within this closed polyline to represent they are selected. My idea is to get all points on the polyline and form a box to calculate actors’ intersections. Thus, subquestions arise here:
* How to get all points positions on the PolyLine? I read the official documents but find no public API applicable in this case.
* How to extrude this curve straight so that I could form a box to do the intersection calculations?
* Once I formed the actor, how to tell whether two actors have intersections or not?
I am not sure whether there are better solutions for this problem, so feel free to propose other ideas!
It seems that you want to do a 2D polyline that you want to extrude rather than a 3D polyline.
If I’m not mistaken, the widget state will give you all the xyz coordinates of that polyline.
With the camera you can convert xyz to display coordinates, in case that matter.
In either way, what you are trying to do is going to be tricky and not easy to implement out of the box.
Yes, I want to do a 2D polyline to make the task easier for the users, but the objects are in 3D, so I tried to place the polyline in a plane. I tried to get the polyline widget states by using:
You can get the list of polyline points from widget.getWidgetState().getHandleList()
If you are in parallel projection, you could extrude the polyline with vtkLinearExtrusionFilter (you would need to port it from C++ to JS).
You would then need to check that your actors are inside the extruded mesh.
That would be a CPU implementation of the picking.
Maybe you would get better results by doing it on the GPU. You might want to look how the picking is done with hardwareselector.