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)
def test_export_off_multi(nurbs_surface_decompose): fname = FILE_NAME + ".off" data = operations.decompose_surface(nurbs_surface_decompose) nurbs_multi = multi.SurfaceContainer(data) nurbs_multi.sample_size = SAMPLE_SIZE exchange.export_off(nurbs_multi, fname) 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" 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)
def test_surf_multi_fig_save(bspline_surface): conf = VisMPL.VisConfig() vis = VisMPL.VisSurfWireframe(config=conf) fname = "test-multi_surface.png" multi = operations.decompose_surface(bspline_surface) multi.vis = vis multi.render(filename=fname, plot=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_surf_multi_fig_nowindow(bspline_surface): conf = VisMPL.VisConfig() vis = VisMPL.VisSurfScatter(config=conf) fname = conf.figure_image_filename multi = operations.decompose_surface(bspline_surface) multi.vis = vis multi.render(plot=False) assert os.path.isfile(fname) assert os.path.getsize(fname) > 0 # Clean up temporary file if exists if os.path.isfile(conf.figure_image_filename): os.remove(conf.figure_image_filename)
def test_surf_multi_fig_save(bspline_surface): conf = VisMPL.VisConfig() vis = VisMPL.VisSurfWireframe(config=conf) fname = "test-multi_surface.png" data = operations.decompose_surface(bspline_surface) multi_shape = multi.SurfaceContainer(data) multi_shape.vis = vis multi_shape.render(filename=fname, plot=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_surf_multi_fig_nowindow(bspline_surface): conf = VisMPL.VisConfig() vis = VisMPL.VisSurfScatter(config=conf) fname = conf.figure_image_filename data = operations.decompose_surface(bspline_surface) multi_shape = multi.SurfaceContainer(data) multi_shape.vis = vis multi_shape.render(plot=False) assert os.path.isfile(fname) assert os.path.getsize(fname) > 0 # Clean up temporary file if exists if os.path.isfile(conf.figure_image_filename): os.remove(conf.figure_image_filename)
surf = NURBS.Surface() # Set degrees surf.degree_u = 1 surf.degree_v = 2 # Set control points surf.set_ctrlpts( *exchange.import_txt("ex_cylinder.cptw", two_dimensional=True)) # Set knot vector surf.knotvector_u = [0, 0, 1, 1] surf.knotvector_v = [0, 0, 0, 0.25, 0.25, 0.5, 0.5, 0.75, 0.75, 1, 1, 1] # Decompose the surface surf_list = operations.decompose_surface(surf) surfaces = multi.SurfaceContainer(surf_list) # Translate one of the surface patch operations.translate(surfaces[1], (-0.25, 0.25, 0), inplace=True) # Set number of samples for all split surfaces surfaces.sample_size = 50 # Plot the control point grid and the evaluated surface vis_comp = VisMPL.VisSurfWireframe() surfaces.vis = vis_comp surfaces.render() # Good to have something here to put a breakpoint pass
# Create a BSpline surface instance surf = BSpline.Surface() # Set degrees surf.degree_u = 3 surf.degree_v = 3 # Set control points surf.set_ctrlpts( *exchange.import_txt("ex_surface01.cpt", two_dimensional=True)) # Set knot vectors surf.knotvector_u = [0.0, 0.0, 0.0, 0.0, 1.0, 2.0, 3.0, 3.0, 3.0, 3.0] surf.knotvector_v = [0.0, 0.0, 0.0, 0.0, 1.0, 2.0, 3.0, 3.0, 3.0, 3.0] # Decompose the surface surfaces = operations.decompose_surface(surf) # Set number of samples for all split surfaces surfaces.sample_size = 20 # Plot the control point grid and the evaluated surface vis_config = VisMPL.VisConfig(legend=False) vis_comp = VisMPL.VisSurface(vis_config) surfaces.vis = vis_comp surfaces.render() # Good to have something here to put a breakpoint pass
# -*- coding: utf-8 -*- """ Examples for the NURBS-Python Package Released under MIT License Developed by Onur Rauf Bingol (c) 2019 Exporting multiple NURBS surfaces in VTK Polydata format """ from geomdl.shapes import surface from geomdl import operations from geomdl import multi from geomdl import exchange_vtk # Create a cylindrical surface cylinder = surface.cylinder(radius=5.0, height=22.5) # Decompose to generate multiple surfaces cylinder_decomposed = operations.decompose_surface(cylinder) # Add decomposed surfaces to a surface container surf_container = multi.SurfaceContainer(cylinder_decomposed) # Export evaluated points as a .vtk file exchange_vtk.export_polydata(surf_container, "cylindrical_surface_decomposed_evalpts.vtk", tessellate=True) # Good to have something here to put a breakpoint pass
# Set knot vectors surf1.knotvector_u = [0.0, 0.0, 0.0, 0.0, 1.0, 2.0, 3.0, 3.0, 3.0, 3.0] surf1.knotvector_v = [0.0, 0.0, 0.0, 0.0, 1.0, 2.0, 3.0, 3.0, 3.0, 3.0] # Set evaluation delta surf1.delta = 0.025 # Rotate surf1 and generate a copy in surf2 surf2 = operations.rotate(surf1, 45, axis=2) # Visualize surfaces msurf1 = multi.SurfaceContainer(surf1, surf2) msurf1.vis = vis.VisSurface() msurf1.render() # Decompose surf1 surf1_decomposed = operations.decompose_surface(surf1) msurf2 = multi.SurfaceContainer(surf1_decomposed) # Rotate decomposed surface msurf2_rotated = operations.rotate(msurf2, 90, axis=1) # Visualize decomposed and decomposed-rotated surfaces msurf3 = multi.SurfaceContainer(msurf2, msurf2_rotated) msurf3.vis = vis.VisSurface() msurf3.render() # Good to have something here to put a breakpoint pass