Exemple #1
0
 def ImplicitModeller(self, currentElement):
     impModeller = vtk.vtkImplicitModeller()
     # Datatype(s) I need for input:  Algorithm
     AlgorithmElement = ''
     for childElement in currentElement.getchildren():
         if childElement.tag in vtkTypes['Algorithm']:
             AlgorithmElement = childElement
     if AlgorithmElement != '':
         dataset = self.namesToFunctions[AlgorithmElement.tag](AlgorithmElement)
         self.logger.debug("  .. <ImplicitModeller> trying to SetInputConnection")
         try:
             impModeller.SetInputConnection(dataset.GetOutputPort())
         except:
             self.logger.error("  .. <ImplicitModeller> failed to SetInputConnection")
     else:
         self.logger.error('  .. <ImplicitModeller> needs an Algorithm-type childElement')
     if 'SetSampleDimensions' in currentElement.keys():
         self.logger.debug('  .. <ImplicitModeller> trying to SetSampleDimensions')
         try:
             impModeller.SetSampleDimensions( str2ints(currentElement.get('SetSampleDimensions')) )
         except:
             self.logger.error('  .. <ImplicitModeller> failed to SetSampleDimensions')
     if 'SetModelBounds' in currentElement.keys():
         self.logger.debug('  .. <ImplicitModeller> trying to SetModelBounds')
         try:
             impModeller.SetModelBounds( str2floats(currentElement.get('SetModelBounds')) )
         except:
             self.logger.error('  .. <ImplicitModeller> failed to SetModelBounds')
     if 'SetMaximumDistance' in currentElement.keys():
         self.logger.debug('  .. <ImplicitModeller> trying to SetMaximumDistance')
         try:
             impModeller.SetMaximumDistance( float(currentElement.get('SetMaximumDistance')) )
         except:
             self.logger.error('  .. <ImplicitModeller> failed to SetMaximumDistance')
     return impModeller
 def __init__(self, module_manager):
     SimpleVTKClassModuleBase.__init__(
         self, module_manager,
         vtk.vtkImplicitModeller(), 'Processing.',
         ('vtkDataSet',), ('vtkImageData',),
         replaceDoc=True,
         inputFunctions=None, outputFunctions=None)
    def __init__(self, module_manager):
        # initialise our base class
        ModuleBase.__init__(self, module_manager)

        self._implicitModeller = vtk.vtkImplicitModeller()

        module_utils.setup_vtk_object_progress(
            self, self._implicitModeller,
            'Converting surface to distance field')
                                           
        self._config.bounds = (-1, 1, -1, 1, -1, 1)
        self._config.dimensions = (64, 64, 64)
        self._config.maxDistance = 0.1
        
        configList = [
            ('Bounds:', 'bounds', 'tuple:float,6', 'text',
             'The physical location of the sampled volume in space '
             '(x0, x1, y0, y1, z0, z1)'),
            ('Dimensions:', 'dimensions', 'tuple:int,3', 'text',
             'The number of points that should be sampled in each dimension.'),
            ('Maximum distance:', 'maxDistance', 'base:float', 'text',
             'The distance will only be calculated up to this maximum.')]

        ScriptedConfigModuleMixin.__init__(
            self, configList,
            {'Module (self)' : self,
             'vtkImplicitModeller' : self._implicitModeller})

        self.sync_module_logic_with_config()
