Python vtk.vtkSTLReader() Examples
The following are 7
code examples of vtk.vtkSTLReader().
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: mesh.py From OpenWARP with Apache License 2.0 | 7 votes |
def _read_stl(file_name): '''Internal function to read stl mesh files ''' reader = vtk.vtkSTLReader() reader.SetFileName(file_name) reader.Update() mesh_data = PanelMesh(file_name) mesh_data.orig_type = 'Stereolithography (.stl)' mesh_data.num_faces = int(reader.GetOutput().GetNumberOfCells()) mesh_data.num_points = mesh_data.num_faces * 3 for i in range(mesh_data.num_faces): n = i*3 mesh_data.faces.append(np.array([n,n+1,n+2,n+2])) mesh_data.points.append(np.array(vtk_to_numpy(reader.GetOutput().GetCell(i).GetPoints().GetData()))) mesh_data.points = np.array(mesh_data.points).reshape([mesh_data.num_faces*3,3]) return mesh_data
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: mesh.py From OpenWARP with Apache License 2.0 | 6 votes |
def _read_stl(file_name): '''Internal function to read stl mesh files ''' reader = vtk.vtkSTLReader() reader.SetFileName(file_name) reader.Update() mesh_data = PanelMesh(file_name) mesh_data.orig_type = 'Stereolithography (.stl)' mesh_data.num_faces = int(reader.GetOutput().GetNumberOfCells()) mesh_data.num_points = mesh_data.num_faces * 3 for i in range(mesh_data.num_faces): n = i*3 mesh_data.faces.append(np.array([n,n+1,n+2,n+2])) mesh_data.points.append(np.array(vtk_to_numpy(reader.GetOutput().GetCell(i).GetPoints().GetData()))) mesh_data.points = np.array(mesh_data.points).reshape([mesh_data.num_faces*3,3]) return mesh_data
Example #5
Source File: mesh.py From OpenWARP with Apache License 2.0 | 6 votes |
def _read_stl(file_name): '''Internal function to read stl mesh files ''' reader = vtk.vtkSTLReader() reader.SetFileName(file_name) reader.Update() mesh_data = PanelMesh(file_name) mesh_data.orig_type = 'Stereolithography (.stl)' mesh_data.num_faces = int(reader.GetOutput().GetNumberOfCells()) mesh_data.num_points = mesh_data.num_faces * 3 for i in range(mesh_data.num_faces): n = i*3 mesh_data.faces.append(np.array([n,n+1,n+2,n+2])) mesh_data.points.append(np.array(vtk_to_numpy(reader.GetOutput().GetCell(i).GetPoints().GetData()))) mesh_data.points = np.array(mesh_data.points).reshape([mesh_data.num_faces*3,3]) return mesh_data
Example #6
Source File: mesh.py From OpenWARP with Apache License 2.0 | 6 votes |
def _read_stl(file_name): '''Internal function to read stl mesh files ''' reader = vtk.vtkSTLReader() reader.SetFileName(file_name) reader.Update() mesh_data = PanelMesh(file_name) mesh_data.orig_type = 'Stereolithography (.stl)' mesh_data.num_faces = int(reader.GetOutput().GetNumberOfCells()) mesh_data.num_points = mesh_data.num_faces * 3 for i in range(mesh_data.num_faces): n = i*3 mesh_data.faces.append(np.array([n,n+1,n+2,n+2])) mesh_data.points.append(np.array(vtk_to_numpy(reader.GetOutput().GetCell(i).GetPoints().GetData()))) mesh_data.points = np.array(mesh_data.points).reshape([mesh_data.num_faces*3,3]) return mesh_data
Example #7
Source File: pointobject.py From Det3D with Apache License 2.0 | 5 votes |
def CreateFromSTL(self, filename): "Create a visualization object from a given STL file" if not filename.lower().endswith(".stl"): raise Exception("Not an STL file") reader = vtk.vtkSTLReader() reader.SetFileName(filename) reader.Update() self.pd = vtk.vtkPolyData() self.pd.DeepCopy(reader.GetOutput()) self.SetupPipelineMesh()