def __init__(self, xml): LoadingHelpers.checkAttribExist(xml, "type", "ns", "z") LoadingHelpers.checkChildExist(xml, "scale", "orientation") self.Type = xml.get("type") LoadingHelpers.checkValueValid(self.Type, "cube", "cylinder", "sphere", "arrow", "mesh") self.Namespace = xml.get("ns") self.Z = float(xml.get("z")) LoadingHelpers.checkAttribExist(xml.find("scale"), "x", "y", "z") self.Scale = [ float(xml.find("scale").get("x")), float(xml.find("scale").get("y")), float(xml.find("scale").get("z")) ] self.Orientation = [ float(xml.find("orientation").get("x")), float(xml.find("orientation").get("z")), float(xml.find("orientation").get("z")) ] # Type-specific attributes self.MeshPath = xml.find("mesh_path").text if xml.find( "mesh_path") is not None else ""
def __init__(self, xml): LoadingHelpers.checkAttribExist(xml, "type") self.Type = xml.get("type") LoadingHelpers.checkValueValid(self.Type, "rect", "circle", "point") if self.Type == "rect": LoadingHelpers.checkAttribExist(xml, "w", "h") self.Width = float(xml.get("w")) self.Height = float(xml.get("h")) elif self.Type == "circle": LoadingHelpers.checkAttribExist(xml, "r") self.Radius = float(xml.get("r")) else: raise ValueError("ERROR: Shape type '{}' not supported.".format( self.Type))