[Paraview] questions concerning vtkFloatArray

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


Hi!
In my new filter, I want to do some calculations with the Attribute Data, i.e Scalars, assign the new points to the output. The geometry is not alterated, although I implemented my new class as a subclass of 
vtkDataSetToStructuredGridFilter. The reason for this is, that I want to input StructuredPoints,StructuredGrid, and RectilinearGrid files. 

Well, that´s what it looks like now: (that´s an extract from the Execute() - method

vtkDataSet *input = this -> GetInput();
 vtkStructuredGrid *output = this ->GetOutput();

 int DataSetType;
 DataSetType = input -> GetDataObjectType();

 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
 int numbOfComp = scalars -> GetNumberOfComponents();
 if(numbOfComp !=1) vtkErrorMacro("Number of Components of Input Array bigger than 1!");
 int numOfTuples = scalars -> GetNumberOfTuples();

 vtkIDList ptId = vtkIDList::New();


 new_scalars -> SetNumberOfComponents(1);
 new_scalars -> SetNumberOfTuples(numOfTuples);


 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);
 }

 else vtkErrorMacro("unsupported Dataset Format");

 //make the float arrays:

 float inPtr[dims[0]*dims[1]*dims[2] +1];
 float outPtr[dims[0]*dims[1]*dims[2] +1];




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?

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?

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?

thx,
Natalie

_________________________________________________________________
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/cfb26321/attachment.htm>


More information about the ParaView mailing list