nortikin / sverchok

Sverchok
http://nortikin.github.io/sverchok/
GNU General Public License v3.0
2.26k stars 233 forks source link

Vectorize Input option in monads/node groups #863

Closed ly29 closed 7 years ago

ly29 commented 8 years ago

skarmavbild 2016-09-06 kl 12 17 08

Since we have many nodes that needs be vectorized and some that can't be easily done without redoing a lot (like 80-90% of nodes). I now introduce a simple option for apply a node group/monad to the input.

This calls the monad on the level 1 input wrapped as separate objects, and the output is extended on the same level not appended and preserving structure.

skarmavbild 2016-09-06 kl 11 15 08 Note that this layout would work if we didn't split the lists as well, but more complex scenarios wouldn't

    def process_split(self):
        monad = self.monad
        in_node = monad.input_node
        out_node = monad.output_node
        ul = make_tree_from_nodes([out_node.name], monad, down=False)

        data_out = [[] for s in self.outputs]

        data = [s.sv_get(deepcopy=False) for s in self.inputs]

        for data in zip(*match_long_repeat(data)):
            for idx, d in enumerate(data):
                in_node.outputs[idx].sv_set([d])
            do_update(ul, monad.nodes)
            for idx, s in enumerate(out_node.inputs[:-1]):
                data_out[idx].extend(s.sv_get(deepcopy=False))

        for idx, socket in enumerate(self.outputs):
            if socket.is_linked:
                socket.sv_set(data_out[idx])
ly29 commented 8 years ago

@zeffii would be happy if you verify that my second loads

zeffii commented 8 years ago

yeah, loads fine

zeffii commented 8 years ago

so. maybe implementation of monad should be more like lukasT's reference. (voodoo)

ghost commented 8 years ago

Wow, thanks a lot for the replies! twist2 is exactly what I was thinking of.

ly29 commented 8 years ago

The only way to move forward is with testing. Maybe some control of which socket splits would be nice but I want test a bit more scenarios before making any more options.

So keep the questions coming.

ghost commented 8 years ago

Ok another question then: now, based on twist2, I am trying to apply the monad to the output of Adaptive Polygons. I get a result but it's not what I would like. It seems like the monad is treating the hole output like one single object, applying the twist to the hole. I tried with list split, monad info and other stuff but nothing... It gets more messy if I feed the third socket with a list. What I would like is to treat each output of adaptive poligon as a single object, applying a specific twist to it. Hope I explained myself.

image

image

ly29 commented 8 years ago

Some quick comments:

Each output of adaptive polygon is a separate object, twist right now assumes the Z axis as the rotation axis, making it generic in that sense requires some rethinking.

ghost commented 8 years ago

Thanks for the tip:} So I modified the monad in order to make che center of each tower the rotation axis. Not sure this is the best way (it's slowing down the hole thing quite a bit) but it works:

cattura

Then, (last) thing I wanted to do was to create another monad that could filter the incoming vectors in order to apply the transformation only to some of them. I first tried it on a new file and it worked:

filtVec.zip

Then I tried to use create a similar monad inside the Twist one but it's not working the way I want. What I would like is to apply the twist only to the vectors above a certain height (and then potentially apply also other filters). Don't know what I am doing wrong since the monad is basically the same as in the other file and, if I remember, it was said before that it is possible to use monad inside monads.

twist_filter.zip

cattura

ly29 commented 8 years ago

It does get heavy real quick, right now that wont't change soon.

To apply some under a condition I would recommend list mask and masked join.

It is possible to use monad inside of monad, as long as there is no recursion, and switch doesn't protect against that like a if case as one would expect. skarmavbild 2016-09-13 kl 08 35 47