[vtkusers] Retrieve poligonal data after delaunay triangulation

Mike Jackson imikejackson at gmail.com
Wed May 16 07:05:59 EDT 2007


Please Keep the discussion on list so others may learn.

In the example code that I sent you there should be some code that  
shows how to create a vtkPolyData from scratch and populate it with  
data. If you do not do this just right you can end up with empty arrays.

 From your code below the "delaunayOutput" variable is not hooked up  
to anything. I am going to assume that there is some method in your  
code in which you populate that object with data. If this is NOT the  
case then you need to do that, then feed the "delaunayOutput" into  
the vtkPolyDataWriter object and you should get some data written to  
a file.

-- 
Mike Jackson   Senior Research Engineer
Innovative Management & Technology Services


On May 16, 2007, at 10:28 AM, Samuel Marcos wrote:

> Well, I actually apply the Delaunay filter to my Polydata then use  
> a PolyDataWriter not hooked to Delaunay Output (only to see what  
> was happening) and then make the "triangles to array extraction"  
> stuff. In pseudocode:
> vtkPolyData* data;
> vtkDelauneyFilter* filter = vtkDelauney::New();
> filter->SetInput(data);
> filter->Update();
> vtkPolyData* delaunayOutput;          // I save the Output of  
> Delaunay in a PolyData
> vtkPolyDataWriter* writer = vtkPolyDataWriter::New();
> writer->SetInput(delaunayOutput);     //use the PolyData as input
> writer->SetFileName( outputFile );
> writer->Update();
> //....
> Triangle extraction from delaunayOutput PolyData part of code here  
> which only works if I do not use the PolyDataWriter. If I use it I  
> get an empty array from delaunayOutput...//
>
> It would be nice to know what I'm missing because I'm obtaining  
> same empty results in other filters I'm using as the threshold  
> filter. Many thanks.
> On 5/16/07, Mike Jackson <imikejackson at gmail.com> wrote:
> usually you hook up the output from a filter to the input of the  
> next filter and it should just work. So in your case, you have an  
> input vtkPolyData object and are feeding that into the  
> DelauneyFilter and then want to write the results out to a file.
>
> The following is some pseudo code but represents what should be done.
>
> vtkPolyData* data;
> vtkDelauneyFilter* filter = vtkDelauney::New();
> filter->SetInput(data);
> filter->Update(); //Forces updating of the pipeline.. Not really  
> needed in some situations
> vtkPolyDataWriter* writer = vtkPolyDataWriter::New();
> writer->SetInputConnection( filter->GetOutputPort() );
> writer->SetFileName( outputFile );
> writer->Update();
>
> writer->Delete()
> filter->Delete()
>
> Hope that helps.
> -- 
> Mike Jackson   Senior Research Engineer
> Innovative Management & Technology Services
>
>
> On May 16, 2007, at 6:42 AM, Samuel Marcos wrote:
>
>> Ok, I've managed it (I write down the part of code in case someone  
>> reads this post and needs it). The weird thing is that I  
>> previously tried to write the PolyData to a text file. If I use  
>> the vtkPolyDataWriter before extracting the triangles, I get an  
>> empty array as if the vtkPolyDataWriter erased the PolyData. Is  
>> that normal? I think this is a begginer question but how do I know  
>> if a filter erases or changes the input contents? I've read each  
>> filter makes a copy of the input so I thought the input would stay  
>> as it is even if passed through a filter. Am I wrong? Many thanks  
>> to all your responses, Luca, burlen and Mike (also for the code).
>>
>>   int j=0;
>>     int h;
>>     int npts=3,*pts;
>>     vtkCellArray* oCellArr= vtkCellArray::New();
>>     oCellArr=oPolyDataDel->GetPolys();
>>      for(int i=0;i<oPolyDataDel->GetNumberOfPolys();i++)
>>      {
>>             h=oCellArr->GetNextCell(npts,pts);
>>
>>             if(h==0){
>>                 break;
>>             }
>>             if(npts==3){
>>             vTriangulos[j]= pts[0];
>>             vTriangulos[j+1]= pts[1];
>>             vTriangulos[j+2]= pts[2];
>>             j+=3;
>>             }
>>
>>      }
>> _______________________________________________
>> 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/20070516/dbae581d/attachment.htm>


More information about the vtkusers mailing list