Thanks David. You a were correct again. I thought I would post my solution for posterity's sake.<br><br> float * pts = (float * )Tubes->GetOutput()->GetPoints()->GetVoidPointer(0);<br> - in this case I needed to cast the void pointer to the underlying data type which was float <br>
<br> int * CA = Tubes->GetOutput()->GetStrips()->GetPointer();<br> - better coding would probably use vtkIdType * instead of int *<br><br>Thanks<br><br>Matt<br><br>And, then pts[0], pts[1], pts[n-1] and the same for CA<br>
<br><div class="gmail_quote">On Mon, Jan 18, 2010 at 5:41 PM, David Gobbi <span dir="ltr"><<a href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi Matt,<br>
<br>
I think you're looking for the GetPointer() method. Every<br>
vtkDataArray has one. It can return a pointer to the start of the<br>
array.<br>
<font color="#888888"><br>
David<br>
</font><div><div></div><div class="h5"><br>
<br>
On Mon, Jan 18, 2010 at 3:45 PM, Matt <<a href="mailto:pspmatt@gmail.com">pspmatt@gmail.com</a>> wrote:<br>
> Ok! So, I have managed to use my underlying C arrays without much overhead.<br>
> Here, is the code:<br>
><br>
> float *vtkPts = (float * ) argv[0];<br>
> int *vtkCells = (int * ) argv[1];<br>
> int PtsArraySize = * (int *) argv[2];<br>
> int CellArraySize = * (int *) argv[3];<br>
> int nCells = * (int *) argv[4];<br>
><br>
> // Here comes the vtk stuff<br>
><br>
> vtkSmartPointer <vtkFloatArray> pts_fltarr =<br>
> vtkSmartPointer<vtkFloatArray>::New();<br>
> pts_fltarr->SetNumberOfComponents(3); // X,Y,Z<br>
> pts_fltarr->SetArray(vtkPts, PtsArraySize, 1);<br>
><br>
> vtkSmartPointer <vtkPoints> Points = vtkSmartPointer<vtkPoints>::New();<br>
> Points->SetData(pts_fltarr);<br>
><br>
><br>
> vtkSmartPointer <vtkIdTypeArray> Conn =<br>
> vtkSmartPointer<vtkIdTypeArray>::New();<br>
> Conn->SetArray(vtkCells, CellArraySize,1);<br>
><br>
> vtkSmartPointer <vtkCellArray> Polys =<br>
> vtkSmartPointer<vtkCellArray>::New();<br>
> Polys->SetCells(nCells,Conn);<br>
><br>
> vtkSmartPointer <vtkPolyData> Tracts = vtkSmartPointer<br>
> <vtkPolyData>::New();<br>
><br>
> Tracts->SetPoints(Points);<br>
> Tracts->SetLines(Polys);<br>
> Tracts->Update();<br>
><br>
> vtkSmartPointer <vtkTubeFilter> Tubes =<br>
> vtkSmartPointer<vtkTubeFilter>::New();<br>
> Tubes->SetInput(Tracts);<br>
> Tubes->SetRadius(.2);<br>
> Tubes->SetNumberOfSides(6);<br>
> Tubes->Update();<br>
><br>
> ------------------------------<br>
><br>
> Now, I want to pass back two new arrays to IDL that contains the point data<br>
> and the triangle strip (connectivity).<br>
> Again, if I could just access the arrays directly life would be much<br>
> simpler. However, it appears going in reverse might be harder than what I<br>
> have already setup.<br>
><br>
> This will give me the size needed for the arrays:<br>
><br>
> // pts<br>
> int NumPoints = Tubes->GetOutput()->GetNumberOfPoints();<br>
><br>
> // cells/strips/num of elemens in array<br>
> int NumConn = Tubes->GetOutput()->GetStrips()->GetSize();<br>
><br>
> The plan would be to allocate an array of ints (vtkIdType) to hold the<br>
> strips and an array of floats to hold the point data. Both, 1D.<br>
><br>
> Strips (connectivity):<br>
> -------------------------------<br>
><br>
> Tubes->GetOutput()->GetStrips()->GetData() // Will give me a vtkIdTypeArray<br>
> - but I really want is an array of vtkIdType.<br>
> -- At this point, I'd like to use a getArray function like the setArray<br>
> function - but, it doesn't exist.<br>
> -- So, do I need to loop through the whole vtkIdTypeArray and copy it into<br>
> an array of vtkIdType??<br>
> -- or can I avoid this with some trick that I can't figure out?<br>
><br>
> Points:<br>
> ----------<br>
> Tubes->GetOutput()->GetPoints() // will give me a vtkPoints object with all<br>
> of my points<br>
><br>
> -- Again, at this point, I'd like to be able to extract the float array in<br>
> the same way I set it, i.e setdata()<br>
> -- I don't see a good option to do this.<br>
> -- Do, I need to go point-by-point filling a new float array?<br>
><br>
><br>
> Let me know if you can think of a way I can accomplish this? I can write my<br>
> own code to it. But, wonder if there is a way to do this and my lack of<br>
> experience with vtk is not allowing me to see it.<br>
><br>
> Thanks again,<br>
><br>
> Matt<br>
</div></div></blockquote></div><br>