-
-
Save zeffii/925af1372fae476956d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# kdArrange | |
import bpy | |
from collections import defaultdict | |
from BioBlender.table_values import values_fi | |
''' | |
[x] step 01: first store atoms as {element_name: [co,..], } | |
[ ] step 02: generate singular ordered mesh by adding vertices | |
in clumps of element types. (H,H,H,H,H,H,O,O,O,O,O,O..) | |
[ ] step 03: track start and end index for each element into mapper_obj | |
[ ] step 04: preprocess obj.fi_value = BBinfo.get(') | |
[ ] step 05: get surface mesh. | |
[ ] step 06: for every vertex on surface mesh find closest | |
vertex in proxy_ob, and MLP value | |
''' | |
# step 01 | |
atom_to_fi = defaultdict(list) | |
proxy_obj = defaultdict(list) | |
nstr = '_4GE.001' | |
objs = bpy.data.objects[nstr].children | |
for o in objs: | |
_name = o.BBInfo[12:16].strip() | |
_amino = o.BBInfo[17:20].strip() | |
fi = values_fi[_amino][_name] | |
co = o.location[:] | |
proxy_obj[_name].append(co) # element name | |
atom_to_fi[_name].append(fi) | |
# step 03 | |
# will just hold a fi vale for every vertex in the atom cloud. | |
idx_to_fi = [] | |
mapper_obj = {} | |
verts = [] | |
idx = 0 | |
for key in sorted(proxy_obj.keys()): | |
start = len(verts) | |
verts.extend(proxy_obj[key]) | |
end = len(verts)-1 | |
mapper_obj[key] = (start, end) | |
idx_to_fi.extend(atom_to_fi[key]) | |
# print(mapper_obj) | |
# {'C': (0, 97), 'N': (98, 124), 'O': (125, 153) ...} | |
# step 02 | |
mesh = bpy.data.meshes.new("mesh_name") | |
mesh.from_pydata(verts, edges=[], faces=[]) | |
mesh.update() | |
obj = bpy.data.objects.new("obj_name", mesh) | |
scene = bpy.context.scene | |
scene.objects.link(obj) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment