polishing
This commit is contained in:
parent
6fbace8220
commit
81e98055dd
|
@ -1,24 +1,32 @@
|
||||||
|
import tkinter
|
||||||
import os
|
import os
|
||||||
|
|
||||||
class Environment():
|
class Environment():
|
||||||
__slots__ = [ \
|
|
||||||
'options',
|
|
||||||
]
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""Read and provide values of DAMASK configuration."""
|
"""Read and provide values of DAMASK configuration."""
|
||||||
self.options = {}
|
self.options = self._get_options()
|
||||||
self.__get_options()
|
tk = tkinter.Tk()
|
||||||
|
self.screen_width = tk.winfo_screenwidth()
|
||||||
|
self.screen_height = tk.winfo_screenheight()
|
||||||
|
|
||||||
|
|
||||||
def relPath(self,relative = '.'):
|
def relPath(self,relative = '.'):
|
||||||
|
"""Return absolute path from path relative to DAMASK root."""
|
||||||
return os.path.join(self.rootDir(),relative)
|
return os.path.join(self.rootDir(),relative)
|
||||||
|
|
||||||
|
|
||||||
def rootDir(self):
|
def rootDir(self):
|
||||||
|
"""Return DAMASK root path."""
|
||||||
return os.path.normpath(os.path.join(os.path.realpath(__file__),'../../../'))
|
return os.path.normpath(os.path.join(os.path.realpath(__file__),'../../../'))
|
||||||
|
|
||||||
def __get_options(self):
|
|
||||||
|
def _get_options(self):
|
||||||
|
options = {}
|
||||||
for item in ['DAMASK_NUM_THREADS',
|
for item in ['DAMASK_NUM_THREADS',
|
||||||
'MSC_ROOT',
|
'MSC_ROOT',
|
||||||
'MARC_VERSION',
|
'MARC_VERSION',
|
||||||
]:
|
]:
|
||||||
self.options[item] = os.environ[item] if item in os.environ else None
|
options[item] = os.environ[item] if item in os.environ else None
|
||||||
|
|
||||||
|
return options
|
||||||
|
|
|
@ -5,9 +5,11 @@ import numpy as np
|
||||||
import vtk
|
import vtk
|
||||||
from vtk.util.numpy_support import numpy_to_vtk as np_to_vtk
|
from vtk.util.numpy_support import numpy_to_vtk as np_to_vtk
|
||||||
|
|
||||||
from . import table
|
from . import Table
|
||||||
|
from . import Environment
|
||||||
from . import version
|
from . import version
|
||||||
|
|
||||||
|
|
||||||
class VTK:
|
class VTK:
|
||||||
"""
|
"""
|
||||||
Spatial visualization (and potentially manipulation).
|
Spatial visualization (and potentially manipulation).
|
||||||
|
@ -200,7 +202,7 @@ class VTK:
|
||||||
self.geom.GetPointData().AddArray(d)
|
self.geom.GetPointData().AddArray(d)
|
||||||
elif isinstance(data,pd.DataFrame):
|
elif isinstance(data,pd.DataFrame):
|
||||||
pass
|
pass
|
||||||
elif isinstance(data,table):
|
elif isinstance(data,Table):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@ -232,7 +234,8 @@ class VTK:
|
||||||
|
|
||||||
ren.AddActor(actor)
|
ren.AddActor(actor)
|
||||||
ren.SetBackground(0.2,0.2,0.2)
|
ren.SetBackground(0.2,0.2,0.2)
|
||||||
renWin.SetSize(1024, 1024)
|
|
||||||
|
renWin.SetSize(Environment().screen_width,Environment().screen_height)
|
||||||
|
|
||||||
iren = vtk.vtkRenderWindowInteractor()
|
iren = vtk.vtkRenderWindowInteractor()
|
||||||
iren.SetRenderWindow(renWin)
|
iren.SetRenderWindow(renWin)
|
||||||
|
|
|
@ -8,14 +8,15 @@ import h5py
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
from . import VTK
|
from . import VTK
|
||||||
from . import util
|
from . import Table
|
||||||
from . import version
|
|
||||||
from . import table
|
|
||||||
from . import mechanics
|
|
||||||
from . import Rotation
|
from . import Rotation
|
||||||
from . import Orientation
|
from . import Orientation
|
||||||
from . import Environment
|
from . import Environment
|
||||||
from . import grid_filters
|
from . import grid_filters
|
||||||
|
from . import mechanics
|
||||||
|
from . import util
|
||||||
|
from . import version
|
||||||
|
|
||||||
|
|
||||||
class Result:
|
class Result:
|
||||||
"""
|
"""
|
||||||
|
@ -287,12 +288,12 @@ class Result:
|
||||||
try:
|
try:
|
||||||
tbl[inc].add(path,data)
|
tbl[inc].add(path,data)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
tbl[inc] = table.Table(data.reshape(self.Nmaterialpoints,-1),{path:data.shape[1:]})
|
tbl[inc] = Table(data.reshape(self.Nmaterialpoints,-1),{path:data.shape[1:]})
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
tbl.add(path,data)
|
tbl.add(path,data)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
tbl = table.Table(data.reshape(self.Nmaterialpoints,-1),{path:data.shape[1:]})
|
tbl = Table(data.reshape(self.Nmaterialpoints,-1),{path:data.shape[1:]})
|
||||||
|
|
||||||
return tbl
|
return tbl
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue