[Paraview] questions concerning vtkFloatArray

Natalie Happenhofer nataliehapp at hotmail.com
Thu Sep 11 12:11:41 EDT 2008


Hi Burlen,
thanks for your answer! 
I still have a few questions:

-) I don´t understand the structure of the vtkFloatArray (or in general, of the vtkDataArray): I have not points, but tuples? How is the data organised? Let´s assume, I have as an input a structured grid with 1000 points and scalar attribute data attached. In Vtk the points section would be described as a vtkDataArray with 1000 tuples and each tuple has 3 components. The scalar attribute data is another vtkDataArray with 1000 Tuples and each tuple has just 1 component. If it was vector attribute data, there would be again 3 components/ tuple. Did I get that right?
So, in my filter, I want to get the scalar attribute data and actually perform arithmetic operations with it, so I want to "get the values out" of the vtkDataArray, do some calculations, and assign the new array as scalar attribute data to the output. 

The grid itself, i.e the points would stay untouched, it is just that I have as input structured grid, rectilinear grid and structured points. In order to assign the geometry to the output, which has the format structured grid, is it ok to cast my rectilinear grid or my structured points to vtkStructuredGrid and use then the "CopyStructure"-Method? Or will this not work and I have to compute the points from the rectilinear grid and the structured points manually and insert it to the output structured grid?

-)to use the RequestData() method I have to specify the input in the server manager xml file, right?

thx a lot!
Natalie

> Date: Thu, 11 Sep 2008 09:46:16 -0400
> From: burlen.loring at kitware.com
> To: nataliehapp at hotmail.com
> CC: paraview at paraview.org
> Subject: Re: [Paraview] questions concerning vtkFloatArray
> 
> Hi Natalie,
> Some comments follow:
> 
> >  int dims[3],i,j,k;
> >  // pointer for casting
> >  vtkRectilinearGrid *rect_input = vtkRectilinearGrid::New();
> >  vtkStructuredGrid *structgrid_input = vtkStructuredGrid::New();
> >
> >
> >  vtkDataArray *scaldat = this -> 
> > vtkAlgorithm::GetInputArrayToProcess(0,input);
> >  vtkDataArray *new_scaldat;
> >
> >  vtkFloatArray *scalars = vtkFloatArray::New();
> >  vtkFloatArray *new_scalars = vtkFloatArray::New();
> >
> >  scalars = vtkFloatArray::SafeDownCast(scaldat); //this is now the 
> > input as vtkFloatArray
> 
> This is going to create a memory leak. You New()'d a vtkFloatArray and 
> never called Delete() before reassigning.
> 
> >  if((DataSetType == VTK_RECTILINEAR_GRID) && (rect_input = 
> > vtkRectilinearGrid::SafeDownCast(input)))
> >   {
> >    rect_input -> GetDimensions(dims);
> >   }
> >
> >  else if((DataSetType == VTK_STRUCTURED_GRID )&& (structgrid_input = 
> > vtkStructuredGrid::SafeDownCast(input)))
> >  {
> >  structgrid_input->GetDimensions(dims);
> >  }
> >
> 
> Also these are going to create leaks. You never call Delete() on the 
> data sets you New()'d before reassigning.
> 
> > My first problem occurs in the part, where I already got the input 
> > Scalar array and casted it to vtkFloatArray. In order to perform 
> > arithmetic operations with the data in it, I want to assign each point 
> > of the vtkFloatArray to a "real" float array, but to do that, I need 
> > to get the vtkIDList of the vtkFloatArray , so I can use the 
> > GetPoint(vtkId x)-method.
> >
> > How do I get a vtkIDList of my vtkFloatArray?
> There is no GetPoint() method for a vtkFloatArray. Do you mean GetTuple? 
> The Tuples are ordered such the tuple 0 is associated with point/cell 0 
> for point/cell data arrays. Are you looking to get the points associated 
> with the data set or the scalar values associated with the points?
> >
> > secondly,
> > i don´t really now how to set the output correctly.
> > I want to use a method like CopyStructure() so that the grid is copied 
> > from input to output, but as the input is a DataSet and the output 
> > StructuredGrid, does this method compute points and so for the 
> > structuredGrid Format or do I have to assign them manually?
> CopyStructure, does copy the geometry. Both the source and destination 
> data set have to be the same type.
> 
> >
> > Thirdly, I don´t know how to assign my new vtkFloatArray as Attribute 
> > Data to the output. SetScalars() does not work here, the compiler says 
> > that this is not a member function of vtkStructuredGrid. But surely 
> > there must be a method to assign attribute data to a structured grid?
> if you have point data then you can:
> 
> output->GetPointData()->AddArray(someArray);
> 
> There are similar calls for CellData and FieldData.
> 
> I would advise taking a close look at the examples in the vtk user 
> guide. In the filters I have seen you will implement RequestData and get 
> the input and output from an instance of vtkInformation. here is an 
> example using unstructured grids:
> 
> int MyPv3Filter::RequestData(
>         vtkInformation *req,
>         vtkInformationVector **input,
>         vtkInformationVector *output)
> {
>   vtkDataObject *tmpDataObj;
>   // Get the inputs
>   tmpDataObj
>     = input[0]->GetInformationObject(0)->Get(vtkDataObject::DATA_OBJECT());
>   vtkUnstructuredGrid *usgIn
>     = dynamic_cast<vtkUnstructuredGrid *>(tmpDataObj);
>   // Get the outputs
>   tmpDataObj
>     = output->GetInformationObject(0)->Get(vtkDataObject::DATA_OBJECT());
>   vtkUnstructuredGrid *usgOut
>     = dynamic_cast<vtkUnstructuredGrid *>(tmpDataObj);
>  
>   // do stuff here
> 
>   return 1;
> }
> 
> In regard to the input arrays, they can be easily obtained from 
> PointData, CellData, or FieldData via a call such as
> 
> usgIn->GetPointData()->GetArray(x).
> >
> > thx,
> > Natalie
> >
> > ------------------------------------------------------------------------
> > Express yourself instantly with MSN Messenger! MSN Messenger 
> > <http://clk.atdmt.com/AVE/go/onm00200471ave/direct/01/>
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > ParaView mailing list
> > ParaView at paraview.org
> > http://www.paraview.org/mailman/listinfo/paraview
> >   
> 
> 
> -- 
> Burlen Loring
> Kitware, Inc.
> R&D Engineer
> 28 Corporate Drive
> Clifton Park, NY 12065-8662
> Phone: 518-371-3971 x137
> 

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20080911/4572ff8e/attachment.htm>


More information about the ParaView mailing list