def AddPolyDataMeshActor(self, pd): "Add a supplied vtkPolyData object to the visualizer" obj = VTKObject() obj.CreateFromPolyData(pd) self.pointObjects.append(obj) self.renderer.AddActor(obj.GetActor()) return obj
def AddPLYActor(self, filename): "Load a mesh from a PLY file and add it to the visualizer" obj = VTKObject() obj.CreateFromPLY(filename) self.pointObjects.append(obj) self.renderer.AddActor(obj.GetActor()) return obj
def AddBox(self, bounds): "Add a box witih the given bounds=[xmin,xmax,ymin,ymax,zmin,zmax]" obj = VTKObject() obj.CreateBox(bounds) self.pointObjects.append(obj) self.renderer.AddActor(obj.GetActor()) return obj
def AddLine(self, p1, p2): "Add a 3D line from p1=[x1,y1,z1] to p2=[x2,y2,z2]" obj = VTKObject() obj.CreateLine(p1, p2) self.pointObjects.append(obj) self.renderer.AddActor(obj.GetActor()) return obj
def AddSphere(self, origin, r): "Add a sphere with given origin (x,y,z) and radius r" obj = VTKObject() obj.CreateSphere(origin, r) self.pointObjects.append(obj) self.renderer.AddActor(obj.GetActor()) return obj
def AddCylinder(self, origin, r, h): "Add a cylinder with given origin (x,y,z), radius r and height h" obj = VTKObject() obj.CreateCylinder(origin, r, h) self.pointObjects.append(obj) self.renderer.AddActor(obj.GetActor()) return obj
def AddActor(self, actor): "Add a supplied vtkActor object to the visualizer" obj = VTKObject() obj.CreateFromActor(actor) self.pointObjects.append(obj) self.renderer.AddActor(obj.GetActor()) return obj
def AddPolygonActor(self, points, color=(255, 255, 255)): obj = VTKObject() obj.CreatePolygon(points) obj.actor.GetProperty().SetColor(*color) self.pointObjects.append(obj) self.renderer.AddActor(obj.GetActor()) return obj
def AddAxesActor(self, length): "Add coordinate system axes with specified length" obj = VTKObject() obj.CreateAxes(length) self.pointObjects.append(obj) self.renderer.AddActor(obj.GetActor()) return obj
def AddPlane(self, normal=None, origin=None): """Add a plane (optionally with a given normal vector and origin) Note: SetActorScale can be used to scale the extent of the plane""" obj = VTKObject() obj.CreatePlane(normal, origin) self.pointObjects.append(obj) self.renderer.AddActor(obj.GetActor()) return obj
def AddTrianglesActor(self, pc, triangles): """Add mesh consists of triangles Example: viz.AddTrianglesActor(pc_3d, scipy.spatial.Delaunay(pc_2d).simplices) """ obj = VTKObject() obj.CreateTriangles(pc, triangles) obj.SetupPipelineMesh() self.pointObjects.append(obj) self.renderer.AddActor(obj.GetActor()) return obj
def AddShadedPointsActor(self, pc): """Add a point cloud with shaded points based on supplied normal vectors The NumPy array should have dimension Nx6 where the first three dimensions correspond to x, y and z and the last three dimensions correspond to surface normals (nx, ny, nz) """ obj = VTKObject() obj.CreateFromArray(pc[:, 0:3]) obj.AddNormals(pc[:, 3:6]) self.pointObjects.append(obj) self.renderer.AddActor(obj.GetActor()) return obj
def AddColoredPointCloudActor(self, pc): """Add a point cloud with colors from a given NumPy array The NumPy array should have dimension Nx6 where the first three dimensions correspond to X, Y and Z and the last three dimensions correspond to R, G and B values (between 0 and 255) """ obj = VTKObject() obj.CreateFromArray(pc[:, :3]) obj.AddColors(pc[:, 3:6].astype(np.uint8)) self.pointObjects.append(obj) self.renderer.AddActor(obj.GetActor()) return obj
def AddPointCloudActor(self, pc): """Add a point cloud from a given NumPy array The NumPy array should have dimension Nxd where d >= 3 If d>3, the points will be colored according to the last column in the supplied array (values should be between 0 and 1, where 0 is black and 1 is white) """ obj = VTKObject() obj.CreateFromArray(pc) self.pointObjects.append(obj) self.renderer.AddActor(obj.GetActor()) return obj
def AddTrajectoryActor(self, pose_matrices, scale=1): "Add coordinate system axes with specified length" obj = VTKObject() obj.CreateAxesSimplified(scale) obj.AddPoses(pose_matrices) obj.SetupPipelinePose() self.pointObjects.append(obj) self.renderer.AddActor(obj.GetActor()) return obj
def AddNormalsActor(self, pc, scale): """Add a set of surface normals to the visualizer The input is a NumPy array with dimension Nx6 with (x,y,z) and (nx,ny,nz) values for the points and associated surface normals The normals will be scaled according to given scale factor""" obj = VTKObject() obj.CreateFromArray(pc[:, 0:3]) obj.AddNormals(pc[:, 3:6]) obj.SetupPipelineHedgeHog(scale) self.pointObjects.append(obj) self.renderer.AddActor(obj.GetActor()) return obj