旋转扫描实体示例:vtkQuadRotationalExtrusionFilter

vtkQuadRotationalExtrusionFilter

Detailed Description

sweep polygonal data creating "skirt" from free edges and lines, and lines from vertices

vtkQuadRotationalExtrusionFilter is a modeling filter. It takes polygonal data as input and generates polygonal data on output. The input dataset is swept around the z-axis to create new polygonal primitives. These primitives form a "skirt" or swept surface. For example, sweeping a line results in a cylindrical shell, and sweeping a circle creates a torus.

There are a number of control parameters for this filter. You can control whether the sweep of a 2D object (i.e., polygon or triangle strip) is capped with the generating geometry via the "Capping" instance variable. Also, you can control the angle of rotation, and whether translation along the z-axis is performed along with the rotation. (Translation is useful for creating "springs".) You also can adjust the radius of the generating geometry using the "DeltaRotation" instance variable.

The skirt is generated by locating certain topological features. Free edges (edges of polygons or triangle strips only used by one polygon or triangle strips) generate surfaces. This is true also of lines or polylines. Vertices generate lines.

This filter can be used to model axisymmetric objects like cylinders, bottles, and wine glasses; or translational/rotational symmetric objects like springs or corkscrews.

Warning:
If the object sweeps 360 degrees, radius does not vary, and the object does not translate, capping is not performed. This is because the cap is unnecessary.
Some polygonal objects have no free edges (e.g., sphere). When swept, this will result in two separate surfaces if capping is on, or no surface if capping is off.
See also:
vtkLinearExtrusionFilter vtkRotationalExtrusionFilter
Thanks:
This class was initially developed by Daniel Aguilera, CEA/DIF Ported and modified by Philippe Pebay, Kitware, 2011
Tests:
vtkQuadRotationalExtrusionFilter (Tests)

Definition at line 74 of file vtkQuadRotationalExtrusionFilter.h.

示例代码:

#ifndef INITIAL_OPENGL
#define INITIAL_OPENGL
#include <vtkAutoInit.h>
VTK_MODULE_INIT(vtkRenderingOpenGL)
VTK_MODULE_INIT(vtkInteractionStyle)
#endif
#include <iostream>

