Beispiel #1
0
              resolution_y=600,
              resolution_percentage=100,
              alpha_mode='SKY',
              horizon_color=[1,1,1],
              light_samples=10,
              use_environment_light=True,
              environment_energy=0.2,
              environment_color='PLAIN')

# clear Blender scene
lbu.clear_scene(meshes=True, lamps=False, cameras=False)

# read polynomial coefficients in Chebyshev basis
#filecoefs = '/stck/bandrieu/Bureau/Manuscrit/memoire_bak_29_03_2019/figures/code/parametric_patch.cheb'
filecoefs = '/d/bandrieu/GitHub/FFTsurf/test/coeffstest/C1_test01.txt'#'C2_test31.txt'
c = cheb.read_polynomial2(filecoefs)

# compute Oriented Bounding Box
center, ranges, axes = cheb.obb_chebyshev2(c, AABB)

# add OBB as polyhedron
obb = lbu.obb_to_mesh(center, ranges, axes)
obb.name = 'OBB0'


"""
# add tensor product patch
xyz = chebgrid2d(u, u, c)
myl.addTensorProductPatch(xyz[0], xyz[1], xyz[2],
                          name="patch",
                          periodu=False, periodv=False,
import bpy
import numpy
from numpy.polynomial.chebyshev import chebval, chebgrid2d, chebval2d

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
Beispiel #3
0
for mat in obj.data.materials:
    mat.diffuse_color = color_face[int(mat.name[3:]) - 1]
    mat.diffuse_intensity = 1
    mat.specular_intensity = 0
    mat.specular_hardness = 30

#xyz_facelabel = []
normals = []
xyz_facecenter = []
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')
    cu, cv = lcheb.diff2(c)

    xyz_u = chebgrid2d(Vuv[iloc][0], Vuv[iloc][1], cu)
    xyz_v = chebgrid2d(Vuv[iloc][0], Vuv[iloc][1], cv)
    normals.append(Vector(xyz_u).cross(Vector(xyz_v)).normalized())
    xyz_facecenter.append(chebval2d(0, 0, c))

normal_avg = Vector((0, 0, 0))
for nor in normals:
    normal_avg += nor
normal_avg.normalize()
################################################################

################################################################
# ADJUST CAMERA
color_face = lco.cc_hsv(color_face, fs=1.2, fv=1.0)

m = 100
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)
u = numpy.linspace(-1, 1, m)

nf = len(V.faces)
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) -
Beispiel #6
0
for a, b in edg_inner:
    f.write('%d %d\n' % (a + n_outer + 1, b + n_outer + 1))
f.close()

hmin = 1e-3
hmax = 1e-2
tolchord = 1e-3
file_info = pth + 'info.dat'
f = open(file_info, 'w')
f.write('%s\n%s\n%s' % (hmin, hmax, tolchord))
f.close()

os.system('cp /d/bandrieu/GitHub/FFTsurf/test/demo_EoS_MAT/c_skeleton.cheb ' +
          pth + 'c_skeleton.cheb')

c = lcheb.read_polynomial2(pth + 'c_skeleton.cheb')
c = lcheb.flip_polynomial2(c, flip_u=False, flip_v=True)
lcheb.write_polynomial2(c, pth + 'c_skeleton.cheb')

os.system(
    'cp /d/bandrieu/GitHub/FFTsurf/test/demo_EoS_MAT/surfnew_c_01.cheb ' +
    pth + 'c_eos.cheb')

print 'Running meshgen...'
run_meshgen(pth + 'c_skeleton.cheb', file_bpts, file_bedg, file_info,
            pth + 'tri0.dat', pth + 'uv0.dat', pth + 'xyz0.dat')
run_meshgen(pth + 'c_eos.cheb', file_bpts, file_bedg, file_info,
            pth + 'tri1.dat', pth + 'uv1.dat', pth + 'xyz1.dat')
print 'done.'

print 'Running meshconv...'
Beispiel #7
0
    xyz = numpy.loadtxt(pthin + 'xyz' + str(isurf) + '.dat', dtype=float)

    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)
    edge_xyz,
    name='edge',
    thickness=1e-3,
)
edge.data.materials.append(mat_edge)
edge.hide_render = True
f.close()
################################################################

################################################################
# EDGE PSEUDO-EoS
m = 200
n = 50
u = numpy.linspace(-1.0, 1.0, m)
v = numpy.linspace(-1.0, 1.0, n)
c = lcheb.read_polynomial2(pthin + 'debug/eos_edge_c_' + format(iedge, '03') +
                           '.cheb')
c = lcheb.flip_polynomial2(c, flip_u=True, flip_v=True)

cu, cv = lcheb.diff2(c)

xyz = chebgrid2d(u, v, c)
verts, faces = lbu.tensor_product_mesh_vf(xyz[0], xyz[1], xyz[2])

pseudoEdS = lbu.pydata_to_mesh(verts, faces, edges=None, name='pseudoEdS')
# set smooth shading
lbe.set_smooth(pseudoEdS)

# set material
mat_pseudoEdS = bpy.data.materials.new('mat_pseudoEdS')
mat_pseudoEdS.diffuse_color = numpy.array([137, 126, 218
                                           ]) / 255.  #(0.603, 0.488, 0.8)