<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html><body>
<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>
</body></html>