[vtkusers] vtkSTLWriter.

#YAN RI AN# PS7278514B at ntu.edu.sg
Fri Sep 27 08:01:14 EDT 2002


Dear All:

   I want to export my visualization result with *.stl format. 

   but I cannot get any stl file.

   what matter?

Thanks a lot.

   vtkVolume16Reader *v16=vtkVolume16Reader::New();
    v16->SetDataDimensions(64,64);
    v16->GetOutput()->SetOrigin(0,0,0);
    v16->SetDataByteOrderToLittleEndian();
    v16->SetFilePrefix("c:/Vtkdata/Data/headsq/quarter");
    v16->SetImageRange(1,93);
    v16->SetDataSpacing(1,1,0.5);

    vtkMarchingContourFilter *iso=vtkMarchingContourFilter::New();
    iso->SetInput(v16->GetOutput());
    iso->SetValue(0,1125);

    vtkPolyDataMapper *isoMapper=vtkPolyDataMapper::New();
    isoMapper->SetInput(iso->GetOutput());
    isoMapper->ScalarVisibilityOff();


    vtkActor *isoActor=vtkActor::New();
    isoActor->SetMapper(isoMapper);
    isoActor->GetProperty()->SetColor(1,1,1);

// Add the actors to the renderer, set the background and size
     vtkRenderer *ren1 = vtkRenderer::New();
     ren1->AddActor(isoActor);
     ren1->SetBackground(0,0,1);
 
    vtkRenderWindow *renWin = vtkRenderWindow::New();
    renWin->AddRenderer(ren1);
    renWin->SetSize(600,600);
  
  vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
  iren->SetRenderWindow(renWin);	
  
  renWin->Render();
  iren->Start();
  
   vtkTriangleFilter *triangles=vtkTriangleFilter::New();
   triangles->SetInput(iso->GetOutput());

   vtkSTLWriter *stl=vtkSTLWriter::New();
   stl->SetInput(triangles->GetOutput());
   stl->SetFileName("c:/yanrian/head.stl");
   stl->Write();


*************************************** 
* Best Regards
* Yan Rian (Research Student) 
* Email : ps7278514b at ntu.edu.sg
* Lab : AMRC Research Centre 
* Nanyang Technological University 
* Singapore 
***************************************





More information about the vtkusers mailing list