[Paraview] filter
Mike Jackson
mike.jackson at bluequartz.net
Tue Sep 16 13:45:37 EDT 2008
what line of code is the access violation occurring at?
_________________________________________________
| Mike Jackson - Principal Software Engineer |
| BlueQuartz Software |
| mike.jackson at bluequartz.net |
| www.bluequartz.net |
---------------------------------------------------
On Sep 16, 2008, at 1:08 PM, Natalie Happenhofer wrote:
> Hi!
> I´m still encountering problems with my filter, it does compile and
> link neatly with paraview, but at runtime an error occurs which
> causes paraview to shut down. I´m pretty sure that the problem is
> how I define the output, that this is not done correctly. Lastly, I
> commented just the algorithm out to test the in- and output, and it
> looks like this:
>
> void vtkHorizontalAverage::Execute()
> {vtkDataSet *input = this -> GetInput();
> vtkStructuredGrid *output = this -> GetOutput();
>
> int DataSetType;
> DataSetType = input -> GetDataObjectType();
>
> if(DataSetType != VTK_RECTILINEAR_GRID)
> { vtkErrorMacro("unsupported DataSet format");}
>
>
>
> int dims[3],i,j,k;
> // pointer for casting
> vtkSmartPointer<vtkRectilinearGrid> rect_input =
> vtkSmartPointer<vtkRectilinearGrid>::New();
> //vtkStructuredGrid *structgrid_input = vtkStructuredGrid::New();
>
>
> vtkPointData *scaldat = input -> GetPointData();
> vtkDataArray *new_scaldat;
>
> vtkSmartPointer<vtkFloatArray> scalars =
> vtkSmartPointer<vtkFloatArray>::New();
> vtkSmartPointer<vtkFloatArray> new_scalars =
> vtkSmartPointer<vtkFloatArray>::New();
>
> scalars = vtkFloatArray::SafeDownCast(scaldat); //this is now the
> input as vtkFloatArray
> scaldat -> Delete();
> int numbOfComp = scalars -> GetNumberOfComponents();
> if(numbOfComp ==1) vtkErrorMacro("Number of Components of Input
> Array bigger than 1!"); //!!!!
> int numOfTuples = scalars -> GetNumberOfTuples();
>
>
> new_scalars -> SetNumberOfComponents(1);
> new_scalars -> SetNumberOfTuples(numOfTuples);
>
>
> rect_input = vtkRectilinearGrid::SafeDownCast(input);
>
> if(!rect_input) {vtkErrorMacro("SafeDownCast to Rectilinear Grid
> failed");}
>
> else { rect_input -> GetDimensions(dims);
>
> //get the points:
> /*vtkDataArray *XCoord = vtkDataArray::New();
> vtkDataArray *YCoord = vtkDataArray::New();
> vtkDataArray *ZCoord = vtkDataArray::New();*/
>
> vtkDataArray *XCoord = rect_input -> GetXCoordinates();
> vtkDataArray *YCoord = rect_input -> GetYCoordinates();
> vtkDataArray *ZCoord = rect_input -> GetZCoordinates();
>
> output -> SetDimensions(dims);
> vtkSmartPointer<vtkPoints> pts =
> vtkSmartPointer<vtkPoints>::New();
> pts -> SetNumberOfPoints(numOfTuples);
>
>
> for(int i=0;i<=dims[2];i++)
> { for(int j=0;j<=dims[1];j++)
> {for(int k=0;k<=dims[0];k++)
> {pts -> InsertNextPoint(XCoord -> GetTuple1(k),YCoord ->
> GetTuple1(j), ZCoord -> GetTuple1(i));
> }//for (int k
> }//for(int j
> }//for (int i
>
> XCoord -> Delete();
> YCoord -> Delete();
> ZCoord -> Delete();
>
> output -> SetPoints(pts); //Now the points are set
> //output -> GetPointData()-> CopyAllocate(new_scalars,
> 0,new_scalars -> GetNumberOfTuples());
> output -> GetPointData() -> PassData(input -> GetPointData());
> new_scalars -> Delete();
>
>
> Here I get as an input a data set, cast it down to rectilinear grid
> and compute the points for the structured grid. As I said, Paraview
> shuts down (Access violation my debugger says) when I execute it.
>
> Any help would be appreciated!
> thx,
> NH
>
> Express yourself instantly with MSN Messenger! MSN Messenger
> _______________________________________________
> ParaView mailing list
> ParaView at paraview.org
> http://www.paraview.org/mailman/listinfo/paraview
More information about the ParaView
mailing list