Exemple #4
0
 def __init__(self, module_manager):
     SimpleVTKClassModuleBase.__init__(self,
                                       module_manager,
                                       vtk.vtkImplicitModeller(),
                                       'Processing.', ('vtkDataSet', ),
                                       ('vtkImageData', ),
                                       replaceDoc=True,
                                       inputFunctions=None,
                                       outputFunctions=None)
 def implicit_modeller(self, distance):
     print('implicit modelling')
     # Create implicit model with vtkImplicitModeller at the 'distance' (in mesh's units) from the provided geometry.
     bounds = np.array(self.mesh.GetOutput().GetPoints().GetBounds())
     max_dist = self.calculate_maximum_distance(bounds, distance)
     imp = vtk.vtkImplicitModeller()
     imp.SetInputConnection(self.mesh.GetOutputPort())
     imp.SetSampleDimensions(500, 500, 500)
     imp.SetMaximumDistance(max_dist)
     imp.ScaleToMaximumDistanceOn()
     imp.SetModelBounds(*(bounds * 1.5))
     imp.CappingOn()
     imp.SetCapValue(255)
     imp.Update()
     self.mesh = imp
	def __init__(self):
		"""
		Initialization
		"""
		self.defaultObjectsFile = u"statistics.csv"
		self.objectsBox = None
		self.timepointData = {}
		self.polyDataSource = None
		self.segmentedSource = None
		self.delayedData = None
		self.vtkfilter = vtk.vtkImplicitModeller()
		self.vtkfilter.SetProcessModeToPerVoxel()
		self.vtkfilter.SetNumberOfThreads(2)
		lib.ProcessingFilter.ProcessingFilter.__init__(self,(1,1))
		for i in range(1, 2):
			self.setInputChannel(i, i)
		self.descs = {"MaximumDistance":"Max. distance","Capping":"Mark outer boundary","CapValue":"Boundary value", "ScaleToMax":"Scale output values to max."}
Exemple #7
0
    def __init__(self):
        """
		Initialization
		"""
        self.defaultObjectsFile = u"statistics.csv"
        self.objectsBox = None
        self.timepointData = {}
        self.polyDataSource = None
        self.segmentedSource = None
        self.delayedData = None
        self.vtkfilter = vtk.vtkImplicitModeller()
        self.vtkfilter.SetProcessModeToPerVoxel()
        self.vtkfilter.SetNumberOfThreads(2)
        lib.ProcessingFilter.ProcessingFilter.__init__(self, (1, 1))
        for i in range(1, 2):
            self.setInputChannel(i, i)
        self.descs = {
            "MaximumDistance": "Max. distance",
            "Capping": "Mark outer boundary",
            "CapValue": "Boundary value",
            "ScaleToMax": "Scale output values to max."
        }
Exemple #8
0
from vtk.util.misc import vtkGetDataRoot
VTK_DATA_ROOT = vtkGetDataRoot()

