Problems using vtkContourWidget, vtkAppendPolyData, and vtkDelaunay3D

Hello,

I have a ImageResliceVTKWidget. I can move across a series of medical images. Say I am moving from left to right between images. To create a contour on a certain image, I use the vtkContourWidget. I click multiple points and create a closed loop.

First I create a large circle, then move to the right. Then I create a smaller circle. Then move to the right. Then create a large circle again.

I would like to create a volume using these contours. So I use the vtkAppendPolyData. I do something like…

vtkAppendPolyData.AddInputData(vtkContourWidget.GetContourRepresentation().GetContourRepresentationAsPolyData())

I create a vtkDelaunay3D object and then do vtkDelaunay3D.SetInputData(vtkAppendPolyData.GetOuput()).

Then I create the mapper and actor the usual way.

When I render the actor on ImagePlanesVTKWidget, I see a cylinder like object. I seems as if the first and last contours were used to create the render and it ignored the second contour (the smaller circle). What I wanted was a shape like an hour glass. How would I accomplish this?

Any help would be greatly appreciated.
Thank you.

It seems that a convex hull is generated, which is what vtkDelaunay3D is expected to do.

You can adjust alpha parameters on the vtkDelaunay3D filter, to make it generate concave objects, but it may make mesh generation fail. Alternatively, if the shape is just slightly concave then you may get away without using alpha shapes and applying vtkButterflySubdivisionFilter on the output.

You can try both these options in 3D Slicer’s Markups To Model module (install 3D Slicer and then in the Slicer extension manager install MarkupsToModel extension). Also, full source code is here. Short demo:

You may also try other surface reconstruction filters. Note that all these filters only use the points and ignore all the polygons.

You can make use of the polygons if the contours are defined on parallel planes. If you don’t need to keep the original point coordinates and geometry is simple (no branching, variable spacing, missing slices, etc.) then you might be able to use vtkVoxelContoursToSurfaceFilter. To preserve original point coordinates and handle branching, allow keyhole technique for holes within contours, smooth end-capping, etc. you may use 3D Slicer’s planar contour to closed surface converter (it is used automatically when you import set of planar contour from DICOM RTSTRUCT objects).

Could you please look at my code, I keep getting the same error and I don’t know how to fix it. I’d really appreciate it.

ERROR: In /work/standalone-x64-build/VTK-source/Common/ExecutionModel/vtkDemandDrivenPipeline.cxx, line 709
vtkCompositeDataPipeline (0x915f840): Input port 0 of algorithm vtkBooleanOperationPolyDataFilter(0x7f48bc00eda0) has 0 connections but is not optional.

ERROR: In /work/standalone-x64-build/VTK-source/Common/ExecutionModel/vtkDemandDrivenPipeline.cxx, line 709
vtkCompositeDataPipeline (0x915f840): Input port 1 of algorithm vtkBooleanOperationPolyDataFilter(0x7f48bc00eda0) has 0 connections but is not optional.

code.txt (2.4 KB)