[vtkusers] triangulating a cylinder
debbie larson
debbielarson_9 at hotmail.com
Thu Dec 7 13:09:23 EST 2006
Hi,
I am now using vtkCylinderSource to build the cylinder. The problem is that
I want to build several cylinders with different radii and located at
different positions. Do I assign one actor for each cylinder? How exactly I
specify the center of each cylinder? (The code below doesnt seem to work)
Here it is my current code (which is not working; it only displays one
cylinder)
Thanks
deb
-----------------------------------------------------------------------------
vtkCylinderSource* cylinder=vtkCylinderSource::New();
vtkPolyDataMapper *icylinderMapper = vtkPolyDataMapper::New();
vtkActor *icylinderActor = vtkActor::New();
icylinderActor->GetProperty()->SetColor(1.0000, 0.3882, 0.2784);//RGB
color
icylinderActor->RotateX(30.0);
icylinderActor->RotateY(-45.0);
vtkRenderer *ren1 = vtkRenderer::New();
vtkRenderWindow *renWin = vtkRenderWindow::New();
renWin->AddRenderer(ren1);
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);
ren1->SetBackground(0.1, 0.2, 0.4);
renWin->SetSize(500, 500);
for (int i=0;i<num_cylinders;i++)
{
float oradius=tdplane.getradius(i);
//Get the position of the center of the cylinder
float position[2]=tdplane.getposition();
float center_positionx=position[0];
float center_positiony=position[1];
cylinder->SetHeight(cylinder_height);
cylinder->SetRadius(iradius);
cylinder->SetCenter(center_positionx,0,center_positiony);
cylinder->CappingOff();
cylinder->SetResolution(8);
icylinderMapper->SetInputConnection(cylinder->GetOutputPort());
icylinderActor->SetMapper(icylinderMapper);
//Add the actors to the renderer
ren1->AddActor(icylinderActor);
}
ren1->ResetCamera();
ren1->GetActiveCamera()->Zoom(1.0);
renWin->Render();
iren->Start();
cylinder->Delete();
icylinderMapper->Delete();
icylinderActor->Delete();
ren1->Delete();
renWin->Delete();
iren->Delete();
}
_________________________________________________________________
Visit MSN Holiday Challenge for your chance to win up to $50,000 in Holiday
cash from MSN today!
http://www.msnholidaychallenge.com/index.aspx?ocid=tagline&locale=en-us
More information about the vtkusers
mailing list