using namespace std;
#include "vtkCamera.h"
#include "vtkInformation.h"
#include "vtkLineSource.h"
#include "vtkMultiBlockDataSet.h"
#include "vtkNew.h"
#include "vtkPolyDataMapper.h"
#include "vtkPolyDataNormals.h"
#include "vtkProperty.h"
#include "vtkRegressionTestImage.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkQuadRotationalExtrusionFilter.h"
#include "vtkTestUtilities.h"
int main()
{
    // Create a line source
    vtkNew<vtkLineSource> line;
    line->SetPoint1( 0., 1., 0. );
    line->SetPoint2( 0., 1., 2. );
    line->SetResolution( 10 );
    line->Update();

    // Create mapper for line segment
    vtkNew<vtkPolyDataMapper> lineMapper;
    lineMapper->SetInputConnection( line->GetOutputPort() );

    // Create actor for line segment
    vtkNew<vtkActor> lineActor;
    lineActor->SetMapper( lineMapper.GetPointer() );
    lineActor->GetProperty()->SetLineWidth( 5 );
    lineActor->GetProperty()->SetColor( 0., .749, 1. ); // deep sky blue

    // Create multi-block data set for quad-based sweep
    vtkNew<vtkMultiBlockDataSet> lineMB;
    lineMB->SetNumberOfBlocks( 1 );
    lineMB->GetMetaData( static_cast<unsigned>( 0 ) )->Set( vtkCompositeDataSet::NAME(), "Line" );
    lineMB->SetBlock( 0, line->GetOutput() );

    // Create 3/4 of a cylinder by rotational extrusion
    vtkNew<vtkQuadRotationalExtrusionFilter> lineSweeper;
    lineSweeper->SetResolution( 20 );
    lineSweeper->SetInputData( lineMB.GetPointer() );
    lineSweeper->SetDefaultAngle( 270 );
    lineSweeper->Update();

    // Retrieve polydata output
    vtkMultiBlockDataSet* cylDS = vtkMultiBlockDataSet::SafeDownCast( lineSweeper->GetOutputDataObject( 0 ) );
    vtkPolyData* cyl = vtkPolyData::SafeDownCast( cylDS->GetBlock( 0 ) );

    // Create normals for smooth rendering
    vtkNew<vtkPolyDataNormals> normals;
    normals->SetInputData( cyl );

    // Create mapper for surface representation
    vtkNew<vtkPolyDataMapper> cylMapper;
    cylMapper->SetInputConnection( normals->GetOutputPort() );
    cylMapper->SetResolveCoincidentTopologyToPolygonOffset();

    // Create mapper for wireframe representation
    vtkNew<vtkPolyDataMapper> cylMapperW;
    cylMapperW->SetInputData( cyl );
    cylMapperW->SetResolveCoincidentTopologyToPolygonOffset();

    // Create actor for surface representation
    vtkNew<vtkActor> cylActor;
    cylActor->SetMapper( cylMapper.GetPointer() );
    cylActor->GetProperty()->SetRepresentationToSurface();
    cylActor->GetProperty()->SetInterpolationToGouraud();
    cylActor->GetProperty()->SetColor( 1., 0.3882, .2784 ); // tomato

    // Create actor for wireframe representation
    vtkNew<vtkActor> cylActorW;
    cylActorW->SetMapper( cylMapperW.GetPointer() );
    cylActorW->GetProperty()->SetRepresentationToWireframe();
    cylActorW->GetProperty()->SetColor( 0., 0., 0.);
    cylActorW->GetProperty()->SetAmbient( 1. );
    cylActorW->GetProperty()->SetDiffuse( 0. );
    cylActorW->GetProperty()->SetSpecular( 0. );

    // Create a renderer, add actors to it
    vtkNew<vtkRenderer> ren1;
    ren1->AddActor( lineActor.GetPointer() );
    ren1->AddActor( cylActor.GetPointer() );
    ren1->AddActor( cylActorW.GetPointer() );
    ren1->SetBackground( 1., 1., 1. );

    // Create a renderWindow
    vtkNew<vtkRenderWindow> renWin;
    renWin->AddRenderer( ren1.GetPointer() );
    renWin->SetSize( 300, 300 );
    renWin->SetMultiSamples( 0 );

    // Create a good view angle
    vtkNew<vtkCamera> camera;
    camera->SetClippingRange( 0.576398, 28.8199 );
    camera->SetFocalPoint( 0.0463079, -0.0356571, 1.01993 );
    camera->SetPosition( -2.47044, 2.39516, -3.56066 );
    camera->SetViewUp( 0.607296, -0.513537, -0.606195 );
    ren1->SetActiveCamera( camera.GetPointer() );

    // Create interactor
    vtkNew<vtkRenderWindowInteractor> iren;
    iren->SetRenderWindow( renWin.GetPointer() );
    // Render and test
    renWin->Render();
        iren->Start();

    return 0;
}

运行显示结果:

时间: 2024-08-09 13:10:09

旋转扫描实体示例:vtkQuadRotationalExtrusionFilter的相关文章

应用程序框架实战三十四:数据传输对象(DTO)介绍及各类型实体比较(转)

本文将介绍DDD分层架构中广泛使用的数据传输对象Dto,并且与领域实体Entity,查询实体QueryObject,视图实体ViewModel等几种实体进行比较. 领域实体为何不能一统江湖? 当你阅读我或其它博主提供的示例代码时,会发现几种类型的实体,这几种实体初步看上去区别不大,只是名称不同,特别在这些示例非常简单的情况下更是如此.你可能会疑惑为何要搞得这么复杂,采用一种实体不是更好? 在最理想的情况下,我们只想采用领域实体Entity进行所有的操作. 领域实体是领域层的核心,是业务逻辑的主要

