[vtkusers] Create "ovoid" with VTK

mar x myint101 at gmail.com
Tue Jul 9 17:06:15 EDT 2013


Dear VTK list,

I want to create a 3D object that looks like an egg/ovoid. I tried to to
this with vtkSphere and by setting the vtkTransform->Scale to something
like 3,1,1 but it's not working. I would be very glad if you could help me
on this. Please find below the code and thank you for any help!


vtkSphereSource *sSource= vtkSphereSource::New();
   sSource->SetThetaResolution( 12);
   sSource->SetPhiResolution (  12);
   sSource->SetCenter( 0, 0, 0 );
   sSource->SetRadius( 10.0 );

vtkTransform* transform = vtkTransform::New();
     transform->Identity();
   transform->Scale(3,1,1);
   transform->Update();
   vtkSphere* sphere = vtkSphere::New();
   sphere->SetCenter(0,0,0);
  sphere->SetTransform(transform);

     vtkSmartPointer<vtkClipPolyData> clipper =
vtkSmartPointer<vtkClipPolyData>::New();
    clipper->SetInputConnection(sSource->GetOutputPort());
    clipper->SetClipFunction(sphere);
    clipper->SetValue(0);
    clipper->Update();

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

  vtkActor *aSphere = vtkActor::New();
  aSphere->SetMapper(map);
  aSphere->GetProperty()->SetColor(0,0,1);
......
.....
.....
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130709/849d93ed/attachment.htm>


More information about the vtkusers mailing list