VTK8.2 VS 2017 Windows 10 C++インストール
18479 ワード
1、インストールまずはhttps://vtk.org/download/公式にパッケージをダウンロードし、解凍します. なかったら 開く クリック
ここでデフォルトはwin 32、つまり32ビットのプロジェクトですが、x 64のプロジェクトが必要な場合は、x 64プラットフォームを選択し続けてください.そうしないと、win 32のプロジェクトで変更すると多くの問題が発生します.例えば最初はこの問題に気づかなかったのですが、QT 64ビットを使うので、プロジェクトをx 64に変更した結果、多くの問題が発生しました.例えば構成が完了すると、赤い選択肢がたくさん出てくるので、もう一度注文 新規の格納を見つける 2、配置空の項目C++項目を新規作成する. プロジェクト->属性->構成属性->VC++ディレクトリ->含むディレクトリに追加 プロジェクト->プロパティ->構成プロパティ->リンクアタッチメントライブラリディレクトリに追加 編集項目->属性->構成属性->リンク->追加依存項目を入力し、4.生成されたすべての プロジェクト->属性->構成属性->デバッグ環境に書き込む
これで
3、テスト
付録は公式サイトが与えた例(c++)、すべてのケースのウェブサイトですhttps://lorensen.github.io/VTKExamples/site/Cxx/最初の部分では公式とは異なり、主に
これは、公式に
多くの人が案に遭遇し、以下のように説明しています.https://stackoverflow.com/questions/18642155/no-override-found-for-vtkpolydatamapper正常に実行すると、円柱が表示されます.
4、付録
cmake
、インストールcmake
ソフト、Windowsでのcmake
GUIがあれば使えて便利です.cmake
選択vtk
のルートディレクトリ(あるCMakeLists.txt
ファイル)をsource
ディレクトリとして新規作成cmake
build
プロジェクトを格納するディレクトリとしてフォルダをどこに置いても良いのでおすすめsource
同級ディレクトリに置くconfig
配置を行い、ここではVS2017
を使用するので、VS2017
とデフォルトのコンパイラを選択します.ここでデフォルトはwin 32、つまり32ビットのプロジェクトですが、x 64のプロジェクトが必要な場合は、x 64プラットフォームを選択し続けてください.そうしないと、win 32のプロジェクトで変更すると多くの問題が発生します.例えば最初はこの問題に気づかなかったのですが、QT 64ビットを使うので、プロジェクトをx 64に変更した結果、多くの問題が発生しました.例えば
“X64” “X86”
、これはcmake生成プロジェクトを開始するときにwin 32が配置されていたためです.その後、x 64を変更する多くの構成が変更されていない(一つ一つ修正するのも難しい)ので、手動で少し修正するよりも、cmakeの時にx 64を生産するプロジェクトを指定すると、多くの問題が解決します.config
赤い選択肢が消えてしまう.多くの選択肢がありますが、特別な需要がなければ一時的にデフォルトでいいので、注意してください.一つの選択肢はCMAKE_INSTALL_PREFIX
、後ろの経路は私たちがコンパイルした.h
lib
・dll
ファイルを保存して、カスタマイズして設定することができます.それから、generate
エントリを生成して、完成したらプロジェクトが生成して、cmake
の役割が終わります.build
後ファイルのディレクトリを開く.sln
ファイルを開き、ソリューションを生成(時間が少し長い)してからInstall
プロジェクトを生成する.これにより、必要なすべてのライブラリファイルがCMAKE_INSTALL_PREFIX
指定されたファイルフォルダ内に生成される.vtk
のinclude
フォルダ.vtk
のlib
フォルダ.vtk
のlib
フォルダ内に新規txt
ファイルを作成し、DIR *.lib /B >LIBLIST.TXT
ファイルを書き込み保存し、接尾辞を変更.txt
.bat
として実行する.これはディレクトリに新たな.txt
ファイルが生成され、ファイルはすべてlib
ファイルの名前が格納されている.lib
ファイルの名前を貼り付けます.PATH= vtk dll (bin )
VS
ファイルを見つけるdll
ファイル、またはdll
ファイルをすべてプロジェクトにコピーし、具体的に検索することができます.これで
.h,lib,dll
ファイルが配置されてコードが書けるようになりました.3、テスト
付録は公式サイトが与えた例(c++)、すべてのケースのウェブサイトですhttps://lorensen.github.io/VTKExamples/site/Cxx/最初の部分では公式とは異なり、主に
#include
VTK_MODULE_INIT(vtkRenderingOpenGL2);
VTK_MODULE_INIT(vtkInteractionStyle);
これは、公式に
cmakelists
ファイルが与えられていて、cmake
で構築されたアイテムで、ここに直接貼り付けられたコードが、若干異なっているため、初期化操作を行う必要があります.Error: no override found for 'vtkPolyDataMapper'.
多くの人が案に遭遇し、以下のように説明しています.https://stackoverflow.com/questions/18642155/no-override-found-for-vtkpolydatamapper正常に実行すると、円柱が表示されます.
4、付録
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
VTK_MODULE_INIT(vtkRenderingOpenGL2);// ,
VTK_MODULE_INIT(vtkInteractionStyle);
int main(int, char *[]) {
vtkSmartPointer<vtkNamedColors> colors =
vtkSmartPointer<vtkNamedColors>::New();
// Set the background color.
std::array<unsigned char, 4> bkg{{26, 51, 102, 255}};
colors->SetColor("BkgColor", bkg.data());
// This creates a polygonal cylinder model with eight circumferential facets
// (i.e, in practice an octagonal prism).
vtkSmartPointer<vtkCylinderSource> cylinder =
vtkSmartPointer<vtkCylinderSource>::New();
cylinder->SetResolution(8);
// The mapper is responsible for pushing the geometry into the graphics
// library. It may also do color mapping, if scalars or other attributes are
// defined.
vtkSmartPointer<vtkPolyDataMapper> cylinderMapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
cylinderMapper->SetInputConnection(cylinder->GetOutputPort());
// The actor is a grouping mechanism: besides the geometry (mapper), it
// also has a property, transformation matrix, and/or texture map.
// Here we set its color and rotate it around the X and Y axes.
vtkSmartPointer<vtkActor> cylinderActor = vtkSmartPointer<vtkActor>::New();
cylinderActor->SetMapper(cylinderMapper);
cylinderActor->GetProperty()->SetColor(
colors->GetColor4d("Tomato").GetData());
cylinderActor->RotateX(30.0);
cylinderActor->RotateY(-45.0);
// The renderer generates the image
// which is then displayed on the render window.
// It can be thought of as a scene to which the actor is added
vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();
renderer->AddActor(cylinderActor);
renderer->SetBackground(colors->GetColor3d("BkgColor").GetData());
// Zoom in a little by accessing the camera and invoking its "Zoom" method.
renderer->ResetCamera();
renderer->GetActiveCamera()->Zoom(1.5);
// The render window is the actual GUI window
// that appears on the computer screen
vtkSmartPointer<vtkRenderWindow> renderWindow =
vtkSmartPointer<vtkRenderWindow>::New();
renderWindow->SetSize(300, 300);
renderWindow->AddRenderer(renderer);
renderWindow->SetWindowName("Cylinder");
// The render window interactor captures mouse events
// and will perform appropriate camera or actor manipulation
// depending on the nature of the events.
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
renderWindowInteractor->SetRenderWindow(renderWindow);
// This starts the event loop and as a side effect causes an initial render.
renderWindowInteractor->Start();
return EXIT_SUCCESS;
}