Example #1
0
    def draw_forces(self, scale=None, color=None):
        self.clear_forces()

        lines = []
        color = color or self.settings['color.force']
        scale = scale or self.settings['scale.force']
        tol   = self.settings['tol.force']
        tol2  = tol ** 2

        for u, v, attr in self.form.edges_where({'is_edge': True, 'is_external': False}, True):
            sp, ep = self.form.edge_coordinates(u, v)
            radius = scale * attr['f']

            if radius ** 2 < tol2:
                continue

            lines.append({
                'start'  : sp,
                'end'    : ep,
                'radius' : radius,
                'color'  : color,
                'name'   : "{}.force.{}-{}".format(self.form.name, u, v)
            })

        compas_rhino.draw_cylinders(lines, layer=self.layer, clear=False, redraw=False)
Example #2
0
 def draw_forces(self, scale=1.0, layer="Mesh::Forces"):
     forces = []
     for u, v, attr in self.datastructure.edges(True):
         force = attr['f']
         start = self.datastructure.vertex_coordinates(u)
         end = self.datastructure.vertex_coordinates(v)
         radius = scale * force
         forces.append({
             'start': start,
             'end': end,
             'radius': radius,
             'color': (255, 0, 0)
         })
     compas_rhino.draw_cylinders(forces, layer=layer, clear=True)
Example #3
0
    def draw_pipes(self, edges, color, scale, tol):
        node_xyz = self.node_xyz
        cylinders = []

        forces = get_force_mags(self.diagram.dual, self.diagram)

        for edge in edges:
            u, v = edge
            start = node_xyz[u]
            end = node_xyz[v]
            force = abs(forces[edge])
            force = scale * force
            if force < tol:
                continue
            radius = sqrt(force / pi)
            if isinstance(color, dict):
                pipe_color = color[edge]
            else:
                pipe_color = color
            cylinders.append({
                'start': start,
                'end': end,
                'radius': radius,
                'color': pipe_color
            })
        return compas_rhino.draw_cylinders(cylinders,
                                           layer=self.layer,
                                           clear=False,
                                           redraw=False)
Example #4
0
 def draw_pipes(self, keys, color, scale, tol):
     cylinders = []
     for key in keys:
         u, v = key
         start = self.mesh.vertex_attributes(u, 'xyz')
         end = self.mesh.vertex_attributes(v, 'xyz')
         force = self.mesh.edge_attribute(key, '_f')
         force = scale * force
         if force < tol:
             continue
         radius = sqrt(force / pi)
         if isinstance(color, dict):
             pipe_color = color[key]
         else:
             pipe_color = color
         cylinders.append({
             'start': start,
             'end': end,
             'radius': radius,
             'color': pipe_color
         })
     guids = compas_rhino.draw_cylinders(cylinders,
                                         layer=self.layer,
                                         clear=False,
                                         redraw=False)
     return guids
Example #5
0
 def draw_pipes(self, edges, color, scale, tol):
     vertex_xyz = self.vertex_xyz
     cylinders = []
     for edge in edges:
         u, v = edge
         start = vertex_xyz[u]
         end = vertex_xyz[v]
         force = self.mesh.edge_attribute(edge, '_f')
         force = scale * force
         if force < tol:
             continue
         radius = sqrt(force / pi)
         if isinstance(color, dict):
             pipe_color = color[edge]
         else:
             pipe_color = color
         cylinders.append({
             'start': start,
             'end': end,
             'radius': radius,
             'color': pipe_color
         })
     return compas_rhino.draw_cylinders(cylinders,
                                        layer=self.layer,
                                        clear=False,
                                        redraw=False)
Example #6
0
    def draw_forces(self, scale=None, color=None):
        """Draw the forces.

        Parameters
        ----------
        scale : float, optional
            Scaling factor for the force pipes.
            Default is the value from the settings.
        color : tuple, optional
            RGB color components for force pipes.
            Default is the value from the settings.

        Returns
        -------
        list
            The GUIDs of the created Rhino objects.
        """
        lines = []
        color = color or self.settings['color.force']
        scale = scale or self.settings['scale.force']
        tol = self.settings['tol.force']
        for u, v in self.form.edges_where({'_is_edge': True}):
            force = self.form.edge_attribute((u, v), '_f')
            sp, ep = self.form.edge_coordinates(u, v)
            radius = scale * force
            if radius < tol:
                continue
            lines.append({
                'start': sp,
                'end': ep,
                'radius': radius,
                'color': color,
                'name': "{}.force.{}-{}".format(self.form.name, u, v)
            })
        guids = compas_rhino.draw_cylinders(lines,
                                            layer=self.layer,
                                            clear=False,
                                            redraw=False)
        self.guids += guids
        return guids
Example #7
0
artist.draw_faces()

forces = []
for u, v, attr in mesh.edges(True):
    force = attr['f']
    start = mesh.vertex_coordinates(u)
    end = mesh.vertex_coordinates(v)
    radius = 0.01 * force
    forces.append({
        'start': start,
        'end': end,
        'radius': radius,
        'color': (255, 0, 0)
    })

compas_rhino.draw_cylinders(forces, layer="Mesh::Forces", clear=True)

reactions = []
for key, attr in mesh.vertices_where({'is_fixed': True}, True):
    reaction = [attr['rx'], attr['ry'], attr['rz']]
    vector = scale_vector(reaction, -0.1)
    start = mesh.vertex_coordinates(key)
    end = add_vectors(start, vector)
    reactions.append({
        'start': start,
        'end': end,
        'arrow': 'end',
        'color': (0, 255, 0)
    })

compas_rhino.draw_lines(reactions, layer="Mesh::Reactions", clear=True)
Example #8
0
from __future__ import absolute_import
Example #9
0
 def _draw_cylinders(self, cylinders):
     compas_rhino.draw_cylinders(cylinders,
                                 layer=self.layer,
                                 clear=False,
                                 redraw=True,
                                 cap=True)