Selecting only the outermost voxels?

I am experimenting with voxel based geometry. I do not want voxels which are invisible, due to being packed from all the sides, to be created or baked at all in order to keep the final filesize low.

How can I do it? I tried to remove voxels by creating a logic where the voxels closest to the large cuboid will be removed but that became a very untidy approch.

I only want voxels which are visible on the outside.


voxel question.gh (10.4 MB)

1 Like

See attached.

Mesh_UnionMeshBoxes_V1A.gh (134.6 KB)

1 Like

Hello
here a way to do it inside Grasshopper. Not very cool you have also duplicate box !!

Calculate the center of the brep and after the face
If 2 centers are near delete the faces or brep so use Cull Duplicates with the option Cull All


voxel question.gh (10.2 MB)

1 Like

Superb!! This is so magical!! I’ll have to go through script multiple times to understand what you’ve done! Thanks a ton! :+1:t2:

What is magical is the Cull Duplicates. Many functionality are inside Grasshopper but are quite hard to find, it is surely why there are so much plugins.
Cull Duplicates has 3 options, right click on component.

1 Like

Thanks a lot. Unfortunately, I don’t know C# coding, hence unable to figure out the process through which you developed the final outcome. You’ve developed a kind of plugin!

I just took a look at the script and understood the entire process. Is there a way to preserve the cubes without splitting them? I want to apply different colour to different cubes by generating some dispatch pattern based segregation.

This has nothing to do with a plug in: it’s just an existed piece of C# code. But due to the ongoing F1 tests in Bahrain (Mercedes/Lewis have various aero issues) I have attached the 100% wrong C#.

So … just for the record get the one suitable for the scope:

Mesh_UnionMeshBoxes_V1B.gh (130.1 KB)

You can use Proximity 3d you count around the center how many others center there is, with a limitation of say 1.2*size of box.
If 6 the box is totally engulfed, if less it is outside.


voxel question.gh (563.8 KB)

1 Like

:thinking: What do F1 tests in Bahrain got to do with arrangement of voxels in the script?

They distort … er … distorted minds (and thus correct attachments).

That said the C# accepts any Box tree and yields either Meshes on a per Box basis or an “united” Mesh on a per Branch basis (in that case the Mesh faces are the “skin envelope” pieces). Meshes are used for speed, mind (30-50 milliseconds for 3K Boxes).

But truth to be said: I confess that is not doing exactly what you want: Instead of an envelope of Boxes it does an envelope of Faces (makes more sense for 3d printing and the likes).

2 Likes

I’m going through your script, will get back. I am realizing that I am creating a problem then asking around here for solutions. I used Crystallon plugin to generate voxels/boxes. Instead of developing voxels on the outer surface, it fills the entire volume with voxels/boxes.

Is there a more suitable way that takes only the outer surface geometry to generate a voxel envelope?

voxelization_crystl.gh (33.4 KB)

You could use naive surface nets like I did there

Dont remember if i posted the script

2 Likes

Superb! I’ll dig more through it! Thanks a ton. :+1:t2:

I went through the pages but didn’t download the script. What your process seems to do is generate a thin surface by selecting the outermost faces of voxels.

What I’m requiring is only the outer solid cubes, in their entirety that make up the surface of the volume.

2 solutions

  1. Use Crystallon and the method I presented with Proximity 3D, you could cluster it to make your own plugin
  2. Develop your own plugin to do what you want.

I see a big problem in you script. You plug directly Subd to Crystallon, it surely not uses the good mesh to calculates the boxes. See the difference. On the left what you did and the automatic conversion ob subd to mesh (construction mesh not the subdivided one !!!)
So use a Brep or Mesh From SubD


voxelization_crystlLD.gh (31.5 KB)

Right! I’ll keep that in mind. Thanks a lot.

I’m just going off the top of my head, but perhaps you could create a logic where you find the volume centroid of each voxel. Pull all centroids to all other centroids. For each voxel, count the number of centroids that are exactly 1 voxel voxel distance away (or < = to the diagonal if you’re including the adjacent corner voxels). If a voxel has 6 centroids (or 12 if you’re including corners) that are 1 voxel distance away, then cull it. You could use a slider to cull 6 (or 12) adjacent centroids, 5, 4, 3, etc. to lower the threshold for culling a voxel. Could get resource intensive if you have 10,000s of voxels.

Of course I just realized this is probably what Proximity 3D is doing like Laurent Delrieu suggested but I’ll let this reply stand in case there’s anything useful.

Yes thats what I proposed here

1 Like

Yes, exactly. I’m new to the Proximity tools (and probably many, many others) so I tend to build from scratch the hard way.

Indeed … but this is a reverse enginnering task anyway (thus slightly pointless). If the “skin” boxes are the required result then one should control that at creation time (but if a black box [some sort of compiled “add-on”] is used then that is more or less impossible).

Anyway the fastest way to do that (via code) has as follows: create a suitable class that defines Properties on a per box faces “info” basis (better turn them as quad meshes for other optional results > see last image) i.e. the box index + the face center. Sample the faces info into that class (as a List of custom type) and then GroupBy the faces centers. Loop into the groups done, get the groups with one item and sample in a HashSet the boxes indices: this is the “envelope” Boxes. For a ollection of about 10K boxes this could yield a result in about 20 to 40 milliseconds. See a test for 3K “envelope” boxes:

Only a single line is required for the result:

And a test for an “envelope” Mesh (per Box collection in a Tree):

2 Likes