I am trying to build a volumetric polydata traversed by a cylinder along given path. I am currently creating cylinders at every point in the path and appending them using vtkAppendPolyData. But this gives be too big polydata at the end. I tried using boolean filter, but it fails to create the union of all the cylinders. It just crashes or too intense operation. Let me know if there are diiferent ways of achieving the same.
FYI- There is a concept in computational geometry called a “swept surface.” (See this article for example.) It is a powerful construct for doing things like path planning, or analyzing robot motion, in complex geometric situations. It can be used to compute bounding boxes too One very fun past project was using swept surfaces to figure out how to remove an oil filter (or other parts) from a jet engine - it’s not easy to get tools in, move the tools appropriately, and get the part out. But I digress.
The basic idea is that an object is placed into a sampling volume, and then “rasterized” repeatedly, using a distance field and union set operations, as small steps are taken to move the object along its path (the path typically being a sequence of interpolated transformations) to accumulate the surface position of the object over time. . I’m sure this is way overkill for what you are trying to do, but maybe it will prompt a useful idea…
I think you could do a continous approximation of your picture example by projecting the oriented cylinder into the path normal plane and using a linear extrusion filter if your path-direction and cylinder-orientation don’t vary too frequently. I think you could use vtkCutter passing through the cylinder-center to get the projection.
Path-direction change points should be appended as cylinders.
Cylinder-orientation change (while translating or not) may be done using a rotation extrusion filter but you need to calculate some transforms to get the correct inputs for the filter.
I think you may achieve near log(n) complexity relative to your current algorithm
I don’t know if this is what Will suggests.
I have done a custom path extrusion filter for myself so I have a little bit of experience, but this post still is a mental exercise for me. Could be wrong
Thank you Will. You pointed me to the right filter. I need cut volume polydata, cut by a cylindrical cutter traversing along the given path of points. I don’t find this SweptSurface filter in my vtk (python). Is it still under patent rights? Any work arounds?
I created vtkImageData from the appended cylinders using vtkVoxelModeller and then used vtkMarchingCubes to extract surface. It works, but the model accuracy is not great. Here is the code:
Here is same code implementing the first steps of the idea I suggested… It’s complex but I think if you put some work into it, it should work releably… The script was made to be executed on Slicer’s python interactor but you can avoid those lines and set your own mappers.
The greatest benefit of this approach is that a linear extrusion only doubles the original number of points of your original polygon, and you would do only one extrusion per uniform path direction, instead of placing n cylinders over that line
Thank you Mauro. I’m impressed with the results and the performance. Model size reduced lot.
I am still appending extruded models for each line though. I need to work on deleting the points and facets inside the final appended polygon. Here is the code snippet I tried.
Congratrulations, I think you achieved your goal…
Very nice pictures!
Maybe now you can use vtkbool library to merge all the appended models into one with less points. Or you could put more work in some kind of extrusion algorithm