vtk类之vtkLineSource:用2点来创建线的poly data
vtkLineSource 通过两点(x, y, z) 来创建一条线的poly data。
基本方法:
virtual void | SetPoint1 (double, double, double) |
virtual void | SetPoint1 (double[3]) |
virtual double * | GetPoint1 () |
virtual void | GetPoint1 (double data[3]) |
virtual void | SetPoint2 (double, double, double) |
virtual void | SetPoint2 (double[3]) |
例子:
#-*- coding: UTF-8 -*- #------------------------------------------------------------------------------- # Name: lineActorFactory2 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 LineActorFactory2(ActorFactory): def __init__(self): ActorFactory.__init__(self) self.__LineSource = vtkLineSource() def __del__(self): del self.__LineSource ## @brief 更新线的poly data def __UpdateData(self): self.__LineSource.SetPoint1(0, 0, 0) self.__LineSource.SetPoint2(100, 200, 300) self.__LineSource.SetResolution(10) ## @brief 重写基类方法 # see ActorFactory._MakeActors def _MakeActors(self): self.__UpdateData() polyDataMapper = vtkPolyDataMapper() polyDataMapper.SetInputConnection(self.__LineSource.GetOutputPort()) actor = self._NewActor() actor.SetMapper(polyDataMapper) actor.GetProperty().SetColor((1, 0, 0.3)) del polyDataMapper return [actor]
运行效果图: