[vtkusers] vtkTriangleStrip and empty vtkSTLWriter output

David Cole DLRdave at aol.com
Wed Oct 14 22:34:25 EDT 2015


I understand it's VTK's style to keep classes as independent of each other
as possible, and to make all things optional and easily connectable, so you
don't have to run unnecessary filters.

But in this case, it's absolutely clear that the STL writer requires
polydata with only triangles in it to write out a meaningful STL file.
(I've encountered this personally before, and it took quite some effort to
figure out that I just had to add a few lines of code to put a triangle
filter in, too...)

So it begs the question: why is this a mailing list question in 2015?

Shouldn't the STL writer detect that its input contains non-triangles, and
**automatically** insert a triangle filter to produce correct output? Or,
at the very least, spit out an error message saying "here, insert this code
before calling Update/Write, and it will work like you want it to" ... ?

(Similarly for rendering crappy polydata using the polydata mapper: it
requires up-to-date normals to render with proper lighting and shading, and
seems like the perfect candidate for **automatically** inserting a polydata
normals filter. This might be harder to detect that the normals are not up
to date, but sure would have saved my team some time recently...)

Would these types of improvements be welcome additions to VTK, or am I
missing some case where you would NOT want this type of behavior?


??
David C.



On Wednesday, October 14, 2015, <piers.barber at logicmonkey.co.uk> wrote:

>  On 2015-10-14 18:10, Cory Quammen wrote:
>
> Maybe try inserting a vtkTriangleFilter in front of your STL writer?
>
> Perfect - many many thanks!
>
> It worked on the triangle mesh AND on the ruled surface. Both STL files
> read into other apps just fine. The ruled surface output is appreciably
> higher quality even than a very high poly count mesh.
>
> For the record...
>
> // write out a STL file
> // run a triangle filter ruled surface to create polys
> vtkSmartPointer<vtkTriangleFilter>
> tris = vtkTriangleFilter::New();
> tris->SetInputConnection(ruled->GetOutputPort());
> vtkSmartPointer<vtkSTLWriter>
> stlWriter = vtkSmartPointer<vtkSTLWriter>::New();
> stlWriter->SetFileName("Ruled.stl");
> stlWriter->SetInputConnection(tris->GetOutputPort());
> stlWriter->Write();
>
> And
>
> // write out a STL file
> // run a triangle filter on the mesh to create polys
> vtkSmartPointer<vtkTriangleFilter>
> tris = vtkTriangleFilter::New();
> tris->SetInputConnection(ruled->GetOutputPort());
>
> vtkSmartPointer<vtkSTLWriter>
>
> stlWriter = vtkSmartPointer<vtkSTLWriter>::New();
>
> stlWriter->SetFileName("Mesh.stl");
> stlWriter->SetInputConnection(tris->GetOutputPort());
> stlWriter->Write();
>
> --
>
> Piers Barber                   (-=:LogicMonkey:=-)
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20151014/9d00cfd7/attachment.html>


More information about the vtkusers mailing list