Grasshopper

algorithmic modeling for Rhino

I'm writing a scripted component that takes 2 tree structures as inputs, and I want to ensure that their topology is identical.

Is it sufficient to just call InTree1.TopologyDescription for each, and see if the resulting strings are identical? That seems a lot faster and easier than traversing the tree, if it will actually work.

Views: 307

Replies to This Discussion

Hi Dave,

what properties do you want to include in your topology? Only the number and values of the paths or also the branch lengths, or...?

The TopologyDescription includes both paths and branch lengths so you could use it. It is unlikely that it will be faster though. TopologyDescription traverses the trees as well whereas your own comparer could stop traversing as soon as a discrepancy is found. However, it would certainly require more code on your part to compare the trees yourself.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

I want a one-to-one correspondence between the trees, so all of the above, including branch lengths.

I see what you're saying about speed, but actual execution speed isn't really important here. What I should have said is "That seems a lot faster and easier for me to write than traversing the tree..."

I admit it: I'm a lazy programmer. If the system can do it for me, then I'll let it (and someone else will have to maintain that code :-)

The only good programmer is a lazy programmer. Another topology property I can imagine is the existence of null items in branches, which TopologyDescription does not look at. But it sounds like you have your answer.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service