n = 100 u = numpy.linspace(0, 1, m) v = numpy.linspace(0, 1, n) g = Bxyz.eval(u) dg = Bxyz.evald(u) d2g = Bxyz.evald2(u) r = Br.eval(u)[:, 1] dr = Br.evald(u)[:, 1] e = canal_surface(g.T, dg.T, d2g.T, r, dr, v) verts, faces = lbu.tensor_product_mesh_vf(e[:, :, 0], e[:, :, 1], e[:, :, 2], periodv=True) EdS = lbu.pydata_to_mesh(verts, faces, edges=None, name='EdSpropre') lbe.set_smooth(EdS) #EdS.show_wire = True #EdS.show_all_edges = True EdS.show_transparent = True mat_EdS = bpy.data.materials.new('mat_EdS') mat_EdS.diffuse_color = (0.527, 0.800, 0.213) mat_EdS.diffuse_intensity = 1 mat_EdS.use_transparency = True mat_EdS.alpha = 0.68 mat_EdS.emit = 1.0
import sys sys.path.append(ROOT + 'GitHub/Code/Python/') import lib_blender_util as lbu import lib_blender_edit as lbe import lib_cadcheb as lcad import lib_chebyshev as lch lbu.clear_scene(True, True, True) cs = lch.read_polynomial2(ROOT+'GitHub/FFTsurf/test/coeffstest/C2_test10.txt') m = 100 u = numpy.linspace(-1, 1, m) xyz = chebgrid2d(u, u, cs) v, f = lbu.tensor_product_mesh_vf(xyz[0], xyz[1], xyz[2]) surf = lbu.pydata_to_mesh( v, f, name='surface' ) lbe.set_smooth(surf) hmin = 1e-3 hmax = 1 tolchord = 1e-3 N = 6 cc = (2*numpy.random.rand(N,2) - 1)/numpy.tile(numpy.arange(1,N+1)**2, (2,1)).T cc[0,:] = 0 cc = 3*cc
normals = [] fclr = open(pthout + 'colors.dat', 'w') for iloc, iface in enumerate(V.faces): strf = format(iface, '03') mat = bpy.data.materials.new('mat_face_' + strf) mat.diffuse_color = color_face[iface - 1] fclr.write('%s, %s, %s\n' % (color_face[iface - 1][0], color_face[iface - 1][1], color_face[iface - 1][2])) c = lcheb.read_polynomial2(pthin + 'brepmesh/c_' + strf + '.cheb') xyz = chebgrid2d(u, u, c) mverts, mfaces = lbu.tensor_product_mesh_vf(xyz[0], xyz[1], xyz[2]) obj = lbu.pydata_to_mesh(mverts, mfaces, name='face_' + strf) lbe.set_smooth(obj) obj.data.materials.append(mat) # OFFSET cu, cv = lcheb.diff2(c) xyz = chebgrid2d(u, u, c) xyz_u = chebgrid2d(u, u, cu) xyz_v = chebgrid2d(u, u, cv) invsqrtdet = 1 / numpy.sqrt( numpy.sum(xyz_u**2, axis=0) * numpy.sum(xyz_v**2, axis=0) - numpy.sum(xyz_u * xyz_v, axis=0)**2) nor = numpy.zeros((3, m, m))
u = numpy.linspace(-1, 1, m) nf = len(V.faces) corners = [] for iloc, iface in enumerate(V.faces): strf = format(iface, '03') mat = bpy.data.materials.new('mat_face_' + strf) mat.diffuse_color = color_face[iface - 1] c = lcheb.read_polynomial2(pthin + 'brepmesh/c_' + strf + '.cheb') xyz = chebgrid2d(u, u, c) mverts, mfaces = lbu.tensor_product_mesh_vf(xyz[0], xyz[1], xyz[2]) obj = lbu.pydata_to_mesh(mverts, mfaces, name='face_' + strf) lbe.set_smooth(obj) obj.data.materials.append(mat) # OFFSET c = lcheb.read_polynomial2(pthin + 'brepmesh_eos/c_' + strf + '.cheb') xyz = chebgrid2d(u, u, c) mverts, mfaces = lbu.tensor_product_mesh_vf(xyz[0], xyz[1], xyz[2]) obj = lbu.pydata_to_mesh(mverts, mfaces, name='EdS_face_' + strf) lbe.set_smooth(obj) obj.data.materials.append(mat) # xyz = chebval2d(Vuv[iloc][0], Vuv[iloc][1], c) corners.append(xyz)
verts = [[x for x in p] for p in xyz] faces = [[int(v) for v in t] for t in tri] obj = lbu.pydata_to_mesh(verts, faces, name='face_' + str(isurf)) mat_face = bpy.data.materials.new('mat_face_' + str(isurf)) mat_face.diffuse_color = clr[isurf] mat_face.diffuse_intensity = 1 mat_face.specular_intensity = 0.2 mat_face.specular_hardness = 30 mat_face.use_transparency = False obj.data.materials.append(mat_face) lbe.set_smooth(obj) c = lcheb.read_polynomial2(pthin + 'c_' + suff[isurf] + '.cheb') xyz = chebgrid2d(u, u, c) verts, faces = lbu.tensor_product_mesh_vf(xyz[0], xyz[1], xyz[2]) surf = lbu.pydata_to_mesh(verts, faces, name='surf_' + str(isurf)) bpy.ops.object.select_all(action='DESELECT') scene.objects.active = surf surf.select = True bpy.ops.object.mode_set(mode='EDIT') print(' unwrap UVs...') bpy.ops.uv.unwrap(method='ANGLE_BASED', fill_holes=True, correct_aspect=True, use_subsurf_data=False, margin=0.001) bpy.ops.object.mode_set(mode='OBJECT') uvlayer = surf.data.uv_layers.active