# use implicit modeller / interpolation to perform 3D morphing
#
# make the letter v
letterV = vtk.vtkVectorText()
letterV.SetText("v")
# read the geometry file containing the letter t
letterT = vtk.vtkVectorText()
letterT.SetText("t")
# read the geometry file containing the letter k
letterK = vtk.vtkVectorText()
letterK.SetText("k")
# create implicit models of each
blobbyV = vtk.vtkImplicitModeller()
blobbyV.SetInputConnection(letterV.GetOutputPort())
blobbyV.SetMaximumDistance(.2)
blobbyV.SetSampleDimensions(50,50,12)
blobbyV.SetModelBounds(-0.5,1.5,-0.5,1.5,-0.5,0.5)
# create implicit models of each
blobbyT = vtk.vtkImplicitModeller()
blobbyT.SetInputConnection(letterT.GetOutputPort())
blobbyT.SetMaximumDistance(.2)
blobbyT.SetSampleDimensions(50,50,12)
blobbyT.SetModelBounds(-0.5,1.5,-0.5,1.5,-0.5,0.5)
# create implicit models of each
blobbyK = vtk.vtkImplicitModeller()
blobbyK.SetInputConnection(letterK.GetOutputPort())
blobbyK.SetMaximumDistance(.2)
blobbyK.SetSampleDimensions(50,50,12)
Exemple #9
0
pd2 = vtk.vtkPolyData()
ca2 = vtk.vtkCellArray()
fp2 = vtk.vtkPoints()
fp2.InsertNextPoint(0, 1, 0)
fp2.InsertNextPoint(8, 1, 0)
fp2.InsertNextPoint(8, 2, 0)
fp2.InsertNextPoint(10, 0.01, 0)
#prevents degenerate triangles
ca2.InsertNextCell(4)
ca2.InsertCellPoint(0)
ca2.InsertCellPoint(1)
ca2.InsertCellPoint(2)
ca2.InsertCellPoint(3)
pd2.SetPoints(fp2)
pd2.SetLines(ca2)
arrowIM = vtk.vtkImplicitModeller()
arrowIM.SetInputData(pd)
arrowIM.SetSampleDimensions(50, 20, 8)
arrowCF = vtk.vtkContourFilter()
arrowCF.SetInputConnection(arrowIM.GetOutputPort())
arrowCF.SetValue(0, 0.2)
arrowWT = vtk.vtkWarpTo()
arrowWT.SetInputConnection(arrowCF.GetOutputPort())
arrowWT.SetPosition(5, 0, 5)
arrowWT.SetScaleFactor(0.85)
arrowWT.AbsoluteOn()
arrowT = vtk.vtkTransform()
arrowT.RotateY(60)
arrowT.Translate(-1.33198, 0, -1.479)
arrowT.Scale(1, 0.5, 1)
arrowTF = vtk.vtkTransformFilter()
Exemple #10
0
lineX.Update()
lineY = vtk.vtkLineSource()
lineY.SetPoint1(0.0, -2.0, 0.0)
lineY.SetPoint2(0.0, 2.0, 0.0)
lineY.Update()
lineZ = vtk.vtkLineSource()
lineZ.SetPoint1(0.0, 0.0, -2.0)
lineZ.SetPoint2(0.0, 0.0, 2.0)
lineZ.Update()
aPlane = vtk.vtkPlaneSource()
aPlane.Update()
# set Data(3) "lineX"
# set Data(1) "lineY"
# set Data(2) "lineZ"
# set Data(0) "aPlane"
imp = vtk.vtkImplicitModeller()
imp.SetSampleDimensions(60, 60, 60)
imp.SetCapValue(1000)
imp.ComputeModelBounds(cubeForBounds.GetOutput())
# Okay now let's see if we can append
imp.StartAppend()
# for {set i 0} {$i < 4} {incr i} {
#     imp Append [$Data($i) GetOutput]
# }
imp.Append(aPlane.GetOutput())
imp.Append(lineZ.GetOutput())
imp.Append(lineY.GetOutput())
imp.Append(lineX.GetOutput())
imp.EndAppend()
cf = vtk.vtkContourFilter()
cf.SetInputConnection(imp.GetOutputPort())
lineX.Update()
lineY = vtk.vtkLineSource()
lineY.SetPoint1(0.0,-2.0,0.0)
lineY.SetPoint2(0.0,2.0,0.0)
lineY.Update()
lineZ = vtk.vtkLineSource()
lineZ.SetPoint1(0.0,0.0,-2.0)
lineZ.SetPoint2(0.0,0.0,2.0)
lineZ.Update()
aPlane = vtk.vtkPlaneSource()
aPlane.Update()
# set Data(3) "lineX"
# set Data(1) "lineY"
# set Data(2) "lineZ"
# set Data(0) "aPlane"
imp = vtk.vtkImplicitModeller()
imp.SetSampleDimensions(60,60,60)
imp.SetCapValue(1000)
imp.ComputeModelBounds(cubeForBounds.GetOutput())
# Okay now let's see if we can append
imp.StartAppend()
# for {set i 0} {$i < 4} {incr i} {
#     imp Append [$Data($i) GetOutput]
# }
imp.Append(aPlane.GetOutput())
imp.Append(lineZ.GetOutput())
imp.Append(lineY.GetOutput())
imp.Append(lineX.GetOutput())
imp.EndAppend()
cf = vtk.vtkContourFilter()
cf.SetInputConnection(imp.GetOutputPort())
Exemple #12
0
def main():
    fileName = get_program_parameters()

    colors = vtk.vtkNamedColors()

    # Create lines which serve as the "seed" geometry. The lines spell the
    # word "hello".
    #
    reader = vtk.vtkPolyDataReader()
    reader.SetFileName(fileName)

    lineMapper = vtk.vtkPolyDataMapper()
    lineMapper.SetInputConnection(reader.GetOutputPort())

    lineActor = vtk.vtkActor()
    lineActor.SetMapper(lineMapper)
    lineActor.GetProperty().SetColor(colors.GetColor3d("Tomato"))
    lineActor.GetProperty().SetLineWidth(3.0)

    # Create implicit model with vtkImplicitModeller. This computes a scalar
    # field which is the distance from the generating geometry. The contour
    # filter then extracts the geometry at the distance value 0.25 from the
    # generating geometry.
    #
    imp = vtk.vtkImplicitModeller()
    imp.SetInputConnection(reader.GetOutputPort())
    imp.SetSampleDimensions(110, 40, 20)
    imp.SetMaximumDistance(0.25)
    imp.SetModelBounds(-1.0, 10.0, -1.0, 3.0, -1.0, 1.0)

    contour = vtk.vtkContourFilter()
    contour.SetInputConnection(imp.GetOutputPort())
    contour.SetValue(0, 0.25)

    impMapper = vtk.vtkPolyDataMapper()
    impMapper.SetInputConnection(contour.GetOutputPort())
    impMapper.ScalarVisibilityOff()

    impActor = vtk.vtkActor()
    impActor.SetMapper(impMapper)
    impActor.GetProperty().SetColor(colors.GetColor3d("Peacock"))
    impActor.GetProperty().SetOpacity(0.5)

    # Create the usual graphics stuff.
    # Create the RenderWindow, Renderer and Interactor.
    #
    ren1 = vtk.vtkRenderer()

    renWin = vtk.vtkRenderWindow()
    renWin.AddRenderer(ren1)

    iren = vtk.vtkRenderWindowInteractor()
    iren.SetRenderWindow(renWin)

    # Add the actors to the renderer, set the background and size
    #
    ren1.AddActor(lineActor)
    ren1.AddActor(impActor)
    ren1.SetBackground(colors.GetColor3d("Wheat"))
    renWin.SetSize(640, 480)

    camera = vtk.vtkCamera()
    camera.SetFocalPoint(4.5, 1, 0)
    camera.SetPosition(4.5, 1.0, 6.73257)
    camera.SetViewUp(0, 1, 0)

    ren1.SetActiveCamera(camera)
    ren1.ResetCamera()
    camera.Dolly(1.3)
    camera.SetClippingRange(1.81325, 90.6627)

    renWin.Render()
    iren.Start()
