Subdivided Voxelization:


I’m trying to make a definition that subdivides the outer voxels into eight voxels. So far I’ve made a scalable box grid that is culled with a brep so that only the inside remains. Now I’m trying to figure out how to make the outer layer of boxes half size.

Is there a way to change the box size dynamically? Some kind of attractor point or list the outer boxes due to intersection with the brep or something?

Thanks in advance!

This is a classic recursive task. Recursion is a rather “odd” way to do business where something calls itself until something else happens and the loop is terminated.

For instance in loop: 0 you subdivide and you get a List of boxes (2d or 3d). Then you sample the ones that yield a ccx event with a Curve and/or a Mesh and/or a Brep (general case) into a tree at branch loop.

Then in loop 1 you gather items from tree branch (loop -1) and for each you subdivide and you sample the new ones (ccx etc etc) into a tree at branch loop. This means that the amount of items can escalate quite fast (but depends on the “filter” used for passing items to the next loop).

A tree like that is in fact the history of the actions that occured (until the recursion termination) … so by selecting a given branch you can inspect what happened per loop.

You can do that via Anemone (or via code - my game). I fact I have stuff like that but is carried over solely via code and works in 3d against any Brep/Mesh.

The result is kinda like “approximating” an image via “pixels” with more and more finer resolution.


grid_cull_2019Oct13a.gh (12.1 KB)

Powers of two (below):


grid_cull_2019Oct13b.gh (18.1 KB)

Hi,
this is an experiment I did a long time ago: It’s not standard cuboid division (by 8) but rather by 2.
they are not cubic voxels (in order to be cut in half and retain a fixed proportion, they are based on the delian constant (2^1/3). I don’t know if you will find it useful.
(also, the definition could be greatly simplified if you use ‘anemone’ for the iterative process)

rose-voxel.gh (209.2 KB)


grid_cull_2019Oct13c.gh (21.5 KB)

Thanks!

Yeah, it would be like pixels getting twice as high resolution between the outer boxes and the boundary.

I’ve encountered Anemone before, so I have it, but I’ve never worked with it form scratch. Will try to learn more about how it works.

Thanks!

That’s a really nice definition, but I feel it’s to complicated for what I’m trying to do (especially after I’ve got the subdivided boxes).

So far I’ve done like this (see definition), but I feel it’s not the smartest solution… Maybe it provides a better picture of what I’m trying to do.Subdivided Crust.gh (90.6 KB)

That’s PER LOOP my friend. What if you have 10 “refinment” phases/loops? Anyway if at some future time you decide to start the coding thingy (and is C#) … just drop a word.


grid3D_cull_2019Oct13a.gh (26.6 KB)

Even division of BBox cube by ‘cube count’ slider (below):


grid3D_cull_2019Oct13b.gh (26.9 KB)

This one below uses Split Brep (white group, slightly slower) instead of BBX, then returns the piece of each split box (boxes that intersect the brep) that is either inside or outside the brep, depending on the Value List switch: “Interior” or “Exterior”.


grid3D_cull_2019Oct13c.gh (37.3 KB)

Both:


grid3D_cull_2019Oct13d.gh (35.6 KB)

Thanks!

I’ll see if there’s anything in your definition that I can use, but from what I see it’s not doing what I tried to accomplish. The point was to have two sizes of voxels/boxes: the main size inside the brep and then subdivide the outer of those voxels to eight voxels.

Ideally I’d have a definition that automatically made the boxes half size after a distance or outside a shape. That’s what I’m trying to figure out how to do.

Here some raw code in c#:



voxelization c#.gh (14.5 KB)

It iteratively save each box that is fully inside the solid (by doing distance check with box diagonal) and split other boxex into 8 smaller (half size) for the next iteration. Boxes that are outside are discarded.
As how this works it always result in a set of boxex that is smaller than the original shape (it would take infinite time to reach correct volume).

43k boxes (centers+sizes) in less than a second, boxes have different size.
The rest of the work, the reconstruction and displaying of the boxes is actually more heavy: rhino viewport almost frozen (really low redraw fps) and baking take most of the time… so components inside attached solution are disabled.

2 Likes

My dear Watson (pick up that %%@ phone and tell me your news). Here’s how to address that voxel puzzle (general case: Lists of any template shape: Breps (slow) or Meshes (OK, but check for islands first) or Both (hmmm)).

  1. First you should mastermind a recursion where the voxel subdivisions are user controlled. Plus you should use alternative ways to cut the mustard (because Ccx is rather slow - see 2). Plus you should control the voxelPlane (so you can animate that for LOL results). Plus you’ll need lot’s of espresso.

  1. Since the N of voxels can escalate “a bit” and in order to finish the task this year (or century)… see 1 above. Plus: in fact that’s a classic // thingy were locking the right tasks is the 1M goal - because in order to proceed to the next recursion loop you should get all the pieces first on hand :

  1. Then you can do things like these (that have no real-life meaning at least in our trade … but anyway):

Moral:

Screen%20Shot%20029


Dear lord of darkness! Please forgive me for my insolence! I will pm right away!
now let us not destroy yet another thread with irrelevant posts!
people come here for answers, not listening to old men rumbling on…
:laughing::laughing::laughing:

1 Like

Wow! That’s a nice definition. Thanks for sharing. Think I’ll need to look into learning c#.

Definitely need to learn c#, although I suspect it might make me want a t-shirt that says “Marry a rich girl, forget C#”…

You are a wise man: act accordingly (life’s short).

Hey there,
I am working with voxelization and would need someones help, I have this code that works good with brep selection,but I want to upgrade it so I have full control over pixel ,box size and can change then to rectangular shape( make them appear exact dimensions as I wan 5.3x11.8x3.5). Right now at the moment when I try to do it, the division between the pixels are destroyed and it wont array along the brep nicely. In attached documents you can find grasshopper code and the rhino file with brep.voxel.gh (21.1 KB) brep AT.3dm (750.5 KB)