[vtkusers] Create "ovoid" with VTK
Shawn Waldon
swaldon at cs.unc.edu
Tue Jul 9 17:11:15 EDT 2013
You probably want something more like:
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();
vtkTransformPolyDataFilter* tFilter = vtkTransformPolyDataFilter::New();
tFilter->SetInputConnection(sSource.GetOutputPort());
tFilter->SetTransform(transform);
tFilter->Update()
vtkPolyDataMapper *map = vtkPolyDataMapper::New();
map->SetInputConnection(tFilter->GetOutputPort());
.................
I didn't change your example much due to laziness and wanting to
copy/paste, but you really should use vtkSmartPointers.
On Tue, Jul 9, 2013 at 5:06 PM, mar x <myint101 at gmail.com> wrote:
> 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);
> ......
> .....
> .....
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
--
Shawn Waldon
Graduate Student
Department of Computer Science
University of North Carolina at Chapel Hill
swaldon at cs.unc.edu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130709/45e7e8a5/attachment.htm>
More information about the vtkusers
mailing list