Exemple #13
0
def main():
    colors = vtk.vtkNamedColors()

    fileName1, fileName2, fileName3 = get_program_parameters()
    aRenderer = vtk.vtkRenderer()
    aRenderWindow = vtk.vtkRenderWindow()
    aRenderWindow.AddRenderer(aRenderer)
    anInteractor = vtk.vtkRenderWindowInteractor()
    anInteractor.SetRenderWindow(aRenderWindow)
    aRenderWindow.SetSize(300, 300)
    aRenderWindow.SetWindowName('BlobbyLogo')

    # Read the geometry file containing the letter v.
    letterV = vtk.vtkPolyDataReader()
    letterV.SetFileName(fileName1)

    # Read the geometry file containing the letter t.
    letterT = vtk.vtkPolyDataReader()
    letterT.SetFileName(fileName2)

    # Read the geometry file containing the letter k.
    letterK = vtk.vtkPolyDataReader()
    letterK.SetFileName(fileName3)

    # Create a transform and transform filter for each letter.
    VTransform = vtk.vtkTransform()
    VTransformFilter = vtk.vtkTransformPolyDataFilter()
    VTransformFilter.SetInputConnection(letterV.GetOutputPort())
    VTransformFilter.SetTransform(VTransform)

    TTransform = vtk.vtkTransform()
    TTransformFilter = vtk.vtkTransformPolyDataFilter()
    TTransformFilter.SetInputConnection(letterT.GetOutputPort())
    TTransformFilter.SetTransform(TTransform)

    KTransform = vtk.vtkTransform()
    KTransformFilter = vtk.vtkTransformPolyDataFilter()
    KTransformFilter.SetInputConnection(letterK.GetOutputPort())
    KTransformFilter.SetTransform(KTransform)

    # Now append them all.
    appendAll = vtk.vtkAppendPolyData()
    appendAll.AddInputConnection(VTransformFilter.GetOutputPort())
    appendAll.AddInputConnection(TTransformFilter.GetOutputPort())
    appendAll.AddInputConnection(KTransformFilter.GetOutputPort())

    # Create normals.
    logoNormals = vtk.vtkPolyDataNormals()
    logoNormals.SetInputConnection(appendAll.GetOutputPort())
    logoNormals.SetFeatureAngle(60)

    # Map to rendering primitives.
    logoMapper = vtk.vtkPolyDataMapper()
    logoMapper.SetInputConnection(logoNormals.GetOutputPort())

    # Now an actor.
    logo = vtk.vtkActor()
    logo.SetMapper(logoMapper)

    # Now create an implicit model of the same letter.
    blobbyLogoImp = vtk.vtkImplicitModeller()
    blobbyLogoImp.SetInputConnection(appendAll.GetOutputPort())
    blobbyLogoImp.SetMaximumDistance(.075)
    blobbyLogoImp.SetSampleDimensions(64, 64, 64)
    blobbyLogoImp.SetAdjustDistance(0.05)

    # Extract an iso surface.
    blobbyLogoIso = vtk.vtkContourFilter()
    blobbyLogoIso.SetInputConnection(blobbyLogoImp.GetOutputPort())
    blobbyLogoIso.SetValue(1, 1.5)

    # Map to rendering primitives.
    blobbyLogoMapper = vtk.vtkPolyDataMapper()
    blobbyLogoMapper.SetInputConnection(blobbyLogoIso.GetOutputPort())
    blobbyLogoMapper.ScalarVisibilityOff()

    tomato = vtk.vtkProperty()
    tomato.SetDiffuseColor(colors.GetColor3d('tomato'))
    tomato.SetSpecular(.3)
    tomato.SetSpecularPower(20)

    banana = vtk.vtkProperty()
    banana.SetDiffuseColor(colors.GetColor3d('banana'))
    banana.SetDiffuse(.7)
    banana.SetSpecular(.4)
    banana.SetSpecularPower(20)

    # Now an actor.
    blobbyLogo = vtk.vtkActor()
    blobbyLogo.SetMapper(blobbyLogoMapper)
    blobbyLogo.SetProperty(banana)

    # Position the letters.

    VTransform.Translate(-16.0, 0.0, 12.5)
    VTransform.RotateY(40)

    KTransform.Translate(14.0, 0.0, 0.0)
    KTransform.RotateY(-40)

    # Move the polygonal letters to the front.
    logo.SetProperty(tomato)
    logo.SetPosition(0, 0, 6)

    aRenderer.AddActor(logo)
    aRenderer.AddActor(blobbyLogo)

    aRenderer.SetBackground(colors.GetColor3d('SlateGray'))

    aRenderWindow.Render()

    # Interact with the data.
    anInteractor.Start()
