Exemple #1
0
def main():
    """
    python3 -m gumby.core
    """
    import meshlab_pickedpoints
    from .path import relative_to_project
    from .landmarks import print_landmarks

    original_mesh = lacecore.load_obj(
        relative_to_project("examples/vitra/vitra.obj"), triangulate=True)

    landmarks = meshlab_pickedpoints.load(
        relative_to_project("examples/vitra/vitra.pp"))
    print_landmarks(landmarks, units="cm", precision=1)

    segments = [
        ("leg seam", "knee bottom", 20),
        ("knee bottom", "knee top", 10),
        ("knee top", "leg top", 10),
        ("back middle", "back top", 50),
    ]
    stretched = stretch_segments_along_y(mesh=original_mesh,
                                         landmarks=landmarks,
                                         segments=segments)

    stretched.write_obj("stretched.obj")
Exemple #2
0
def test_render_longest_xsection_to_svg():
    mesh = lacecore.load_obj(
        "examples/vitra/vitra_without_materials.obj", triangulate=True
    )
    plane = Plane(
        point_on_plane=np.array([-0.869231, 60.8882, -20.1071]),
        unit_normal=vg.normalize(np.array([0.0, 0.1, -1.0])),
    )
    xs = render_longest_xsection_to_svg(
        mesh=mesh, plane=plane, filename="vitra_cross_section.svg"
    )

    Scene().add_meshes(mesh).add_lines(xs).write("vitra_with_cross_section.dae")
Exemple #3
0
def horizontal_xs(mesh_path, heights, out, reference):
    """
    Find the horizontal cross section at the given height and write it to an
    SVG file. Optionally write a COLLADA reference with the mesh and cross
    section.
    """
    import os
    import lacecore
    import numpy as np
    from polliwog import Plane
    from tri_again import Scene
    import vg
    from .core import render_longest_xsection_to_svg

    if reference and not reference.endswith(".dae"):
        raise ValueError("reference-mesh should end with .dae")

    mesh = lacecore.load_obj(mesh_path, triangulate=True)

    reference_lines = []

    for height in heights:
        if out is None:
            filename, extension = os.path.splitext(os.path.basename(mesh_path))
            out_path = "{}_cross_section_at_{}.svg".format(filename, height)

        plane = Plane(point_on_plane=np.array([0.0, height, 0.0]),
                      unit_normal=vg.basis.neg_y)

        xs = render_longest_xsection_to_svg(mesh=mesh,
                                            plane=plane,
                                            filename=out or out_path)

        reference_lines.append(xs)

    if reference:
        Scene().add_meshes(mesh).add_lines(*reference_lines).write(reference)
Exemple #4
0
    def source_mesh(self):
        import lacecore

        return lacecore.load_obj(self.mesh_path, triangulate=self.triangulate)