Skip to content

Commit 0795d4f

Browse files
author
fsalmoir
authored
Merge pull request #83 from fsalmoir/change_fig
Change fig
2 parents 9c7ce99 + f05d16d commit 0795d4f

File tree

4 files changed

+42
-12
lines changed

4 files changed

+42
-12
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ See the **Examples** section below to have an idea of the potential of this pack
1818
## Graphic Unit Interface
1919
**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.
2020

21-
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.
21+
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.
2222

2323
<p align="center">
2424
<img src="readme/gui_PyGeM.png" alt>
25+
</p>
26+
<p align="center">
2527
<em>PyGeM GUI: how it appears when it pops up.</em>
2628
</p>
2729

pygem/igeshandler.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,20 @@ def plot(self, plot_file=None, save_fig=False):
246246
# Load the STL files and add the vectors to the plot
247247
stl_mesh = mesh.Mesh.from_file('aux_figure.stl')
248248
os.remove('aux_figure.stl')
249-
axes.add_collection3d(mplot3d.art3d.Poly3DCollection(stl_mesh.vectors))
250-
251-
# Auto scale to the mesh size
252-
scale = stl_mesh.points.flatten(-1)
253-
axes.auto_scale_xyz(scale, scale, scale)
249+
axes.add_collection3d(mplot3d.art3d.Poly3DCollection(stl_mesh.vectors/1000))
250+
251+
## Get the limits of the axis and center the geometry
252+
max_dim = np.array([np.max(stl_mesh.vectors[:,:,0])/1000, \
253+
np.max(stl_mesh.vectors[:,:,1])/1000, \
254+
np.max(stl_mesh.vectors[:,:,2])/1000])
255+
min_dim = np.array([np.min(stl_mesh.vectors[:,:,0])/1000, \
256+
np.min(stl_mesh.vectors[:,:,1])/1000, \
257+
np.min(stl_mesh.vectors[:,:,2])/1000])
258+
259+
max_lenght = np.max(max_dim - min_dim)
260+
axes.set_xlim(-.6*max_lenght + (max_dim[0]+min_dim[0])/2, .6*max_lenght + (max_dim[0]+min_dim[0])/2)
261+
axes.set_ylim(-.6*max_lenght + (max_dim[1]+min_dim[1])/2, .6*max_lenght + (max_dim[1]+min_dim[1])/2)
262+
axes.set_zlim(-.6*max_lenght + (max_dim[2]+min_dim[2])/2, .6*max_lenght + (max_dim[2]+min_dim[2])/2)
254263

255264
# Show the plot to the screen
256265
if not save_fig:

pygem/stlhandler.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,18 @@ def plot(self, plot_file=None, save_fig=False):
104104
stl_mesh = mesh.Mesh.from_file(plot_file)
105105
axes.add_collection3d(mplot3d.art3d.Poly3DCollection(stl_mesh.vectors))
106106

107-
# Auto scale to the mesh size
108-
scale = stl_mesh.points.flatten(-1)
109-
axes.auto_scale_xyz(scale, scale, scale)
107+
## Get the limits of the axis and center the geometry
108+
max_dim = np.array([np.max(stl_mesh.vectors[:,:,0]), \
109+
np.max(stl_mesh.vectors[:,:,1]), \
110+
np.max(stl_mesh.vectors[:,:,2])])
111+
min_dim = np.array([np.min(stl_mesh.vectors[:,:,0]), \
112+
np.min(stl_mesh.vectors[:,:,1]), \
113+
np.min(stl_mesh.vectors[:,:,2])])
114+
115+
max_lenght = np.max(max_dim - min_dim)
116+
axes.set_xlim(-.6*max_lenght + (max_dim[0]+min_dim[0])/2, .6*max_lenght + (max_dim[0]+min_dim[0])/2)
117+
axes.set_ylim(-.6*max_lenght + (max_dim[1]+min_dim[1])/2, .6*max_lenght + (max_dim[1]+min_dim[1])/2)
118+
axes.set_zlim(-.6*max_lenght + (max_dim[2]+min_dim[2])/2, .6*max_lenght + (max_dim[2]+min_dim[2])/2)
110119

111120
# Show the plot to the screen
112121
if not save_fig:

pygem/vtkhandler.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,19 @@ def plot(self, plot_file=None, save_fig=False):
141141
tri.set_color('b')
142142
tri.set_edgecolor('k')
143143
axes.add_collection3d(tri)
144-
145-
scale = vtx.flatten(-1)
146-
axes.auto_scale_xyz(scale, scale, scale)
144+
145+
## Get the limits of the axis and center the geometry
146+
max_dim = np.array([np.max(vtx[:,:,0]), \
147+
np.max(vtx[:,:,1]), \
148+
np.max(vtx[:,:,2])])
149+
min_dim = np.array([np.min(vtx[:,:,0]), \
150+
np.min(vtx[:,:,1]), \
151+
np.min(vtx[:,:,2])])
152+
153+
max_lenght = np.max(max_dim - min_dim)
154+
axes.set_xlim(-.6*max_lenght + (max_dim[0]+min_dim[0])/2, .6*max_lenght + (max_dim[0]+min_dim[0])/2)
155+
axes.set_ylim(-.6*max_lenght + (max_dim[1]+min_dim[1])/2, .6*max_lenght + (max_dim[1]+min_dim[1])/2)
156+
axes.set_zlim(-.6*max_lenght + (max_dim[2]+min_dim[2])/2, .6*max_lenght + (max_dim[2]+min_dim[2])/2)
147157

148158
# Show the plot to the screen
149159
if not save_fig:

0 commit comments

Comments
 (0)