0% found this document useful (0 votes)
34 views10 pages

U3 - 01 - Data Tree Logic

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views10 pages

U3 - 01 - Data Tree Logic

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

2

Data Tree
advanced data management

Algorithmic modeling is based on data. Complex models, such as tridimensional skins, are based

on the advanced data management. Grasshopper manages data according to an associative logic,

which is based on a hierarchical structure, called “Data Tree”.

Data Tree enables the setting of complex relationships among objects, within a complex

tridimensional model. So far, such a logic it's been completely “invisible” but it’s crucial to learn its

basic rules in order to get a deep control of Grasshopper and deal with complex algorithms. In

order to understand what is meant for Data Tree, we refer to the following example.
3

Let's consider a set of four triangular surfaces drawn in Rhino and collected by a single Geometry

component. Our aim is to draw a polyline curve that connect the twelve vertices.

Therefore, we use a Deconstruct Brep component, in order to extract the vertices, and a Polyline

component to draw the polyline. Nevertheless, the result is different from what we expected. In

fact Grasshopper doesn't create a single polyline through the twelve points but it creates four

polylines, as if it recognizes a hierarchical link between each triplet of vertices (Childs) and their

original triangles (Parents).

In order to understand such a hierarchical logic, we take a closer look at the algorithm. We observe

two important things:

1. A dashed connector outcoming from Deconstruct Brep.

2. Data within the lists are split into four "groups".


4

It is clear that Grasshopper stores data according to a Parent-Child logic, creating a "group" for

each Parent specified by a data path. Referring to our example, Grasshopper creates a group for

each triangular surface and stores the relative vertices within the group. So, the vertices of the

triangle 0 are hosted within the data path {0;0}, the vertices of the triangle 1 are hosted within the

data path {0;1} and so on.

Such a hierarchy is graphically represented through a tree-chart, as shown below. For this reason

"groups" are actually called "branches" and several components refer to this name.
5

As already pointed out, the Data Tree is "invisible" when components do not work simultaneously

on multiple data. In those cases the Tree is made by just one branch or by the only trunk.

The Data Tree has two fundamental rules:

• Branches are "watertight" groups.

In other words, you cannot establish any kind of connection among data hosted in

different groups/branches. Any kind of operation performed on a Data Tree will

involve simultaneously just the data stored in a single group/branch.

For this reason, in the previous example, the Polyline component cannot create a single

polyline through the entire set of vertices, but four different polylines through the

vertices belonging to the relative triangular surface.

• Data Tree can be manipulated

In order to get specific results - e.g. to create a polyline through the points of the

previous example - we should manipulate the Data Tree. It is possible through a set of

specific components.

5.1 Manipulating the Data Tree


Grasshopper provides users of a set of specific components to manipulate the Data Tree. They are

hosted within the Tree panel of Set tab. We will discuss the most important: Flatten Tree, Unflatten

Tree, Graft Tree, Flip Matrix.

5.1.1 Flatten Tree


The Flatten Tree component (Sets > Tree) simplifies a Tree by removing all branching information

and by storing data inside the trunk. In other words, Flatten tears down the "walls" between

"groups" so we can establish any kind of connection among data. As you can notice also the wires

turns from dashed to continuous after the Flatten component.

Of course, if we connect the polyline component to the T-output of Flatten we get the desired

result.

It is important to point out that every component provides the possibility to Flatten the incoming

data through a specific option available within the context menu of the input that receive data.

When an input is in "Flatten mode" the symbol of a downwards arrow appears.


6

FIGURE
A "structured" flow of data can be identified by a dashed wire, while a flattened flow by a continuous line.
7

5.1.2 Unflatten Tree


In many cases it's useful to "branch out" a flattened list according to another Data Tree used as a

"guide". The proper component is Unflatten Tree (Sets > Tree) which requires a flatted list in T and

a guide Data Tree in G. Unflatten Tree works only if the flattened list has the same data of the guide

list.

5.1.3 Graft Tree


Given an arbitrary list, Graft Tree (Sets > Tree) creates a branch for every item. Therefore, if we have

a flattened list with N items, Graft Tree returns a new list with N branches and one item for each

branch.

Graft Tree is very useful when you have to match disconnected sets of corresponding objects. Let's

consider, for an instance, two surfaces collected by two Surface components from which we extract

the relative edges through Deconstruct Brep. Our aim is to generate four loft surfaces through

couples of corresponding edges (a-a', b-b', c-c', d-d'). If we merge the two data flows by the Merge
8

component and then we connect Loft, the result will be different from what expected and similar to

the surface shown below.

It happens because the data gathered by Merge do not have branches (the wire between Merge and

Loft is continuous) and Loft works on a flattened list. In other words, the loft is performed through

the entire set of curves according to the order: a'-b'-c'-d'-a-b-c-d. On the contrary, we need a

branch for each couple of corresponding edges, so the loft could work properly. Such a task can

be accomplished by using two Graft Tree components before the data are gathered by Merge.
9

It is important to point out that every component provides the possibility to Graft the incoming

data through a specific option available within the context menu of the input that receive data.

When an input is in "Graft mode" the symbol of an upwards arrow appears.

5.1.4 Flip Matrix


In order to introduce the Flip Matrix component we will try to accomplish a very simple task:

creating a set of lines (coloured in blue in the following image) by connecting the corresponding

division-points of three circles.


10

If we collect three arbitrary circles and we divide them (into ten parts) by a Divide Curve component,

we get a set of points which can feed a PolyLine component in order to get the desired set of lines.

Nevertheless, as you can easily notice, the polylines do not connect the corresponding division-

points (A-A'-A'') but they are created through the division-points of each circle.

It is clear that the Divide Curve’s Data Tree has 3 branches - corresponding to the 3 circles - with 10

points for each branch. In order to connect the corresponding points and get the desired result,

we have to "flip" the Data Tree, getting a new tree with 10 branches and 3 points for each branch.

The specific component is called Flip Matrix and you can find it in Sets > Tree. As you can see in the

following image, the tree structure can be displayed by adding and double-clicking the Param

Viewer component (Params > Util).

You might also like