0

I like to get a specific contour from image data. My main goal is to remesh a polydata in grid form. So I followed below pipeline:

  1. convert polydata to image using PolyDataToImageData

  2. convert above image output to vtkImageDataGeometryFilter

  3. use vtkImplicitPolyDataDistance to compute the distance from the original polydata

  4. copy the distance values to image output scalars in step 2

    The result is below:

    enter image description here

  5. I then tried to use vtkContourFilter to get polydata with SetValue(0, 0.0). And as you can see the result is not entirely correct:

    enter image description here

The value of distance array is https://pastebin.ubuntu.com/p/2mZsgdrcmX/ and it is never 0 so I think I am doing it wrong in SetValue but I am also not sure how to get that specific green contour.

Is there any way to get those green points contour?

Syed
  • 550
  • 1
  • 7
  • 22
  • Not sure to understand. Is your input a polydata or an image ? Also, the first step of your pipeline should contains a mistake. – Charles Gueunet Aug 24 '20 at 07:41
  • Sorry if I was not clear, my input is a polydata. First step is simply conversion to image (I have double checked by passing it to marching cube/contour filter, it gave correct voxelized shape) – Syed Aug 24 '20 at 16:16

1 Answers1

0

I am not completely sure to understand your pipeline.

In the vtkContourFilter, the SetValue takes two parameters. The first one is the id of the contour (as the filter can extract several contours at once, see the SetNumberOfContours). The second is the isovalue of the contour. Here, you set an isovalue of 0.0. Which means you want the points at a distance 0 of the original data set. Looking at the first image, it seems these are the red points. If you want a contour at the green points, you may want to specify a higher scalar value.

PS: If the goal of your pipeline is to have a "larger version" of your shape, you may also have a look at the vtkWarpVector (and give it the normals of your polydata).

Mathieu Westphal
  • 2,544
  • 1
  • 19
  • 33
Charles Gueunet
  • 1,708
  • 14
  • 14
  • Thanks Charles, I was able to get higher scalar value as you suggested, but I came to know that those green/yellow points are range of scalar values so for one defined iso value lets say 0.1 I get a small number surface unless polydata to image conversion spacing is very very close which turns out takes alot of time to process. So I might have to think something else – Syed Aug 29 '20 at 09:12
  • My ultimate goal is to create a grid mesh like this: http://vtk.1045678.n5.nabble.com/Remeshing-using-Octree-Filter-td5744950.html. So I am now looking into hyper tree grid. I am now using PolyDataToImageData (same vtk example) in step 1 to send it to vtkHyperTreeGridSource input, but I always get: Attempt to connect input port index 0 for an algorithm with 0 input ports. Do you know how may I pass polydaya or image to HyperTreeGridSource. I plan to use this output to convert it to the unstructured grid and then use my pipeline (Implicit distance etc) to get the contour at iso value 0.0 – Syed Aug 29 '20 at 09:27
  • 1
    Sorry, I am not familiar with this kind of subdivision. For this kind of task, I use a morse smale quadrangulation, you have one in a library name [TTK](https://topology-tool-kit.github.io/index.html) that works as a VTK module. You have an example [here](https://topology-tool-kit.github.io/gallery.html) – Charles Gueunet Aug 31 '20 at 07:10