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

歡迎訪問 生活随笔!

生活随笔

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

编程问答

vtk鼠标不交互_vtk 各种不同的鼠标交互方式

發布時間:2024/10/14 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 vtk鼠标不交互_vtk 各种不同的鼠标交互方式 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

/*

演示各種不同的鼠標交互模式

*/

#include "vtkRenderer.h"

#include "vtkRenderWindow.h"

#include "vtkRenderWindowInteractor.h"

#include "vtkVolume16Reader.h"

#include "vtkPolyDataMapper.h"

#include "vtkActor.h"

#include "vtkOutlineFilter.h"

#include "vtkCamera.h"

#include "vtkProperty.h"

#include "vtkPolyDataNormals.h"

#include "vtkContourFilter.h"

#include "vtkMarchingCubes.h"

#include "vtkDICOMImageReader.h"

#include "vtkImageCast.h"

#include "vtkDecimatePro.h"

#include "vtkStripper.h"

#include "vtkImageShrink3D.h"

#include "vtkSmoothPolyDataFilter.h"

#include "vtkTriangleFilter.h"

#include "vtkFeatureEdges.h"

#include "vtkPolyDataWriter.h"

#include "vtkImageData.h"

#include "vtkInteractorStyleTrackballCamera.h"

#include "vtkInteractorStyleUnicam.h"

#include "vtkInteractorStyleUser.h"

#include "vtkInteractorStyleTrackballActor.h"

#include "vtkInteractorStyleTerrain.h"

#include "vtkInteractorStyleSwitch.h"

#include "vtkInteractorStyleFlight.h"

int main ()

