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

Cross Section, Bisect nodes and objects. #1728

Closed
Durman opened this issue Jun 25, 2017 · 26 comments
Closed

Cross Section, Bisect nodes and objects. #1728

Durman opened this issue Jun 25, 2017 · 26 comments

Comments

@Durman
Copy link
Collaborator

Durman commented Jun 25, 2017

Is it possible to cut objects individually? I think this nodes unite objects in one inside itself. It will be better if one matrix cut first object and two matrix cut second object, for me in my case.))

2017-06-25_14-42-44
https://gist.github.com/8b592141eba2da47443ba4e0690fcf6a

@zeffii
Copy link
Collaborator

zeffii commented Jun 25, 2017

@Durman the node doesn't join the objects, but it does perform all matrix cuts on each incoming object.

@zeffii
Copy link
Collaborator

zeffii commented Jun 25, 2017

look at the code to understand why

        for cut_mat in cut_mats:
            pp = cut_mat.to_translation()
            pno = Vector((0.0, 0.0, 1.0)) * cut_mat.to_3x3().transposed()
            for obj in zip(verts_ob, edg_pols):
                res = bisect(obj[0], obj[1], pp, pno, self.outer, self.inner, self.fill)
                if not res:
                    return
                verts_out.append(res[0])
                edges_out.append(res[1])
                polys_out.append(res[2])

@zeffii
Copy link
Collaborator

zeffii commented Jun 25, 2017

it makes sense to add a toggle to use the above algorithm as "All matrices" vs a mode that does "individual matrices".

@zeffii
Copy link
Collaborator

zeffii commented Jun 25, 2017

image

@zeffii
Copy link
Collaborator

zeffii commented Jun 25, 2017

I am reluctant to modify The cross section node too.. can't commit this just yet.

@zeffii
Copy link
Collaborator

zeffii commented Jun 25, 2017

image

@zeffii
Copy link
Collaborator

zeffii commented Jun 25, 2017

i've committed this to Bisect node.

@zeffii zeffii closed this as completed Jun 25, 2017
@Durman
Copy link
Collaborator Author

Durman commented Jun 25, 2017

Thanks Zeffii, very fast.))
Can I Use several cutting matrix for one object and several (may be more) for another? :/

2017-06-25_19-56-51

@Durman
Copy link
Collaborator Author

Durman commented Jun 25, 2017

I can look at the code but I can not understand nothing. My knowledge about Python too poor.

@zeffii
Copy link
Collaborator

zeffii commented Jun 25, 2017

@Durman ofcourse it can be done, but not with the current incarnation. Not sure what the interface should be for that (many options are possible). Maybe the most conventional is to take nested lists of Matrices...

matrix = [[v,v,v,v], [v,v,v,v], [v,v,v,v], [v,v,v,v]]

# normal matrix list 
matrices = [matrix1, matrix2, matrix3]

# nested matrix list
matrices = [[matrix1a, matrix1b, matrix1c], [matrix2a, matrix2b, matrix2c], [matrix3a, matrix3b, matrix3c]]

a bool/toggle for "nested" would iterate over objects, and then sub matrix list.

for idx, obj in enumerate(verts, faces):
   for mat in matrices[idx]:
       ... make chops..

@Durman
Copy link
Collaborator Author

Durman commented Jun 25, 2017

When I tested bisect node I supposed that nested list of matrix received right result, for this I used List split node, but it did not help me.))

@Durman
Copy link
Collaborator Author

Durman commented Jun 25, 2017

With Scale node this method has good work.

scale objects

@zeffii
Copy link
Collaborator

zeffii commented Jun 25, 2017

only a few lines of code need to be added to do what you want @Durman - but i will think about it first before writing code. -- maybe tomorrow.

@zeffii
Copy link
Collaborator

zeffii commented Jun 27, 2017

as for nested Matrix lists.. by which means do you intend to produce them? the normal Matrix In doesn't exactly offer an easy way.

