Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edge Center / Edge Split node ? #1305

Closed
DolphinDream opened this issue Mar 5, 2017 · 35 comments
Closed

Edge Center / Edge Split node ? #1305

DolphinDream opened this issue Mar 5, 2017 · 35 comments

Comments

@DolphinDream
Copy link
Collaborator

DolphinDream commented Mar 5, 2017

I know there is a polygon center node (a few of them) but I can’t seem to find a way to get the center of the edges ? Should there be an Edge center node too? Is there any magic node that can give me these?

Alternatively maybe we can have an Edge Split node which allows you to split the edges anywhere inside the edge.. in the middle or in any “factor” position between 0 and 1 (closer to V1 or close to V2).

@DolphinDream DolphinDream changed the title Edge Center node ? Edge Center / Edge Split node ? Mar 5, 2017
@DolphinDream
Copy link
Collaborator Author

Btw, when you get an edge list input that comes as [[ [1,3], [3,4] ]] etc.. and read this and an input into an node, how do I get rid of the extra nestedness ? Or should I not get rid of it (in case the vectorization later on needs to rely on it?).

@zeffii
Copy link
Collaborator

zeffii commented Mar 5, 2017

the nested nature of the data makes vectorization possible, it's up to you whether you use it ..or stop looking after the first input list (.sv_get()[0] = first list)

@DolphinDream
Copy link
Collaborator Author

DolphinDream commented Mar 5, 2017

Here’s an “Edge Split” node preview.
Each edges is split (generate a new vertex on the edge given the input split factor).

edgesplit-preview

@zeffii
Copy link
Collaborator

zeffii commented Mar 5, 2017

make it split

| -----x---------------------------------x-----|

too :)

@zeffii
Copy link
Collaborator

zeffii commented Mar 5, 2017

i think there's a bmesh.ops now that makes this very simple

@DolphinDream
Copy link
Collaborator Author

DolphinDream commented Mar 5, 2017

What do you mean @zeffii ? Add two vertices on each edge? Is this for your edge net idea, btw? :)

Btw, the node does not adjust the edges, simply generates vertices where the split position on each edge would be.

@DolphinDream
Copy link
Collaborator Author

Btw, is there a way to connect every vertex with every other vertex? Perhaps a combinatorial node would be nice to have.

@zeffii
Copy link
Collaborator

zeffii commented Mar 5, 2017

like edge split in 3dsmax has a mirror option, that splits the way i showed above. This is very useful for when we subdivide an edge based mesh as it allows consistent curvature/radius deformation where there

Btw, the node does not adjust the edges, simply generates vertices where the split position on each edge would be.

oooh. i see - never mind then, it's easy enough to write script nodes for these things..

@zeffii
Copy link
Collaborator

zeffii commented Mar 5, 2017

kdtree edges can be used to connect everthing, but if you want pure topological 'complete' graph from all verts, then..no we don't have a node for that. itertools.combinations(iterable, r) ,where r is 2 and iterable is the list(range(len(verts)).

@DolphinDream
Copy link
Collaborator Author

DolphinDream commented Mar 5, 2017

@zeffii so you don't think a node like this is useful ? It can be made similar to the polygon center node.

@zeffii
Copy link
Collaborator

zeffii commented Mar 5, 2017

i think you are talking about two nodes here? Nodes with too many functions is something I want to avoid, because that brings a new problem of naming the node. and the node internals tend to become very messy. (unless the various modes are utterly trivial and reuse the same sockets..)

just because i don't have a need for a combinatorial node doesn't mean i'm against it.. it just means i'm not going to be excited about it.

@zeffii
Copy link
Collaborator

zeffii commented Mar 5, 2017

the Exec Node Mod is worth exploring for stuff that can be implemented in one or two lines of code
image

@zeffii
Copy link
Collaborator

zeffii commented Mar 5, 2017

import itertools
append(list(itertools.combinations(range(len(V1[0])), 2)))

here append is aliased to the out.append

@DolphinDream
Copy link
Collaborator Author

DolphinDream commented Mar 6, 2017

@zeffii Sorry. I guess my follow up question about full connectivity created some confusion as to what node we are talking about. I was suggesting 2 nodes: one for edge centers (or more generalized edge split vertex node) similar to the polygon center nodes. The other was a node to create combinatorial operations on a set of vertices to allow two generate a complete graph type of connectivity (btw, a fully connected graph is not necessarily a complete graph). (note: your itertools example does create a complete graph though. thanks for the tip). The first node could be extended to do the type of mirroring you suggested and perhaps go beyond that and not just create the vertices on the edges, but also create the additional split edges. I’m not sure how to handle new polygons when the edges are split though and I was not going to tackle the polygons at all in this node, but it’s probably doable. The more i think about it though, an edge splitter that splits also polygons would be pretty much like a subdivide operation, except that an edge splitter that takes a splitting factor as an input can also determine where the subdivide (split) location on an edges will go. I believe blender’s subdivide op puts the split verts at the edge centers.

As for the second node for combinatorics, I can’t see many uses for it either but it would be nice to have. I do need one for something I was working on (e.g. generate the Metatron’s cube lines by fully connecting vertices on a cube). The screenshot below does not have yet the completely connected graph, but i’m getting there. The purple verts/edges are not part of the Metatron’s cube, but I wanted to add them for illustration (hence my need to get the edge centers). Once I connect all the remaining vertices to form a complete graph the MC will be complete :)

sv-metatron-cube-test1

@DolphinDream
Copy link
Collaborator Author

DolphinDream commented Mar 6, 2017

And, voila, with the complete graph the MC is now complete :)

btw.. the "exec node mod” node is kewl 👍 .. Though I wish there was a combinatorics node 😁

sv-metatron-cube-test2

