From db1df0c0413949785dc5fa59a887bac00cf11265 Mon Sep 17 00:00:00 2001 From: blendoit Date: Sun, 6 Oct 2019 19:16:04 -0700 Subject: attempt component tree --- creator/base.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'creator/base.py') diff --git a/creator/base.py b/creator/base.py index c46b297..24b452c 100644 --- a/creator/base.py +++ b/creator/base.py @@ -12,25 +12,24 @@ logging.basicConfig(filename='log.txt', class Aircraft: """This class tracks all sub-components and is fed to the evaluator.""" - def __init__(self, parent, name): - self.parent = parent + def __init__(self, evaluator, name): + evaluator.tree.update({"aircraft": self}) + self.evaluator = evaluator self.name = name - parent.aircrafts.append(name) + self.tree = [] # Nested list of subcomponents class Component: - """Basic component providing coordinates and tools.""" + """Basic component providing coordinates, tools and a component tree.""" def __init__(self, parent, name): - self.parent = None + self.tree = [name] + parent.tree.append(self.tree) self.name = name self.x = np.array([]) self.z = np.array([]) self.material = None self.mass = float() - def __str__(self): - return self.name - def set_material(self, material): """Set the component bulk material.""" self.material = material -- cgit v1.2.3