11#!/usr/bin/env python
22# coding: utf-8
3- from pygem .cffd import CFFD
3+
4+ import sys
5+ import platform
6+ print (f"Python Version: { sys .version } " )
7+ print (f"Platform: { sys .platform } " )
8+ print (f"System: { platform .system ()} { platform .release ()} " )
9+
10+ try :
11+ import pygem
12+ print (f"PyGeM version: { pygem .__version__ } " )
13+ except ImportError :
14+ print (f"PyGeM not found. Installing..." )
15+ import subprocess
16+ subprocess .check_call ([sys .executable , "-m" , "pip" , "install" , "-e" , ".[tut]" ])
17+ import pygem
18+ print (f"PyGeM version: { pygem .__version__ } " )
19+
420import numpy as np
21+ np .random .seed (42 )
22+
523import matplotlib .pyplot as plt
624
25+ from pygem .cffd import CFFD
26+
727np .random .seed (0 )
828x = 0.5 * np .random .rand (100 , 3 ) + 0.25
929ax = plt .axes (projection = "3d" )
1030ax .plot3D (x [:, 0 ], x [:, 1 ], x [:, 2 ], "o" )
31+
1132from pygem .ffd import FFD
1233
1334ffd = FFD ([8 , 8 , 1 ])
@@ -33,6 +54,7 @@ def custom_linear_constraint(x):
3354 "The custom linear function on the classic FFD deformed points is" ,
3455 custom_linear_constraint (x_def ),
3556)
57+
3658from pygem .cffd import CFFD
3759
3860ffd = CFFD (np .array ([1.0 ]), custom_linear_constraint , [3 , 3 , 1 ])
@@ -47,6 +69,7 @@ def custom_linear_constraint(x):
4769 "The custom linear function on the constrained FFD deformed points is" ,
4870 custom_linear_constraint (x_def ),
4971)
72+
5073from pygem .bffd import BFFD
5174
5275
@@ -72,8 +95,14 @@ def mesh_points(num_pts=2000):
7295ax .scatter (* mesh_def .T )
7396ax .scatter (* ffd .control_points ().T , s = 50 , c = "red" )
7497plt .show ()
75- import meshio
76- import numpy as np
98+
99+ try :
100+ import meshio
101+ except ImportError :
102+ print ("meshio not found. Installing..." )
103+ import subprocess
104+ subprocess .check_call ([sys .executable , "-m" , "pip" , "install" , "meshio" ])
105+ import meshio
77106
78107mesh = meshio .read ("../../tests/test_datasets/Stanford_Bunny.stl" )
79108points = mesh .points
@@ -87,6 +116,7 @@ def mesh_points(num_pts=2000):
87116ax .plot_trisurf (
88117 points [:, 0 ], points [:, 1 ], points [:, 2 ], triangles = faces , cmap = plt .cm .Spectral
89118)
119+
90120from pygem .vffd import VFFD , _volume
91121
92122initvolume = _volume (points , faces )
@@ -110,4 +140,4 @@ def mesh_points(num_pts=2000):
110140 mesh_def [:, 2 ],
111141 triangles = faces ,
112142 cmap = plt .cm .Spectral ,
113- )
143+ )
0 commit comments