Пример #1
0
    def __init__(self):
        VTKPythonAlgorithmBase.__init__(self)

        self.SetNumberOfInputPorts(1)
        self.SetNumberOfOutputPorts(1)

        self.visible = True

        self.visible_selection = vtk.vtkIntArray()
        self.visible_selection.SetName("visible")
        self.visible_selection.InsertNextValue(1)
        self.visible_selection.InsertNextValue(1)

        self.selection_vis_node = vtk.vtkSelectionNode()
        self.selection_vis_node.SetContentType(vtk.vtkSelectionNode.THRESHOLDS)
        self.selection_vis_node.SetSelectionList(self.visible_selection)

        self.selection_vis = vtk.vtkSelection()
        self.selection_vis.AddNode(self.selection_vis_node)

        self.ex_vis = vtk.vtkExtractSelection()
        self.ex_vis.ReleaseDataFlagOn()
        self.ex_vis.SetInputDataObject(1, self.selection_vis)

        self._callbacks = []
Пример #2
0
    def __init__(self):
        VTKPythonAlgorithmBase.__init__(self,
                                        nInputPorts=0,
                                        nOutputPorts=1,
                                        outputType='vtkImageData')

        self.__FileName = ""
Пример #3
0
    def __init__(self):
        VTKPythonAlgorithmBase.__init__(self,
                                        nInputPorts=0,
                                        nOutputPorts=1,
                                        outputType='vtkMultiBlockDataSet')

        self.__FileName = ""
Пример #4
0
 def __init__(self):
     VTKPythonAlgorithmBase.__init__(self,
                                     nInputPorts=0,
                                     nOutputPorts=1,
                                     outputType='vtkRectilinearGrid')
     self.__FileName = ""
     self.__Dims = [31, 31, 31]
Пример #5
0
 def __init__(self):
     VTKPythonAlgorithmBase.__init__(
         self,
         nInputPorts=0,
         nOutputPorts=1,
         outputType=self._example_data.GetClassName(),
     )
Пример #6
0
    def __init__(self):
        VTKPythonAlgorithmBase.__init__(self,
                                        nInputPorts=2,
                                        nOutputPorts=1,
                                        outputType='vtkPolyData')

        self.icp = vtk.vtkIterativeClosestPointTransform()
Пример #7
0
 def __init__(self):
     VTKPythonAlgorithmBase.__init__(self,
                                     nInputPorts=1,
                                     inputType='vtkImageData',
                                     nOutputPorts=1,
                                     outputType='vtkImageData')
     self.__UpdateExtent = None
Пример #8
0
    def __init__(self):
        VTKPythonAlgorithmBase.__init__(self,
                                        nInputPorts=1,
                                        inputType='vtkUnstructuredGrid',
                                        nOutputPorts=1,
                                        outputType='vtkUnstructuredGrid')

        self.selection_list = vtk.vtkIntArray()
        self.selection_node = vtk.vtkSelectionNode()
        self.selection = vtk.vtkSelection()
        self.ex = vtk.vtkExtractSelection()

        self.active_groups = set()
        self.active_types = set()
        self.visible_ids = set()
        self.visible_on = True

        self.selection_list.SetName('visible')
        self.selection_list.SetNumberOfValues(2)
        self.selection_list.SetValue(0, 1)
        self.selection_list.SetValue(1, 1)

        self.selection_node.SetContentType(vtk.vtkSelectionNode.THRESHOLDS)
        self.selection_node.SetSelectionList(self.selection_list)
        self.selection.AddNode(self.selection_node)
        self.ex.ReleaseDataFlagOn()
        self.ex.SetInputDataObject(1, self.selection)
Пример #9
0
 def __init__(self):
     self._dimensions = [100, 100, 100]
     self._bounds = [-2.5, 2.5, -2.5, 2.5, 0., 8.]
     VTKPythonAlgorithmBase.__init__(self,
                                     nInputPorts=0,
                                     nOutputPorts=1,
                                     outputType='vtkImageData')
Пример #10
0
    def __init__(self):
        VTKPythonAlgorithmBase.__init__(self,
                                        nInputPorts=0,
                                        nOutputPorts=1,
                                        outputType='vtkUnstructuredGrid')

        self._input_data = vtk.vtkUnstructuredGrid()
        self._opt = None
