예제 #1
0
 def draw(self, layer=None, clear_layer=True, settings=None):
     from compas_fofin.rhino import CablenetArtist
     layer = layer or settings.get('layer')
     artist = CablenetArtist(self, layer=layer)
     if clear_layer:
         artist.clear_layer()
     if settings.get('show.vertices', True):
         vertexcolor = {}
         vertexcolor.update({
             key: (0, 255, 0)
             for key in self.vertices_where_predicate(
                 lambda key, attr: attr['constraint'] is not None)
         })
         vertexcolor.update({
             key: (255, 0, 0)
             for key in self.vertices_where({'is_anchor': True})
         })
         artist.draw_vertices(color=vertexcolor)
     if settings.get('show.edges', True):
         artist.draw_edges()
     if settings.get('show.faces', True):
         artist.draw_faces()
     if settings.get('show.normals', False):
         artist.draw_normals(scale=settings.get('scale.normals'))
     if settings.get('show.forces', False):
         artist.draw_forces(compression=settings.get(
             'color.forces:compression', None),
                            tension=settings.get('color.forces:tension',
                                                 None),
                            scale=settings.get('scale.forces', None))
     if settings.get('show.reactions', False):
         artist.draw_reactions(color=settings.get('color.reactions', None),
                               scale=settings.get('scale.reactions', None))
     if settings.get('show.residuals', False):
         artist.draw_residuals(color=settings.get('color.residuals', None),
                               scale=settings.get('scale.residuals', None),
                               tol=settings.get('tol.residuals', None))
     if settings.get('show.loads', False):
         artist.draw_loads(color=settings.get('color.loads', None),
                           scale=settings.get('scale.loads', None))
     if settings.get('show.selfweight', False):
         artist.draw_selfweight(color=settings.get('color.selfweight',
                                                   None),
                                scale=settings.get('scale.selfweight',
                                                   None))
     if settings.get('show.stress', False):
         artist.draw_stress(scale=settings.get('scale.stress', None))
     artist.redraw()
예제 #2
0
import os
from compas_fofin.datastructures import Cablenet
from compas_fofin.rhino import CablenetArtist
from compas_fofin.equilibrium import cablenet_fd_alglib

HERE = os.path.dirname(__file__)
DATA = os.path.join(HERE, '..', '..', 'data')
FILE = os.path.join(DATA, 'saddle.obj')

cablenet = Cablenet.from_obj(FILE)
cablenet.set_vertices_attribute('is_anchor',
                                True,
                                keys=cablenet.vertices_where(
                                    {'vertex_degree': 1}))

cablenet_fd_alglib(cablenet)

artist = CablenetArtist(cablenet, layer="FoFin::Cablenet")
artist.clear_layer()
artist.draw_vertices()
artist.draw_edges()
artist.draw_forces(scale=0.05)
artist.draw_loads()
artist.draw_reactions()
artist.redraw()