Пример #1
0
# ==============================================================================

scalars = mesh.vertices_attribute('z')
vertices, edges = igl.trimesh_isolines(mesh.to_vertices_and_faces(), scalars,
                                       10)
isolines = igl.groupsort_isolines(vertices, edges)

# ==============================================================================
# Visualisation
# ==============================================================================

viewer = ObjectViewer()

viewer.add(mesh,
           settings={
               'color': '#ffffff',
               'vertices.on': False,
               'edges.on': False
           })

cmap = Colormap(scalars, 'rgb')
for value, paths in isolines:
    for path in paths:
        points = [vertices[path[0][0]]]
        for i, j in path:
            points.append(vertices[j])
        viewer.add(Polyline(points),
                   settings={
                       'edges.color': rgb_to_hex(cmap(value)),
                       'edges.width': 5,
                       'vertices.on': False
                   })
Пример #2
0
# ==============================================================================
# curvature
# ==============================================================================

curvature = igl.trimesh_gaussian_curvature(mesh)

# ==============================================================================
# Visualisation
# ==============================================================================

viewer = ObjectViewer()

viewer.add(mesh,
           settings={
               'color': '#cccccc',
               'vertices.on': True,
               'edges.on': False,
               'opacity': 0.7,
               'vertices.size': 5
           })

for vertex in mesh.vertices():
    if mesh.is_vertex_on_boundary(vertex):
        continue

    point = Point(*mesh.vertex_coordinates(vertex))
    normal = Vector(*mesh.vertex_normal(vertex))
    c = curvature[vertex]
    normal.scale(10 * c)

    color = '#ff0000' if c > 0 else '#0000ff'
Пример #3
0
            else:
                reflections.append((i1, i2))
        else:
            x = intersection_line_plane((i1, r1), ground)
            r1 = Point(*x)
            reflections.append((i1, r1))

# ==============================================================================
# Visualisation
# ==============================================================================

viewer = ObjectViewer()

viewer.add(mesh,
           settings={
               'color': '#cccccc',
               'opacity': 0.5,
               'edges.on': False
           })

for intersection in intersections:
    viewer.add(Line(base, intersection),
               settings={
                   'edges.color': '#ff0000',
                   'edges.width': 3
               })

for reflection in reflections:
    viewer.add(Line(*reflection),
               settings={
                   'edges.color': '#0000ff',
                   'edges.width': 1
Пример #4
0
from compas.geometry import Line
from compas.geometry import Polyline
from compas.geometry import Plane
from compas.geometry import Circle

from compas_viewers.objectviewer import ObjectViewer

viewer = ObjectViewer()

for i in range(10):
    line = Line(
        Point(random.uniform(0, 10), random.uniform(0, 10),
              random.uniform(0, 10)),
        Point(random.uniform(0, 10), random.uniform(0, 10),
              random.uniform(0, 10)))
    viewer.add(line)

point = Point(0, 0, 0)
viewer.add(point, settings={'vertices.size': 10})

polyline = Polyline([[2, 0, 0], [1, 0, 0], [1, 1, 0], [1, 1, 1]])
viewer.add(polyline, settings={'vertices.size': 10})

plane = Plane([0, 0, 2], [1, 1, 1])
viewer.add(plane)

circle = Circle(Plane([0, 0, 3], [1, 1, 1]), 1)
viewer.add(circle)

viewer.update()
viewer.show()
Пример #5
0
from compas.geometry import Translation
from compas.geometry import Rotation

from compas_viewers.objectviewer import ObjectViewer

viewer = ObjectViewer(activate_selection=True)
# make 10 random meshes
# with random position and orientation
for i in range(10):
    T = Translation.from_vector([rdi(0, 10), rdi(0, 10), rdi(0, 5)])
    R = Rotation.from_axis_and_angle([0, 0, 1.0], radians(rdi(0, 180)))
    X = T * R
    box = Box.from_width_height_depth(rdi(1, 3), rdi(1, 3), rdi(1, 3))
    mesh = Mesh.from_shape(box)
    mesh_transform_numpy(mesh, X)

    viewer.add(mesh,
               name="Mesh.%s" % i,
               settings={
                   'color': rgb_to_hex((rdi(0, 255), rdi(0, 255), rdi(0,
                                                                      255))),
                   'edges.width': 2,
                   'opacity': 0.7,
                   'vertices.size': 10,
                   'vertices.on': True,
                   'edges.on': False,
                   'faces.on': True,
               })

viewer.show()
Пример #6
0
# ==============================================================================
# Boundaries
# ==============================================================================

boundaries = igl.trimesh_boundaries(mesh.to_vertices_and_faces())

# ==============================================================================
# Visualize
# ==============================================================================

viewer = ObjectViewer()

viewer.add(mesh,
           settings={
               'color': '#00ff00',
               'opacity': 0.7,
               'edges.on': False,
               'vertices.on': False
           })

for indices in boundaries:
    points = mesh.vertices_attributes('xyz', keys=indices)
    polyline = Polyline(points)
    viewer.add(polyline,
               settings={
                   'edges.color': '#ff0000',
                   'edges.width': 5,
                   'vertices.on': False
               })

viewer.update()
Пример #7
0
import random

from compas.geometry import Plane
from compas.geometry import Circle
from compas.geometry import Cone
from compas.geometry import Polyhedron
from compas_viewers.objectviewer import Arrow

from compas_viewers.objectviewer import ObjectViewer

viewer = ObjectViewer()

plane = Plane([2, 0, 0], [0, 0, 1])
circle = Circle(plane, 0.5)
cone = Cone(circle, 1)
viewer.add(cone)

polyhedron = Polyhedron(4)
viewer.add(polyhedron)

arrow = Arrow([-2, 0, 0], [0, 1, 1])
viewer.add(arrow)

viewer.show()
Пример #8
0
            n = add_vectors(n, x)
            n = Point(*n)
            intersections.append(p)
            reflections.append(r)
            normals.append(n)
            centers.append(mesh.face_centroid(i))

# ==============================================================================
# Visualisation
# ==============================================================================

viewer = ObjectViewer()

viewer.add(mesh,
           settings={
               'color': '#cccccc',
               'opacity': 0.7,
               'vertices.on': False
           })

for i in range(len(intersections) - 132):
    p = intersections[i]
    r = reflections[i]
    n = normals[i]
    c = centers[i]
    viewer.add(Line(base, p),
               settings={
                   'edges.color': '#ff0000',
                   'edges.width': 2
               })
    viewer.add(Line(p, r),
               settings={