Help us understand the problem. What is going on with this article?

VTKによる3Dオブジェクトの幾何学変換

More than 3 years have passed since last update.

VTKによる3Dオブジェクトの幾何学変換

はじめに

VTKで3Dオブジェクト(vtkPolyData)を並進や回転などの
幾何学変換を行う方法について,公式サンプルを元にして解説する.
手順としてはまず変換に関するクラスのオブジェクトを生成し,変換に関するプロパティを設定する.その変換を行うオブジェクト(vtkTransformPolyDataFilter)で変換を実行する.

並進と回転の変換

3Dオブジェクト(vtkPolyData)を並進・回転させるためには,vtkTransformを用いる.

vtkSmartPointer<vtkTransform> tra = vtkSmartPointer<vtkTransform>::New();

//並進
tra->Translate(5.0,5.0,5.0);//x, y, z方向の並進量
//回転
tra->RotateWXYZ(45, 0, 1, 0);//回転軸と回転量を指定.
tra->Update();

vtkMatrix4x4* matrix = tra->GetMatrix();//変換行列を取得.

3Dオブジェクト(vtkPolyData)を変換を実行

vtkTransformPolyDataFilterを用いる.

変換元のオブジェクト(vtkPolyData)と変換(vtkTransform, vtkLandmarkTransform,vtkIterativeClosestPointTransformなど)をセットして,vtkTransformPolyDataFilter::GetOutput()で変換したオブジェクトを得る.

vtkSmartPointer<vtkTransformPolyDataFilter> filter = vtkSmartPointer<vtkTransformPolyDataFilter>::New();

filter->SetInputData(polydata);//変換元のvtkPolyDataをセット.
filter->SetTransform(transform);//変換をセット..
filter->Update();

vtkPolyData* output = filter->GetOutput();//変換後

対応関係を用いた変換

vtkLandmarkTransformを用いる.変形前後における対応関係が既知の点をvtkPointsとして,入力する.公式サンプル

vtkSmartPointer<vtkLandmarkTransform> landmark = vtkSmartPointer<vtkLandmarkTransform>::New();

//対応関係をセットする.
landmark->SetSourceLandmarks(sourcePoints);
landmark->SetTargetLandmarks(targetPoints);

landmark->SetModeToRigidBody();
landmark->Update();

vtkMatrix4x4* matrix = landmark->GetOutput();
vs4sh
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした