[vtkusers] vtkDoubleArray[]...
Shyam Prakash
ramakrishna.prakash at quest-global.com
Mon Oct 20 07:36:10 EDT 2003
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