Пример #11
0
    def __init__(self):
        VTKPythonAlgorithmBase.__init__(self,
                                        nInputPorts=1,
                                        inputType='vtkPolyData',
                                        nOutputPorts=1,
                                        outputType='vtkPolyData')

        self.renderer = None
Пример #12
0
    def __init__(self):
        VTKPythonAlgorithmBase.__init__(self, \
        nInputPorts=1, \
        inputType='vtkUnstructuredGrid', \
        nOutputPorts=0)

        self.__FileName = ""
        self.__NumberOfPieces = 1
        self.__CurrentPiece = 0
Пример #13
0
    def __init__(self):
        VTKPythonAlgorithmBase.__init__(self,
                                        nInputPorts=1,
                                        inputType='vtkUnstructuredGrid',
                                        nOutputPorts=1,
                                        outputType='vtkUnstructuredGrid')

        self.__MaxIt = 20
        self.__ItMethod = 'BJ'
Пример #14
0
 def __init__(self, nInputPorts=1, inputType='vtkPolyData', **kwargs):
     VTKPythonAlgorithmBase.__init__(self, nInputPorts=nInputPorts,
                                           inputType=inputType,
                                           nOutputPorts=0)
     self.__filename = kwargs.get('filename', None)
     self.__fmt = '%.9e'
     # For composite datasets: not always used
     self.__blockfilenames = None
     self.__composite = False
Пример #15
0
    def __init__(self):
        VTKPythonAlgorithmBase.__init__(self,
                                        nInputPorts=1,
                                        inputType='vtkUnstructuredGrid',
                                        nOutputPorts=1,
                                        outputType='vtkUnstructuredGrid')

        self.coord_size = 5.
        self.coord_category = card_info.categories('COORD')
Пример #16
0
 def __init__(self):
     VTKPythonAlgorithmBase.__init__(self,
                                     nInputPorts=0,
                                     nOutputPorts=1,
                                     outputType='vtkPolyData')
     self.TimeStepRange = [0, 0]
     self.TimeStep = 0
     self.ActualTimeStep = 0
     self.TimeStepValues = np.r_[0]
Пример #17
0
    def __init__(self):
        VTKPythonAlgorithmBase.__init__(self,
                                        nInputPorts=1,
                                        inputType='vtkUnstructuredGrid',
                                        nOutputPorts=1,
                                        outputType='vtkUnstructuredGrid')

        self.visible_filter = vtkmyVisibleFilter2()
        self.coord_filter = FirstFilter()
        self.coord_filter.SetInputConnection(
            self.visible_filter.GetOutputPort(0))
Пример #18
0
    def __init__(self):
        VTKPythonAlgorithmBase.__init__(self,
                                        nInputPorts=2,
                                        nOutputPorts=1,
                                        outputType='vtkPolyData')

        self._normalLine = vtk.vtkPolyLineSource()
        self._normalLine.SetNumberOfPoints(2)
        self._normalLine.SetPoint(0, 0, 0, 0)
        self._normalLine.SetPoint(1, 0, 0, 0)
        self.SetInputConnection(1, self._normalLine.GetOutputPort())
Пример #19
0
 def __init__(self):
     """
     1 input port + 1 output port == your common VTK filter.
     0 input port + 1 output port == your common VTK source.
     1 input port + 0 output port == your common VTK sink (writer, mapper etc.).
     """
     VTKPythonAlgorithmBase.__init__(self,
                                     nInputPorts=0,
                                     nOutputPorts=1,
                                     outputType='vtkImageData')
     self.__FileName = ""
Пример #20
0
    def __init__(self):
        VTKPythonAlgorithmBase.__init__(self)

        self.SetNumberOfInputPorts(1)
        self.SetNumberOfOutputPorts(1)

        self.selection_group = vtk.vtkSelection()

        self.ex_group = vtk.vtkExtractSelection()
        self.ex_group.ReleaseDataFlagOn()
        self.ex_group.SetInputDataObject(1, self.selection_group)
Пример #21
0
    def __init__(self):
        VTKPythonAlgorithmBase.__init__(self,
                                        nInputPorts=1,
                                        inputType='vtkUnstructuredGrid',
                                        nOutputPorts=1,
                                        outputType='vtkUnstructuredGrid')

        self.first_filter = vtkmyFirstFilter()

        self.bdf_data = None
        """:type: mrNastran.bdf.bdf_data.BdfData"""
