Grasshopper

algorithmic modeling for Rhino

Hi all,

I've been wrestling with the correct approach for determining the status of many small, world aligned, static (but recalculated at intervals), regularly spaced, bounding boxes (voxels) in relation to a large arbitrarily shaped mesh. I would like to know if a given bounding box is outside, on the boarder, or inside of the mesh (i want to fill a mesh with ever smaller voxels recursively).

In looking though rhinocommon and other libraries i see:

  1. MeshMeshAccurate/MeshMeshFast intersections
  2. The MeshClash class
  3. Something like DigitalRune Geometry for .NET and XNA or a similar library.

In one and two I'll need to translate my bounding boxes into meshes (no big deal). A bigger problem is that it looks like neither 1 nor 2 will provide all three pieces of info that i would like. The problem i see with 3 is that I'll have to translate the format of meshes back and fourth. It is also not clear that game libraries like digitalRune's will provide all three pieces of info.

Does anyone out there have any experience with the rhinocommon classes above or my problem in general?

Views: 7400

Replies to This Discussion

The voxeltools support a geometry that is quite lightweight in terms of memory.  A voxelgrid is defined by it's bounds (a bounding box, can have a plane). The memory footprint of a voxelgrid is 1 bit per voxel + some overhead for the boundingbox, a grid can be converted to a mesh (there is some nice casting going on).

Right now I could not yet work with your example of the bunny, but it should be possible to adapt so it will work anyway. I'll try to wrap up an example tonight.

A bit later than planned, but here they are. This is the latest version - which contains some in development features.

Attached in an example with a C# block that should contain an assembly linked to the attached gha. Right now it does not do completely what you're looking for (but I still have a bit of an A > B problem (For what A, is your mesh mesh intersection the solution).

I'll need to clean this up, add some documentation, and then I'll post the plugin at food4rhino.

Attachments:

Hey Arend,

I still have to look at your tools. I am building a GHA myself. If your tools end up being useful would it be ok to reference your code into my project (i'm not sure if you can load classes from a .gha directly but i know that they are just renamed .dll files)?

In the mean time i looked at the slow code i was writing and found this other"Search" overload in the rhino common sdk:

public static MeshClash[] Search( Mesh meshA, IEnumerablea href="http://4.rhino3d.com/5/rhinocommon/html/T_Rhino_Geometry_Mesh.htm">Mesh> setB, double distance, int maxEventCount )

Because the search generate a compacted list i had to do a bit of acrobatics but the resulting C# component is much faster.

private void RunScript(List<Mesh> testVoxel, Mesh testMesh, ref object A)
{
//do the clash detection on many voxels per mesh at once.
Rhino.Geometry.Intersect.MeshClash[] clashresult = Rhino.Geometry.Intersect.MeshClash.Search(testMesh, testVoxel, 0.0001, 256);
Print(clashresult.Length.ToString());

//create some temporary storage containers
List<Mesh> clashingVoxels = new List<Mesh>();
List<int> results = new List<int>();

//collect all of the voxel meshes that were found to have clashed.
foreach (Rhino.Geometry.Intersect.MeshClash clasher in clashresult)
{
clashingVoxels.Add(clasher.MeshB);
}

//go though the list of all the voxels.
//If a voxel appears in the list of clashing voxels(see above) then output 0.
//If not the test if the voxel is inside or outside of the mesh.
foreach (Mesh voxel in testVoxel)
{
if (clashingVoxels.Contains(voxel))
{
results.Add(0);
}
else
{
VolumeMassProperties voxelMassProp = VolumeMassProperties.Compute(voxel);
if (testMesh.IsPointInside(voxelMassProp.Centroid, 0.00001, true))
{
results.Add(-1);
}
else
{
results.Add(1);
}
}
}
A = results;
}

(speed note) - here I've done 9000 boxes in .4 seconds. The old version did 150 boxes in over 13 seconds. This is a ~1950x improvement! I suspect the problem likes in expensive object creation of my previous version vs an internal space partitioning algorithm being used in the background in this version. Since i want to roll my own (space partitioning) i may need to delve a little deeper.

Hi Arend,

I tried loading up your tools but and find them and your .gh file says that they are not there.

I've verified that your .gha is in my ~\AppData\Roaming\Grasshopper\Libraries\ folder...

Are you sure you included the right version?

Should be ok, did you also unblock the file? That's sometimes needed.

ok, I unblocked it but still had to manually enter the path:

when i manually add the path (as above) grasshopper freezes...

In the mean time i wrote a more complete version in visual Studio (see attached) - it's not quite finished as it doesn't convert it's output to a DataTree but it should produce the data structure I'm looking for for my bigger project...

i realized that have slightly old grasshopper - I'll update it tomorrow and see if it works after that :-)

Could you elaborate on your data structure (and why you need it, perhaps?)

In the bigger project the voxels are smart and communicate information between them. So this voxel class I've written will be extended with many other capabilities into a "Node" Class. The nodes communicate back a fourth between there near neighbors and also between there parents and children.

generally it will work like this:

step 1 - voxleise a model.

step 2 - set up topological relationships

step 3 - set up initial conditions

step 4 - simulate

step 5 - output.

Hello Arend i love the voxel tools, is this the latest version?

Hi all,

Here is a compiling test version of the .gha i created for this... the output is a tree with a recusions of the voxels down to the one you specify.

It works but the performance is terrible (its same problem with the meshclash class as before because each child needs a new mesh clash object). I think if i go a bit lower level I can get a big performance boost. I'm thinking that the mesh face class will be something to look into as i try to roll my own mesh clash detector.

Attachments:

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