def test_export_stl_ascii_single(nurbs_surface):
    fname = FILE_NAME + ".stl"

    nurbs_surface.sample_size = SAMPLE_SIZE
    exchange.export_stl(nurbs_surface, fname, binary=False)

    assert os.path.isfile(fname)
    assert os.path.getsize(fname) > 0

    # Clean up temporary file if exists
    if os.path.isfile(fname):
        os.remove(fname)
Ejemplo n.º 2
0
def test_export_stl_ascii_single(nurbs_surface):
    fname = FILE_NAME + ".stl"

    nurbs_surface.sample_size = SAMPLE_SIZE
    exchange.export_stl(nurbs_surface, fname, binary=False)

    assert os.path.isfile(fname)
    assert os.path.getsize(fname) > 0

    # Clean up temporary file if exists
    if os.path.isfile(fname):
        os.remove(fname)
def test_export_stl_ascii_multi(nurbs_surface_decompose):
    fname = FILE_NAME + ".stl"

    nurbs_multi = operations.decompose_surface(nurbs_surface_decompose)

    nurbs_multi.sample_size = SAMPLE_SIZE
    exchange.export_stl(nurbs_multi, fname, binary=False)

    assert os.path.isfile(fname)
    assert os.path.getsize(fname) > 0

    # Clean up temporary file if exists
    if os.path.isfile(fname):
        os.remove(fname)
Ejemplo n.º 4
0
def test_export_stl_ascii_multi(nurbs_surface_decompose):
    fname = FILE_NAME + ".stl"

    data = operations.decompose_surface(nurbs_surface_decompose)
    nurbs_multi = multi.SurfaceContainer(data)

    nurbs_multi.sample_size = SAMPLE_SIZE
    exchange.export_stl(nurbs_multi, fname, binary=False)

    assert os.path.isfile(fname)
    assert os.path.getsize(fname) > 0

    # Clean up temporary file if exists
    if os.path.isfile(fname):
        os.remove(fname)
Ejemplo n.º 5
0
# Set degrees
surf.degree_u = 3
surf.degree_v = 3

# Get the control points from the generated grid
surf.ctrlpts2d = surfgrid.grid

# Set knot vectors
surf.knotvector_u = utilities.generate_knot_vector(surf.degree_u, surf.ctrlpts_size_u)
surf.knotvector_v = utilities.generate_knot_vector(surf.degree_v, surf.ctrlpts_size_v)

# Set sample size of the surface
surf.sample_size = 50

# Generate the visualization component and its configuration
vis_config = vis.VisConfig(ctrlpts=True, legend=False)
vis_comp = vis.VisSurface(vis_config)

# Set visualization component of the surface
surf.vis = vis_comp

# Plot the surface
surf.render()

# Export the surface as a .stl file
exchange.export_stl(surf, "bump_smoother_1pt-padding.stl")

# Good to have something here to put a breakpoint
pass
Ejemplo n.º 6
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
    Examples for the NURBS-Python Package
    Released under MIT License
    Developed by Onur Rauf Bingol (c) 2018

    Exporting a NURBS surface as .stl file
"""

from geomdl.shapes import surface
from geomdl import exchange

cylinder = surface.cylinder(radius=5.0, height=22.5)
cylinder.delta = 0.01

# Export the surface as a .stl file
exchange.export_stl(cylinder, "cylindrical_surface.stl")

# Good to have something here to put a breakpoint
pass
Ejemplo n.º 7
0
                                   degree_v)

surf = convert.bspline_to_nurbs(surf)
print("surf", type(surf))

# Extract curves from the approximated surface
surf_curves = construct.extract_curves(surf)
plot_extras = [
    dict(points=surf_curves['u'][0].evalpts, name="u", color="red", size=10),
    dict(points=surf_curves['v'][0].evalpts, name="v", color="black", size=10)
]
surf.delta = 0.02
surf.vis = vis.VisSurface()
surf.render(extras=plot_extras)
exchange.export_obj(surf, "fitted_cyl.obj")
exchange.export_stl(surf, "fitted_cyl.stl")
# visualize data samples, original RV data, and fitted surface
eval_surf = np.array(surf.evalpts)
np.savetxt("RV_cyl.dat", eval_surf, delimiter=' ')
cpts = np.array(surf.ctrlpts)
###########
cyl_cpts = np.array(surf.ctrlpts)
# tube_cpts = np.loadtxt('cpts_tube.dat')
# print(len(cyl_cpts),len(tube_cpts))

np.savetxt("cpts_cyl.dat", cyl_cpts, delimiter=' ')
np.savetxt("cyl_cpts.csv", cyl_cpts, delimiter=',')
fig = plt.figure()
ax = plt.axes(projection="3d")
ax.scatter(eval_surf[:, 0], eval_surf[:, 1], eval_surf[:, 2], 'blue')
ax.scatter3D(cyl_pcl[:, 0], cyl_pcl[:, 1], cyl_pcl[:, 2], 'orange')