<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>
Hi!<br>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 <br>vtkDataSetToStructuredGridFilter. The reason for this is, that I want to input StructuredPoints,StructuredGrid, and RectilinearGrid files. <br><br>Well, thatīs what it looks like now: (thatīs an extract from the Execute() - method<br><br>vtkDataSet *input = this -> GetInput();<br> vtkStructuredGrid *output = this ->GetOutput();<br><br> int DataSetType;<br> DataSetType = input -> GetDataObjectType();<br><br> int dims[3],i,j,k;<br> // pointer for casting<br> vtkRectilinearGrid *rect_input = vtkRectilinearGrid::New();<br> vtkStructuredGrid *structgrid_input = vtkStructuredGrid::New();<br><br><br> vtkDataArray *scaldat = this -> vtkAlgorithm::GetInputArrayToProcess(0,input);<br> vtkDataArray *new_scaldat;<br><br> vtkFloatArray *scalars = vtkFloatArray::New();<br> vtkFloatArray *new_scalars = vtkFloatArray::New();<br><br> scalars = vtkFloatArray::SafeDownCast(scaldat); //this is now the input as vtkFloatArray<br> int numbOfComp = scalars -> GetNumberOfComponents();<br> if(numbOfComp !=1) vtkErrorMacro("Number of Components of Input Array bigger than 1!");<br> int numOfTuples = scalars -> GetNumberOfTuples();<br><br> vtkIDList ptId = vtkIDList::New();<br><br><br> new_scalars -> SetNumberOfComponents(1);<br> new_scalars -> SetNumberOfTuples(numOfTuples);<br><br><br> if((DataSetType == VTK_RECTILINEAR_GRID) && (rect_input = vtkRectilinearGrid::SafeDownCast(input)))<br> {<br> rect_input -> GetDimensions(dims);<br> } <br><br> <br><br> else if((DataSetType == VTK_STRUCTURED_GRID )&& (structgrid_input = vtkStructuredGrid::SafeDownCast(input)))<br> {<br> structgrid_input->GetDimensions(dims);<br> }<br><br> else vtkErrorMacro("unsupported Dataset Format");<br><br> //make the float arrays:<br><br> float inPtr[dims[0]*dims[1]*dims[2] +1];<br> float outPtr[dims[0]*dims[1]*dims[2] +1];<br><br><br><br><br>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. <br><br>How do I get a vtkIDList of my vtkFloatArray?<br><br>secondly, <br>i donīt really now how to set the output correctly. <br>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?<br><br>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?<br><br>thx,<br>Natalie<br><br /><hr />Express yourself instantly with MSN Messenger! <a href='http://clk.atdmt.com/AVE/go/onm00200471ave/direct/01/' target='_new'>MSN Messenger</a></body>
</html>