[vtkusers] give direction to cylinder
David Doria
daviddoria at gmail.com
Wed Jul 18 14:41:58 EDT 2012
On Wed, Jul 18, 2012 at 1:53 PM, Gonzalo Amadio <gonzaloamadio at gmail.com>wrote:
> Well, here is my code, now it seems to work .
>
> vtkSmartPointer<vtkCylinderSource> cylinderSource =
>> vtkSmartPointer<vtkCylinderSource>::New();
>> cylinderSource->SetCenter(center[0], center[1], center[2]);
>>
>
>
> vtkSmartPointer<vtkTransform> transform =
>> vtkSmartPointer<vtkTransform>::New();
>> transform->Translate(-center[0],-center[1],-center[2]);
>> transform->PostMultiply(); //This was the fundamental line, if I have
>> not put this line, the second translation goes to a wrong place.
>> transform->RotateX(90);
>> transform->Translate(centerV[0],centerV[1],centerV[2]);
>>
>
>
> vtkSmartPointer<vtkTransformPolyDataFilter> transF =
>> vtkSmartPointer<vtkTransformPolyDataFilter>::New();
>> transF->SetInput(cylinderSource->GetOutput());
>> transF->SetTransform(transform);
>> transF->Update();
>>
>
>
> vtkSmartPointer<vtkPolyData> cylinder = transF->GetOutput();
>
>
You may find Lecture 2: Transforms from here:
http://www.vtk.org/Wiki/VTK/Presentations
useful as well, but it seems you've already solved the problem.
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120718/6aa8b621/attachment.htm>
More information about the vtkusers
mailing list