-
-
Save zeffii/11268783 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
from node_s import * | |
from util import * | |
from mathutils import Vector, Euler, kdtree | |
import bpy | |
class SvKDTreeNode(Node, SverchCustomTreeNode): | |
'''Vertices sort''' | |
bl_idname = 'SvKDTreeNode' | |
bl_label = 'Kdtree search' | |
bl_icon = 'OUTLINER_OB_EMPTY' | |
def mode_change(self, context): | |
mode = self.mode | |
if mode == 'FIND': | |
''' | |
> [Main Verts] | |
> [cVert,..] | |
[Verts.co,..] (for i closest match to cVert[i]) -> | |
[Verts.idx,..] (for i closest match to cVert[i]) -> | |
''' | |
pass | |
if mode == 'FIND_N': | |
pass | |
# if mode == 'FIND_RANGE': | |
# if 'Base Point' not in self.inputs(): | |
# self.inputs.new('VerticesSocket', 'Base Point', 'Base Point') | |
modes = [ | |
("FIND", " 1 ", "Find nearest", 1), | |
("FIND_N", " n ", "Find n nearest", 2), | |
("FIND_RANGE", "distance", "Find within Distance", 3) | |
] | |
mode = bpy.props.EnumProperty( | |
items=modes, default='FIND', update=mode_change) | |
def draw_buttons(self, context, layout): | |
layout.label("Search mode:") | |
layout.prop(self, "mode", expand=True) | |
def init(self, context): | |
self.inputs.new('VerticesSocket', 'Verts', 'Verts') | |
self.inputs.new('VerticesSocket', 'Check Verts', 'Check Verts') | |
self.outputs.new('VerticesSocket', 'proximity Verts', 'proximity Verts') | |
self.outputs.new('StringsSocket', 'proximity Indices', 'proximity Indices') | |
def update(self): | |
inputs = self.inputs | |
outputs = self.outputs | |
if not ('Vertices' in inputs and inputs['Vertices'].links): | |
return | |
verts = SvGetSocketAnyType(self, inputs['Vertices']) | |
if self.mode == 'FIND': | |
pass | |
elif self.mode == 'FIND_N': | |
pass | |
elif self.mode == 'FIND_RANGE': | |
pass | |
# SvSetSocketAnyType(self, 'PolyEdge', edges_out) | |
def update_socket(self, context): | |
self.update() | |
def register(): | |
bpy.utils.register_class(SvKDTreeNode) | |
def unregister(): | |
bpy.utils.unregister_class(SvKDTreeNode) | |
if __name__ == "__main__": | |
register() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment