Python vtk.vtkPolyDataMapper() Examples
The following are 30
code examples of vtk.vtkPolyDataMapper().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
vtk
, or try the search function
.
Example #1
Source File: visualization.py From CityEnergyAnalyst with MIT License | 8 votes |
def stl2actor(ageometry_path, ageometry_name, ageometry_color): appendfilter = vtk.vtkAppendPolyData() render_lib = vtk.vtkSTLReader() polydata = vtk.vtkPolyData() render_lib.SetFileName(os.path.join(ageometry_path, ageometry_name+".stl")) render_lib.Update() polydata.ShallowCopy(render_lib.GetOutput()) appendfilter.AddInputConnection(polydata.GetProducerPort()) appendfilter.Update() # Remove any duplicate points. cleanfilter = vtk.vtkCleanPolyData() cleanfilter.SetInputConnection(appendfilter.GetOutputPort()) cleanfilter.Update() mapper = vtk.vtkPolyDataMapper() mapper.SetInputConnection(cleanfilter.GetOutputPort()) actor = vtk.vtkActor() actor.SetMapper(mapper) actor.GetProperty().SetColor(ageometry_color) return actor, polydata
Example #2
Source File: vis.py From DeepV2D with BSD 3-Clause "New" or "Revised" License | 6 votes |
def create_pointcloud_actor(points, colors=None): """Creates a vtkActor with the point cloud from numpy arrays points: numpy.ndarray pointcloud with shape (n,3) colors: numpy.ndarray uint8 array with colors for each point. shape is (n,3) Returns vtkActor object """ vpoly = create_pointcloud_polydata(points, colors) mapper = vtk.vtkPolyDataMapper() mapper.SetInputData(vpoly) actor = vtk.vtkActor() actor.SetMapper(mapper) actor.GetProperty().SetPointSize(5) return actor
Example #3
Source File: serial_link.py From robopy with MIT License | 6 votes |
def __setup_pipeline_objs(self): """ Internal function to initialise vtk objects. :return: reader_list, actor_list, mapper_list """ reader_list = [0] * len(self.stl_files) actor_list = [0] * len(self.stl_files) mapper_list = [0] * len(self.stl_files) for i in range(len(self.stl_files)): reader_list[i] = vtk.vtkSTLReader() loc = pkg_resources.resource_filename("robopy", '/'.join(('media', self.name, self.stl_files[i]))) reader_list[i].SetFileName(loc) mapper_list[i] = vtk.vtkPolyDataMapper() mapper_list[i].SetInputConnection(reader_list[i].GetOutputPort()) actor_list[i] = vtk.vtkActor() actor_list[i].SetMapper(mapper_list[i]) actor_list[i].GetProperty().SetColor(self.colors[i]) # (R,G,B) return reader_list, actor_list, mapper_list
Example #4
Source File: Visualization.py From PyNite with MIT License | 6 votes |
def __init__(self, node, scale_factor, text_height=5, combo_name='Combo 1'): # Calculate the node's deformed position newX = node.X + scale_factor*(node.DX[combo_name]) newY = node.Y + scale_factor*(node.DY[combo_name]) newZ = node.Z + scale_factor*(node.DZ[combo_name]) # Generate a sphere for the node sphere = vtk.vtkSphereSource() sphere.SetCenter(newX, newY, newZ) sphere.SetRadius(0.6*text_height) # Set up a mapper for the node mapper = vtk.vtkPolyDataMapper() mapper.SetInputConnection(sphere.GetOutputPort()) # Set up an actor for the node self.actor = vtk.vtkActor() self.actor.GetProperty().SetColor(255, 255, 0) # Yellow self.actor.SetMapper(mapper) # Create the text for the node label label = vtk.vtkVectorText() label.SetText(node.Name) # Set up a mapper for the node label lblMapper = vtk.vtkPolyDataMapper() lblMapper.SetInputConnection(label.GetOutputPort()) # Set up an actor for the node label self.lblActor = vtk.vtkFollower() self.lblActor.SetMapper(lblMapper) self.lblActor.SetScale(text_height, text_height, text_height) self.lblActor.SetPosition(newX + 0.6*text_height, newY + 0.6*text_height, newZ) self.lblActor.GetProperty().SetColor(255, 255, 0) # Yellow #%% # Converts a member object into a member in its deformed position for the viewer
Example #5
Source File: util.py From sanet_relocal_demo with GNU General Public License v3.0 | 6 votes |
def create_camera_actor(R, t, color=(1.0, 0.0, 0.0), camera_obj_scale=0.25): """Creates a vtkActor object with a camera mesh""" import vtk vpoly = create_camera_polydata(R, t, only_polys=False, scale=camera_obj_scale) mapper = vtk.vtkPolyDataMapper() mapper.SetInputData(vpoly) color = (int(255.0*color[0]), int(255.0*color[1]), int(255.0*color[2])) actor = vtk.vtkActor() actor.SetMapper(mapper) actor.GetProperty().LightingOff() actor.GetProperty().SetLineWidth(2) actor.GetProperty().SetColor(color[0], color[1], color[2]) return actor
Example #6
Source File: vtkpointcloud.py From deep-prior-pp with GNU General Public License v3.0 | 6 votes |
def __init__(self, pts=None, zMin=-10.0, zMax=10.0, maxNumPoints=1e6, color='depth'): """ Initialize class :param zMin: minimum depth :param zMax: maximum depth :param maxNumPoints: maximum number of points :return: None """ self.color = color self.maxNumPoints = int(maxNumPoints) self.vtkPolyData = vtk.vtkPolyData() self.clearPoints() mapper = vtk.vtkPolyDataMapper() mapper.SetInputData(self.vtkPolyData) mapper.SetColorModeToDefault() mapper.SetScalarRange(zMin, zMax) mapper.SetScalarVisibility(1) self.vtkActor = vtk.vtkActor() self.vtkActor.SetMapper(mapper) self.vtkActor.GetProperty().SetPointSize(3.0) self.rng = numpy.random.RandomState(23455) if pts is not None: self.addPoints(pts)
Example #7
Source File: util.py From sanet_relocal_demo with GNU General Public License v3.0 | 6 votes |
def create_pointcloud_actor(points, colors=None, pt_size=3): """Creates a vtkActor with the point cloud from numpy arrays points: numpy.ndarray pointcloud with shape (n,3) colors: numpy.ndarray uint8 array with colors for each point. shape is (n,3) Returns vtkActor object """ import vtk vpoly = create_pointcloud_polydata(points, colors) mapper = vtk.vtkPolyDataMapper() mapper.SetInputData(vpoly) actor = vtk.vtkActor() actor.SetMapper(mapper) actor.GetProperty().SetPointSize(pt_size) return actor
Example #8
Source File: vtkpointcloud.py From deep-prior with GNU General Public License v3.0 | 6 votes |
def __init__(self, zMin=-10.0, zMax=10.0, maxNumPoints=1e6): """ Initialize class :param zMin: minimum depth :param zMax: maximum depth :param maxNumPoints: maximum number of points :return: None """ self.maxNumPoints = int(maxNumPoints) self.vtkPolyData = vtk.vtkPolyData() self.clearPoints() mapper = vtk.vtkPolyDataMapper() mapper.SetInputData(self.vtkPolyData) mapper.SetColorModeToDefault() mapper.SetScalarRange(zMin, zMax) mapper.SetScalarVisibility(1) self.vtkActor = vtk.vtkActor() self.vtkActor.SetMapper(mapper)
Example #9
Source File: vtk_utils.py From TractSeg with Apache License 2.0 | 6 votes |
def label(text='Origin', pos=(0, 0, 0), scale=(0.2, 0.2, 0.2), color=(1, 1, 1)): atext = vtk.vtkVectorText() atext.SetText(text) textm = vtk.vtkPolyDataMapper() textm.SetInputConnection(atext.GetOutputPort()) texta = vtk.vtkFollower() texta.SetMapper(textm) texta.SetScale(scale) texta.GetProperty().SetColor(color) texta.SetPosition(pos) return texta
Example #10
Source File: visualization.py From CityEnergyAnalyst with MIT License | 6 votes |
def face_points2actor(fps_df): cell_array = vtk.vtkCellArray() points = vtk.vtkPoints() point_id = 0 for i in range(fps_df.shape[0]): polygon = vtk.vtkPolygon() polygon.GetPointIds().SetNumberOfIds(3) for n in range(3): points.InsertNextPoint(fps_df.ix[i, 0+3*n], fps_df.ix[i, 1+3*n], fps_df.ix[i, 2+3*n]) polygon.GetPointIds().SetId(n, point_id) point_id += 1 cell_array.InsertNextCell(polygon) polydata = vtk.vtkPolyData() polydata.SetPoints(points) polydata.SetPolys(cell_array) # mapper mapper = vtk.vtkPolyDataMapper() mapper.SetInput(polydata) # actor actor = vtk.vtkActor() actor.SetMapper(mapper) return actor, polydata
Example #11
Source File: visualization.py From CityEnergyAnalyst with MIT License | 6 votes |
def points2actor(xyz, apoint_size): import vtk points = vtk.vtkPoints() # Create the topology of the point (a vertex) vertices = vtk.vtkCellArray() # Add points for i in range(0, len(xyz)): p = xyz.loc[i].values.tolist() point_id = points.InsertNextPoint(p) vertices.InsertNextCell(1) vertices.InsertCellPoint(point_id) # Create a poly data object polydata = vtk.vtkPolyData() # Set the points and vertices we created as the geometry and topology of the polydata polydata.SetPoints(points) polydata.SetVerts(vertices) polydata.Modified() # Mapper for points mapper = vtk.vtkPolyDataMapper() mapper.SetInput(polydata) # ACTOR for points actor = vtk.vtkActor() actor.SetMapper(mapper) actor.GetProperty().SetPointSize(apoint_size) return actor, polydata
Example #12
Source File: tessagon_vtk_demo.py From tessagon with Apache License 2.0 | 6 votes |
def tessellate(self, f, tessagon_class, **kwargs): extra_args = {'function': f, 'adaptor_class': VtkAdaptor} tessagon = tessagon_class(**{**kwargs, **extra_args}) poly_data = tessagon.create_mesh() mapper = vtk.vtkPolyDataMapper() mapper.SetInputData(poly_data) mapper.SetLookupTable(self.lut) mapper.SetScalarRange(poly_data.GetScalarRange()) actor = vtk.vtkActor() actor.SetMapper(mapper) actor.GetProperty().SetColor(tomato) actor.GetProperty().SetEdgeColor(0.0, 0.0, 0.0) actor.GetProperty().EdgeVisibilityOn() actor.SetPosition(kwargs['position']) self.ren.AddActor(actor)
Example #13
Source File: wvtk.py From pyCGNS with GNU Lesser General Public License v2.1 | 6 votes |
def s_highlightPoint(self, grid, index): if self.actorpt is not None: self._vtkren.RemoveActor(self.actorpt) if grid is None: return (i, j, k) = index filter = vtk.vtkStructuredGridGeometryFilter() if VTK_VERSION_MAJOR < 8: raise RuntimeError("VTK version is too old, please upgrade") filter.SetInputData(grid) filter.SetExtent(i - 1, i - 1, j - 1, j - 1, k - 1, k - 1) mapper = vtk.vtkPolyDataMapper() mapper.SetInputConnection(filter.GetOutputPort()) self.actorpt = vtk.vtkActor() self.actorpt.SetMapper(mapper) self.actorpt.GetProperty().SetColor(0, 1, 0) self.actorpt.GetProperty().SetPointSize(6) self.actorpt.PickableOff() self.actorpt.DragableOff() self._vtkren.AddActor(self.actorpt) self._iren.Render()
Example #14
Source File: vis.py From demon with GNU General Public License v3.0 | 6 votes |
def create_pointcloud_actor(points, colors=None): """Creates a vtkActor with the point cloud from numpy arrays points: numpy.ndarray pointcloud with shape (n,3) colors: numpy.ndarray uint8 array with colors for each point. shape is (n,3) Returns vtkActor object """ import vtk vpoly = create_pointcloud_polydata(points, colors) mapper = vtk.vtkPolyDataMapper() mapper.SetInputData(vpoly) actor = vtk.vtkActor() actor.SetMapper(mapper) actor.GetProperty().SetPointSize(3) return actor
Example #15
Source File: pointobject.py From Det3D with Apache License 2.0 | 6 votes |
def SetupPipelinePose(self): """Set up the VTK pipeline for visualizing multiple copies of a geometric representation with different poses""" # use vtkTensorGlyph set 3d pose for each actor instance tensorGlyph = vtk.vtkTensorGlyph() tensorGlyph.SetInputData(self.pose_pd) # setup with AddPoses() tensorGlyph.SetSourceData(self.pd) tensorGlyph.ColorGlyphsOff() tensorGlyph.ThreeGlyphsOff() tensorGlyph.ExtractEigenvaluesOff() tensorGlyph.Update() # Set up mappers and actors self.mapper = vtk.vtkPolyDataMapper() self.mapper.SetInputData(tensorGlyph.GetOutput()) self.mapper.Update() self.actor = vtk.vtkActor() self.actor.GetProperty().SetLineWidth(1.5) self.actor.SetMapper(self.mapper)
Example #16
Source File: viz.py From 3d-semantic-segmentation with MIT License | 6 votes |
def getActorCircle(radius_inner=100, radius_outer=99, color=(1,0,0)): """""" # create source source = vtk.vtkDiskSource() source.SetInnerRadius(radius_inner) source.SetOuterRadius(radius_outer) source.SetRadialResolution(100) source.SetCircumferentialResolution(100) # Transformer transform = vtk.vtkTransform() transform.RotateWXYZ(90, 1, 0, 0) transformFilter = vtk.vtkTransformPolyDataFilter() transformFilter.SetTransform(transform) transformFilter.SetInputConnection(source.GetOutputPort()) transformFilter.Update() # mapper mapper = vtk.vtkPolyDataMapper() mapper.SetInputConnection(transformFilter.GetOutputPort()) # actor actor = vtk.vtkActor() actor.GetProperty().SetColor(color) actor.SetMapper(mapper) return actor
Example #17
Source File: base.py From BrainSpace with BSD 3-Clause "New" or "Revised" License | 6 votes |
def __getattr__(self, name): """ Forwards unknown attribute requests to vtk object. Examples -------- >>> import vtk >>> from brainspace.vtk_interface.wrappers import BSVTKObjectWrapper >>> m1 = BSVTKObjectWrapper(vtk.vtkPolyDataMapper()) >>> m1.GetArrayId() # same as self.VTKObject.GetArrayId() -1 >>> self.arrayId # same as self.VTKObject.GetArrayId() -1 """ # We are here cause name is not in self # First forward to vtkobject # If it doesn't exist, look for it in vtk_map, find its corresponding # vtk name and forward again try: return VTKMethodWrapper(super().__getattr__(name)) except: return self._handle_call('get', name, None)
Example #18
Source File: base.py From BrainSpace with BSD 3-Clause "New" or "Revised" License | 6 votes |
def __setattr__(self, name, value): """ Forwards unknown set requests to vtk object. Examples -------- >>> import vtk >>> from brainspace.vtk_interface.wrappers import BSVTKObjectWrapper >>> m1 = BSVTKObjectWrapper(vtk.vtkPolyDataMapper()) >>> m1.GetArrayId() -1 >>> self.arrayId = 3 # same as self.VTKObject.SetArrayId(3) >>> m1.GetArrayId() 3 """ # Check self attributes first # Note: With this we cannot create attributes dynamically if name in self.__dict__: VTKMethodWrapper(super().__setattr__(name, value)) else: self._handle_call('set', name, value)
Example #19
Source File: pointobject.py From Det3D with Apache License 2.0 | 6 votes |
def CreatePolygon(self, points): "Create a 3D plane from Nx3 numpy array" self.verts = vtk.vtkPoints() polygon = vtk.vtkPolygon() polygon_pid = polygon.GetPointIds() for i, p in enumerate(points): self.verts.InsertNextPoint(*tuple(p)) polygon_pid.InsertNextId(i) polygon_cell = vtk.vtkCellArray() polygon_cell.InsertNextCell(polygon) self.pd = vtk.vtkPolyData() self.pd.SetPoints(self.verts) self.pd.SetPolys(polygon_cell) self.mapper = vtk.vtkPolyDataMapper() self.mapper.SetInputData(self.pd) self.actor = vtk.vtkActor() self.actor.SetMapper(self.mapper)
Example #20
Source File: pointobject.py From Det3D with Apache License 2.0 | 6 votes |
def SetupPipelineHedgeHog(self, scale=15.0): """Set up the VTK pipeline for visualizing points with surface normals" The surface normals are visualized as lines with the given scale""" hh = vtk.vtkHedgeHog() hh.SetInputData(self.pd) hh.SetVectorModeToUseNormal() hh.SetScaleFactor(scale) hh.Update() # Set up mappers and actors self.mapper = vtk.vtkPolyDataMapper() self.mapper.SetInputConnection(hh.GetOutputPort()) self.mapper.Update() self.actor = vtk.vtkActor() self.actor.SetMapper(self.mapper) self.actor.GetProperty().SetColor(1, 0, 0) # Default color
Example #21
Source File: pointobject.py From Det3D with Apache License 2.0 | 6 votes |
def SetupPipelineMesh(self): "Set up the VTK pipeline for visualizing a mesh" self.mapper = vtk.vtkPolyDataMapper() self.mapper.SetInputData(self.pd) if self.scalars != None: if self.pd.GetPointData() != None: if (self.pd.GetPointData().GetScalars != None) and (self.LUT != None): self.pd.GetPointData().GetScalars().SetLookupTable(self.LUT) self.mapper.ScalarVisibilityOn() self.mapper.SetColorModeToMapScalars() self.mapper.SetScalarModeToUsePointData() self.mapper.SetScalarRange(0, 1) else: self.mapper.ScalarVisibilityOff() self.actor = vtk.vtkActor() self.actor.SetMapper(self.mapper) self.actor.GetProperty().SetRepresentationToSurface() self.actor.GetProperty().SetInterpolationToGouraud()
Example #22
Source File: utility.py From ILCC with BSD 2-Clause "Simplified" License | 6 votes |
def draw_one_grd_vtk(ls): # arr:[a,b,c,d],a:orig, b, point1, c,point 2, d,color source = vtk.vtkPlaneSource() source.SetOrigin(ls[0]) source.SetPoint1(ls[1]) source.SetPoint2(ls[2]) source.Update() # source.SetPoint1(0, 0, 0) # source.SetPoint2(4, 3, 0) # mapper mapper = vtk.vtkPolyDataMapper() color = vtk.vtkUnsignedCharArray() color.SetName("colors") color.SetNumberOfComponents(3) # color_tup = np.random.randint(1, 255, 3) color.SetNumberOfTuples(source.GetOutput().GetNumberOfCells()) for i in xrange(source.GetOutput().GetNumberOfCells()): color_tup = np.array([255, 255, 255]) * ls[3] color.InsertTuple(i, color_tup) source.GetOutput().GetCellData().SetScalars(color) mapper.SetInputConnection(source.GetOutputPort()) # actor actor = vtk.vtkActor() actor.SetMapper(mapper) # assign actor to the renderer # ren.AddActor(actor) return actor # generate the color list of the point cloud for different color styles. intens_rg: color by reflectance intensity (red:high green:low), # intens: color by reflectance intensity (white:high back:low), autumn: matplotlib autumn color map, cool: matplotlib cool color map
Example #23
Source File: test_vtk.py From panel with BSD 3-Clause "New" or "Revised" License | 6 votes |
def make_render_window(): #cone actor cone = vtk.vtkConeSource() coneMapper = vtk.vtkPolyDataMapper() coneMapper.SetInputConnection(cone.GetOutputPort()) coneActor = vtk.vtkActor() coneActor.SetMapper(coneMapper) #text actor following camera text = vtk.vtkVectorText() text.SetText("Origin") textMapper = vtk.vtkPolyDataMapper() textMapper.SetInputConnection(text.GetOutputPort()) textActor = vtk.vtkFollower() textActor.SetMapper(textMapper) ren = vtk.vtkRenderer() ren.AddActor(coneActor) ren.AddActor(textActor) textActor.SetCamera(ren.GetActiveCamera()) renWin = vtk.vtkRenderWindow() renWin.AddRenderer(ren) return renWin
Example #24
Source File: vtkpointcloud.py From semi-auto-anno with GNU General Public License v3.0 | 6 votes |
def __init__(self, zMin=-10.0, zMax=10.0, maxNumPoints=1e6): """ Initialize class :param zMin: minimum depth :param zMax: maximum depth :param maxNumPoints: maximum number of points :return: None """ self.maxNumPoints = int(maxNumPoints) self.vtkPolyData = vtk.vtkPolyData() self.clearPoints() mapper = vtk.vtkPolyDataMapper() mapper.SetInputData(self.vtkPolyData) mapper.SetColorModeToDefault() mapper.SetScalarRange(zMin, zMax) mapper.SetScalarVisibility(1) self.vtkActor = vtk.vtkActor() self.vtkActor.SetMapper(mapper) self.vtkActor.GetProperty().SetPointSize(3.0) self.rng = numpy.random.RandomState(23455)
Example #25
Source File: pc_viz.py From deep_gcns_torch with MIT License | 5 votes |
def __init__(self, point_size=18, maxNumPoints=1e8): self.maxNumPoints = maxNumPoints self.vtkPolyData = vtk.vtkPolyData() self.clear_points() self.colors = vtk.vtkUnsignedCharArray() self.colors.SetNumberOfComponents(3) self.colors.SetName("Colors") mapper = vtk.vtkPolyDataMapper() mapper.SetInputData(self.vtkPolyData) self.vtkActor = vtk.vtkActor() self.vtkActor.SetMapper(mapper) self.vtkActor.GetProperty().SetPointSize(point_size)
Example #26
Source File: pc_viz.py From deep_gcns_torch with MIT License | 5 votes |
def getActorCircle(radius_inner=100, radius_outer=99, color=(1, 0, 0)): """""" # create source source = vtk.vtkDiskSource() source.SetInnerRadius(radius_inner) source.SetOuterRadius(radius_outer) source.SetRadialResolution(100) source.SetCircumferentialResolution(100) # Transformer transform = vtk.vtkTransform() transform.RotateWXYZ(90, 1, 0, 0) transformFilter = vtk.vtkTransformPolyDataFilter() transformFilter.SetTransform(transform) transformFilter.SetInputConnection(source.GetOutputPort()) transformFilter.Update() # mapper mapper = vtk.vtkPolyDataMapper() mapper.SetInputConnection(transformFilter.GetOutputPort()) # actor actor = vtk.vtkActor() actor.GetProperty().SetColor(color) actor.SetMapper(mapper) return actor
Example #27
Source File: gui_viewer.py From voxel-dcgan with MIT License | 5 votes |
def create_actor(self): self.points = vtk.vtkPoints() self.colors = vtk.vtkUnsignedCharArray() self.colors.SetName("colors") self.colors.SetNumberOfComponents(4) polydata = vtk.vtkPolyData() polydata.SetPoints(self.points) polydata.GetPointData().SetScalars(self.colors) # create cell voxel = self.create_voxel() self.glyph3D = vtk.vtkGlyph3D() self.glyph3D.SetColorModeToColorByScalar() self.glyph3D.SetSource(voxel.GetOutput()) self.glyph3D.SetInput(polydata) self.glyph3D.ScalingOff() self.glyph3D.Update() # mapper mapper = vtk.vtkPolyDataMapper() mapper.SetInput(self.glyph3D.GetOutput()) # actor self.actor = vtk.vtkActor() self.actor.SetMapper(mapper) self.actor.GetProperty().SetAmbient(0.15)
Example #28
Source File: pointobject.py From Det3D with Apache License 2.0 | 5 votes |
def SetupPipelineCloud(self): "Set up the VTK pipeline for visualizing a point cloud" self.mapper = vtk.vtkPolyDataMapper() self.mapper.SetInputData(self.pd) if self.scalars != None: self.ScalarsOn() self.SetScalarRange(0, 1) self.actor = vtk.vtkActor() self.actor.SetMapper(self.mapper) self.actor.GetProperty().SetRepresentationToPoints() self.actor.GetProperty().SetColor(0.0, 1.0, 0.0)
Example #29
Source File: show_lidar_vtk.py From Det3D with Apache License 2.0 | 5 votes |
def __init__(self, zMin=-10.0, zMax=10.0, maxNumPoints=1e6): self.maxNumPoints = maxNumPoints self.vtkPolyData = vtk.vtkPolyData() self.clearPoints() mapper = vtk.vtkPolyDataMapper() mapper.SetInputData(self.vtkPolyData) mapper.SetColorModeToDefault() mapper.SetScalarRange(-255, 255) mapper.SetScalarVisibility(1) self.vtkActor = vtk.vtkActor() self.vtkActor.SetMapper(mapper)
Example #30
Source File: show_lidar_vtk.py From Det3D with Apache License 2.0 | 5 votes |
def draw_box(x): cube = vtk.vtkPolyData() points = vtk.vtkPoints() polys = vtk.vtkCellArray() scalars = vtk.vtkFloatArray() for i in range(8): points.InsertPoint(i, x[i]) for i in range(6): polys.InsertNextCell(mkVtkIdList(pts[i])) for i in range(8): scalars.InsertTuple1(i, i) cube.SetPoints(points) del points cube.SetPolys(polys) del polys cube.GetPointData().SetScalars(scalars) del scalars cubeMapper = vtk.vtkPolyDataMapper() if vtk.VTK_MAJOR_VERSION <= 5: cubeMapper.SetInput(cube) else: cubeMapper.SetInputData(cube) cubeMapper.SetScalarRange(0, 7) # cubeMapper.SetScalarVisibility(2) cubeActor = vtk.vtkActor() cubeActor.SetMapper(cubeMapper) cubeActor.GetProperty().SetOpacity(0.4) return cubeActor