zoukankan      html  css  js  c++  java
  • vtk类之vtkOutlineSource:创建边界盒状或者带弧度角度的poly data

    vtkOutlineSource 创建一个线框的形状盒子。通过SetBounds()方法可以设置边界盒的长高宽。通过SetCorners()方法可以设置边角的弧度形状。

    例子:

    #-*- coding: UTF-8 -*-
    #-------------------------------------------------------------------------------
    # Name:        outlineActorFactory package
    # Purpose:     通过两个点,创建一条直线
    #
    # Author:      ankier
    #
    # Created:     08-12-2012
    # Copyright:   (c) ankier 2012
    # Licence:     <your licence>
    #-------------------------------------------------------------------------------
    
    from ActorFactory import ActorFactory 
    from vtk import *
    
    ## @brief 直线的actor factory
    class OutlineActorFactory(ActorFactory):
        def __init__(self):
            ActorFactory.__init__(self)
            self.__OutlineSource = vtkOutlineSource()
           
        def __del__(self):
            del self.__OutlineSource
        
        ## @brief 更新线的poly data
        def __UpdateData(self):
            self.__OutlineSource.SetBounds(-20, 20, -32.5, 32.5, -50, 50)
    #        self.__OutlineSource.SetBoxTypeToOriented() #设置box 的 起点为原点。旋转box 的时候,绕原点旋转。
    #        self.__OutlineSource.GenerateFacesOn() #设置生产面
    #        self.__OutlineSource.SetCorners ([2, 6, 7, 8, 9, 10, 15, 20,2, 6, 7, 8, 9, 10, 15, 20,2, 6, 7, 8, 9, 10, 15, 20])
    #        
        
        ## @brief 重写基类方法
        #  see    ActorFactory._MakeActors
        def _MakeActors(self): 
            self.__UpdateData()       
            polyDataMapper = vtkPolyDataMapper()
            polyDataMapper.SetInputConnection(self.__OutlineSource.GetOutputPort())
            actor = self._NewActor()
            actor.SetMapper(polyDataMapper)
            actor.GetProperty().SetColor((1, 0, 0.3))
            del polyDataMapper
            return [actor]
            
            

    运行结果:

    使用方法 GenerateFacesOn()方法,可以开启生产面

    效果:

    使用方法 SetBoxTypeToOriented()和SetCorners() 可以设置弧度。

  • 相关阅读:
    mysql清空表中内容
    Proteus元件查找
    HDG12864F1 proteus仿真取模【PCtoLCD完美版】
    OLED取模(汉字加图片)
    Failed to connect to ESP8266: Timed out waiting for packet header
    AD常用快捷键
    Authentication method 'caching_sha2_password' not supported by any of the available plugins.
    spark阶段学习总结(三)
    spark阶段学习总结(一)
    spark阶段学习总结(二)
  • 原文地址:https://www.cnblogs.com/ankier/p/2808927.html
Copyright © 2011-2022 走看看