Grasshopper

algorithmic modeling for Rhino

Predicament:

Attempting to cull specific 3d grid cells based on point inclusion from cellular automata.

Problem:

The normal Mesh Inclusion does not test all points in all cells, it seems random and unstructured. So it does not create the correct cull pattern.

See attached C# attempt:

Plugins- PanelingTools, Rabbit

Ideally I would like to use the standard grid cells to test for inclusion but then use the morphed grid with the generated cull pattern. But that does not seem to work at all. It gets somewhat close to where it is now but still is not correct.

Thanks in advance.

Views: 3196

Attachments:

Replies to This Discussion

Here's the code if too lazy to open file.

private void RunScript(List<Mesh> meshes, List<Point3d> points, ref object A)
{
List<bool> cullList = new List<bool>();

for(int i = 0; i < meshes.Count; i++)
{
bool inside = false;
foreach(Point3d pt in points)
{

if(meshes[i].IsPointInside(pt, 0.1, true) == true)
{
inside = true;
}
}

cullList.Add(inside);
}

A = cullList;

Can you simplify the definition so you don't need third party plugins?

Internalize data for everything except that part that is not working properly. If the file becomes very large, include only a subset of the geometry that still contains the error.

Sure, here is internalized points meshes. Morphed Cell Meshes is what I want to cull from, and Standard Cell Meshes is what I want to test for inclusion. But it currently only somewhat works when I test for the same set of meshes that I cull.

Attachments:

There seems to be a bug in the IsPointInside method.

I'm going to try to guess what is happening (It's likely I'm completely wrong):

This method gets the diagonal vector of the bounding box of the mesh and shoots a ray from the point in that direction. If the number of times the ray intersects with the mesh is odd, the point is inside.

In your case the point seems to be in the exact middle of the box and the mesh shape is the same as it's bounding box, meaning it intersects in exactly a corner. I guess this special case of intersecting exactly in a corner or edge might sometimes return an undesired number of intersections.

If you wiggle the points a bit you'll see it will work properly. Move them in two different axis so that the rays don't intersect on the edges.

In this particular case, though, you can just get the bounding box of each mesh and use the Contains method.

Your theory is interesting and had me temporarily excited. But I moved the points in the z and x directions and I got another different but still not correct result. I got practically no result when I used the bounding box and used Point in Brep, unless I misinterpreted what you meant by 'contains method.'

This is how I got it working.

You can call the Contains method from a scripting component, I don't think there is an equivalent Grasshopper component.

Something like:

bool isInside = mesh.GetBoundingBox().Contains(point);

Wonderful. Thank you, sir.

I've created a plugin that can ease up this usage. It only works for orthogonal grids, but it does not require any intersection. Its internal representation is a list of bits (storage is quite low, compared to mesh boxes). The output is a voxelgrid that can be converted to a closed mesh. (only the outer faces are shown). If your input is points it works pretty well.


See also this thread: http://www.grasshopper3d.com/forum/topics/mesh-bounding-box-clash-d...

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