[vtkusers] What to use: 'vtkDataArray' or 'vtkDoubleArray'?
B. C.
butterfly.1688 at yahoo.fr
Mon Oct 27 10:43:20 EDT 2008
Thank you Michael for your help.
Can you tell me if i want to store the value of 'myArray->GetTuple(i,pt)' into a variable to make a test, waht type should i use?
In fact, i want to do this:
if (this_value<0) : delete the point(i) of the ploydata
--- En date de : Lun 27.10.08, Michael Jackson <mike.jackson at bluequartz.net> a écrit :
De: Michael Jackson <mike.jackson at bluequartz.net>
Objet: Re: [vtkusers] What to use: 'vtkDataArray' or 'vtkDoubleArray'?
À: butterfly.1688 at yahoo.fr, vtkusers at vtk.org
Date: Lundi 27 Octobre 2008, 13h24
vtkDoubleArray is a high level class that hides the actual array
implementation.
What you probably want to do is this:
vtkDoubleArray* myArray=vtkDoubleArray::SafeDownCast(myPolyData-
>GetPoints());
if (NULL == myArray)
{
Error ....
}
vtkIdType nPoints = myArray->GetNumberOfTuples();
double pt[3];
for (vtkIdType i = 0; i < nPoints; ++i)
{
myArray->GetTuple(i,pt);
// Do something with pt.
}
The above code is from memory but should be pretty close.
If you really just want to access the data from the Data array then
you can do the following:
vtkDoubleArray* myArray=vtkDoubleArray::SafeDownCast(myPolyData-
>GetPoints());
if (NULL == myArray)
{
Error...
}
double* pts = static_cast<double*>(myArray->GetVoidPointer());
That should get you a raw pointer to the data. So as long as you
understand the how the data is stored in that pointer you can iterate
over the pointer.
_________________________________________________________
Mike Jackson mike.jackson at bluequartz.net
BlueQuartz Software www.bluequartz.net
Principal Software Engineer Dayton, Ohio
On Oct 27, 2008, at 6:41 AM, B. C. wrote:
> Hi everyone.
> I want to save the values of the points of a polydata in an array
> and then access to each one. I used this:
>
> double curveValue;
> vtkDoubleArray *myArray;
> for (int i=0; i<myPolydata->GetNumberOfPoints(); i++)
> {
> myArray[i] = myPolyData->GetPoints()->GetPoint(i);
> curveValue = myArray->GetValue(i);
> }
>
> I have this error:
> binary '=' : no operator defined which takes a right-hand operand
of
> type 'double *'
>
> When i change the array type to 'vtkDataArray', i have this code:
> double *curveValue;
> vtkDataArray *myArray = myPolyData->GetPoints()->GetData();
> for (int i=0; i<myPolyData->GetNumberOfPoints(); i++)
> {
> curveValue = myArray->GetTuple(i);
> }
>
> I have no more errors, but when i run the program, i have a bug and
> the cursor indicates this line:
> vtkDataArray *myArray = myPolyData->GetPoints()->GetData();
>
> I don't understand any one of the 2 error cases!!!
> Please, can someone tell me what type of array should i use? and how
> to rectify the code
> to have no more errors?
>
> Thank you for you help
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20081027/9e382c9a/attachment.htm>
More information about the vtkusers
mailing list