Пример #22
0
 def __init__(self):
     VTKPythonAlgorithmBase.__init__(self,
                                     nInputPorts=0,
                                     nOutputPorts=1,
                                     outputType='vtkMultiBlockDataSet')
     # one should only change N. This ensures an even number for dims
     self.__N = 5
     self.__CompositeBlockDims = [
         2 * self.__N + 1, 2 * self.__N + 1, 2 * self.__N + 1
     ]
     self.__NumberOfBlocks = 4
Пример #23
0
    def __init__(self):
        VTKPythonAlgorithmBase.__init__(self,
                                        nInputPorts=1,
                                        inputType='vtkUnstructuredGrid',
                                        nOutputPorts=1,
                                        outputType='vtkPolyData')

        self.extract_edges = False
        self.edge_filter = vtk.vtkExtractEdges()
        self.edge_filter.ReleaseDataFlagOn()
        self.geom_filter = vtk.vtkGeometryFilter()
        self.geom_filter.ReleaseDataFlagOn()
Пример #24
0
    def __init__(self):
        VTKPythonAlgorithmBase.__init__(self,
                                        nInputPorts=0,
                                        nOutputPorts=1,
                                        outputType='vtkUnstructuredGrid')

        self._bdf = None
        self._opt = None
        self._data = None

        self.default_group = vtk.vtkIntArray()
        self.default_group.SetName("group_default")
Пример #25
0
    def __init__(self):
        VTKPythonAlgorithmBase.__init__(self,
                                        nInputPorts=0,
                                        nOutputPorts=1,
                                        outputType='vtkPolyData')

        self._objects = {'table': True, 'left_cup': True, 'right_cup': True}

        self._polydata = {'table': None, 'left_cup': None, 'right_cup': None}

        self._floor = True
        self._floor_polydata = None
Пример #26
0
    def __init__(self):
        VTKPythonAlgorithmBase.__init__(self,
                                        nInputPorts=1,
                                        inputType='vtkUnstructuredGrid',
                                        nOutputPorts=0)

        self.cc = vtk.vtkCellCenters()

        # tried using a vtkCellLocator for FindCellsAlongLine
        # but it wouldn't find the vertex cells for some reason...
        self.tree = vtk.vtkKdTree()

        self._empty_dataset = False
Пример #27
0
    def __init__(self):
        VTKPythonAlgorithmBase.__init__(self,
                                        nInputPorts=1, inputType='vtkUnstructuredGrid',
                                        nOutputPorts=4, outputType='vtkUnstructuredGrid')

        self.selection_node = vtk.vtkSelectionNode()
        self.selection = vtk.vtkSelection()
        self.ex = vtk.vtkExtractSelection()
        self.ex.ReleaseDataFlagOn()

        self.selection_node.SetContentType(vtk.vtkSelectionNode.THRESHOLDS)
        self.selection.AddNode(self.selection_node)
        self.ex.SetInputDataObject(1, self.selection)
Пример #28
0
    def __init__(self):
        VTKPythonAlgorithmBase.__init__(self,
                                        nInputPorts=0,
                                        nOutputPorts=1, outputType='vtkPolyData')

        self._objects = {'table': True,
                         'left_cup': True,
                         'right_cup': True}

        self._polydata = {'table': None,
                          'left_cup': None,
                          'right_cup': None}

        self._floor = True
        self._floor_polydata = None
Пример #29
0
    def __init__(self):
        VTKPythonAlgorithmBase.__init__(
            self,
            nInputPorts=0,
            nOutputPorts=1,
            outputType='vtkMultiBlockDataSet')

        self._file_name = ""
        self._output = None
        self._cell_dim = None
        self._labels = {}
        self._graph = {}
        self._multi_idx = 0
        self._cell_connectivity = None
        self._block_info = None
        self._sideset_info = None
Пример #30
0
    def __init__(self):
        VTKPythonAlgorithmBase.__init__(self,
                                        nInputPorts=1,
                                        inputType='vtkUnstructuredGrid',
                                        nOutputPorts=1,
                                        outputType='vtkUnstructuredGrid')

        self.append_filter = vtk.vtkAppendFilter()
        self.append_filter.ReleaseDataFlagOn()
        self.triangle_filter = vtk.vtkTriangleFilter()
        self.planes = vtk.vtkPlanes()

        self.ex = vtk.vtkExtractSelectedFrustum()
        self.ex.ReleaseDataFlagOn()

        self.poly_pick_data = None
        self.renderer = None