Exemple #14
0
def main():
    colors = vtk.vtkNamedColors()

    # Set the colors.
    azArrowColor = map(lambda x: x / 255.0, [255, 77, 77])
    colors.SetColor('AzimuthArrowColor', *azArrowColor)
    elevArrowColor = map(lambda x: x / 255.0, [77, 255, 77])
    colors.SetColor('ElevationArrowColor', *elevArrowColor)
    rollArrowColor = map(lambda x: x / 255.0, [255, 255, 77])
    colors.SetColor('RollArrowColor', *rollArrowColor)
    spikeColor = map(lambda x: x / 255.0, [255, 77, 255])
    colors.SetColor('SpikeColor', *spikeColor)
    bkg = map(lambda x: x / 255.0, [25, 51, 102])
    colors.SetColor('BkgColor', *bkg)

    # Create a rendering window, renderer and interactor.
    ren = vtk.vtkRenderer()
    renWin = vtk.vtkRenderWindow()
    renWin.AddRenderer(ren)
    iren = vtk.vtkRenderWindowInteractor()
    iren.SetRenderWindow(renWin)

    # Create a camera model.
    camCS = vtk.vtkConeSource()
    camCS.SetHeight(1.5)
    camCS.SetResolution(12)
    camCS.SetRadius(0.4)

    camCBS = vtk.vtkCubeSource()
    camCBS.SetXLength(1.5)
    camCBS.SetZLength(0.8)
    camCBS.SetCenter(0.4, 0, 0)

    camAPD = vtk.vtkAppendFilter()
    camAPD.AddInputConnection(camCBS.GetOutputPort())
    camAPD.AddInputConnection(camCS.GetOutputPort())

    camMapper = vtk.vtkPolyDataMapper()
    camMapper.SetInputConnection(camAPD.GetOutputPort())
    camActor = vtk.vtkLODActor()
    camActor.SetMapper(camMapper)
    camActor.SetScale(2, 2, 2)

    # Draw the arrows.
    pd = vtk.vtkPolyData()
    ca = vtk.vtkCellArray()
    fp = vtk.vtkPoints()
    fp.InsertNextPoint(0, 1, 0)
    fp.InsertNextPoint(8, 1, 0)
    fp.InsertNextPoint(8, 2, 0)
    fp.InsertNextPoint(10, 0.01, 0)
    fp.InsertNextPoint(8, -2, 0)
    fp.InsertNextPoint(8, -1, 0)
    fp.InsertNextPoint(0, -1, 0)
    ca.InsertNextCell(7)
    ca.InsertCellPoint(0)
    ca.InsertCellPoint(1)
    ca.InsertCellPoint(2)
    ca.InsertCellPoint(3)
    ca.InsertCellPoint(4)
    ca.InsertCellPoint(5)
    ca.InsertCellPoint(6)
    pd.SetPoints(fp)
    pd.SetPolys(ca)

    pd2 = vtk.vtkPolyData()
    ca2 = vtk.vtkCellArray()
    fp2 = vtk.vtkPoints()
    fp2.InsertNextPoint(0, 1, 0)
    fp2.InsertNextPoint(8, 1, 0)
    fp2.InsertNextPoint(8, 2, 0)
    fp2.InsertNextPoint(10, 0.01, 0)
    ca2.InsertNextCell(4)
    ca2.InsertCellPoint(0)
    ca2.InsertCellPoint(1)
    ca2.InsertCellPoint(2)
    ca2.InsertCellPoint(3)
    pd2.SetPoints(fp2)
    pd2.SetLines(ca2)

    arrowIM = vtk.vtkImplicitModeller()
    arrowIM.SetInputData(pd)
    arrowIM.SetSampleDimensions(50, 20, 8)

    arrowCF = vtk.vtkContourFilter()
    arrowCF.SetInputConnection(arrowIM.GetOutputPort())
    arrowCF.SetValue(0, 0.2)

    arrowWT = vtk.vtkWarpTo()
    arrowWT.SetInputConnection(arrowCF.GetOutputPort())
    arrowWT.SetPosition(5, 0, 5)
    arrowWT.SetScaleFactor(0.85)
    arrowWT.AbsoluteOn()

    arrowT = vtk.vtkTransform()
    arrowT.RotateY(60)
    arrowT.Translate(-1.33198, 0, -1.479)
    arrowT.Scale(1, 0.5, 1)

    arrowTF = vtk.vtkTransformFilter()
    arrowTF.SetInputConnection(arrowWT.GetOutputPort())
    arrowTF.SetTransform(arrowT)

    arrowMapper = vtk.vtkDataSetMapper()
    arrowMapper.SetInputConnection(arrowTF.GetOutputPort())
    arrowMapper.ScalarVisibilityOff()

    # Draw the azimuth arrows.
    a1Actor = vtk.vtkLODActor()
    a1Actor.SetMapper(arrowMapper)
    a1Actor.RotateZ(180)
    a1Actor.SetPosition(1, 0, -1)
    a1Actor.GetProperty().SetColor(colors.GetColor3d("AzimuthArrowColor"))
    a1Actor.GetProperty().SetSpecularColor(colors.GetColor3d("White"))
    a1Actor.GetProperty().SetSpecular(0.3)
    a1Actor.GetProperty().SetSpecularPower(20)
    a1Actor.GetProperty().SetAmbient(0.2)
    a1Actor.GetProperty().SetDiffuse(0.8)

    a2Actor = vtk.vtkLODActor()
    a2Actor.SetMapper(arrowMapper)
    a2Actor.RotateZ(180)
    a2Actor.RotateX(180)
    a2Actor.SetPosition(1, 0, 1)
    a2Actor.GetProperty().SetColor(colors.GetColor3d("AzimuthArrowColor"))
    a2Actor.GetProperty().SetSpecularColor(colors.GetColor3d("White"))
    a2Actor.GetProperty().SetSpecular(0.3)
    a2Actor.GetProperty().SetSpecularPower(20)
    a2Actor.GetProperty().SetAmbient(0.2)
    a2Actor.GetProperty().SetDiffuse(0.8)

    # Draw the elevation arrows.
    a3Actor = vtk.vtkLODActor()
    a3Actor.SetMapper(arrowMapper)
    a3Actor.RotateZ(180)
    a3Actor.RotateX(90)
    a3Actor.SetPosition(1, -1, 0)
    a3Actor.GetProperty().SetColor(colors.GetColor3d("ElevationArrowColor"))
    a3Actor.GetProperty().SetSpecularColor(colors.GetColor3d("White"))
    a3Actor.GetProperty().SetSpecular(0.3)
    a3Actor.GetProperty().SetSpecularPower(20)
    a3Actor.GetProperty().SetAmbient(0.2)
    a3Actor.GetProperty().SetDiffuse(0.8)

    a4Actor = vtk.vtkLODActor()
    a4Actor.SetMapper(arrowMapper)
    a4Actor.RotateZ(180)
    a4Actor.RotateX(-90)
    a4Actor.SetPosition(1, 1, 0)
    a4Actor.GetProperty().SetColor(colors.GetColor3d("ElevationArrowColor"))
    a4Actor.GetProperty().SetSpecularColor(colors.GetColor3d("White"))
    a4Actor.GetProperty().SetSpecular(0.3)
    a4Actor.GetProperty().SetSpecularPower(20)
    a4Actor.GetProperty().SetAmbient(0.2)
    a4Actor.GetProperty().SetDiffuse(0.8)

    # Draw the DOP.
    arrowT2 = vtk.vtkTransform()
    arrowT2.Scale(1, 0.6, 1)
    arrowT2.RotateY(90)

    arrowTF2 = vtk.vtkTransformPolyDataFilter()
    arrowTF2.SetInputData(pd2)
    arrowTF2.SetTransform(arrowT2)

    arrowREF = vtk.vtkRotationalExtrusionFilter()
    arrowREF.SetInputConnection(arrowTF2.GetOutputPort())
    arrowREF.CappingOff()
    arrowREF.SetResolution(30)

    spikeMapper = vtk.vtkPolyDataMapper()
    spikeMapper.SetInputConnection(arrowREF.GetOutputPort())

    a5Actor = vtk.vtkLODActor()
    a5Actor.SetMapper(spikeMapper)
    a5Actor.SetScale(.3, .3, .6)
    a5Actor.RotateY(90)
    a5Actor.SetPosition(-2, 0, 0)
    a5Actor.GetProperty().SetColor(colors.GetColor3d("SpikeColor"))
    a5Actor.GetProperty().SetAmbient(0.2)
    a5Actor.GetProperty().SetDiffuse(0.8)

    # Focal point.
    fps = vtk.vtkSphereSource()
    fps.SetRadius(0.5)
    fpMapper = vtk.vtkPolyDataMapper()
    fpMapper.SetInputConnection(fps.GetOutputPort())
    fpActor = vtk.vtkLODActor()
    fpActor.SetMapper(fpMapper)
    fpActor.SetPosition(-9, 0, 0)
    fpActor.GetProperty().SetSpecularColor(colors.GetColor3d("White"))
    fpActor.GetProperty().SetSpecular(0.3)
    fpActor.GetProperty().SetAmbient(0.2)
    fpActor.GetProperty().SetDiffuse(0.8)
    fpActor.GetProperty().SetSpecularPower(20)

    # Create the roll arrows.
    arrowWT2 = vtk.vtkWarpTo()
    arrowWT2.SetInputConnection(arrowCF.GetOutputPort())
    arrowWT2.SetPosition(5, 0, 2.5)
    arrowWT2.SetScaleFactor(0.95)
    arrowWT2.AbsoluteOn()

    arrowT3 = vtk.vtkTransform()
    arrowT3.Translate(-2.50358, 0, -1.70408)
    arrowT3.Scale(0.5, 0.3, 1)

    arrowTF3 = vtk.vtkTransformFilter()
    arrowTF3.SetInputConnection(arrowWT2.GetOutputPort())
    arrowTF3.SetTransform(arrowT3)

    arrowMapper2 = vtk.vtkDataSetMapper()
    arrowMapper2.SetInputConnection(arrowTF3.GetOutputPort())
    arrowMapper2.ScalarVisibilityOff()

    # Draw the roll arrows.
    a6Actor = vtk.vtkLODActor()
    a6Actor.SetMapper(arrowMapper2)
    a6Actor.RotateZ(90)
    a6Actor.SetPosition(-4, 0, 0)
    a6Actor.SetScale(1.5, 1.5, 1.5)
    a6Actor.GetProperty().SetColor(colors.GetColor3d("RollArrowColor"))
    a6Actor.GetProperty().SetSpecularColor(colors.GetColor3d("White"))
    a6Actor.GetProperty().SetSpecular(0.3)
    a6Actor.GetProperty().SetSpecularPower(20)
    a6Actor.GetProperty().SetAmbient(0.2)
    a6Actor.GetProperty().SetDiffuse(0.8)

    # Add the actors to the renderer, set the background and size.
    ren.AddActor(camActor)
    ren.AddActor(a1Actor)
    ren.AddActor(a2Actor)
    ren.AddActor(a3Actor)
    ren.AddActor(a4Actor)
    ren.AddActor(a5Actor)
    ren.AddActor(a6Actor)
    ren.AddActor(fpActor)
    ren.SetBackground(colors.GetColor3d("BkgColor"))
    ren.SetBackground(colors.GetColor3d("SlateGray"))
    renWin.SetSize(640, 480)

    # Render the image.

    cam1 = (ren.GetActiveCamera())
    ren.ResetCamera()
    cam1.Azimuth(150)
    cam1.Elevation(30)
    cam1.Dolly(1.5)
    ren.ResetCameraClippingRange()

    # Create a TextActor for azimuth  (a1 and a2 actor's color).
    text = vtk.vtkTextActor()
    text.SetInput("Azimuth")
    tprop = text.GetTextProperty()
    tprop.SetFontFamilyToArial()
    tprop.ShadowOff()
    tprop.SetLineSpacing(1.0)
    tprop.SetFontSize(36)
    tprop.SetColor(a1Actor.GetProperty().GetColor())
    text.SetDisplayPosition(20, 50)
    ren.AddActor2D(text)

    # Create a TextActor for elevation  (a3 and a4 actor's color).
    text2 = vtk.vtkTextActor()
    text2.SetInput("Elevation")
    tprop = text2.GetTextProperty()
    tprop.SetFontFamilyToArial()
    tprop.ShadowOff()
    tprop.SetLineSpacing(1.0)
    tprop.SetFontSize(36)
    tprop.SetColor(a3Actor.GetProperty().GetColor())
    text2.SetDisplayPosition(20, 100)
    ren.AddActor2D(text2)

    # Create a TextActor for roll (a6 actor's color).
    text3 = vtk.vtkTextActor()
    text3.SetInput("Roll")
    tprop = text3.GetTextProperty()
    tprop.SetFontFamilyToArial()
    tprop.ShadowOff()
    tprop.SetLineSpacing(1.0)
    tprop.SetFontSize(36)
    tprop.SetColor(a6Actor.GetProperty().GetColor())
    text3.SetDisplayPosition(20, 150)
    ren.AddActor2D(text3)

    iren.Initialize()
    iren.Start()
