[Insight-users] Unable to write a delaunay2D mesh in a .vtu file

David Doria daviddoria at gmail.com
Fri Mar 9 06:41:10 EST 2012


On Fri, Mar 9, 2012 at 1:54 AM, Sylvain Bernhardt <sylvainb at ece.ubc.ca> wrote:
> Hi all,
> I'm triangulating a 2D Delaunay mesh from a cloud of points encapsulated in
> std::vector<int> *N like so:
>
>     vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
>
>     for(int i = 0; i < N->size(); i += 2)
>         points->InsertNextPoint(N->at(i), N->at(i+1), some_value[i]);
>
>     vtkSmartPointer<vtkPolyData> polydata =
> vtkSmartPointer<vtkPolyData>::New();
>     polydata->SetPoints(points);
>
>     vtkSmartPointer<vtkDelaunay2D> delaunay =
> vtkSmartPointer<vtkDelaunay2D>::New();
>     delaunay->SetInput(polydata);
>     delaunay->Update();
>
>     vtkSmartPointer<vtkXMLUnstructuredGridWriter> writer =
>         vtkSmartPointer<vtkXMLUnstructuredGridWriter>::New();
>     writer->SetInputConnection(delaunay->GetOutputPort());
>     writer->SetFileName("Mesh.vtu");
>     writer->Write();
>
> Apparently the triangulation is fine since I'm able to render it later on.
> But the writing part triggers the following error:
> ERROR: In ..\..\Filtering\vtkDemandDrivenPipeline.cxx, line 827
> vtkStreamingDemandDrivenPipeline (0000000002E8D030): Input for connection
> index 0 on input port index 0 for algorithm
> vtkXMLUnstructuredGridWriter(00000000035DC9C0) is of type vtkPolyData, but a
> vtkUnstructuredGrid is required.
>
> I find it weird since I pretty much did exactly the same than in this
> example with a delaunay3d.
>
> Any thoughts ?
>
> Cheers,
> S.
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>

Did you mean to send this to the VTK list?

Delaunay2D is a subclass of vtkPolyDataAlgorithm, whereas Delaunny3D
is a subclass of vtkUnstructuredGridAlgorithm. You have to use a
vtkXMLPolyDataWriter to write the result of the Delaunay2D filter.

David


More information about the Insight-users mailing list