VTK笔记-图形相关-圆锥体-vtkConeSoure类
圆锥体
文章目录
- 圆锥体
- 前言
- 一、代码
- 1.1流程
- 二、遇到的问题
- 1.运行时异常
- 2.在ThinkPad E530C笔记本上出现的异常
- 3.运行结果
- 三、相机旋转
- 四、vtkConeSource
- 4.1类图
- 4.2常用接口说明
- 五、资料
前言
使用VTK构建一个圆锥体展示;
执行的具体步骤为:
1.创建一个vtkConeSoure类的实例cone;
表示一个圆锥(正棱锥,有棱数目),有三个属性:高度、半径、分辨率(棱数目);
2.创建一个映射器,vtkPolyDataMapper实例;
cone的输出可以作为映射器的输入,
vtk中使用GetOutputPort()作为输出;
VTK常见使用方法:将一个对象的输出当另一个对象的输入;
常见用来作为数据流的处理:将多个对象串联在一起形成一条链,称之为可视化流水线;
3.渲染部分
通过方法SetMapper将vtkActor对象和映射器关联在一起;之后渲染过程暂时省略,在以后的部分单独说明;
一、代码
#include "vtkConeSource.h" #include "vtkPolyDataMapper.h" #include "vtkRenderWindow.h" #include "vtkActor.h" #include "vtkRenderer.h" #include "vtkAutoInit.h" #include "vtkAutoInit.h" VTK_MODULE_INIT(vtkRenderingOpenGL2); // VTK was built with vtkRenderingOpenGL2 VTK_MODULE_INIT(vtkInteractionStyle); int main() {vtkConeSource *cone = vtkConeSource::New();cone->SetHeight(3.0);cone->SetRadius(1.0);cone->SetResolution(10);vtkPolyDataMapper *coneMapper = vtkPolyDataMapper::New();coneMapper->SetInputConnection(cone->GetOutputPort());vtkActor *coneActor = vtkActor::New();coneActor->SetMapper(coneMapper);vtkRenderer *ren1 = vtkRenderer::New();ren1->AddActor(coneActor);ren1->SetBackground(0.1, 0.2, 0.4);vtkRenderWindow *renWin = vtkRenderWindow::New();renWin->AddRenderer(ren1);renWin->SetSize(300, 300);for (size_t i = 0; i < 360; i++){renWin->Render();}cone->Delete();coneMapper->Delete();coneActor->Delete();ren1->Delete();renWin->Delete(); }1.1流程
#mermaid-svg-w8260LfJzGzxFn1O .label{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);fill:#333;color:#333}#mermaid-svg-w8260LfJzGzxFn1O .label text{fill:#333}#mermaid-svg-w8260LfJzGzxFn1O .node rect,#mermaid-svg-w8260LfJzGzxFn1O .node circle,#mermaid-svg-w8260LfJzGzxFn1O .node ellipse,#mermaid-svg-w8260LfJzGzxFn1O .node polygon,#mermaid-svg-w8260LfJzGzxFn1O .node path{fill:#ECECFF;stroke:#9370db;stroke-width:1px}#mermaid-svg-w8260LfJzGzxFn1O .node .label{text-align:center;fill:#333}#mermaid-svg-w8260LfJzGzxFn1O .node.clickable{cursor:pointer}#mermaid-svg-w8260LfJzGzxFn1O .arrowheadPath{fill:#333}#mermaid-svg-w8260LfJzGzxFn1O .edgePath .path{stroke:#333;stroke-width:1.5px}#mermaid-svg-w8260LfJzGzxFn1O .flowchart-link{stroke:#333;fill:none}#mermaid-svg-w8260LfJzGzxFn1O .edgeLabel{background-color:#e8e8e8;text-align:center}#mermaid-svg-w8260LfJzGzxFn1O .edgeLabel rect{opacity:0.9}#mermaid-svg-w8260LfJzGzxFn1O .edgeLabel span{color:#333}#mermaid-svg-w8260LfJzGzxFn1O .cluster rect{fill:#ffffde;stroke:#aa3;stroke-width:1px}#mermaid-svg-w8260LfJzGzxFn1O .cluster text{fill:#333}#mermaid-svg-w8260LfJzGzxFn1O div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);font-size:12px;background:#ffffde;border:1px solid #aa3;border-radius:2px;pointer-events:none;z-index:100}#mermaid-svg-w8260LfJzGzxFn1O .actor{stroke:#ccf;fill:#ECECFF}#mermaid-svg-w8260LfJzGzxFn1O text.actor>tspan{fill:#000;stroke:none}#mermaid-svg-w8260LfJzGzxFn1O .actor-line{stroke:grey}#mermaid-svg-w8260LfJzGzxFn1O .messageLine0{stroke-width:1.5;stroke-dasharray:none;stroke:#333}#mermaid-svg-w8260LfJzGzxFn1O .messageLine1{stroke-width:1.5;stroke-dasharray:2, 2;stroke:#333}#mermaid-svg-w8260LfJzGzxFn1O #arrowhead path{fill:#333;stroke:#333}#mermaid-svg-w8260LfJzGzxFn1O .sequenceNumber{fill:#fff}#mermaid-svg-w8260LfJzGzxFn1O #sequencenumber{fill:#333}#mermaid-svg-w8260LfJzGzxFn1O #crosshead path{fill:#333;stroke:#333}#mermaid-svg-w8260LfJzGzxFn1O .messageText{fill:#333;stroke:#333}#mermaid-svg-w8260LfJzGzxFn1O .labelBox{stroke:#ccf;fill:#ECECFF}#mermaid-svg-w8260LfJzGzxFn1O .labelText,#mermaid-svg-w8260LfJzGzxFn1O .labelText>tspan{fill:#000;stroke:none}#mermaid-svg-w8260LfJzGzxFn1O .loopText,#mermaid-svg-w8260LfJzGzxFn1O .loopText>tspan{fill:#000;stroke:none}#mermaid-svg-w8260LfJzGzxFn1O .loopLine{stroke-width:2px;stroke-dasharray:2, 2;stroke:#ccf;fill:#ccf}#mermaid-svg-w8260LfJzGzxFn1O .note{stroke:#aa3;fill:#fff5ad}#mermaid-svg-w8260LfJzGzxFn1O .noteText,#mermaid-svg-w8260LfJzGzxFn1O .noteText>tspan{fill:#000;stroke:none}#mermaid-svg-w8260LfJzGzxFn1O .activation0{fill:#f4f4f4;stroke:#666}#mermaid-svg-w8260LfJzGzxFn1O .activation1{fill:#f4f4f4;stroke:#666}#mermaid-svg-w8260LfJzGzxFn1O .activation2{fill:#f4f4f4;stroke:#666}#mermaid-svg-w8260LfJzGzxFn1O .mermaid-main-font{font-family:"trebuchet ms", verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-w8260LfJzGzxFn1O .section{stroke:none;opacity:0.2}#mermaid-svg-w8260LfJzGzxFn1O .section0{fill:rgba(102,102,255,0.49)}#mermaid-svg-w8260LfJzGzxFn1O .section2{fill:#fff400}#mermaid-svg-w8260LfJzGzxFn1O .section1,#mermaid-svg-w8260LfJzGzxFn1O .section3{fill:#fff;opacity:0.2}#mermaid-svg-w8260LfJzGzxFn1O .sectionTitle0{fill:#333}#mermaid-svg-w8260LfJzGzxFn1O .sectionTitle1{fill:#333}#mermaid-svg-w8260LfJzGzxFn1O .sectionTitle2{fill:#333}#mermaid-svg-w8260LfJzGzxFn1O .sectionTitle3{fill:#333}#mermaid-svg-w8260LfJzGzxFn1O .sectionTitle{text-anchor:start;font-size:11px;text-height:14px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-w8260LfJzGzxFn1O .grid .tick{stroke:#d3d3d3;opacity:0.8;shape-rendering:crispEdges}#mermaid-svg-w8260LfJzGzxFn1O .grid .tick text{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-w8260LfJzGzxFn1O .grid path{stroke-width:0}#mermaid-svg-w8260LfJzGzxFn1O .today{fill:none;stroke:red;stroke-width:2px}#mermaid-svg-w8260LfJzGzxFn1O .task{stroke-width:2}#mermaid-svg-w8260LfJzGzxFn1O .taskText{text-anchor:middle;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-w8260LfJzGzxFn1O .taskText:not([font-size]){font-size:11px}#mermaid-svg-w8260LfJzGzxFn1O .taskTextOutsideRight{fill:#000;text-anchor:start;font-size:11px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-w8260LfJzGzxFn1O .taskTextOutsideLeft{fill:#000;text-anchor:end;font-size:11px}#mermaid-svg-w8260LfJzGzxFn1O .task.clickable{cursor:pointer}#mermaid-svg-w8260LfJzGzxFn1O .taskText.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-w8260LfJzGzxFn1O .taskTextOutsideLeft.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-w8260LfJzGzxFn1O .taskTextOutsideRight.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-w8260LfJzGzxFn1O .taskText0,#mermaid-svg-w8260LfJzGzxFn1O .taskText1,#mermaid-svg-w8260LfJzGzxFn1O .taskText2,#mermaid-svg-w8260LfJzGzxFn1O .taskText3{fill:#fff}#mermaid-svg-w8260LfJzGzxFn1O .task0,#mermaid-svg-w8260LfJzGzxFn1O .task1,#mermaid-svg-w8260LfJzGzxFn1O .task2,#mermaid-svg-w8260LfJzGzxFn1O .task3{fill:#8a90dd;stroke:#534fbc}#mermaid-svg-w8260LfJzGzxFn1O .taskTextOutside0,#mermaid-svg-w8260LfJzGzxFn1O .taskTextOutside2{fill:#000}#mermaid-svg-w8260LfJzGzxFn1O .taskTextOutside1,#mermaid-svg-w8260LfJzGzxFn1O .taskTextOutside3{fill:#000}#mermaid-svg-w8260LfJzGzxFn1O .active0,#mermaid-svg-w8260LfJzGzxFn1O .active1,#mermaid-svg-w8260LfJzGzxFn1O .active2,#mermaid-svg-w8260LfJzGzxFn1O .active3{fill:#bfc7ff;stroke:#534fbc}#mermaid-svg-w8260LfJzGzxFn1O .activeText0,#mermaid-svg-w8260LfJzGzxFn1O .activeText1,#mermaid-svg-w8260LfJzGzxFn1O .activeText2,#mermaid-svg-w8260LfJzGzxFn1O .activeText3{fill:#000 !important}#mermaid-svg-w8260LfJzGzxFn1O .done0,#mermaid-svg-w8260LfJzGzxFn1O .done1,#mermaid-svg-w8260LfJzGzxFn1O .done2,#mermaid-svg-w8260LfJzGzxFn1O .done3{stroke:grey;fill:#d3d3d3;stroke-width:2}#mermaid-svg-w8260LfJzGzxFn1O .doneText0,#mermaid-svg-w8260LfJzGzxFn1O .doneText1,#mermaid-svg-w8260LfJzGzxFn1O .doneText2,#mermaid-svg-w8260LfJzGzxFn1O .doneText3{fill:#000 !important}#mermaid-svg-w8260LfJzGzxFn1O .crit0,#mermaid-svg-w8260LfJzGzxFn1O .crit1,#mermaid-svg-w8260LfJzGzxFn1O .crit2,#mermaid-svg-w8260LfJzGzxFn1O .crit3{stroke:#f88;fill:red;stroke-width:2}#mermaid-svg-w8260LfJzGzxFn1O .activeCrit0,#mermaid-svg-w8260LfJzGzxFn1O .activeCrit1,#mermaid-svg-w8260LfJzGzxFn1O .activeCrit2,#mermaid-svg-w8260LfJzGzxFn1O .activeCrit3{stroke:#f88;fill:#bfc7ff;stroke-width:2}#mermaid-svg-w8260LfJzGzxFn1O .doneCrit0,#mermaid-svg-w8260LfJzGzxFn1O .doneCrit1,#mermaid-svg-w8260LfJzGzxFn1O .doneCrit2,#mermaid-svg-w8260LfJzGzxFn1O .doneCrit3{stroke:#f88;fill:#d3d3d3;stroke-width:2;cursor:pointer;shape-rendering:crispEdges}#mermaid-svg-w8260LfJzGzxFn1O .milestone{transform:rotate(45deg) scale(0.8, 0.8)}#mermaid-svg-w8260LfJzGzxFn1O .milestoneText{font-style:italic}#mermaid-svg-w8260LfJzGzxFn1O .doneCritText0,#mermaid-svg-w8260LfJzGzxFn1O .doneCritText1,#mermaid-svg-w8260LfJzGzxFn1O .doneCritText2,#mermaid-svg-w8260LfJzGzxFn1O .doneCritText3{fill:#000 !important}#mermaid-svg-w8260LfJzGzxFn1O .activeCritText0,#mermaid-svg-w8260LfJzGzxFn1O .activeCritText1,#mermaid-svg-w8260LfJzGzxFn1O .activeCritText2,#mermaid-svg-w8260LfJzGzxFn1O .activeCritText3{fill:#000 !important}#mermaid-svg-w8260LfJzGzxFn1O .titleText{text-anchor:middle;font-size:18px;fill:#000;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-w8260LfJzGzxFn1O g.classGroup text{fill:#9370db;stroke:none;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);font-size:10px}#mermaid-svg-w8260LfJzGzxFn1O g.classGroup text .title{font-weight:bolder}#mermaid-svg-w8260LfJzGzxFn1O g.clickable{cursor:pointer}#mermaid-svg-w8260LfJzGzxFn1O g.classGroup rect{fill:#ECECFF;stroke:#9370db}#mermaid-svg-w8260LfJzGzxFn1O g.classGroup line{stroke:#9370db;stroke-width:1}#mermaid-svg-w8260LfJzGzxFn1O .classLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.5}#mermaid-svg-w8260LfJzGzxFn1O .classLabel .label{fill:#9370db;font-size:10px}#mermaid-svg-w8260LfJzGzxFn1O .relation{stroke:#9370db;stroke-width:1;fill:none}#mermaid-svg-w8260LfJzGzxFn1O .dashed-line{stroke-dasharray:3}#mermaid-svg-w8260LfJzGzxFn1O #compositionStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-w8260LfJzGzxFn1O #compositionEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-w8260LfJzGzxFn1O #aggregationStart{fill:#ECECFF;stroke:#9370db;stroke-width:1}#mermaid-svg-w8260LfJzGzxFn1O #aggregationEnd{fill:#ECECFF;stroke:#9370db;stroke-width:1}#mermaid-svg-w8260LfJzGzxFn1O #dependencyStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-w8260LfJzGzxFn1O #dependencyEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-w8260LfJzGzxFn1O #extensionStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-w8260LfJzGzxFn1O #extensionEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-w8260LfJzGzxFn1O .commit-id,#mermaid-svg-w8260LfJzGzxFn1O .commit-msg,#mermaid-svg-w8260LfJzGzxFn1O .branch-label{fill:lightgrey;color:lightgrey;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-w8260LfJzGzxFn1O .pieTitleText{text-anchor:middle;font-size:25px;fill:#000;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-w8260LfJzGzxFn1O .slice{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-w8260LfJzGzxFn1O g.stateGroup text{fill:#9370db;stroke:none;font-size:10px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-w8260LfJzGzxFn1O g.stateGroup text{fill:#9370db;fill:#333;stroke:none;font-size:10px}#mermaid-svg-w8260LfJzGzxFn1O g.statediagram-cluster .cluster-label text{fill:#333}#mermaid-svg-w8260LfJzGzxFn1O g.stateGroup .state-title{font-weight:bolder;fill:#000}#mermaid-svg-w8260LfJzGzxFn1O g.stateGroup rect{fill:#ECECFF;stroke:#9370db}#mermaid-svg-w8260LfJzGzxFn1O g.stateGroup line{stroke:#9370db;stroke-width:1}#mermaid-svg-w8260LfJzGzxFn1O .transition{stroke:#9370db;stroke-width:1;fill:none}#mermaid-svg-w8260LfJzGzxFn1O .stateGroup .composit{fill:white;border-bottom:1px}#mermaid-svg-w8260LfJzGzxFn1O .stateGroup .alt-composit{fill:#e0e0e0;border-bottom:1px}#mermaid-svg-w8260LfJzGzxFn1O .state-note{stroke:#aa3;fill:#fff5ad}#mermaid-svg-w8260LfJzGzxFn1O .state-note text{fill:black;stroke:none;font-size:10px}#mermaid-svg-w8260LfJzGzxFn1O .stateLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.7}#mermaid-svg-w8260LfJzGzxFn1O .edgeLabel text{fill:#333}#mermaid-svg-w8260LfJzGzxFn1O .stateLabel text{fill:#000;font-size:10px;font-weight:bold;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-w8260LfJzGzxFn1O .node circle.state-start{fill:black;stroke:black}#mermaid-svg-w8260LfJzGzxFn1O .node circle.state-end{fill:black;stroke:white;stroke-width:1.5}#mermaid-svg-w8260LfJzGzxFn1O #statediagram-barbEnd{fill:#9370db}#mermaid-svg-w8260LfJzGzxFn1O .statediagram-cluster rect{fill:#ECECFF;stroke:#9370db;stroke-width:1px}#mermaid-svg-w8260LfJzGzxFn1O .statediagram-cluster rect.outer{rx:5px;ry:5px}#mermaid-svg-w8260LfJzGzxFn1O .statediagram-state .divider{stroke:#9370db}#mermaid-svg-w8260LfJzGzxFn1O .statediagram-state .title-state{rx:5px;ry:5px}#mermaid-svg-w8260LfJzGzxFn1O .statediagram-cluster.statediagram-cluster .inner{fill:white}#mermaid-svg-w8260LfJzGzxFn1O .statediagram-cluster.statediagram-cluster-alt .inner{fill:#e0e0e0}#mermaid-svg-w8260LfJzGzxFn1O .statediagram-cluster .inner{rx:0;ry:0}#mermaid-svg-w8260LfJzGzxFn1O .statediagram-state rect.basic{rx:5px;ry:5px}#mermaid-svg-w8260LfJzGzxFn1O .statediagram-state rect.divider{stroke-dasharray:10,10;fill:#efefef}#mermaid-svg-w8260LfJzGzxFn1O .note-edge{stroke-dasharray:5}#mermaid-svg-w8260LfJzGzxFn1O .statediagram-note rect{fill:#fff5ad;stroke:#aa3;stroke-width:1px;rx:0;ry:0}:root{--mermaid-font-family: '"trebuchet ms", verdana, arial';--mermaid-font-family: "Comic Sans MS", "Comic Sans", cursive}#mermaid-svg-w8260LfJzGzxFn1O .error-icon{fill:#522}#mermaid-svg-w8260LfJzGzxFn1O .error-text{fill:#522;stroke:#522}#mermaid-svg-w8260LfJzGzxFn1O .edge-thickness-normal{stroke-width:2px}#mermaid-svg-w8260LfJzGzxFn1O .edge-thickness-thick{stroke-width:3.5px}#mermaid-svg-w8260LfJzGzxFn1O .edge-pattern-solid{stroke-dasharray:0}#mermaid-svg-w8260LfJzGzxFn1O .edge-pattern-dashed{stroke-dasharray:3}#mermaid-svg-w8260LfJzGzxFn1O .edge-pattern-dotted{stroke-dasharray:2}#mermaid-svg-w8260LfJzGzxFn1O .marker{fill:#333}#mermaid-svg-w8260LfJzGzxFn1O .marker.cross{stroke:#333}:root { --mermaid-font-family: "trebuchet ms", verdana, arial;} #mermaid-svg-w8260LfJzGzxFn1O {color: rgba(0, 0, 0, 0.75);font: ;} vtkConeSource vtkPolyDataMapper vtkActor vtkRenderer vtkRenderWindow二、遇到的问题
1.运行时异常
按照《医学图像编程技术》的代码录入编译成功后,执行是出现异常:
VTK的错误调试日志窗口显示如下:
网上找到的回答为https://stackoverflow.com/questions/18642155/no-override-found-for-vtkpolydatamapper
Stackoverflow上的回答为:
I too was getting this error. The error means that the linker can’t find the definition for the vtkPolyDataMapper method. One has to note which vtk rendering backend they used, during build. It will probably be either vtkRenderingOpenGL, or vtkRenderingOpenGL2. Go to your build/lib folder and search for either one of these. I have VS 2015 Community and had the vtkRenderingOpenGL2, with vtk-7.1 built on Windows 8.1, x86_64 Platform, Release configuration.
I fixed the issue by inserting the 3 following lines at the very top of my source files, before any other preprocessor directives:
This initializes the specified VTK modules. CMake includes these by default, but other compilers such as VS do not.
The last two lines can be combined into the following:
还有另外一个回答:
I had the same issue at my platform; Visual Studio 2015 Windows 7 VTK 6.3
I followed VTK/Build System Migration from Marcus D. Hanwell’s post, and it works. My additonal lines are;
on the top of preprocessor. The difference from RestlessC0bra’s post is probably OpenGL version.
采用第一个回答,在main之前增加:
#include “vtkAutoInit.h”
VTK_MODULE_INIT(vtkRenderingOpenGL2); // VTK was built with vtkRenderingOpenGL2
VTK_MODULE_INIT(vtkInteractionStyle);
2.在ThinkPad E530C笔记本上出现的异常
在家里12年的老笔记本Thinpad E530C上运行这个例子,提示
搜索到的资料是“VTK7.0要求OPENGL3.2以上,很多笔记本集成显卡都达不到要求,换成独显就可以了”;
使用台式机(有独立显卡),可以运行不会报错;
3.运行结果
运行结果图如下:
三、相机旋转
在上面一代码中,增加对相机方位角设置,可以使得相机围绕圆锥体拍摄,在窗口内可以观察到圆锥体在旋转;大家自己在代码上修改,观察一下效果;
int main() {vtkConeSource *cone = vtkConeSource::New();cone->SetHeight(3.0);cone->SetRadius(1.0);cone->SetResolution(10);vtkPolyDataMapper *coneMapper = vtkPolyDataMapper::New();coneMapper->SetInputConnection(cone->GetOutputPort());vtkActor *coneActor = vtkActor::New();coneActor->SetMapper(coneMapper);vtkRenderer *ren1 = vtkRenderer::New();ren1->AddActor(coneActor);ren1->SetBackground(0.1, 0.2, 0.4);vtkRenderWindow *renWin = vtkRenderWindow::New();renWin->AddRenderer(ren1);renWin->SetSize(300, 300);for (size_t i = 0; i < 360; i++){renWin->Render();ren1->GetActiveCamera()->Azimuth(1);}cone->Delete();coneMapper->Delete();coneActor->Delete();ren1->Delete();renWin->Delete();system("pause");return 0; }四、vtkConeSource
类说明:
vtkConeSource创建一个以指定点为中心并指向指定方向的锥。(默认情况下,中心是原点,方向是x轴。)根据此对象的分辨率,系统会创建不同的表示形式。
如果创建分辨率=0,则创建一条直线;
如果分辨率=1,则创建一个三角形;
如果分辨率=2,则创建两个交叉三角形。如果分辨率大于2,创建一个3D cone(分辨率边边)。也可以控制圆锥的底部是否有一个(分辨率面的)多边形,并指定圆锥的高度和半径。
4.1类图
4.2常用接口说明
virtual void vtkConeSource::SetHeight(double):设置圆锥高度;
virtual void vtkConeSource::SetRadius(double) :设置圆锥底部基础半径;
virtual void vtkConeSource::SetResolution (int):设置分辨率(棱)个数;
virtual void vtkConeSource::SetCenter(double,double,double);
virtual void vtkConeSource::SetCenter(double[3]);设置圆锥体中心点,而不是底部圆半径的中心点,默认坐标是(0,0,0);
virtual void vtkConeSource::SetDirection(double[3]):设置圆锥体的朝向,参数应该是一个向量,可以是XYZ轴的余弦值,也可以不是归一化的值,这个朝向是从底部的半径中心点指向圆锥顶部尖端位置,默认值为(1,0,0),即方向是向着X轴的的正向;
void vtkConeSource::SetAngle(double angle):这是锥轴和总线之间的角度。警告:这不是光圈!棱边旋转的角度是这个角度的两倍。作为一个副作用,角度加高度设置了圆锥的基本半径。角度用度表示。
五、资料
1.《医学图像编程技术》
2.https://stackoverflow.com/questions/18642155/no-override-found-for-vtkpolydatamapper
本文完整项目代码在百度网盘,失效请回复;
链接:https://pan.baidu.com/s/1b6EJFH4UtTy9EXsk_5eKEA
提取码:kej8
总结
以上是生活随笔为你收集整理的VTK笔记-图形相关-圆锥体-vtkConeSoure类的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: .h5文件的读取
- 下一篇: 作业二:wireshark抓包与ping