support comments also in vtr
This commit is contained in:
parent
9a2ac31545
commit
2751cdb6af
|
@ -359,11 +359,12 @@ class Geom:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
v = VTK.from_file(fname if str(fname).endswith('.vtr') else str(fname)+'.vtr')
|
v = VTK.from_file(fname if str(fname).endswith('.vtr') else str(fname)+'.vtr')
|
||||||
|
comments = v.get_comments()
|
||||||
grid = np.array(v.geom.GetDimensions())-1
|
grid = np.array(v.geom.GetDimensions())-1
|
||||||
bbox = np.array(v.geom.GetBounds()).reshape(3,2).T
|
bbox = np.array(v.geom.GetBounds()).reshape(3,2).T
|
||||||
size = bbox[1] - bbox[0]
|
size = bbox[1] - bbox[0]
|
||||||
|
|
||||||
return Geom(v.get('materialpoint').reshape(grid,order='F'),size,bbox[0])
|
return Geom(v.get('materialpoint').reshape(grid,order='F'),size,bbox[0],comments=comments)
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -527,6 +528,7 @@ class Geom:
|
||||||
"""
|
"""
|
||||||
v = VTK.from_rectilinearGrid(self.grid,self.size,self.origin)
|
v = VTK.from_rectilinearGrid(self.grid,self.size,self.origin)
|
||||||
v.add(self.microstructure.flatten(order='F'),'materialpoint')
|
v.add(self.microstructure.flatten(order='F'),'materialpoint')
|
||||||
|
v.add_comments(self.comments)
|
||||||
|
|
||||||
if fname:
|
if fname:
|
||||||
v.write(fname if str(fname).endswith('.vtr') else str(fname)+'.vtr')
|
v.write(fname if str(fname).endswith('.vtr') else str(fname)+'.vtr')
|
||||||
|
|
|
@ -284,7 +284,7 @@ class VTK:
|
||||||
|
|
||||||
def set_comments(self,comments):
|
def set_comments(self,comments):
|
||||||
"""
|
"""
|
||||||
Set Comments.
|
Set comments.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
|
@ -301,7 +301,7 @@ class VTK:
|
||||||
|
|
||||||
def add_comments(self,comments):
|
def add_comments(self,comments):
|
||||||
"""
|
"""
|
||||||
Add Comments.
|
Add comments.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
|
@ -309,7 +309,7 @@ class VTK:
|
||||||
Comments to add.
|
Comments to add.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
self.set_comments(self.get_comments + ([comments] if isinstance(comments,str) else comments))
|
self.set_comments(self.get_comments() + ([comments] if isinstance(comments,str) else comments))
|
||||||
|
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
|
Loading…
Reference in New Issue