Пример #31
0
    def __init__(self):
        VTKPythonAlgorithmBase.__init__(self,
                                        nInputPorts=0,
                                        nOutputPorts=1,
                                        outputType='vtkRectilinearGrid')

        self.__DFileName = ""
        self.__GFileName = ""

        self.nx = 1
        self.ny = 1
        self.nz = 1

        self.nvar = 1
        self.ngvar = 0

        self._fields = []
Пример #32
0
    def __init__(self, param_classifier_threshold=0.01):
        """
        :param param_classifier_threshold: default=0.01
          Threshold to determine when the difference in the depth images is too big
          and is therefore a novel measurement.
        :return:
        """

        VTKPythonAlgorithmBase.__init__(self,
                                        nInputPorts=2, inputType='vtkImageData',
                                        nOutputPorts=1, outputType='vtkImageData')

        self._param_classifier_threshold = param_classifier_threshold

        self._postprocess = []
        self._postprocess_im1 = []
        self._postprocess_im2 = []
        self._postprocess_difim = []
Пример #33
0
    def __init__(self, nbunnies=1):

        VTKPythonAlgorithmBase.__init__(self,
                                        nInputPorts=0,
                                        nOutputPorts=1, outputType='vtkPolyData')

        self._bunny_ply_file = os.path.join(os.path.dirname(__file__),
                                            'stanford_bunny.ply')

        self._nbunnies = nbunnies

        dis = 1.5
        ytrans = -0.2
        if nbunnies is 1:
            trans = [(0.0, ytrans, 0.0)]
        elif nbunnies is 2:
            trans = [(-dis, ytrans, 0.0),
                     (dis, ytrans, 0.0)]
        elif nbunnies is 3:
            trans = [(-dis, ytrans, 0.0),
                     (0.0, ytrans, 0.0),
                     (dis, ytrans, 0.0)]
        elif nbunnies is 4:
            trans = [(-dis, ytrans, 0.0),
                     (0.0, ytrans, dis),
                     (dis, ytrans, 0.0),
                     (0.0, ytrans, -dis)]

        self.objects = {'bunny_' + str(x): True for x in range(nbunnies)}
        self._polydata = {'bunny_'+str(x): vtk.vtkTransformPolyDataFilter() for x in range(nbunnies)}
        self._keys = self.objects.keys()
        for i, (key, tfilter) in enumerate(self._polydata.iteritems()):
            reader = vtk.vtkPLYReader()
            reader.SetFileName(self._bunny_ply_file)
            transform = vtk.vtkTransform()
            # transform.Scale(10.0, 10.0, 10.0)
            transform.Translate(trans[i])
            tfilter.SetInputConnection(reader.GetOutputPort())
            tfilter.SetTransform(transform)

        self._floor = True
        self._floor_polydata = None
Пример #34
0
    def __init__(self, color=False):
        """
        :param color: default=False
          Color every new surface of the global mesh a different color.
        :return:
        """

        VTKPythonAlgorithmBase.__init__(self,
                                        nInputPorts=1, inputType='vtkPolyData',
                                        nOutputPorts=1, outputType='vtkPolyData')

        self._worldmesh = vtk.vtkAppendPolyData()

        # colormap for changing polydata on every iteration
        # http://matplotlib.org/examples/color/colormaps_reference.html
        self._color = color
        if self._color:
            gist_rainbow_r = plt.cm.get_cmap(name='gist_rainbow_r')
            mycm = gist_rainbow_r(range(160, 260, 5))[:, 0:3]
            self._colorcycle = cycle(mycm)
