A couple more fixes for mesh to/from XML

This commit is contained in:
amandalund 2019-05-01 12:20:46 -04:00
parent c0ede1ec8d
commit 81674a1c2d
2 changed files with 9 additions and 4 deletions

View file

@ -231,8 +231,9 @@ class Mesh(IDManagerMixin):
element.set("id", str(self._id))
element.set("type", self._type)
subelement = ET.SubElement(element, "dimension")
subelement.text = ' '.join(map(str, self._dimension))
if self._dimension is not None:
subelement = ET.SubElement(element, "dimension")
subelement.text = ' '.join(map(str, self._dimension))
subelement = ET.SubElement(element, "lower_left")
subelement.text = ' '.join(map(str, self._lower_left))
@ -264,7 +265,10 @@ class Mesh(IDManagerMixin):
"""
mesh_id = int(get_text(elem, 'id'))
mesh = cls(mesh_id)
mesh.type = get_text(elem, 'type')
mesh_type = get_text(elem, 'type')
if mesh_type is not None:
mesh.type = mesh_type
dimension = get_text(elem, 'dimension')
if dimension is not None:

View file

@ -551,7 +551,8 @@ class Settings(object):
@entropy_mesh.setter
def entropy_mesh(self, entropy):
cv.check_type('entropy mesh', entropy, Mesh)
cv.check_length('entropy mesh dimension', entropy.dimension, 3)
if entropy.dimension:
cv.check_length('entropy mesh dimension', entropy.dimension, 3)
cv.check_length('entropy mesh lower-left corner', entropy.lower_left, 3)
cv.check_length('entropy mesh upper-right corner', entropy.upper_right, 3)
self._entropy_mesh = entropy