Download Images With Python

Download image files from website with Python.The module request can help us to fetch contents of web page, we can use BeautifulSoup to parse the html string and collect all interesting elements, download images by relevant URLs which are filtered by our script. import requests, sys, webbrowser, bs4, urllib if Read more…

Add Log For Python Project

The log file is important for the developer to debug, it also ensures that the user will not be distracted by program message. Python provides module logging to help developers to complete the task conveniently, we can set customized format and different log levels for it. Developers can also turn Read more…

VTK – Import And Export 3D Model

The instance of vtkImporter contains vtkRenderWindow and vtkRenderer objects. It supports to recover original scene including lights, cameras, actors, etc. Here is a simple example which imports 3D studio file and shows the whole scene. import vtk DataRoot = “/Users/weiyang/Downloads/VTKData” importer = vtk.vtk3DSImporter() importer.ComputeNormalsOn() importer.SetFileName( DataRoot + “/Data/iflamigm.3ds” ) importer.Read() Read more…

VTK – Area Layouts Of Graph Visualizations

There are three examples using views displaying relations of vtk classes. The article learned from VTKUsersGuide vtkTreeRingView Python #!/usr/bin/env python from vtk import * def main(): datapath = “/Users/weiyang/Downloads/VTKData” #vtk.util.misc.vtkGetDataRoot() reader1 = vtkXMLTreeReader() reader1.SetFileName(datapath + “/Data/Infovis/XML/vtkclasses.xml”) reader1.SetEdgePedigreeIdArrayName(“tree edge”) reader1.GenerateVertexPedigreeIdsOff(); reader1.SetVertexPedigreeIdArrayName(“id”); reader2 = vtkXMLTreeReader() reader2.SetFileName(datapath + “/Data/Infovis/XML/vtklibrary.xml”) reader2.SetEdgePedigreeIdArrayName(“graph edge”) reader2.GenerateVertexPedigreeIdsOff(); reader2.SetVertexPedigreeIdArrayName(“id”); Read more…

Two Ways To Add Data Object For vtkView

Two ways to add data object for a vtkView. 1) Create a representation object, set the inputs for it by calling SetInputConnection() or SetInput(), then add representation for the view. 2) Use AddRepresentationFromInputConnection or AddRepresentationFromInput to create representation automatically. 1) Python from vtk import * surfaceRepresentation = vtkRenderedSurfaceRepresentation() sphere = Read more…

Example: vtkGraphLayoutView And vtkGraphToGlyphs

vtkGraphLayoutView is a subclass of vtkGraphLayoutView which has own renderer, renderWindow, command observer, actor and etc. The following code shows how to use it to display a 2D image. from vtk import * def main(): # create a random graph source = vtkRandomGraphSource() source.SetNumberOfVertices(100) source.SetNumberOfEdges(110) source.StartWithTreeOn() source.Update() arcParallelStrategy = vtkArcParallelEdgeStrategy() Read more…

Tex To PDF
: convert the Latex file which suffix is tex to a PDF file

X