Пример #35
0
    def __init__(self,
                 param_farplane_threshold=1.0,
                 param_convolution_threshold=0.01):
        """
        Algorithm setup and define parameters.
        :param param_farplane_threshold: default=1.0
          Values on the depth image range from 0.0-1.0. Points with depth values greater
          than param_farplane_threshold will be thrown away.
        :param param_convolution_threshold: default=0.01
          Convolution is used to determine pixel neighbors with a large difference. If
          there is one, the point will be thrown away. This threshold controls sensitivity.
        """

        VTKPythonAlgorithmBase.__init__(self,
                                        nInputPorts=1, inputType='vtkImageData',
                                        nOutputPorts=1, outputType='vtkPolyData')

        self._param_farplane_threshold = param_farplane_threshold
        self.param_convolution_theshold = param_convolution_threshold

        self._sizex = []
        self._sizey = []
        self._viewport = []

        self._display_pts = []
        self._viewport_pts = []
        self._world_pts = []

        self._points = vtk.vtkPoints()
        self._polys = vtk.vtkCellArray()
        self._polydata = vtk.vtkPolyData()
        self._polydata.SetPoints(self._points)
        self._polydata.SetPolys(self._polys)

        self._extract = vtk.vtkExtractPolyDataGeometry()
        DebugTimeVTKFilter(self._extract)
        self._extract.SetInputData(self._polydata)
        planefunc = vtk.vtkPlane()
        planefunc.SetNormal(0.0, -1.0, 0.0)
        planefunc.SetOrigin(0.0, -1.0, 0.0)
        self._extract.SetImplicitFunction(planefunc)
 def __init__(self):
     VTKPythonAlgorithmBase.__init__(self,
         nInputPorts=0,
         nOutputPorts=1, outputType='vtkPolyData')
Пример #37
0
    def __init__(self,
                 name='none',
                 offscreen=False,
                 noise=0.0,
                 depth_image_size=(640, 480)):
        """
        :param name: default='none'
          Used for the logging statements.
        :param offscreen:
          Create the render window that is used to produce the depth image offscreen.
        :param noise:
          Noise to add to depth image.
        :param depth_image_size:
          Size of the depth image.
        """

        VTKPythonAlgorithmBase.__init__(self,
                                        nInputPorts=0,
                                        nOutputPorts=1, outputType='vtkImageData')
        self._name = name

        if type(noise) == bool:
            if noise:
                noise = 0.002
            else:
                noise = 0.0
        self._noise = noise

        # vtk render objects
        self._ren = vtk.vtkRenderer()
        self._renWin = vtk.vtkRenderWindow()
        self._iren = vtk.vtkRenderWindowInteractor()

        # wire them up
        self._renWin.AddRenderer(self._ren)
        self._iren.SetRenderWindow(self._renWin)

        # offscreen rendering
        if offscreen:
            self._renWin.SetOffScreenRendering(1)

        # kinect intrinsic parameters
        # https://msdn.microsoft.com/en-us/library/hh438998.aspx
        self._renWin.SetSize(depth_image_size)
        self._ren.GetActiveCamera().SetViewAngle(60.0)
        self._ren.GetActiveCamera().SetClippingRange(0.8, 4.0)
        self._iren.GetInteractorStyle().SetAutoAdjustCameraClippingRange(0)

        # have it looking down and underneath the "floor"
        # so that it will produce a blank vtkImageData until
        # set_sensor_orientation() is called
        self._ren.GetActiveCamera().SetPosition(0.0, -20.0, 0.0)
        self._ren.GetActiveCamera().SetFocalPoint(0.0, -25.0, 0.0)

        # calculate image bounds
        self._imageBounds = [0, 0, 0, 0]
        viewport = self._ren.GetViewport()
        size = self._renWin.GetSize()
        self._imageBounds[0] = int(viewport[0] * size[0])
        self._imageBounds[1] = int(viewport[1] * size[1])
        self._imageBounds[2] = int(viewport[2] * size[0] + 0.5) - 1
        self._imageBounds[3] = int(viewport[3] * size[1] + 0.5) - 1
Пример #38
0
 def __init__(self):
     VTKPythonAlgorithmBase.__init__(self)
     self.InputType = "vtkDataSet"
     self.OutputType = "vtkDataObject"
     self.Counter = 0
Пример #39
0
 def __init__(self):
     VTKPythonAlgorithmBase.__init__(self,
         nInputPorts=0, nOutputPorts=1, outputType='vtkStructuredGrid')
     self.__FileName = ""
Пример #40
0
 def __init__(self):
     VTKPythonAlgorithmBase.__init__(self,
         nInputPorts=0, nOutputPorts=1, outputType='vtkImageData')
     self.__FileName = ""
 def __init__(self):
     VTKPythonAlgorithmBase.__init__(self,
         nInputPorts=0, nOutputPorts=1, outputType='vtkRectilinearGrid')
     self.__FileName = ""
     self.__Dims = [31, 31, 31]