Beispiel #1
0
def check_type(frame):
    """Return the type of the element.
    """

    a = abs(frame.xaxis.dot(Vector.Zaxis()))
    b = abs(frame.xaxis.dot(Vector.Yaxis()))

    if a > 0.9:
        elem_type = 'Z'
    elif a < 0.1:
        if b > 0.9:
            elem_type = 'Y'
        else:
            elem_type = 'X'
    else:
        elem_type = None

    return elem_type
Beispiel #2
0
    [Point(0, 3, 0),
     Point(1, 3, 0),
     Point(2, 3, 0),
     Point(3, 3, 0)],
]

surface = OCCNurbsSurface.from_points(points=points)

# ==============================================================================
# Intersections
# ==============================================================================

base = Point(*centroid_points_xy(list(flatten(points))))
line = Line(base, base + Vector(0, 0, 1))

Ry = Rotation.from_axis_and_angle(Vector.Yaxis(), radians(30), point=base)
line.transform(Ry)

lines = []
for i in range(30):
    Rz = Rotation.from_axis_and_angle(Vector.Zaxis(),
                                      radians(i * 360 / 30),
                                      point=base)
    lines.append(line.transformed(Rz))

intersections = []
for line in lines:
    x = surface.intersections_with_line(line)
    if x:
        intersections.append(x[0])
Beispiel #3
0
from compas.geometry import Point, Vector, Frame, Polyline
from compas.geometry import Box
from compas.geometry import Translation
from compas.datastructures import Mesh

from compas_view2.app import App
from compas_gmsh.models import ShapeModel

# ==============================================================================
# Geometry
# ==============================================================================

b1 = Box(Frame.worldXY(), 1, 1, 1)
b2 = Box(Frame(b1.vertices[6], Vector.Xaxis(), Vector.Yaxis()), 1, 1, 1)

# ==============================================================================
# CSG Model
# ==============================================================================

model = ShapeModel(name="booleans")

model.options.mesh.lmin = 0.2
model.options.mesh.lmax = 0.2

model.boolean_fragment([model.add_box(b1)], [model.add_box(b2)])

model.generate_mesh(2)
model.optimize_mesh()

# ==============================================================================
# Fragments