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