[vtkusers] give direction to cylinder
Gonzalo Amadio
gonzaloamadio at gmail.com
Wed Jul 18 13:53:37 EDT 2012
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();
2012/7/18 David Doria <daviddoria at gmail.com>
> On Wed, Jul 18, 2012 at 10:07 AM, Gonzalo Amadio <gonzaloamadio at gmail.com>wrote:
>
>> I forgot to put the code, I only add this to the previous one
>>
>> vtkSmartPointer<vtkTransform> transform =
>>> vtkSmartPointer<vtkTransform>::New();
>>> transform->RotateY(90);
>>>
>>
>>
>> vtkSmartPointer<vtkTransformPolyDataFilter> transF =
>>> vtkSmartPointer<vtkTransformPolyDataFilter>::New();
>>> transF->SetInput(cylinderSource->GetOutput());
>>> transF->SetTransform(transform);
>>> transF->Update();
>>>
>>
>>
>> vtkSmartPointer<vtkPolyData> cylinder = transF->GetOutput();
>>
>>
> These are transformation it the mathematical sense - i.e. "around the
> origin". You'd have to center your data (by subtracting it's center, a
> translation to the origin), apply the rotation, and then return your data
> to its original position by adding its center (a final translation).
>
> David
>
--
--------
Gonzalo Amadio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120718/c3af8d91/attachment.htm>
More information about the vtkusers
mailing list