FW: [vtkusers] vtkDoubleArray[]...
Shyam Prakash
ramakrishna.prakash at quest-global.com
Tue Oct 21 04:40:44 EDT 2003
Said,
If you have not received the reply see the message below. Else
ignore this.
--Shyam
> -----Original Message-----
> From: Shyam Prakash [mailto:ramakrishna.prakash at quest-global.com]
> Sent: Monday, October 20, 2003 5:06 PM
> To: 'Said.'; VTKUserList (vtkusers at www.vtk.org)
> Subject: RE: [vtkusers] vtkDoubleArray[]...
>
> Said,
> In the following line you are just creating an array of length
> NUMBER_OF_ARRAYS.
>
> solution = new vtkDoubleArray[NUMBER_OF_ARRAYS];
>
> However, the elements at each row of the array is still null.
You
> need to create an object at each row before you access them. Following
is
> the updated code.
>
>
> private void initDataArray(int nv){
> solution = new vtkDoubleArray[NUMBER_OF_ARRAYS];
> System.out.println(solution.length);
> int counter = 0;
> String[] names = new
> String[]{"Ex","Ey","Ez","||E||","Hx","Hy","Hz","||H||"};
> for(counter = 0; counter < NUMBER_OF_ARRAYS; counter++){
>
> //here you need to create a new object
> solution[counter] = new vtkDoubleArray();
>
> //rest of the code is fine
>
>
> --Shyam
>
>
> -----Original Message-----
> From: vtkusers-admin at vtk.org [mailto:vtkusers-admin at vtk.org] On Behalf
Of
> Said.
> Sent: Monday, October 20, 2003 4:17 PM
> To: vtkusers
> Subject: [vtkusers] vtkDoubleArray[]...
>
> Hi vtkusers,
>
> In this method I instanciate an attay of vtkDoubleArray class.
>
> System.out.println(solution.length); ==> 8 OK.
>
> The problem here is, when I try call a method on solution[counter]
> object like this:
> solution[counter].SetNumberOfValues(nv);
>
> I get a NullPointerException. Does any of you have an idea ?
>
> Thanks.
>
> private void initDataArray(int nv){
> solution = new vtkDoubleArray[NUMBER_OF_ARRAYS];
> System.out.println(solution.length);
> int counter = 0;
> String[] names = new
> String[]{"Ex","Ey","Ez","||E||","Hx","Hy","Hz","||H||"};
> for(counter = 0; counter < NUMBER_OF_ARRAYS; counter++){
> solution[counter].SetNumberOfValues(nv);
> solution[counter].SetName(names[counter]);
> }
> for(counter=0; counter < nv;counter++){
> solution[counter].SetValue(counter,0);
> }
> }
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> <http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
More information about the vtkusers
mailing list