<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;"><DIV>Thank you Michael for your help.</DIV>
<DIV>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?</DIV>
<DIV> </DIV>
<DIV>In fact, i want to do this:</DIV>
<DIV>if (this_value<0) : delete the point(i) of the ploydata</DIV>
<DIV><BR><BR>--- En date de : <B>Lun 27.10.08, Michael Jackson <I><mike.jackson@bluequartz.net></I></B> a écrit :<BR></DIV>
<BLOCKQUOTE style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: rgb(16,16,255) 2px solid">De: Michael Jackson <mike.jackson@bluequartz.net><BR>Objet: Re: [vtkusers] What to use: 'vtkDataArray' or 'vtkDoubleArray'?<BR>À: butterfly.1688@yahoo.fr, vtkusers@vtk.org<BR>Date: Lundi 27 Octobre 2008, 13h24<BR><BR><PRE>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@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
</PRE></BLOCKQUOTE></td></tr></table><br>