[vtkusers] converting vtkImageData to vtkUnstructuredGrid

Liam Kurmos quantum.leaf at gmail.com
Sun Apr 10 19:46:40 EDT 2011


> Use vtkDataSetTriangleFilter to convert your image data (or any
> volumetric data) directly into tetrahedrons.  It won't be 2-to-1
> ratio, though... it's impossible to generate two tetrahedrons by
> cutting a cube in half, so I'm not sure where you got that ratio from.

ah... i guess i was being a bit naive...  only when i thought about
how i would implement it myself did i recall that a cube does not
divide into 2 equal tetrahedra. I must have confused a square based
pyramid with a tetrahedron... maybe because a square can be divided
into two triangles. Now i realise the problem is non-trivial and
recall a cube is divided into 5 non-equal tetrahedra, i'm very glad
i'm not going to have to implement this myself... ( as much as the
exercise would probably have helped my geometry i have limited time to
work on this at the moment).

Incidentally, do you know what the equivalent of Delaney Triangulation
is called higher dimensional simplexes? I guess this what
vtkDataSetTriangleData does to produce tetrahedra from arbitrary
points.

On Sun, Apr 10, 2011 at 4:59 PM, Bill Lorensen <bill.lorensen at gmail.com> wrote:
> A Quad is 2D while a Tetra is 3D. A Quad can be turned into a triangle with
> vtkTriangleFilter.

sorry, i meant a cube not a quad. I'm working with 3D data.

thanks both of you for taking the time to reply,

Liam




>
> On Sun, Apr 10, 2011 at 11:21 AM, Liam Kurmos <quantum.leaf at gmail.com>
> wrote:
>>
>> Does vtk provide a way to turn quads into tetras?
>>
>> Liam
>>
>>
>> On Sat, Apr 9, 2011 at 11:52 AM, Liam Kurmos <quantum.leaf at gmail.com>
>> wrote:
>> > Thanks David!
>> >
>> > On Sat, Apr 9, 2011 at 11:27 AM, David E DeMarle
>> > <dave.demarle at kitware.com> wrote:
>> >> It produces voxel cells not tetrahedral cells, so the mapping is one to
>> >> one.
>> >>
>> >> David E DeMarle
>> >> Kitware, Inc.
>> >> R&D Engineer
>> >> 28 Corporate Drive
>> >> Clifton Park, NY 12065-8662
>> >> Phone: 518-371-3971 x109
>> >>
>> >>
>> >>
>> >> On Sat, Apr 9, 2011 at 3:59 AM, Liam Kurmos <quantum.leaf at gmail.com>
>> >> wrote:
>> >>> I've attempted to convert imagedata to unstructured data as you
>> >>> suggested some time back using vtkthreshold.
>> >>> In the code below vtkVol is a vtkImageData with scalar point data.
>> >>> However when i query the number of cells in the output unstructured
>> >>> grid i get the same as in the structured data. I would image there
>> >>> should be twice as many unstructured tetrahedra as cells in the
>> >>> structured data, can you comment on this?
>> >>>
>> >>> Liam
>> >>>
>> >>>
>> >>>    vtkSmartPointer<vtkThreshold>
>> >>> threshold=vtkSmartPointer<vtkThreshold>::New();
>> >>>    threshold->SetInput(vtkVol);
>> >>>    threshold->ThresholdByUpper(0);//scalars are all postive so
>> >>> threshold all
>> >>>    vtkSmartPointer<vtkUnstructuredGrid>
>> >>> volumeMesh=threshold->GetOutput();
>> >>>    threshold->Update();
>> >>>    cout<<" vtkug num cells "<<volumeMesh->GetNumberOfCells()<<endl;
>> >>>    cout<<" imagedata num cells "<<vtkVol->GetNumberOfCells()<<endl;
>> >>>
>> >>>
>> >>>
>> >>> On Wed, Feb 9, 2011 at 3:34 PM, David E DeMarle
>> >>> <dave.demarle at kitware.com> wrote:
>> >>>> Threshold and many other subsetting filters produce arbitrary sets of
>> >>>> cells, thus by definition they can not produce structured data.
>> >>>>
>> >>>> David E DeMarle
>> >>>> Kitware, Inc.
>> >>>> R&D Engineer
>> >>>> 28 Corporate Drive
>> >>>> Clifton Park, NY 12065-8662
>> >>>> Phone: 518-371-3971 x109
>> >>>>
>> >>>>
>> >>>>
>> >>>> On Wed, Feb 9, 2011 at 10:05 AM, Liam Kurmos <quantum.leaf at gmail.com>
>> >>>> wrote:
>> >>>>> Hi David,
>> >>>>>
>> >>>>> Thanks for replying.
>> >>>>>
>> >>>>>> One way is to apply the threshold filter and set the threshold so
>> >>>>>> that
>> >>>>>> it includes the entire scalar range.
>> >>>>>
>> >>>>> is it a side affect of the threshold filter that it will also
>> >>>>> produce
>> >>>>> an unstructured grid from a structured one?
>> >>>>>
>> >>>>> cheers,
>> >>>>>
>> >>>>> Liam
>> >>>>>
>> >>>>
>> >>>
>> >>
>> >
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the VTK FAQ at:
>> http://www.vtk.org/Wiki/VTK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtkusers
>
>



More information about the vtkusers mailing list