Grasshopper

algorithmic modeling for Rhino

Search and replace index items in a data tree - Eliminate small edges of Vornoi

I am trying to eliminate short segments of a voronoi diagram to eliminate problems in manufacturing small joints. I am doing this by grouping points together based on a threshold value and averaging them. Now I need to search through the original points that comprise the voronoi diagram and replace them with the new averaged points. I need to do this while still preserving the logic of the old data tree which is comprised of {i}j values. In other words each point is grouped into a vornoi cell so that the cells can be created with the polyline component

I believe I have a relatively simple solution, but need help create a python script that searches and replaces values within a data tree.See the psuedo code below:

Psuedo-Code:

For each item(i) in Data tree B (list of index values points to be replaced grouped into a data tree corresponding to the new point) find the corresponding integer in Data tree C (list of points grouped around {i;j} values)

Then replace the integer in Data Tree C with the key value (the data tree path) that corresponds to the item from Data tree B that is replacing the item from Data tree C

For example:

Data Tree B
{14}
(0)2
(1)3
(2)6
(3)11
(4)13
(5)14

Data Tree C
{0;1}
(0)2
(1)3
(2)6

Output:

Data Tree {0;1}
(0){14}
(1){14}
(2){14}

List A - Single point (New Point) with Data Tree/Key value corresponding to group of points it will replace ( List B)

List B-list of index values of flattened voronoi point list with Data Tree/Key Value corresponding to List A - in other words these are all the points I need to replace with the point in List A

List C-list of index values of flattened voronoi point list with Data Tree/Key Value corresponding to {i}j values necessary to re-create voronoi cells with the polyline component

Once this is done I can use the Output and the new Points in List A to replace the set of old points in the original voronoi diagram with the new set up reduced points.

If there is another way to achieve the goal of eliminating small edges of a vorononi diagram, I'm open to suggestions.



Views: 1331

Attachments:

Replies to This Discussion

I was able to solve this problem with some simple list management and the enumerate list function. Ironically, i think the better approach to getting rid of small edge lengths would be by using Kangaroo. reducing the points changes the topology of the cell, and its not very visually appealing.

Attachments:

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service