Divide Hexagons into Sub-quads

hexa divide problem v0.gh (112.0 KB)
R8, No plugin.

I like to subdivide a hexagon into 3 quads using the sequences {center,0,1,2}, {center,2,3,4}, {center,4,5,0}.

It is very easy to handle a single hexagon, but when there is more than one, there arises a tricky data tree issue I cannot solve.

Every tree branch holds the hexagon’s six points, and I want to split each branch into 3 sub-branches with the specified subset of points.

I know I can generate the final shape using other methods, but I really want to work out this logic, as it has been troubling me for a long time. Thank you!


New edit:

So, my goal is like

{0}[0,1,2,3,4,5],
{1}[0,1,2,3,4,5]

to

{0;0}[center,0,1,2]
{0;1}[center,2,3,4]
{0;2}[center,5,1,2],
{1;0}[center,0,1,2]
{1;1}[center,2,3,4]
{1;2}[center,5,1,2]

Here’s a solution with native components:

Thank you! But it still has the same problem, doesn’t it, when there are many hexagons.

You might have to move the curve seam first so the points are in the right order.

Oh, I guess I didn’t explain myself properly.
My problem is how to divide branches of points of 6 into 3 subbranches (insert the average point of the branch into every subbranch) and keep the original data structure by going down 1 layer deeper.
So, it is like

{0}[0,1,2,3,4,5],
{1}[0,1,2,3,4,5]

to

{0;0}[center,0,1,2]
{0;1}[center,2,3,4]
{0;2}[center,5,1,2],
{1;0}[center,0,1,2]
{1;1}[center,2,3,4]
{1;2}[center,5,1,2]

Or you type this into a panel once?

Thank you! I got it and it works beautifully.
But I still wonder if there is a way to subdivide branches and insert the center points into the subbranches. Or is that a limitation of the original data tree manipulation tools?

I mean I can think of a brutal way to duplicate every branch of points 3 times and also repeat the 3 indexes a bunch of times to match the data structure of the duplicated points, but I don’t think that is an elegant way.

Also:


or

but won’t work for non-planar hexes

This is another way with native components:

hex-quad.gh (20.0 KB)

For non-planar hexes, assuming you’ll provide the vertex average:

exagon.gh (10.7 KB)

:eyes:

I love you guys, but what is with all these convoluted solutions involving meshes and Path Mapper ?

Unless they have been remapped, polylines always have discontinuities at whole number params. So, you can get subcurves at known domains (0 To 2, 2 To 4, and 4 To 6), stack the polygon centers by the number of domains, match branch adresses, and build closed polylines from the merged point lists:

Divide Hexagons into Sub-quads VR1.gh (40.1 KB)

Divide Hexagons into Sub-quads VR2.gh (41.2 KB)

this look even more convoluted :rofl:

the mesh one looks like the cleanest with less component needed.
if by not convoluted you mean the less manipulation needed, just pick points from initial polyline

@Volker_Rakow,

We were simply carving out all the dirt for you!

Very nice—I did mean to ask Quan Li yesterday if the meshing truly mattered (and it doesn’t, really, for the purposes of the hex-to-quads solution(s) as you’ve shown); the original topic title itself was already unintentionally misleading into mesh quad construction. @martinsiegrist had it right and neat from the start too, regardless. I was realizing that after my approach but did not attain your elegance.

Thank you for the answers, guys. Every solution has its elegance, and I really appreciate all the replies.

if the meshing truly mattered

And sorry for the misleading title, the meshing does matter in this case, but what I truly want to understand is the datatree manipulation method.
I have been encountering this datatree problem in different facets for years, sometimes it was merely number matching (Divide lists of 6 numbers into 3 sublists and insert the average of the 6 numbers into every sublist), sometimes it is a tangible polygon division like this case.

I imagine there is an elegant way of subdividing and manipulating the DataTree only with the native components.

True. It is easy to see solutions when other people have struggled to come up with a first idea. Also, I assumed that the meshes were being introduced only as a means to solve the problem. I did not know they were the desired end result. But as @Fabio_Franchetti said, the mesh solution does seem like cleanest with the least number of components needed. I just don’t like the idea of randomly creating mesh geometry when I don’t need it. Maybe too pedantic?

Another one, just for the fun of it:


Shift list is there just so that you can cycle between the two possible ways of dividing a hex into quads.
Shift to 0:

Shift to 1:

I think to answer your question directly, the data manipulation tools (those components under the Tree panel of the Sets register) restructure, merge or retrieve subsets of data. They do not magically create new data. So no, you cannot do this with those components alone. You will have to replicate the data with Repeat Data, Stack Data, Cross Reference, or Longest List.

I mean yes, but that is not what you doing here. You’re trying to merge an item or branch into multiple branches.

can you explain for me what is the meaning of Q ?

Quad