{

vtkRenderer *aRenderer = vtkRenderer::New();

vtkRenderWindow *renWin = vtkRenderWindow::New();

renWin->AddRenderer(aRenderer);

///

vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();

iren->SetRenderWindow(renWin);

// 總共10種交互方式 下面是八種

// vtkInteractorStyleTrackballCamera *style = //常用的方式 移動攝像機

// vtkInteractorStyleTrackballCamera::New();

// iren->SetInteractorStyle(style);

// vtkInteractorStyleTrackballActor *style = //移動對象

// vtkInteractorStyleTrackballActor::New();

// iren->SetInteractorStyle(style);

// For a 3-button mouse, the left button is for rotation, the right button for zooming,

//the middle button for panning, and ctrl + left button for spinning.

//(With fewer mouse buttons, ctrl + shift + left button is for zooming,

//and shift + left button is for panning.)

// vtkInteractorStyleUnicam *style = //只有放大和平移的功能

// vtkInteractorStyleUnicam::New();

// iren->SetInteractorStyle(style);

// vtkInteractorStyleUser *style = //沒有鼠標響應 主要用于用戶自定義的操作

// vtkInteractorStyleUser::New();

// iren->SetInteractorStyle(style);

// vtkInteractorStyleTerrain *style =

// vtkInteractorStyleTerrain::New();

// iren->SetInteractorStyle(style);

/*

vtkInteractorStyleSwitch *style =

vtkInteractorStyleSwitch::New();

iren->SetInteractorStyle(style);

*/

// vtkInteractorStyleFlight *style =

// vtkInteractorStyleFlight::New();

// iren->SetInteractorStyle(style);

// vtkInteractorStyleRubberBandZoom *style=vtkInteractorStyleRubberBandZoom::New();

// iren->SetInteractorStyle(style);

// vtkInteractorStyleSwitch *style=vtkInteractorStyleSwitch::New();

// iren->SetInteractorStyle(style);

// vtkInteractorStyleJoystickCamera *style=vtkInteractorStyleJoystickCamera::New();

// iren->SetInteractorStyle(style);

// vtkInteractorStyleJoystickActor *style=vtkInteractorStyleJoystickActor::New();

// iren->SetInteractorStyle(style);

///

vtkDICOMImageReader *reader = vtkDICOMImageReader::New();

reader->SetDataByteOrderToLittleEndian();

reader->SetDirectoryName("D://1//3");

vtkImageData *imageData = vtkImageData::New();

imageData = reader->GetOutput();

imageData->SetOrigin(.0,.0,.0);

//imageData->SetDimensions(64,64,93);

vtkImageShrink3D *shrink=vtkImageShrink3D::New();//二次采樣

shrink->SetInput((vtkDataObject *)reader->GetOutput());

shrink->SetShrinkFactors(4,4,1);//采樣因子

vtkMarchingCubes *skinExtractor = vtkMarchingCubes::New();

skinExtractor->SetInputConnection(shrink->GetOutputPort());

skinExtractor->SetValue(0,200);//計算體素的等值面 可以提取多個等值面 0~200表示第一個等值面的值為200

vtkDecimatePro *deci=vtkDecimatePro::New();//減少mesh的三角面片

deci->SetInputConnection(skinExtractor->GetOutputPort());

deci->SetTargetReduction(0.3);//將原先的三角面片減少到原來的百分之七十

// Specify the desired reduction in the total number of polygons (e.g., if TargetReduction is set to 0.9, this filter will try to reduce the data set to 10% of its original size). Because of various constraints, this level of reduction may not be realized. If you want to guarantee a particular reduction, you must turn off PreserveTopology, turn on SplitEdges and BoundaryVertexDeletion, and set the MaximumError to VTK_DOUBLE_MAX (these ivars are initialized this way when the object is instantiated).

//adjust point positions using Laplacian smoothing

vtkSmoothPolyDataFilter *smooth=vtkSmoothPolyDataFilter::New();

smooth->SetInputConnection(deci->GetOutputPort());

smooth->SetNumberOfIterations(100) ;//設置Laplace平滑的迭代次數

vtkPolyDataNormals *skinNormals = vtkPolyDataNormals::New();//compute normals for polygonal mesh

skinNormals->SetInputConnection(smooth->GetOutputPort());

skinNormals->SetFeatureAngle(60.0);//Specify the angle that defines a sharp edge. If the difference in angle across neighboring polygons is greater than this value, the shared edge is considered "sharp".

// vtkTriangleFilter *triangle_filter=vtkTriangleFilter::New();//create triangle polygons from input polygons and triangle strips

// triangle_filter->SetInput( skinNormals->GetOutput());

vtkFeatureEdges *edges_extractor=vtkFeatureEdges::New();//extract boundary, non-manifold, and/or sharp edges from polygonal data

edges_extractor->SetInput(skinNormals->GetOutput());

edges_extractor->ColoringOff();//Turn on/off the coloring of edges by type.

edges_extractor->BoundaryEdgesOn();//Turn on/off the extraction of boundary edges

edges_extractor->ManifoldEdgesOn();//Turn on/off the extraction of manifold edges.

edges_extractor->NonManifoldEdgesOn();//Turn on/off the extraction of non-manifold edges.

vtkStripper *stripper=vtkStripper::New();

stripper->SetInput(skinNormals->GetOutput());

/*

vtkPolyDataWriter *wSP=vtkPolyDataWriter::New();

wSP->SetInput(stripper->GetOutput());

wSP->SetFileName("E://CT/aaaa.VTK");

wSP->Write();

wSP->Delete();

*///保存為VTK格式

vtkPolyDataMapper *skinMapper = vtkPolyDataMapper::New();

skinMapper->SetInput(stripper->GetOutput());

skinMapper->ScalarVisibilityOff();//Turn on/off flag to control whether the symbol's scalar data is used to color the symbol. If off, the color of the vtkLegendBoxActor is used.

vtkActor *skin = vtkActor::New();

skin->SetMapper(skinMapper);

skin->GetProperty()->SetDiffuseColor(1, 0.49, 0.25);

skin->GetProperty()->SetSpecular(.3);

skin->GetProperty()->SetSpecularPower(20);

vtkCamera *aCamera = vtkCamera::New();

aCamera->SetViewUp (0, 0, -1);

aCamera->SetPosition (0, 1, 0);//Set/Get the position of the camera in world coordinates. The default position is (0,0,1).

aCamera->SetFocalPoint (0, 0, 0);

aCamera->ComputeViewPlaneNormal();

aRenderer->AddActor(skin);

aRenderer->SetActiveCamera(aCamera);

aRenderer->ResetCamera ();//Automatically set up the camera based on the visible actors. The camera will reposition itself to view the center point of the actors, and move along its initial view plane normal (i.e., vector defined from camera position to focal point) so that all of the actors can be seen.

aCamera->Dolly(1.5);// Move the position of the camera along the direction of projection. Moving towards the focal point (e.g., greater than 1) is a dolly-in, moving away from the focal point (e.g., less than 1) is a dolly-out.

aRenderer->SetBackground(1,1,1);

renWin->SetSize(640, 480);

aRenderer->ResetCameraClippingRange (); // Reset the camera clipping range based on the bounds of the visible actors. This ensures that no props are cut off

iren->Initialize();

iren->Start();

shrink->Delete();

smooth->Delete();

deci->Delete();

stripper->Delete();

skinExtractor->Delete();

skinNormals->Delete();

skinMapper->Delete();

skin->Delete();

aCamera->Delete();

iren->Delete();

renWin->Delete();

aRenderer->Delete();

reader->Delete();

return 0;

}

總結

以上是生活随笔為你收集整理的vtk鼠标不交互_vtk 各种不同的鼠标交互方式的全部內容,希望文章能夠幫你解決所遇到的問題。

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