How_to_Merge_small_surfaces_using_multi

22 views
Skip to first unread message

Ali Dashti

unread,
May 17, 2021, 10:25:51 AM5/17/21
to nurbs-...@googlegroups.com
Dear community,
I want to create several surfaces in a for loop and then merge the surfaces. I have no idea how to concatenate surfaces at the end of my loop. I do appreciate any help. I my simplified example I have three surface which I wan to merge them as a single big one. This is my code (python file is also uploaded):

import numpy as np
conc_res= [np.array([[ 1. ,  8. , 20.1],
                     [ 1. ,  9. , 20.5],
                     [ 2. ,  8. , 22. ],
                     [ 2. ,  9. , 24. ],
                     [ 3. ,  8. , 30. ],
                     [ 3. ,  9. , 31. ]]),
           np.array([[ 3.,  8., 30.],
                     [ 3.,  9., 31.],
                     [ 3., 10., 33.],
                     [ 4.,  8., 35.],
                     [ 4.,  9., 37.],
                     [ 4., 10., 36.],
                     [ 5.,  8., 20.],
                     [ 5.,  9., 19.],
                     [ 5., 10., 20.]]),
           np.array([[ 5.,  9., 19.],
                     [ 5., 10., 20.],
                     [ 6.,  9., 15.],
                     [ 6., 10., 18.],
                     [ 7.,  9., 11.],
                     [ 7., 10., 10.]])]
from geomdl import BSpline
from geomdl import utilities
from geomdl import tessellate
from geomdl import multi
from geomdl.visualization import VisMPL
from geomdl import exchange
for ind,data in enumerate (conc_res):
    surf_ind = BSpline.Surface()
# Set up the Bezier surface
    surf_ind.degree_u = 2
    surf_ind.degree_v = 1
    control_points = data.tolist()
    clt_u=np.unique(data[:,1],return_counts=True)[-1][0] # No. of points in Y direc of my grid
    clt_v=np.unique(data[:,0],return_counts=True)[-1][0] # No. of points in X direc of my grid
    surf_ind.set_ctrlpts(control_points, clt_u, clt_v)
    surf_ind.knotvector_u = utilities.generate_knot_vector(surf_ind.degree_u, surf_ind.ctrlpts_size_u)
    surf_ind.knotvector_v = utilities.generate_knot_vector(surf_ind.degree_v, surf_ind.ctrlpts_size_v)
# Set sample size
    surf_ind.sample_size = 25
# Evaluate surface
    surf_ind.evaluate()
   
surfs=multi.SurfaceContainer(surf_0, surf_1, surf_2)
# Plot the control point grid and the evaluated surface
vis_comp = VisMPL.VisSurface()
surfs.vis = vis_comp
surfs.render()
exchange.export_stl(surfs, "surfs.stl")
question.py
Reply all
Reply to author
Forward
0 new messages