2.演示各种不同的鼠标交互模式
来源:互联网 发布:c语言教程视频百度云 编辑:程序博客网 时间:2024/06/06 03:14
- /*
- 演示各种不同的鼠标交互模式
- */
- #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;
- }
0 0
- 2.演示各种不同的鼠标交互模式
- vtk 各种不同的鼠标交互方式
- 各种不同演示的图片滚动
- 利用Observer模式解决不同模块之间的交互
- JS定义各种不同鼠标形状
- 鼠标的各种样式
- 各种形状的鼠标
- 各种形状的鼠标
- 交互:更好的鼠标控制
- 各种浏览器的不同
- 相当便利的UI交互演示工具
- 便利的UI交互演示工具: Chainco
- Selenium的模拟鼠标和键盘演示
- 2.交互-对鼠标及键盘的使用
- 不同系统不同语言之间的交互
- 鼠标事件的各种属性
- 常用各种形状的鼠标
- 杂记:设计模式的适用性,设计模式与类库框的不同.各种理解误区.学习方法论..
- 堆与堆排序
- 解决Failed to load class "org.slf4j.impl.StaticLoggerBinder"
- 设计手机网站的一下注意事项
- 项目启动时报的错误信息,求指教!!!!
- xss漏洞之进制转换
- 2.演示各种不同的鼠标交互模式
- 如何使用cocos2d和box2d来制作一个Breakout游戏
- 搭建Android AR技术开发环境(Aqumented Reality)
- Android(Java):视频播放升级版——播放m3u8
- select、checkbox自动选定给定的选项
- jQuery Select操作大集合
- “多负载识别监控平台(上位机)”技术细节 之 总述
- SharePoint 2010在win7 x64 安装
- MFC半透明按钮,修改