开发系统网站建设,如何利用wordpress编辑网站,深圳网站关键词优化推广,网页设计代码中相对定位1. 效果#xff1a; 2.简介#xff1a;
可以实现在多边形上进行交互#xff0c;选择#xff1b;在多边形曲面上实现轮廓点的交互绘制。
该类的使用需要结合 vtkPolygonalSurfacePointPlacer 类#xff0c;定位点的功能也就是拾取器。
前提#xff1a;输入的多边形曲面… 1. 效果 2.简介
可以实现在多边形上进行交互选择在多边形曲面上实现轮廓点的交互绘制。
该类的使用需要结合 vtkPolygonalSurfacePointPlacer 类定位点的功能也就是拾取器。
前提输入的多边形曲面需要计算法向量。
3.源码
#include vtkActor.h
#include vtkCamera.h
#include vtkContourWidget.h
#include vtkNamedColors.h
#include vtkNew.h
#include vtkOrientedGlyphContourRepresentation.h
#include vtkPolyData.h
#include vtkPolyDataCollection.h
#include vtkPolyDataMapper.h
#include vtkPolygonalSurfaceContourLineInterpolator.h
#include vtkPolygonalSurfacePointPlacer.h
#include vtkProperty.h
#include vtkRenderWindow.h
#include vtkRenderWindowInteractor.h
#include vtkRenderer.h
#include vtkSmartPointer.h
#include vtkSphereSource.h
#include vtkTriangleFilter.h
#include vtkXMLPolyDataReader.hint main(int argc, char* argv[])
{vtkNewvtkNamedColors colors;vtkSmartPointervtkPolyData polyData;if (argc 2){vtkNewvtkSphereSource sphereSource;sphereSource-SetThetaResolution(40);sphereSource-SetPhiResolution(20);sphereSource-Update();polyData sphereSource-GetOutput();}else{vtkNewvtkXMLPolyDataReader reader;reader-SetFileName(argv[1]);reader-Update();polyData reader-GetOutput();}// The Dijkistra interpolator will not accept cells that arent triangles.vtkNewvtkTriangleFilter triangleFilter;triangleFilter-SetInputData(polyData);triangleFilter-Update();auto pd triangleFilter-GetOutput();// Create a mapper and actor.vtkNewvtkPolyDataMapper mapper;mapper-SetInputConnection(triangleFilter-GetOutputPort());vtkNewvtkActor actor;actor-SetMapper(mapper);actor-GetProperty()-SetInterpolationToFlat();actor-GetProperty()-SetColor(colors-GetColor3d(MistyRose).GetData());// Create the render window, renderer and interactor.vtkNewvtkRenderer renderer;vtkNewvtkRenderWindow renderWindow;renderWindow-AddRenderer(renderer);renderWindow-SetWindowName(PolygonalSurfaceContourLineInterpolator);vtkNewvtkRenderWindowInteractor interactor;interactor-SetRenderWindow(renderWindow);// Add the actors to the renderer, set the background and size.renderer-AddActor(actor);renderer-SetBackground(colors-GetColor3d(CadetBlue).GetData());// Here comes the contour widget stuff...vtkNewvtkContourWidget contourWidget;contourWidget-SetInteractor(interactor);vtkSmartPointervtkOrientedGlyphContourRepresentation rep dynamic_castvtkOrientedGlyphContourRepresentation*(contourWidget-GetRepresentation());rep-GetLinesProperty()-SetColor(colors-GetColor3d(Crimson).GetData());rep-GetLinesProperty()-SetLineWidth(3.0);vtkNewvtkPolygonalSurfacePointPlacer pointPlacer;pointPlacer-AddProp(actor);pointPlacer-GetPolys()-AddItem(pd);rep-SetPointPlacer(pointPlacer);vtkNewvtkPolygonalSurfaceContourLineInterpolator interpolator;interpolator-GetPolys()-AddItem(pd);rep-SetLineInterpolator(interpolator);renderWindow-Render();interactor-Initialize();contourWidget-EnabledOn();interactor-Start();return EXIT_SUCCESS;
}
4.使用场景
可以用来做任意曲面切割 曲面拟合主要用的贝塞尔曲面交互部分用
vtkPolygonalSurfacePointPlacer
vtkPolygonalSurfaceContourLineInterpolator
也可使用
vtkOrientedGlyphContourRepresentation 以及自定义的vtk3DWidget子类