Beispiel #1
0
    def AddLineSegments(self,
                        points,
                        edges,
                        color=None,
                        scalars=None,
                        ncolors=256):
        """ Adds arrows to plotting object """

        cent = (points[edges[:, 0]] + points[edges[:, 1]]) / 2
        direction = points[edges[:, 1]] - points[edges[:, 0]]
        # pdata = vtkInterface.CreateVectorPolyData(cent, direction)
        pdata = vtkInterface.CreateVectorPolyData(cent, direction)
        arrows, mapper = CreateLineSegmentsActor(pdata)

        # set color
        if isinstance(color, str):
            color = vtkInterface.StringToRGB(color)
            mapper.ScalarVisibilityOff()
            arrows.GetProperty().SetColor(color)

        if scalars is not None:
            if scalars.size == edges.shape[0]:
                pdata.AddCellScalars(scalars, '', True)
                mapper.SetScalarModeToUseCellData()
                mapper.GetLookupTable().SetNumberOfTableValues(ncolors)
                # if interpolatebeforemap:
                # self.mapper.InterpolateScalarsBeforeMappingOn()
            else:
                raise Exception('Number of scalars must match number of edges')

        # add to rain class
        self.AddActor(arrows)
        return arrows
Beispiel #2
0
    def AddLineSegments(self, points, edges, color=None):
        """ Adds arrows to plotting object """
        
        cent = (points[edges[:, 0]] + points[edges[:, 1]])/2
        direction = points[edges[:, 1]] - points[edges[:, 0]]
        pdata = vtkInterface.CreateVectorPolyData(cent, direction)
        
        pdata = vtkInterface.CreateVectorPolyData(cent, direction)
        arrows, mapper = CreateLineSegmentsActor(pdata)
        
        # set color
        if type(color) is str or type(color) is unicode:
            color = vtkInterface.StringToRGB(color)
            mapper.ScalarVisibilityOff()
            arrows.GetProperty().SetColor(color)
#            print 'color', str(color)
            
        # add to mrain class
        self.AddActor(arrows)
        return arrows
Beispiel #3
0
    def AddArrows(self, cent, direction, mag=1):
        """ Adds arrows to plotting object """
        
        if cent.ndim != 2:
            cent = cent.reshape((-1, 3))
            
        if direction.ndim != 2:
            direction = direction.reshape((-1, 3))
        
        pdata = vtkInterface.CreateVectorPolyData(cent, direction*mag)
        arrows = CreateArrowsActor(pdata)
        self.AddActor(arrows)

        return arrows