日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

VTK修炼之道4_Win32控制台项目

發布時間:2025/3/15 编程问答 21 豆豆
生活随笔 收集整理的這篇文章主要介紹了 VTK修炼之道4_Win32控制台项目 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1.類的定義

myVTKapp.h

#include "windows.h" #include "vtkConeSource.h" #include "vtkPolyDataMapper.h" #include "vtkRenderWindow.h" #include "vtkRenderWindowInteractor.h" #include "vtkRenderer.h"static HANDLE hinst; long FAR PASCAL WndProc (HWND,UINT,UINT,LONG);class myVTKapp { public:myVTKapp(HWND parent);~myVTKapp(); private:vtkRenderWindow *renWin;vtkRenderer *renderer;vtkRenderWindowInteractor *iren;vtkConeSource *cone;vtkPolyDataMapper *coneMapper;vtkActor *coneActor; };

2.類的實現

myVTKapp.ccp #include <vtkAutoInit.h> VTK_MODULE_INIT(vtkRenderingOpenGL); /// #include "myVTKcpp.h"myVTKapp::myVTKapp(HWND hwnd) {// we create the basic parts of a pipeline and connect themthis->renderer = vtkRenderer::New();this->renWin = vtkRenderWindow::New();this->renWin->AddRenderer(this->renderer);// setup the parent windowthis->renWin->SetParentId(hwnd);this->iren = vtkRenderWindowInteractor::New();this->iren->SetRenderWindow(this->renWin);//Datathis->cone = vtkConeSource::New();this->cone->SetHeight(4.0);this->cone->SetRadius(2.0);this->cone->SetResolution( 20 );//???this->coneMapper = vtkPolyDataMapper::New();this->coneMapper->SetInputConnection(this->cone->GetOutputPort());this->coneActor = vtkActor::New();this->coneActor->SetMapper(this->coneMapper);this->renderer->AddActor(this->coneActor);this->renderer->SetBackground(0.2,0.3,0.4);this->renWin->SetSize(800,800);//finally we start the interactor so that event will be handlethis->renWin->Render(); } myVTKapp::~myVTKapp() {renWin->Delete();renderer->Delete();iren->Delete();cone->Delete();coneMapper->Delete();coneActor->Delete();}

3.主調函數

myVTKapp.cpp
/// //WinMain int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpszCmdParam, int nCmdShow) {static char szAppName[] = "Win32Cone";HWND hwnd ;MSG msg ;WNDCLASS wndclass ;if (!hPrevInstance){wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;wndclass.lpfnWndProc = WndProc ;wndclass.cbClsExtra = 0 ;wndclass.cbWndExtra = 0 ;wndclass.hInstance = hInstance;wndclass.hIcon = LoadIcon(NULL,IDI_APPLICATION);wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);wndclass.lpszMenuName = NULL;wndclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);wndclass.lpszClassName = szAppName;RegisterClass (&wndclass);}hinst = hInstance;hwnd = CreateWindow ( szAppName,"Draw Window",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,800,800,NULL,NULL,hInstance,NULL);ShowWindow (hwnd, nCmdShow);UpdateWindow (hwnd);while (GetMessage (&msg, NULL, 0, 0)){TranslateMessage (&msg);DispatchMessage (&msg);}return msg.wParam; }long FAR PASCAL WndProc (HWND hwnd, UINT message,UINT wParam, LONG lParam) {static HWND ewin;static myVTKapp *theVTKApp;switch (message){case WM_CREATE:{ewin = CreateWindow("button","Exit",WS_CHILD | WS_VISIBLE | SS_CENTER,0,800,800,60,hwnd,(HMENU)2,(HINSTANCE)GetWindowLong(hwnd,GWL_HINSTANCE),NULL);theVTKApp = new myVTKapp(hwnd);return 0;}case WM_COMMAND:switch (wParam){case 2:PostQuitMessage (0);if (theVTKApp){delete theVTKApp;theVTKApp = NULL;}break;}

4.運行結果


總結

以上是生活随笔為你收集整理的VTK修炼之道4_Win32控制台项目的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。