nested arrays

 
 
 
Posted by:jcdeblok
Data created:23 October 2012

What is the best way to get all the single values from a nested array, take this for example:

polygons=[ polygon[1,2,3,4], polygon[2,3,4,1], polygon[4,5,6,2] ]

Using method 'getValue' and an index I can get to a single  polygon, and again with getValue and an index I can get to each of the polygon's vertexindeces, that works.

But If I want to get them all using a series I can't seem te break out of the first level since a using a series on the main polygons array yield the exact same array, an array of polygons.

Anyways I want to end up with [1,2,3,4,2,3,4,1,4,5,6,2]  and I know I can use the ContPolyData for that but that isn't allways the case and in general I seem to get stuck with nested arrays..

You can create a subgraph which extracts the vertex indices from each polygon and returns int[], then feed an array of polygons into that sub-graph so it returns int[][]. Then you can create a "Flatten" function which flattens that jagged array into a single one. I actually had that function in Ephere.Utilities I think but its not there for some reason. I can add it back in for next build.

Marsel Khadiyev (Software Developer, EPHERE Inc.)

I tried that but that didn't work to well! single poly works:

main graph: mesh->polygons->typenode:getItem[1]->typenode:VerticIndices->[1,2,3,4]

-When I group the 'typenode:VertexIndices' the two nodes in the new sub-graph get disconnected?

-When I reconnect them inside the subgraph it does output output [1,2,3,4] as expected with a single poly input.

-when  I put in an array of polygons into the subgraph it freezes (one time I got redlines and an exception too)  

 

Attached is a ctx (geometryModifier) file to reproduce:

1) validate output of 'node5', should be an array of vertexIndeces for a single poly

2) group 'node4' and 'node5' togehter

3) enter subgraph and observe disconnected nodes inside

4) fix subgraph so it outputs vertexIndeces again

5) go back to main graph and validate ouput of subgraph (should be same as step 1)

6) Now input an array of polygons to subgraph

7) freeze/error


Attached Files:

>problem.ctx (29871 bytes),

Got it, thanks for the file. I will investigate what's going on.

Marsel Khadiyev (Software Developer, EPHERE Inc.)

Fixed in 0.1.3.0 (next build)

Marsel Khadiyev (Software Developer, EPHERE Inc.)

Cool!