[vtkusers] Re: Regarding vtkFieldData

Steve Kirstukas sjk60 at iastate.edu
Mon Oct 11 08:09:07 EDT 2004


You need to tie the array to your points. fieldData, the way you are using it,
is attached to the polyData but not to the points.  Rather than explicitly using
vtkFieldData, try ...

cube->GetPointData()->AddArray( pElement );

Now the filter should work as you intended.

-Steve

> Date: Sat, 09 Oct 2004 00:18:24 -0500
> From: "Neerajk" <neerajk at vitinfotech.com>
> Subject: [vtkusers] Regarding vtkFieldData
> To: vtkusers at vtk.org
> 
> Hi all
> 
> I want to add my field data into vtkpolydata to keep information about modified
data, if I do apply any filter on polydata, then I am getting the same field
data as it was earlier.
> Here is what I am doing discussed below, please let me know if any part of the
logic is wrong here or I am expecting a behavior which is not there.
> 
> a. I create vtkPolydata and add VtkPoints and vtkCellArray.
> 
> b. Then to this polydata I add vtkFieldData( Having a float array ) by calling
SetFieldData.
> 
> c. Create a VtkDecimatePro filter and decimate the polydata created in step a.
> 
> d. Get the output polydata from filter and call GetFieldData().
> 
> Result: The FieldData come out without any modification but the vtk points are
reduced.
> 
> Question again: 
> 1. Aren't filter suppose to modify field data?
> 
> 
> vtkFloatArray *pElement = vtkFloatArray::New();
> for (i=0; iInsertTuple1(i,i);
> pElement->SetName("Element");
> vtkFieldData *pFieldData = vtkFieldData::New();
> pFieldData->AddArray(pElement);
> 
> vtkPolyData *cube = vtkPolyData::New();
> cube->SetPoints(points);
> cube->SetPolys(polys);
> cube->GetPointData()->SetScalars(scalars);
> cube->SetFieldData(pFieldData);
> 
> vtkDecimatePro *pFilter = vtkDecimatePro::New();
> pFilter->SetInput( cube );
> pFilter->SetTargetReduction( 50 );
> pFilter->PreserveTopologyOn();
> pFilter->BoundaryVertexDeletionOff();
> pFilter->SetFeatureAngle( 90 );
> pFilter->UpdateWholeExtent();
> 
> vtkFieldData *pFieldDataNew = pFilter->GetOutput()->GetFieldData();
> vtkFloatArray *pElementNew = (vtkFloatArray
*)pFieldDataNew->GetArray("Element");
> 
> 
> Thanks & Regards
> Neeraj
> 





More information about the vtkusers mailing list