[vtkusers] converting vtkImageData to vtkUnstructuredGrid

Liam Kurmos quantum.leaf at gmail.com
Sun Mar 13 19:52:28 EDT 2011


I'm returning to the problem of creating a reeb graph in vtk using
vtkReebGraph and trying to write a simple example. I still feel quite
novice with vtk so please point out if you see i obvious problems in
what i'm doing.

i have some vtkImageData initialised like this:

vtkVol->SetScalarComponentFromFloat(i, j, k, 0, val);

//i think the 0 is the id of the scalar field which in supplying the
float val for. Is this pointData? what about cell data, is that
generated automatically?

i need first to turn the vtkImageData to vtkUnstructuredGrid data. I
do this with the threshold filter.

    vtkSmartPointer<vtkThreshold>
threshold=vtkSmartPointer<vtkThreshold>::New();
    threshold->SetInput(vtkVol);
    threshold->ThresholdByUpper(0);//scalars are all postive so threshold all
    vtkSmartPointer<vtkUnstructuredGrid>
unstructuredData=threshold->GetOutput();
    threshold->Update();

//i think this works, no error. I wonder if would be worth creating an
example of how to convert vtkImageData to vtkUnstructuredGrid with
this?
//next i create a Reeb Graph:

    vtkSmartPointer<vtkReebGraph>
reebGraph=vtkSmartPointer<vtkReebGraph>::New();
    reebGraph->Build(unstructuredData,(vtkIdType)0);
//i put 0 here, as it is the id of the scalar field i set up on my
vtkImageData. If i wanted to use the version of this called that takes
a vtkDataArray* could i get this directly from my unstructured grid?

    cout<<" vcount "<<reebGraph->GetNumberOfVertices()<<endl;

My problem now is that this is producing 0.
The test data is 3 gaussian disc so there should be critical points....

can any give advice or suggestions on how to proceed?

Liam




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
>>
>



More information about the vtkusers mailing list