[Paraview] SafeDownCast to vtkDoubleArray fails

Natalie Happenhofer nataliehapp at hotmail.com
Tue Sep 23 12:54:37 EDT 2008


I tried that Print(cerr), but I didn´t see anything printed on my console.. I hoped that would give me information to which class my getArr belongs. 
thats the line where I used it:

input -> GetPointData() -> GetArray(0) ->Print(cerr);

I do not know what I should try next.. 
NH

> Date: Mon, 22 Sep 2008 09:18:00 -0400
> From: burlen.loring at kitware.com
> To: nataliehapp at hotmail.com
> CC: paraview at paraview.org
> Subject: Re: [Paraview] SafeDownCast to vtkDoubleArray fails
> 
> Natalie Happenhofer wrote:
> > Hi!
> > Thx a lot, I get now a DataArray using
> > getArr = scaldat ->GetArray(0); //I just have one array in my point data
> >
> > But still the downcast to vtkDoubleArray fails, here is the code I used:
> >
> > scaldat = input -> GetPointData();
> > vtkDataArray *getArr = vtkDataArray::CreateDataArray(VTK_DOUBLE);
> > getArr = scaldat -> GetArray(0);
> This is going to create a leak, because you ask for a New() an array 
> then reassign your pointer to it before you call Delete().
> 
> >
> >  vtkDoubleArray *scalars = vtkDoubleArray::New();
> > scalars = vtkDoubleArray::SafeDownCast(getArr); //this downcast fails, 
> > i.e at runtime I get that warning below
> Again this results in a leak for same reason.
> >  if(!scalars) vtkErrorMacro("SafeDownCast to vtkDoubleArray failed");
> >
> >
> > With the member function "IsTypeOf(char *classname)" I tried to find 
> > out if getArr is an array of a subclass of vtkDataArray, but this does 
> > not seem to be the case. getArr is just a vtkDataArray. But I need to 
> > access the values in it!!!
> There are a few reasons why the cast could fail. Do you know for sure 
> that getArr is not null? Could you check to be sure the array in 
> question is actually a double array? Try getArr->Print(cerr); That 
> should give more info. If this happened to me I would open the code in a 
> debugger and single step through this portion of the code examining 
> variables to see they have the expected values.
> 
> 
> >
> > thx,
> > NH
> >
> >
> >
> > > Date: Sun, 21 Sep 2008 11:49:00 -0400
> > > From: burlen.loring at kitware.com
> > > To: nataliehapp at hotmail.com
> > > CC: paraview at paraview.org
> > > Subject: Re: [Paraview] SafeDownCast to vtkDoubleArray fails
> > >
> > > Natalie Happenhofer wrote:
> > > > Hi!
> > > > I need to cast my Point Data to a vtkDoubleArray, but it fails:
> > > >
> > > > vtkPointData *scaldat = input -> GetPointData();
> > > > vtkDoubleArray *scalars = vtkDoubleArray::New();
> > > > scalars = vtkDoubleArray::SafeDownCast(scaldat);
> > > > if(!scalars) vtkErrorMacro("SafeDownCast to vtkDoubleArray failed");
> > > PointData is not an array, it's a container of arrays. To get one of 
> > its
> > > arrays see the GetArray methods.
> > > 
> > http://www.vtk.org/doc/nightly/html/classvtkFieldData.html#888a6492210426d4ba4d358b87ab198f
> > >
> > > To find this in the documentation you would have to use the inheritance
> > > diagrams. PointData "is a" DataSetAttibutes "is a" FieldData and so on.
> > >
> > > >
> > > > and everytime I run the program I get that vtkErrorMacro.
> > > > as far as I know from the input files, the PointData should be float,
> > > > but casting to vtkFloatArray fails as well. Why? and what can I do
> > > > about it?
> > > >
> > > > thx a lot,
> > > > NH
> > > >
> > > > 
> > ------------------------------------------------------------------------
> > > > 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! MSN Messenger 
> > <http://clk.atdmt.com/AVE/go/onm00200471ave/direct/01/>
> 
> 
> -- 
> 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/20080923/bfab27bb/attachment.htm>


More information about the ParaView mailing list