S1/使用HTML语言和CSS开发商业站点/01-HTML基础

HTML会是一种超文本标记语言(Hyper Text Mark Language),也就是说,HTML不是一种编程语言,仅是一种标记语言(Markup Language). 网页基本信息: 1.DOCTYPE声明 HTML代码中最上面有两行关于“DOCTYPE”文档类型的声明,他约束HTML文档结构,检验是否符合相关Web标准,同时高速浏览器,使用哪种规范来解释这个文档中的代码.DOCTYPE声明必须位于HTML文档的第一行,XHTML3.0规定了3种级别的声明. (1)Strict(严格类型)

oCanvas 教程学习摘要(一)

1.oCanvas对象 oCanvas 是一个全局对象,包含了所有的模块,以及核心的构造器和一些其它的方法. 2.create(settings) create 方法被用来设置一个核心实体,核心实体是每个oCanvas对象都需要的,所以调用create方法就能保证你能访问到核心实体. settings 是一个对象入参,可选属性如下: canvas :字符串或者一个HTMLCanvasElement background :canvas 对象的 background 样式,默认值为transpar

Hibernate之关联关系

时间:2017-1-20 16:28 --一对多配置 1.第一步:创建实体类    *   客户实体    *   订单实体 示例代码:        /** * 客户实体 * @author WYC * */ public class Customer { private Integer cid; private String name; // 一个客户有多个订单            // 拥有哪些订单 private Set<Order> orders = new HashSet<

锚点、target=&quot;page1&quot;、浮标回到顶部(该点未实现,能力不足)

<html> <head> <meta charset="utf-8"> <title>链接</title> <!-- HTML页面 <div id="gotop"></div> --> <!--CSS样式--> <style type="css/text"> #gotop{position:fixed;right:10px;b

Markdown 的 BUG丨CSDN

标题格式[#]定义的bug 按照正常格式还是出现的BUG ##数组的概念 > 同一种类型数据的集合,其实数组就是一个容器 --- ##一维数组 ###格式① > 元素类型[] 数组名 = new 元素类型[元素个数或数组长度]; ####示例: >> int[] arr = new int{5]: > >与上一个属于同一类的还有下面的另外一种定义格式: > >>int arr[] = new int[5]; > >其中的new用来在容器中产

&lt;&lt;ABP框架&gt;&gt; 数据过滤

文档目录 本节内容: 简介 预定义过滤 ISoftDelete 何时可用? IMustHaveTenant 何时可用? IMayHaveTenant 何时可用? 禁用过滤 关于using声明 关于多租户 启用过滤 设置过滤参数 SetTenantId 方法 自定义过滤 EntityFramework.DynamicFilters 文档 其它 ORM 简介 通常都会用到软删除模式(不把一个实体从数据库中删除,只是给它做个标志“deleted“),如果一个实体被软删除,它不应被应用意外地获取,为了提

基于SID的高可扩展性数据模型

前言 此文根据TMF SID规范撰写,欢迎大家提出建议和意见. TMF文档版权信息 Copyright © TeleManagement Forum 2013. All Rights Reserved. This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist i

GO-指针与函数

一.指针类型 1.普通类型,变量存的就是值,也叫值类型.指针类型存的是地址 2.获取变量的地址,用&,比如:var a int, 获取a的地址 &a 3.指针类型,变量存的是一个地址,这个地址存的才是值 4.获取指针类型所指向的值,使用:* ,比如:var p *int,使用*p获取p指向的变量的值 var a int = 5 var p *int = &a 0xefefefe 指向变量a的值是 5 5.指针类型的变量初始话有两种: 5.1.直接给指针赋值其他变量的地址 func