Logic for generating boxes

(Amir Habibi) #1

Hi , I came up with What is the logic for creating boxes at a mass of points ? , as there is a component written by @MateuszZwierzycki


(David Rutten) #2

You’re going to have to elaborate a bit. Grasshopper doesn’t work with Voxels, so are you talking about a specific plugin or a way to mimic voxels in vanilla Grasshopper or…?

(Amir Habibi) #3

There is no Voxel Type in grasshopper or rhino , and i don’t mean the output , or the used type (brep ,mesh ,…)
I was looking for the logic of pixels and further (voxels) , so that to create adjacent cubes not intersected from a bunch of points .

(Amir Habibi) #4

In Mateusz Zwierzycki’s version of voxel generating the output is a single mesh and when the cubes meet each other the adjacent faces will be culled .

(David Rutten) #5

It sounds like that needs some serious coding, because there’s various intricate loops involved that are not easily done in Grasshopper. In general the default approach would be to generate all the voxel volumes, then test each point for inside/outside relationships. This is exceedingly inefficient as the number of tests you have to perform is the number of points times the number of voxels. In code it is much easier to figure out for each point in what voxel it resides, reducing the runtime to just the number of points.


Wouldn’t that be the number of points six times? Being a homogeneous topology, with a voxel up, down, front, back, right and left, it would not be enough to know the absence of a neighbor to add a face?

(David Rutten) #7

That’s the next step I haven’t even thought about yet. First you need to figure out which voxels in the infinite voxel space contain one or more points. The attached file uses a HashSet<VoxelIndex> to build the list of voxels that are touched by points, but if you’re happy setting up finite space boundaries and you know that you’re not going to deal with too many potential voxels, you could use a 3D array as well.

voxel solver.gh (14.4 KB)

(Michael Pryor) #8

Mateusz voxels are very fast and def math based. I don’t think he makes cubes and remove walls. Also always post some link to plug-ins so people know what you are referring to.


(Amir Habibi) #9

It merges all the adjacent faces , and it’s optional not to merge by grafting the point list . the point is that I don’t know if the code makes each voxel cube and recognize the adjacent ones and omit them or not .

Thanks for clarification .

(Amir Habibi) #10

Thanks a lot David
Well I gotta add the adjacent faces removing part , And I was not familiar with HashSet data storage .

(Michael Pryor) #11

I know what it does, what I am saying is it doesn’t make each cube, it calculates the final mesh boundary from the point space. Of course it makes separate voxels with graft, because then each voxel space is one point.

(David Rutten) #12

If the total number of voxels you would possible add does not exceed ~1million or so, using a multi-dimensional or nested array of booleans will both be faster and easier when testing for adjacency. But I think it also makes it all a little bit more complicated.

I quite like the idea of having some sort of voxel geometry type in GH2, but I haven’t done enough with them in the past to really know yet what would be involved.