pd2 = vtk.vtkPolyData()
ca2 = vtk.vtkCellArray()
fp2 = vtk.vtkPoints()
fp2.InsertNextPoint(0,1,0)
fp2.InsertNextPoint(8,1,0)
fp2.InsertNextPoint(8,2,0)
fp2.InsertNextPoint(10,0.01,0)
#prevents degenerate triangles
ca2.InsertNextCell(4)
ca2.InsertCellPoint(0)
ca2.InsertCellPoint(1)
ca2.InsertCellPoint(2)
ca2.InsertCellPoint(3)
pd2.SetPoints(fp2)
pd2.SetLines(ca2)
arrowIM = vtk.vtkImplicitModeller()
arrowIM.SetInputData(pd)
arrowIM.SetSampleDimensions(50,20,8)
arrowCF = vtk.vtkContourFilter()
arrowCF.SetInputConnection(arrowIM.GetOutputPort())
arrowCF.SetValue(0,0.2)
arrowWT = vtk.vtkWarpTo()
arrowWT.SetInputConnection(arrowCF.GetOutputPort())
arrowWT.SetPosition(5,0,5)
arrowWT.SetScaleFactor(0.85)
arrowWT.AbsoluteOn()
arrowT = vtk.vtkTransform()
arrowT.RotateY(60)
arrowT.Translate(-1.33198,0,-1.479)
arrowT.Scale(1,0.5,1)
arrowTF = vtk.vtkTransformFilter()