@enzyme69
Copy link
Collaborator

enzyme69 commented Mar 6, 2017 via email

@DolphinDream
Copy link
Collaborator Author

Here’s the edge split node with “mirror” option.

Now that i’m thinking about we could add a number of splits as well (1,2,3 infinity :)

edgesplit-demo1

@enzyme69
Copy link
Collaborator

enzyme69 commented Mar 6, 2017 via email

@DolphinDream
Copy link
Collaborator Author

DolphinDream commented Mar 6, 2017

And the version where the edges are actually split .. with or without mirroring. (added new edges output)

edgesplit-demo2

@zeffii
Copy link
Collaborator

zeffii commented Mar 6, 2017

Make a combinatorial node, with the few obvious modes. Itertools is your friend, spacial searches are already implemented in kdtree nodes.

@DolphinDream
Copy link
Collaborator Author

If needed i could pull request my EdgeSplit branch:
https://github.com/DolphinDream/sverchok/tree/edgeSplitNode

@zeffii
Copy link
Collaborator

zeffii commented Jul 26, 2017

if you move it to Modifiers / Change , then i'm happy to accept the Pull Request.

@zeffii zeffii closed this as completed Jul 26, 2017
@DolphinDream
Copy link
Collaborator Author

will do.. soon. It’s been a while.. time to get back to the SV realms :)

@enzyme69
Copy link
Collaborator

enzyme69 commented Jul 27, 2017 via email

@DolphinDream
Copy link
Collaborator Author

I just realized (going back to my blend files using this node) that I actually failed to honor the initial title I gave to this issue “Edge Center” :) I needed the edge centers.. not just to split the edges. Any objection to adding a “Split Verts” output so that I can get access the actual vertices added during the split ? It would provide a similar functionality to the poly center node, but for edges.

SplitEdges-splitVerts

@enzyme69
Copy link
Collaborator

enzyme69 commented Aug 7, 2017 via email

@DolphinDream
Copy link
Collaborator Author

DolphinDream commented Aug 7, 2017

Sure.. though I imagine you would have to split the edges and average each edge vertices or something like that.

Here’s a demo with the SplitVerts addition.. which outputs the vertices generated during the split for any given factor (not just 0.5).. and also works with mirrored splitting.

sv-splitcenteredges-demo3

@cosmopardo
Copy link

hi guys! i'm so -soooo- noob.
and i have this problem using edge-lenght.py on SNL
when i input a box <ex: 2units side>, i obtain a list (on sthetoscope) of 12 elements with of 2units lenght. right?
but, when i try join the SNL's out-socket with text-imput of ViewerIndex for visualize the results, i can visualize only 8 values, and all of them are on the verts.
i would like to use it as «linear-dimension»of typically CADsofts, and measure some or all edges on a solid. some ideas?
i tried to make a matrix with edge-centers (SplitEdges at .5 factorI). and use the new mid-vertex location to positionate the lenghts. but the result is horrible (like my eng, sorry)
giphy

@zeffii
Copy link
Collaborator

zeffii commented Dec 5, 2017

You want the Edge Length per Edge to appear on the Edge using ViewerIndex node? Admittedly we have no convenience method for this, but i'd use something like:

here's a modified version of edge-length.py (this is not a SNL script.. its a ScriptNode 1 script...)

import mathutils 
from mathutils import Vector

#get length of all edges
 
def sv_main(verts=[[]],edges=[[]]):
 
    # in boilerplate - make your own sockets
    in_sockets = [
        ['v', 'Vertices',  verts],
        ['s', 'Edges',  edges],
    ]
    lengths = []
    locations = []
    for v,es in zip(verts,edges):
        lens=[]
        locs=[]
        for e0,e1 in es:
            edgelen = (Vector(v[e0])-Vector(v[e1])).length
            lens.append([round(edgelen, 4)])
            locs.append(((Vector(v[e0])+Vector(v[e1]))/2)[:])
        lengths.append(lens)
        locations.append(locs)
    
    out_sockets = [
        ['s', 'Lengths', lengths],
        ['v', 'Locations', locations]
    ]
 
    return in_sockets, out_sockets

image

@zeffii
Copy link
Collaborator

zeffii commented Dec 5, 2017

here's SNLite version.. with adjustable rounding

"""
in verts v
in edges s
in roundn s default=5 nested=2
out locations v
out lengths s
"""

import mathutils 
from mathutils import Vector


for v, es in zip(verts, edges):
    lens = []
    locs = []
    for e0, e1 in es:
        edgelen = (Vector(v[e0])-Vector(v[e1])).length
        edgemid = ((Vector(v[e0])+Vector(v[e1]))/2)[:]
        lens.append([round(edgelen, roundn)])
        locs.append(edgemid)
    lengths.append(lens)
    locations.append(locs)

image

@cosmopardo
Copy link

madonna! is too much!

1st: thank you very much. 2nd: XD which the difference between SN and SNL? code type?

you are a CRACK. i follow you (and follow jimmy on youtube), and both are a great inspiration to my work. in fact, im still starting on blender. i installed it on january, and step by step i leaved the others softwares.

@zeffii
Copy link
Collaborator

zeffii commented Dec 5, 2017

let me respond in a dedicated thread: #1903

@Durman
Copy link
Collaborator

Durman commented Dec 5, 2017

@cosmopardo
SNL more comfortable for scripting. Documentation is here #942

@Durman
Copy link
Collaborator

Durman commented Dec 22, 2017

This node could have been useful for creating something like this:

2017-12-22_10-34-55

@Durman
Copy link
Collaborator

Durman commented Dec 22, 2017

Works wrong but looks interesting.

spli_edges

@zeffii zeffii mentioned this issue Jan 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants