Esempio n. 1
0
 def do(self):
     cache = context.application.cache
     for node in cache.nodes:
         child_translations = []
         translated_children = []
         for child in node.children:
             if isinstance(child, GLTransformationMixin) and isinstance(child.transformation, Translation):
                 if child.get_fixed():
                     translated_children = []
                     break
                 translated_children.append(child)
                 child_translations.append(child.transformation)
         if len(translated_children) > 0:
             translation = Translation(calculate_center(child_translations))
             CenterAlignBase.do(self, node, translated_children, translation)
Esempio n. 2
0
 def do(self):
     cache = context.application.cache
     for node in cache.nodes:
         child_translations = []
         translated_children = []
         for child in node.children:
             if isinstance(child, GLTransformationMixin) and isinstance(
                     child.transformation, Translation):
                 if child.get_fixed():
                     translated_children = []
                     break
                 translated_children.append(child)
                 child_translations.append(child.transformation)
         if len(translated_children) > 0:
             translation = Translation(calculate_center(child_translations))
             CenterAlignBase.do(self, node, translated_children,
                                translation)
Esempio n. 3
0
 def analyze_selection():
     # A) calling ancestor
     if not CenterAlignBase.analyze_selection(): return False
     # B) validating
     cache = context.application.cache
     for node in cache.nodes:
         if not isinstance(node, ContainerMixin): return False
     # C) passed all tests:
     return True
Esempio n. 4
0
 def analyze_selection():
     # A) calling ancestor
     if not CenterAlignBase.analyze_selection(): return False
     # B) validating
     cache = context.application.cache
     for node in cache.nodes:
         if not isinstance(node, ContainerMixin): return False
     # C) passed all tests:
     return True
Esempio n. 5
0
    def do(self):
        cache = context.application.cache
        for node in cache.nodes:
            translated_children = []
            for child in node.children:
                if isinstance(child, GLTransformationMixin) and isinstance(child.transformation, Translation):
                    if child.get_fixed():
                        translated_children = []
                        break
                    translated_children.append(child)
            if len(translated_children) == 0:
                continue

            mass, com = compute_center_of_mass(iter_particles(node))
            if mass == 0.0:
                continue

            CenterAlignBase.do(self, node, translated_children, Translation(com))
Esempio n. 6
0
 def analyze_selection():
     # A) calling ancestor
     if not CenterAlignBase.analyze_selection(): return False
     # B) validating
     cache = context.application.cache
     node = cache.node
     if not isinstance(node, GLTransformationMixin): return False
     if not isinstance(node.transformation, Rotation): return False
     if cache.some_neighbors_fixed: return False
     # C) passed all tests:
     return True
Esempio n. 7
0
    def do(self):
        cache = context.application.cache
        for node in cache.nodes:
            translated_children = []
            for child in node.children:
                if isinstance(child, GLTransformationMixin) and isinstance(
                        child.transformation, Translation):
                    if child.get_fixed():
                        translated_children = []
                        break
                    translated_children.append(child)
            if len(translated_children) == 0:
                continue

            mass, com = compute_center_of_mass(iter_particles(node))
            if mass == 0.0:
                continue

            CenterAlignBase.do(self, node, translated_children,
                               Translation(com))
Esempio n. 8
0
 def analyze_selection():
     # A) calling ancestor
     if not CenterAlignBase.analyze_selection(): return False
     # B) validating
     cache = context.application.cache
     node = cache.node
     if not isinstance(node, GLTransformationMixin): return False
     if not isinstance(node.transformation, Rotation): return False
     if cache.some_neighbors_fixed: return False
     # C) passed all tests:
     return True
Esempio n. 9
0
    def do(self):
        cache = context.application.cache
        for node in cache.nodes:
            transformation = Complete()

            translated_children = []
            for child in node.children:
                if isinstance(child, GLTransformationMixin) and isinstance(child.transformation, Translation):
                    if child.get_fixed():
                        translated_children = []
                        break
                    translated_children.append(child)
            if len(translated_children) == 0:
                continue

            mass, com = compute_center_of_mass(yield_particles(node))
            if mass == 0.0:
                continue

            transformation.t = com
            tensor = compute_inertia_tensor(yield_particles(node), com)
            transformation.r = default_rotation_matrix(tensor)
            CenterAlignBase.do(self, node, translated_children, transformation)
Esempio n. 10
0
 def do(self):
     cache = context.application.cache
     rotation = Rotation()
     rotation.r = copy.deepcopy(cache.node.transformation.r)
     CenterAlignBase.do(self, cache.parent, cache.transformed_neighbors, rotation)
Esempio n. 11
0
 def do(self):
     cache = context.application.cache
     translation = Translation()
     translation.t = copy.deepcopy(cache.node.transformation.t)
     CenterAlignBase.do(self, cache.parent, cache.translated_neighbors, translation)
Esempio n. 12
0
 def do(self):
     cache = context.application.cache
     CenterAlignBase.do(self, cache.parent, cache.transformed_neighbors, cache.node.transformation)
Esempio n. 13
0
 def do(self):
     cache = context.application.cache
     rotation = Rotation(cache.node.transformation.r)
     CenterAlignBase.do(self, cache.parent, cache.transformed_neighbors,
                        rotation)
Esempio n. 14
0
 def do(self):
     cache = context.application.cache
     translation = Translation(cache.node.transformation.t)
     CenterAlignBase.do(self, cache.parent, cache.translated_neighbors,
                        translation)