I have some basic code that creates a 3D text, applies a linear extrusion filter, and then displays it in a viewport. This works well, but now I would like to output the result of the extrusion to an STL file using vtkStlWriter. I am extremely new to VTK (just got it to compile two hours ago), so I believe I'm just missing something really basic. Here is the relevant code:<br>
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> ...<br><br> // Create vector text</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> vtkVectorText* vecText = vtkVectorText::New();</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> vecText->SetText("Text!");</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> // Apply linear extrusion </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> vtkLinearExtrusionFilter* extrude = vtkLinearExtrusionFilter::New();</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> extrude->SetInputConnection( vecText->GetOutputPort());</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> extrude->SetExtrusionTypeToNormalExtrusion();</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> extrude->SetVector(0, 0, 1 );</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> extrude->SetScaleFactor (0.5);</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> // output the mesh to a PolyDataMapper and then to an Actor</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> vtkPolyDataMapper* txtMapper = vtkPolyDataMapper::New();</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> txtMapper->SetInputConnection( extrude->GetOutputPort());</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> vtkActor* txtActor = vtkActor::New();</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> txtActor->SetMapper(txtMapper);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> // add it to the renderer</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> ren->AddActor(txtActor);</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> // attempt to write an STL file</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> std::string outputFilename = "test.stl";</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> vtkSmartPointer<vtkPolyData> data = vtkSmartPointer<vtkPolyData>::New();</span><br>
<br><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> <b>// data = extrude->getOutput();</b> // this line causes an error: <b>'class vtkLinearExtrusionFilter' has no member named 'getOutput'</b></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> vtkSmartPointer<vtkSTLWriter> stlWriter = vtkSmartPointer<vtkSTLWriter>::New();</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> stlWriter->SetFileName(outputFilename.c_str());</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> <br> <b>stlWriter->SetInput(data);</b> // passing <b>extrude->getOutput()</b> here seems to work, but doesn't send the walls of the extrusion</span> <br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> stlWriter->Write();</span><br><br><span style="font-family: courier new,monospace;"> ...</span><br style="font-family: courier new,monospace;"><br>When I try to run: <br>
<br><span style="font-family: courier new,monospace;"> stlWriter->setInput(extrude->getOutput())</span>;<br><br>it just outputs the text twice, separated by the thickness of the extrusion but without the walls. Does that make sense. Let me know if I'm missing something or if it is not possible. Thanks for the help, and I can certainly send the whole code if someone wants to run it, but I think my problem is simple enough that someone can just glance at the code and see what's wrong. Thanks for the help in advance,<br>
<br>Dave<br>