polishing

This commit is contained in:
Martin Diehl 2020-03-12 19:52:33 +01:00
parent 6fbace8220
commit 81e98055dd
3 changed files with 28 additions and 16 deletions

View File

@ -1,24 +1,32 @@
import tkinter
import os
class Environment():
__slots__ = [ \
'options',
]
def __init__(self):
"""Read and provide values of DAMASK configuration."""
self.options = {}
self.__get_options()
self.options = self._get_options()
tk = tkinter.Tk()
self.screen_width = tk.winfo_screenwidth()
self.screen_height = tk.winfo_screenheight()
def relPath(self,relative = '.'):
"""Return absolute path from path relative to DAMASK root."""
return os.path.join(self.rootDir(),relative)
def rootDir(self):
"""Return DAMASK root path."""
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',
'MSC_ROOT',
'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

View File

@ -5,9 +5,11 @@ import numpy as np
import 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
class VTK:
"""
Spatial visualization (and potentially manipulation).
@ -200,7 +202,7 @@ class VTK:
self.geom.GetPointData().AddArray(d)
elif isinstance(data,pd.DataFrame):
pass
elif isinstance(data,table):
elif isinstance(data,Table):
pass
@ -232,7 +234,8 @@ class VTK:
ren.AddActor(actor)
ren.SetBackground(0.2,0.2,0.2)
renWin.SetSize(1024, 1024)
renWin.SetSize(Environment().screen_width,Environment().screen_height)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)

View File

@ -8,14 +8,15 @@ import h5py
import numpy as np
from . import VTK
from . import util
from . import version
from . import table
from . import mechanics
from . import Table
from . import Rotation
from . import Orientation
from . import Environment
from . import grid_filters
from . import mechanics
from . import util
from . import version
class Result:
"""
@ -287,12 +288,12 @@ class Result:
try:
tbl[inc].add(path,data)
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:
try:
tbl.add(path,data)
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