<div dir="ltr"><span style="font-size:12.8px">Maybe try inserting a vtkTriangleFilter in front of your STL writer?</span><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">- Cory</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 12, 2015 at 6:12 PM,  <span dir="ltr"><<a href="mailto:piers.barber@logicmonkey.co.uk" target="_blank">piers.barber@logicmonkey.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><u></u>
<div>
<p>Hello VTKers</p>
<p>I was getting empty STL file output from a program I wrote using the ruled surface filter. So I thought I would take a different approach and create triangle strips.</p>
<p>The code does what I would expect, but I still get an empty STL file (which I think would be because there are no polys in the polydata).</p>
<p>The ruled surface I can believe would have this problem, but a triangle strip should be OK?</p>
<p>My full test example code follows. It creates a triangle strip 2 triangles at a time by starting with 2 points and then successively adding more in pairs.</p>
<p>If there is a step that I have missed that is required to convert this to individual triangles for vtxSTLWriter, what would happen to vertex winding order?</p>
<p>All comments and observations welcome!</p>
<p>Thanks.</p>
<p>-=:LogicMonkey:=-</p>
<p>#include <vtkVersion.h> <br>#include <vtkSmartPointer.h><br>#include <vtkRenderer.h><br>#include <vtkRenderWindow.h><br>#include <vtkRenderWindowInteractor.h><br>#include <vtkCellArray.h><br>#include <vtkTransform.h><br>#include <vtkTransformPolyDataFilter.h><br>#include <vtkAppendPolyData.h><br>#include <vtkPolyDataMapper.h><br>#include <vtkProperty.h><br>#include <vtkCamera.h><br>#include <vtkTriangleStrip.h><br>#include <vtkSTLWriter.h></p>
<p>#define VERTICES 100</p>
<p>int main(int, char *[]) {</p>
<p>vtkSmartPointer<vtkPoints><br> points = vtkSmartPointer<vtkPoints>::New();<br> points->InsertPoint(0, 0, 0, 0); <br> points->InsertPoint(1, 0, 1, 0);</p>
<p>vtkSmartPointer<vtkTriangleStrip><br> strip = vtkSmartPointer<vtkTriangleStrip>::New();<br> strip->GetPointIds()->SetNumberOfIds(VERTICES);<br> strip->GetPointIds()->SetId(0,0);<br> strip->GetPointIds()->SetId(1,1);</p>
<p>for( int i=1; i<VERTICES/2; i++ ) {</p>
<p>points->InsertPoint(2*i, (double) i, 0, 0); <br> points->InsertPoint(2*i+1, (double) i, 1, 0);</p>
<p>strip->GetPointIds()->SetId(2*i,2*i);<br> strip->GetPointIds()->SetId(2*i+1,2*i+1);<br> }</p>
<p>vtkSmartPointer<vtkPolyData><br> polydata = vtkSmartPointer<vtkPolyData>::New();</p>
<p>polydata->SetPoints(points);</p>
<p>vtkSmartPointer<vtkCellArray><br> cells = vtkSmartPointer<vtkCellArray>::New();<br> cells->InsertNextCell(strip);</p>
<p>polydata->SetStrips(cells);</p>
<p>// STL file output</p>
<p>vtkSmartPointer<vtkSTLWriter><br> stlWriter = vtkSmartPointer<vtkSTLWriter>::New();<br> stlWriter->SetFileName("StripEx.stl");<br> stlWriter->SetInputData(polydata);<br> stlWriter->Write();</p>
<p>// now the usual VTK render and displey pipeline</p>
<p>vtkSmartPointer<vtkPolyDataMapper><br> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();<br> mapper->SetInputData(polydata); // data to mapper</p>
<p>vtkSmartPointer<vtkActor><br> actor = vtkSmartPointer<vtkActor>::New();<br> actor->SetMapper(mapper); // mapper to actor</p>
<p>actor->GetProperty()->SetColor(0.89, 0.81, 0.34);<br> actor->GetProperty()->SetRepresentationToWireframe();</p>
<p>// Add the actors to the renderer, set the background and size<br> vtkSmartPointer<vtkRenderer><br> renderer = vtkSmartPointer<vtkRenderer>::New();</p>
<p>vtkSmartPointer<vtkRenderWindow><br> renderWindow = vtkSmartPointer<vtkRenderWindow>::New();<br> renderWindow->AddRenderer(renderer);</p>
<p>vtkSmartPointer<vtkRenderWindowInteractor><br> interactor = vtkSmartPointer<vtkRenderWindowInteractor>::New();<br> interactor->SetRenderWindow(renderWindow);</p>
<p>renderer->AddActor(actor);<br> renderer->SetBackground(.3, .4, .5);</p>
<p>renderer->ResetCamera();<br> renderer->GetActiveCamera()->Azimuth(60);<br> renderer->GetActiveCamera()->Elevation(60);<br> renderer->GetActiveCamera()->Dolly(1.2);<br> renderer->ResetCameraClippingRange();</p>
<p>renderWindow->Render();<br> interactor->Start();</p>
<p>return EXIT_SUCCESS;</p>
<p>}</p>
<div> </div>
</div>
<br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Cory Quammen<br>R&D Engineer<br>Kitware, Inc.</div>
</div>