1.安装vs2019 Enterprise,visual assist x,cmake
Microsoft Visual Studio Enterprise 2019 sn:
BF8Y8-GN2QH-T84XB-QVY3B-RC4DF
2.下载vtk
https://www.vtk.org/files/release/9.2/VTK-9.2.6.tar.gz
3.cmake编译配置选中Example,可编译官方例子
先点一次configure初始化之后,选中VTK_BUILD_EXAMPLES再点一次configure;点generate;点open project。
4.demo
VTK_DIR指向刚才vtk库build的产出。参考代码如下:
CMakeLists.txt
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(Chap02)
FIND_PACKAGE(VTK REQUIRED)
include(${VTK_USE_FILE})
ADD_EXECUTABLE(RenderCylinder RenderCylinder.cpp)
TARGET_LINK_LIBRARIES(RenderCylinder ${VTK_LIBRARIES})
RenderCylinder.cpp
#include <vtkSmartPointer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkInteractorStyleTrackballCamera.h>
#include <vtkCylinderSource.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
int main()
{
vtkSmartPointer<vtkCylinderSource> cylinder = vtkSmartPointer<vtkCylinderSource>::New();
cylinder->SetHeight(3.0);
cylinder->SetRadius(1.0);
cylinder->SetResolution(10);
}
publish.sh
cp -r /D/desktop/VTK-9.2.6/build/bin/Debug/* ./build/Debug/
*附:
visual assist x试用期到期之后重置状态继续试用:
reset-vassistx.bat 管理员权限运行
@echo off
set tempfile="%temp%\1489AFE4.TMP"
set regkey=HKEY_CURRENT_USER\SOFTWARE\Licenses
set has_error=0
tasklist | find /I "devenv.exe" > NUL
if %errorlevel% == 0 (
echo Please close Visual Studio and try again.
exit /B 1
)
echo.
echo Resetting Visual Assist X trial period
echo Deleting registry key %regkey% ...
reg delete %regkey% /f
if %errorlevel% == 1 (
echo Registry key was not deleted.
set has_error=1
)
echo.
echo Deleting temporary file %tempfile% ...
del %tempfile%>NUL
echo.
if %has_error% == 0 (
echo Done. Visual Assist X should have forgotten about your trial period now.
) else (
echo Done. However, maybe not everything worked out right.
)
exit /B %has_error%
问题:
1.为什么不使用vs2022?vs2022过于先进支持的visual assist x不好用。vs2022不支持扩展-管理扩展方式安装visual assist x;vs2022编辑代码时visual assist x不能自动生成代码。
2.为什么不用vs2019以前版本?因为支持的其他第三方开源库少或者是低版本,整个环境搭建有问题。
就这样,你看到这篇日志节省一点开发环境搭建时间,过低版本其他生态需要的开源库也必须是低版本甚至无法使用,追求高版本浪费时间不容易搭建。