vtkPolygonalSurfaceContourLineInterpolator 多边形曲面上的多边形绘制器
来源:互联网 发布:货品查询软件 编辑:程序博客网 时间:2024/05/16 18:24
【类简介】
在多边形曲面上实现轮廓点的交互绘制。
该类主要是实现在多边形曲面上绘制、移动轮廓点。该类插入的节点主要是用多边形数据来计算图像的测地距离,也就是说两点之间连线的是沿着几何表面的最短路径,使用Dijkstra算法。
该类的使用需要结合 vtkPolygonalSurfacePointPlacer 类,定位点的功能也就是拾取器。
前提:输入的多边形曲面需要计算法向量。
【示例】
</pre><pre code_snippet_id="1970532" snippet_file_name="blog_20161107_16_2205487" name="code" class="cpp">#include <vtkVersion.h>#include "vtkSmartPointer.h" #include "vtkActor.h"#include "vtkCamera.h"#include "vtkCellArray.h"#include "vtkImageDataGeometryFilter.h"#include "vtkPoints.h"#include "vtkPolyData.h"#include "vtkPolyDataCollection.h"#include "vtkPolyDataMapper.h"#include "vtkProperty.h"#include "vtkRenderWindow.h"#include "vtkRenderWindowInteractor.h"#include "vtkRenderer.h"#include "vtkSphereSource.h"#include "vtkTriangleFilter.h"#include "vtkXMLPolyDataReader.h" #include "vtkContourWidget.h"#include "vtkOrientedGlyphContourRepresentation.h"#include "vtkPolygonalSurfacePointPlacer.h"#include "vtkPolygonalSurfaceContourLineInterpolator.h" int main(int argc, char *argv[]){ vtkSmartPointer<vtkPolyData> polyData; if (argc < 2) { vtkSmartPointer<vtkSphereSource> sphereSource = vtkSmartPointer<vtkSphereSource>::New(); sphereSource->SetThetaResolution(40); sphereSource->SetPhiResolution(20); sphereSource->Update(); polyData = sphereSource->GetOutput(); } else { vtkSmartPointer<vtkXMLPolyDataReader> reader = vtkSmartPointer<vtkXMLPolyDataReader>::New(); reader->SetFileName(argv[1]); reader->Update(); polyData = reader->GetOutput(); } // The Dijkistra interpolator will not accept cells that aren't triangles vtkSmartPointer<vtkTriangleFilter> triangleFilter = vtkSmartPointer<vtkTriangleFilter>::New();#if VTK_MAJOR_VERSION <= 5 triangleFilter->SetInput( polyData );#else triangleFilter->SetInputData( polyData );#endif triangleFilter->Update(); vtkSmartPointer<vtkPolyData> pd = triangleFilter->GetOutput(); //Create a mapper and actor vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New(); mapper->SetInputConnection(triangleFilter->GetOutputPort()); vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New(); actor->SetMapper(mapper); actor->GetProperty()->SetInterpolationToFlat(); // Create the render window, renderer and interactor. vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New(); vtkSmartPointer<vtkRenderWindow> renderWindow = vtkSmartPointer<vtkRenderWindow>::New(); renderWindow->AddRenderer(renderer); vtkSmartPointer<vtkRenderWindowInteractor> interactor = vtkSmartPointer<vtkRenderWindowInteractor>::New(); interactor->SetRenderWindow(renderWindow); // Add the actors to the renderer, set the background and size renderer->AddActor(actor); renderer->SetBackground (.3, .4, .5); // Here comes the contour widget stuff... vtkSmartPointer<vtkContourWidget> contourWidget = vtkSmartPointer<vtkContourWidget>::New(); contourWidget->SetInteractor(interactor); vtkSmartPointer<vtkOrientedGlyphContourRepresentation> rep = vtkOrientedGlyphContourRepresentation::SafeDownCast( contourWidget->GetRepresentation()); rep->GetLinesProperty()->SetColor(1, 0.2, 0); rep->GetLinesProperty()->SetLineWidth(3.0); vtkSmartPointer<vtkPolygonalSurfacePointPlacer> pointPlacer = vtkSmartPointer<vtkPolygonalSurfacePointPlacer>::New(); pointPlacer->AddProp(actor); pointPlacer->GetPolys()->AddItem( pd ); rep->SetPointPlacer(pointPlacer); vtkSmartPointer<vtkPolygonalSurfaceContourLineInterpolator> interpolator = vtkSmartPointer<vtkPolygonalSurfaceContourLineInterpolator>::New(); interpolator->GetPolys()->AddItem( pd ); rep->SetLineInterpolator(interpolator); renderWindow->Render(); interactor->Initialize(); contourWidget->EnabledOn(); interactor->Start(); return EXIT_SUCCESS;}
0 0
- vtkPolygonalSurfaceContourLineInterpolator 多边形曲面上的多边形绘制器
- 地图上绘制多边形
- Android绘制平面上的多边形
- 多边形面的绘制
- 绘制多边形
- 绘制多边形
- 多边形绘制
- 绘制多边形
- 绘制多边形
- 绘制多边形
- OpenGL多边形的绘制(三角形)
- 2.11_多边形的绘制
- C#计算多边形面积,判断绘制多边形的方向
- 创建曲面的多边形需要注意的一些问题
- OpenGL源代码之多边形的绘制
- gl 绘制多边形的函数解析
- gl 绘制多边形的函数解析 .
- 基于SVG的绘制多边形jQuery插件
- LeetCode 34. Search for a Range
- VMware问题解决
- 通过 http 协议上传文件
- Gank 是一个 MaterialDesign 风格和[MVP]模式的项目。
- java中观察者模式的使用场景
- vtkPolygonalSurfaceContourLineInterpolator 多边形曲面上的多边形绘制器
- 关于CSR8670如何使用PioSetMapPins32()函数配置额外的IO口
- 更完美的《iOS中textField、textView判断过滤禁用emoji表情》,解决过滤表情后九宫格输入不了问题
- 不定长参数
- (环问题并查集)Codeforces Round #363 D Fix a Tree
- js正则表达exec与match的区别
- ImageView 实现 floatingActionButton 的效果
- 简单例子教你理解ImageLoader
- java语言是一种半编译半解释的语言