Example #1
0
def test_booleans():

    # ==============================================================================
    # Make a box and a sphere
    # ==============================================================================

    box = Box.from_width_height_depth(2, 2, 2)
    box = Mesh.from_shape(box)
    box.quads_to_triangles()

    A = box.to_vertices_and_faces()

    sphere = Sphere(Point(1, 1, 1), 1)
    sphere = Mesh.from_shape(sphere, u=30, v=30)
    sphere.quads_to_triangles()

    B = sphere.to_vertices_and_faces()

    # ==============================================================================
    # Remesh the sphere
    # ==============================================================================

    B = remesh(B, 0.3, 10)

    # ==============================================================================
    # Compute the boolean mesh
    # ==============================================================================

    V, F = boolean_union(A, B)

    mesh = Mesh.from_vertices_and_faces(V, F)
Example #2
0
# ==============================================================================
# Make a box and a sphere
# ==============================================================================

box = Box.from_width_height_depth(2, 2, 2)
box = Mesh.from_shape(box)
box.quads_to_triangles()

A = box.to_vertices_and_faces()

sphere = Sphere(Point(1, 1, 1), 1)
sphere = Mesh.from_shape(sphere, u=30, v=30)
sphere.quads_to_triangles()

B = sphere.to_vertices_and_faces()

# ==============================================================================
# Remesh the sphere
# ==============================================================================

proxy.package = 'compas_cgal.meshing'

B = proxy.remesh(B, 0.3, 10)

# ==============================================================================
# Compute the intersections
# ==============================================================================

proxy.package = 'compas_cgal.intersections'
Example #3
0
import compas_libigl as igl


origin = Point(0.0, 0.0, 0.0)

cube = Box.from_width_height_depth(1.0, 1.0, 1.0)
sphere = Sphere(origin, 0.95 * sqrt(0.5 ** 2 + 0.5 ** 2))

xcyl = Cylinder(Circle(Plane(origin, Vector(1.0, 0.0, 0.0)), 0.35), 2.0)
ycyl = Cylinder(Circle(Plane(origin, Vector(0.0, 1.0, 0.0)), 0.35), 2.0)
zcyl = Cylinder(Circle(Plane(origin, Vector(0.0, 0.0, 1.0)), 0.35), 2.0)

a = Mesh.from_vertices_and_faces(cube.vertices, cube.faces)
a = mesh_subdivide_quad(a, k=3)
b = Mesh.from_vertices_and_faces(* sphere.to_vertices_and_faces(u=30, v=30))
c = Mesh.from_vertices_and_faces(* xcyl.to_vertices_and_faces(u=30))
d = Mesh.from_vertices_and_faces(* ycyl.to_vertices_and_faces(u=30))
e = Mesh.from_vertices_and_faces(* zcyl.to_vertices_and_faces(u=30))

mesh_quads_to_triangles(a)
mesh_quads_to_triangles(b)
mesh_quads_to_triangles(c)
mesh_quads_to_triangles(d)
mesh_quads_to_triangles(e)

VA = numpy.array(a.get_vertices_attributes('xyz'), dtype=numpy.float64)
FA = numpy.array([a.face_vertices(face) for face in a.faces()], dtype=numpy.int32)
VB = numpy.array(b.get_vertices_attributes('xyz'), dtype=numpy.float64)
FB = numpy.array([b.face_vertices(face) for face in b.faces()], dtype=numpy.int32)
VC = numpy.array(c.get_vertices_attributes('xyz'), dtype=numpy.float64)