Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ See the **Examples** section below to have an idea of the potential of this pack
## Graphic Unit Interface
**PyGeM** is now provided with a very basic Graphic Unit Interface (GUI) that, in Ubuntu environment, looks like the one depicted below. This feature can be easily used even by the pythonists beginners with not much effort. Up to now, PyGeM GUI works on linux and Mac OS X computers.

Pick the geometry, the parameters file, set the name of the output and decide whether dump the FFD lattice or not. Now just click on the `Run PyGeM` button and that is it.
Pick the geometry, the parameters file, set the name of the output and decide whether dump the FFD lattices or not. Now just click on the `Run PyGeM` button and that is it.

<p align="center">
<img src="readme/gui_PyGeM.png" alt>
</p>
<p align="center">
<em>PyGeM GUI: how it appears when it pops up.</em>
</p>

Expand Down
19 changes: 14 additions & 5 deletions pygem/igeshandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,20 @@ def plot(self, plot_file=None, save_fig=False):
# Load the STL files and add the vectors to the plot
stl_mesh = mesh.Mesh.from_file('aux_figure.stl')
os.remove('aux_figure.stl')
axes.add_collection3d(mplot3d.art3d.Poly3DCollection(stl_mesh.vectors))

# Auto scale to the mesh size
scale = stl_mesh.points.flatten(-1)
axes.auto_scale_xyz(scale, scale, scale)
axes.add_collection3d(mplot3d.art3d.Poly3DCollection(stl_mesh.vectors/1000))

## Get the limits of the axis and center the geometry
max_dim = np.array([np.max(stl_mesh.vectors[:,:,0])/1000, \
np.max(stl_mesh.vectors[:,:,1])/1000, \
np.max(stl_mesh.vectors[:,:,2])/1000])
min_dim = np.array([np.min(stl_mesh.vectors[:,:,0])/1000, \
np.min(stl_mesh.vectors[:,:,1])/1000, \
np.min(stl_mesh.vectors[:,:,2])/1000])

max_lenght = np.max(max_dim - min_dim)
axes.set_xlim(-.6*max_lenght + (max_dim[0]+min_dim[0])/2, .6*max_lenght + (max_dim[0]+min_dim[0])/2)
axes.set_ylim(-.6*max_lenght + (max_dim[1]+min_dim[1])/2, .6*max_lenght + (max_dim[1]+min_dim[1])/2)
axes.set_zlim(-.6*max_lenght + (max_dim[2]+min_dim[2])/2, .6*max_lenght + (max_dim[2]+min_dim[2])/2)

# Show the plot to the screen
if not save_fig:
Expand Down
15 changes: 12 additions & 3 deletions pygem/stlhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,18 @@ def plot(self, plot_file=None, save_fig=False):
stl_mesh = mesh.Mesh.from_file(plot_file)
axes.add_collection3d(mplot3d.art3d.Poly3DCollection(stl_mesh.vectors))

# Auto scale to the mesh size
scale = stl_mesh.points.flatten(-1)
axes.auto_scale_xyz(scale, scale, scale)
## Get the limits of the axis and center the geometry
max_dim = np.array([np.max(stl_mesh.vectors[:,:,0]), \
np.max(stl_mesh.vectors[:,:,1]), \
np.max(stl_mesh.vectors[:,:,2])])
min_dim = np.array([np.min(stl_mesh.vectors[:,:,0]), \
np.min(stl_mesh.vectors[:,:,1]), \
np.min(stl_mesh.vectors[:,:,2])])

max_lenght = np.max(max_dim - min_dim)
axes.set_xlim(-.6*max_lenght + (max_dim[0]+min_dim[0])/2, .6*max_lenght + (max_dim[0]+min_dim[0])/2)
axes.set_ylim(-.6*max_lenght + (max_dim[1]+min_dim[1])/2, .6*max_lenght + (max_dim[1]+min_dim[1])/2)
axes.set_zlim(-.6*max_lenght + (max_dim[2]+min_dim[2])/2, .6*max_lenght + (max_dim[2]+min_dim[2])/2)

# Show the plot to the screen
if not save_fig:
Expand Down
16 changes: 13 additions & 3 deletions pygem/vtkhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,19 @@ def plot(self, plot_file=None, save_fig=False):
tri.set_color('b')
tri.set_edgecolor('k')
axes.add_collection3d(tri)

scale = vtx.flatten(-1)
axes.auto_scale_xyz(scale, scale, scale)

## Get the limits of the axis and center the geometry
max_dim = np.array([np.max(vtx[:,:,0]), \
np.max(vtx[:,:,1]), \
np.max(vtx[:,:,2])])
min_dim = np.array([np.min(vtx[:,:,0]), \
np.min(vtx[:,:,1]), \
np.min(vtx[:,:,2])])

max_lenght = np.max(max_dim - min_dim)
axes.set_xlim(-.6*max_lenght + (max_dim[0]+min_dim[0])/2, .6*max_lenght + (max_dim[0]+min_dim[0])/2)
axes.set_ylim(-.6*max_lenght + (max_dim[1]+min_dim[1])/2, .6*max_lenght + (max_dim[1]+min_dim[1])/2)
axes.set_zlim(-.6*max_lenght + (max_dim[2]+min_dim[2])/2, .6*max_lenght + (max_dim[2]+min_dim[2])/2)

# Show the plot to the screen
if not save_fig:
Expand Down