Stlhandler¶
Derived module from filehandler.py to handle STereoLithography files.
Warning
This module will be deprecated in next releases. Follow updates on https://github.com/mathLab for news about file handling.
- class StlHandler[source]
Bases:
pygem.filehandler.FileHandler
STereoLithography file handler class
- Variables
infile (string) – name of the input file to be processed.
outfile (string) – name of the output file where to write in.
extensions (list) – extensions of the input/output files. It is equal to [‘.stl’].
- parse(filename)[source]
Method to parse the filename. It returns a matrix with all the coordinates.
- Parameters
filename (string) – name of the input file.
- Returns
mesh_points: it is a n_points-by-3 matrix containing the coordinates of the points of the mesh
- Return type
- write(mesh_points, filename, write_bin=False)[source]
Writes a stl file, called filename, copying all the lines from self.filename but the coordinates. mesh_points is a matrix that contains the new coordinates to write in the stl file.
- Parameters
mesh_points (numpy.ndarray) – it is a n_points-by-3 matrix containing the coordinates of the points of the mesh.
filename (string) – name of the output file.
write_bin (boolean) – flag to write in the binary format. Default is False.
- plot(plot_file=None, save_fig=False)[source]
Method to plot an stl file. If plot_file is not given it plots self.infile.
- Parameters
plot_file (string) – the stl filename you want to plot.
save_fig (bool) – a flag to save the figure in png or not. If True the plot is not shown. The default value is False.
- Returns
figure: matlplotlib structure for the figure of the chosen geometry
- Return type
matplotlib.pyplot.figure
- show(show_file=None)[source]
Method to show a vtk file. If show_file is not given it shows self.infile.
- Parameters
show_file (string) – the vtk filename you want to show.