Exemplo n.º 1
0
def draw_edge_rhino(edge):
    # ==============================================================================
    # Use a frame artist to visualize the boundary frame.
    # ==============================================================================
    artist = FrameArtist(edge['frames'][0],
                         layer=edge['layer'] + "::Frame",
                         scale=0.3)
    artist.clear_layer()
    artist.draw()
    # ==============================================================================
    # Use a frame artist to visualize the frame of the intersection points.
    # ==============================================================================
    artist = FrameArtist(edge['frames'][1],
                         layer=edge['layer'] + "::Frame",
                         scale=0.3)
    artist.clear_layer()
    artist.draw()
    # ==============================================================================
    # Use a point artist to visualize the intersection points.
    # ==============================================================================
    PointArtist.draw_collection(edge['intersections'],
                                layer=edge['layer'] + "::Intersections",
                                clear=True)
    # ==============================================================================
    # Use a mesh artist to visualize beams
    # ==============================================================================
    artist = MeshArtist(None, layer=edge['layer'] + "::BBox")
    artist.clear_layer()
    for mesh in edge['meshes']:
        artist = MeshArtist(mesh, layer=edge['layer'] + "::BBox")
        artist.draw_mesh()
Exemplo n.º 2
0
 def draw_interface_frames(self):
     """Draw the frames of the interfaces.
     """
     layer = "{}::Interfaces::Frames".format(
         self.layer) if self.layer else None
     compas_rhino.clear_layer(layer)
     guids = []
     for edge in self.assembly.edges():
         interface = self.assembly.edge_attribute(edge, 'interface')
         artist = FrameArtist(interface.frame, layer=layer)
         guids += artist.draw()
     return guids
Exemplo n.º 3
0
from compas.geometry import Transformation
from compas.geometry import Box
from compas.datastructures import Mesh
from compas_rhino.artists import FrameArtist
from compas_rhino.artists import MeshArtist

# Box in the world coordinate system
frame = Frame([1, 0, 0], [-0.45, 0.1, 0.3], [1, 0, 0])
width, length, height = 1, 1, 1
box = Box(frame, width, length, height)

# Frame F representing a coordinate system
F = Frame([2, 2, 2], [0.978, 0.010, -0.210], [0.090, 0.882, 0.463])

# Get transformation between frames and apply transformation on box.
T = Transformation.from_frame_to_frame(Frame.worldXY(), F)
box_transformed = box.transformed(T)
print("Box frame transformed", box_transformed.frame)

# create artists
artist1 = FrameArtist(Frame.worldXY())
artist2 = MeshArtist(Mesh.from_shape(box))
artist3 = FrameArtist(F)
artist4 = MeshArtist(Mesh.from_shape(box_transformed))

# draw
artist1.draw()
artist2.draw_faces()
artist3.draw()
artist4.draw_faces()
Exemplo n.º 4
0
        frame = joint.origin.transformed(transformations[joint.name])
        frame.name = joint.name
        frames.append(frame)

        axis = joint.axis.transformed(transformations[joint.name])
        axis.name = joint.name
        axes.append(axis)

    # Visualization

    for frame in frames:
        artist = FrameArtist(frame,
                             scale=0.3,
                             layer="Frames::{}".format(frame.name))
        artist.clear_layer()
        artist.draw()

    for a, b in pairwise(frames):
        line = Line(a.point, b.point)
        artist = LineArtist(line, layer="Links::{}".format(a.name))
        artist.draw()

    tpl = Cylinder(Circle(Plane(Point(0, 0, 0), Vector(0, 0, 1)), 0.05), 0.2)
    for frame, axis in zip(frames, axes):
        point = frame.point
        normal = Vector(axis.x, axis.y, axis.z)
        plane = Plane(point, normal)
        frame = Frame.from_plane(plane)
        X = Transformation.from_frame(frame)
        cylinder = tpl.transformed(X)
        artist = CylinderArtist(cylinder, layer="Axes::{}".format(axis.name))
Exemplo n.º 5
0
P5 = Projection.from_plane_and_point(planexy,
                                     Point(3, -3,
                                           -1))  # perspective Projection

# Create a Mesh from the Box
mesh = Mesh.from_shape(box)

# Apply the Projection onto the mesh
mesh_projected3 = mesh.transformed(P3)
mesh_projected4 = mesh.transformed(P4)
mesh_projected5 = mesh.transformed(P5)

# Create artists
artist1 = BoxArtist(box)
artist2 = FrameArtist(frame)
artist3 = MeshArtist(mesh_projected3, layer="P3")
artist4 = MeshArtist(mesh_projected4, layer="P4")
artist5 = MeshArtist(mesh_projected5, layer="P5")

#clear layers
artistl = [artist1, artist2, artist3, artist4, artist5]
for arty in artistl:
    arty.clear_layer()

# Draw
artist1.draw()
artist2.draw()
artist3.draw_edges(color="#00ffa0")
artist4.draw_edges(color=(200, 0, 0))
artist5.draw_edges(color=(200, 100, 0))
point = [0, 0, 0]
normal = [0, 0, -1]
plane = Plane(point, normal)
direction = [2, -2, 1]
P = Projection.from_plane_and_direction(plane, direction)

# Create a Mesh from the Box
mesh = Mesh.from_shape(box)
tmesh = Mesh.from_shape(box_transformed)

# Apply the Projection onto the mesh
mesh_projected = tmesh.transformed(P)

# clear layer
artist = BoxArtist(box, layer="Default")
artist.clear_layer()

# defining Artists
artist1 = BoxArtist(box)
artist2 = BoxArtist(box_transformed)
artist3 = MeshArtist(mesh_projected)
artist4 = FrameArtist(frame, scale=1.0)
artist5 = FrameArtist(frame1, scale=1.0)

# Draw
artist1.draw()
artist2.draw()
artist3.draw_edges(color="#00ffff")
artist4.draw()
artist5.draw()