@Durman
Copy link
Collaborator Author

Durman commented Jun 27, 2017

Good question.)) I thought something like this but it does not work I am not understanding why.

unite matix

@zeffii
Copy link
Collaborator

zeffii commented Jun 27, 2017

it's possible to give Matrix In a "Multi Matrix" mode., which expects "complex" input (nested input). Without a convenient way to make nested Matrix lists... i don't see much reason to push the changes to Bisector node ( I already have a branch that should work on nested matrix lists ..and have not tested it yet)

@Durman
Copy link
Collaborator Author

Durman commented Jun 27, 2017

ok

@Durman
Copy link
Collaborator Author

Durman commented Jun 30, 2017

I did it with Scripted node lite and Python.))

section

@zeffii
Copy link
Collaborator

zeffii commented Jun 30, 2017

good work on solving your own problem!

@nortikin
Copy link
Owner

nortikin commented Jul 1, 2017

Yes, go ahead for more results. Can do!

@Durman
Copy link
Collaborator Author

Durman commented Jul 27, 2017

I have reconstructed Bisect node. I have changed input matrix on two vectors inputs, first for moving section plane second for rotation. Now it is possible to mange with section plane for each input object.

mybisect
2017-07-27_13-41-16

'''
in vertices v
in edg_pols s
in move_matrix v d=[[(0,0,0)]] n=0
in rotate_matrix v d=[[(0,0,1)]] n=0
out verts_out v
out edges_out s
out polys_out s
'''
from mathutils import Vector
from sverchok.data_structure import Matrix_generate, Vector_generate, match_long_repeat
from sverchok.nodes.modifier_make.bisect import bisect
from sverchok.utils.sv_mesh_utils import mesh_join

def input_mat(io):
    def check_len(data, io):
        if len(data) > io: return io
        else: return -1
    return match_long_repeat([move_matrix[check_len(move_matrix, io)]] + [rotate_matrix[check_len(rotate_matrix, io)]])

verts_ob = Vector_generate(vertices)

for io,obj in enumerate(zip(verts_ob, edg_pols)):
    ln_e,ln_p = 0,0
    v_obj,e_obj,p_obj = [],[],[]

    for i,p_mat in enumerate(zip(*input_mat(io))):
        pp = Vector(p_mat[0])
        pno = Vector(p_mat[1])
        
        res = bisect(obj[0], obj[1], pp, pno, True, True, True)
        
        v_obj.extend([res[0]])
        e_obj.extend([res[1]])
        p_obj.extend([res[2]])
        
    v_obj,e_obj,p_obj = mesh_join(v_obj,e_obj,p_obj)
            
    verts_out.append(v_obj)
    edges_out.append(e_obj)
    polys_out.append(p_obj)

@zeffii
Copy link
Collaborator

zeffii commented Jul 27, 2017

@Durman i think it is great that you have managed to solve this for yourself. That's what SNLite was made for.

  • I'm not going to modify the current bisect node to behave this way (maybe you, or someone else wants to... )
  • Maybe there should be a more convenient way to store user-created SNLite scripts locally / online..
  • Maybe a more convenient way to include custom nodes in a user's sverchok folder..

@zeffii
Copy link
Collaborator

zeffii commented Jul 27, 2017

I will think about this when time permits.

@nortikin
Copy link
Owner

@Durman
Copy link
Collaborator Author

Durman commented Jul 28, 2017

@zeffii
I think logic of this node too unlike to another nodes of Sverchek.
@nortikin
Something strange.))

Where can I to find code of the delaunay node on the Sverchek store?

@zeffii
Copy link
Collaborator

zeffii commented Jul 28, 2017

@Durman , the delaunay node is located in the same file as 2dvoronoi ( https://github.com/nortikin/sverchok/blob/master/nodes/modifier_make/voronoi_2d.py )

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

3 participants