[vtkusers] Please help me with vtkLinearExtrusion usage

dinglw at sei.com.cn dinglw at sei.com.cn
Sun Feb 25 20:02:08 EST 2007


I want to use vtkLinearExtrusion to generate a pad with 5~8 or more edge. 
As the code list following, vtkPoints -> vtkCellArray -> vtkPolyData -> 
vtkLinearExtrusion -> vtkPolyDataMapper , but when I render this in ren 
window, there's an exception error. 

Does anybody know how to create the pad like this? Could anyone give me a 
example code to do this.


  //Create Pad Section
  vtkPoints *points=vtkPoints::New();
    double rDir = -1.; // Ellipsoidal Head direction
    double rDo, rDi, rH;
    rDi = 40.;

    points->InsertPoint(0, 0.,     0,  0);
    points->InsertPoint(1, rDi/2., 30,  0);

    points->InsertPoint(2, rDi/2.,  45,  0);
    points->InsertPoint(3, 22,      15,  0);
    points->InsertPoint(4, 60.,     50,  0);
    points->InsertPoint(5, 20.,     50,  0);
  int nPoints= 5;
  vtkCellArray *poly=vtkCellArray::New();
    poly->InsertNextCell(nPoints);
    for (int i=0; i<= nPoints; i++)
      {
        poly->InsertCellPoint(i);
      }
  // Construct profile
  vtkPolyData *profile=vtkPolyData::New();
    profile->SetPoints(points);
    profile->SetPolys(poly);
    profile->SetLines(poly);


  // Extrude profile
  vtkLinearExtrusionFilter *extrude = vtkLinearExtrusionFilter::New();
    extrude->SetCapping(1);
    extrude->SetScaleFactor(12);
    extrude->SetExtrusionTypeToNormalExtrusion();
    extrude->SetVector(0,0,1);
    extrude->SetInput(profile);


  vtkPolyDataMapper *map=vtkPolyDataMapper::New();
    map->SetInput(extrude->GetOutput());

  vtkActor *pPad = vtkActor::New();
    pPad->SetMapper(map);

 // Render object in current render window
  vtkWindow1->GetRenderer()->AddActor(pPad);
  Delete object does not used anymore
  pPad->Delete();
  map->Delete();
  extrude->Delete();
  vtkWindow1->GetRenderer()->ResetCamera();
  vtkWindow1->Invalidate();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20070226/61b5edf6/attachment.htm>


More information about the vtkusers mailing list