Grasshopper

algorithmic modeling for Rhino

hello everybody,

how can i identify a brep rhinoObject as box in grasshopper? is there a comparable

command to rhinoscripts isBox()? i didn't find anything like that

Views: 835

Replies to This Discussion

Weird box I got here:

Come on, lighten up.

This might work. Check for 6 faces, get the bounding box aligned to the first face, and check if the volume is equal to the volume of the boundingbox.


bool IsBrep (Brep x)
{
if (!(x.Faces.Count == 6))
{
return false;
}

// check for faces
Brep face = x.Faces[0].DuplicateFace(false);
if (!(face.Vertices.Count == 4))
{
return false;
}

// check volume
Plane pln = new Plane(face.Vertices[0].Location, face.Vertices[1].Location, face.Vertices[2].Location);
Box b = new Box(pln, x);

// 3d degree root of the tolerance - since we're doing volumes
double tolerance = Math.Pow(RhinoDocument.ModelAbsoluteTolerance, (1.0 / 3.0));
return RhinoMath.EpsilonEquals(b.Volume, x.GetVolume(), tolerance);
}

Yep, that's basically what Rhinoscript's IsBox(obj) function is doing:

https://github.com/mcneel/rhinoscript/blob/master/IsBox.rvb

It also checks for planar surfaces but I don't think is necessary (maybe to skip when possible calculating the brep volume?). It also gets the bbox orientation by creating a surface frame rather than with 3 corner points (I don't think it matters).

The IsBox function uses the default tolerance. Why are you square rooting the tolerance? Shouldn't be larger rather than smaller? (to the power of 3).

 

cube rooting i mean

ah, that's a nice link. like a dictonary rhinoscribt to vbscribt

I think checking for planar surfaces can be a good thing - calculating volume can become quite expensive, when it's not really a cube, checking planarity should be cheap.

Hmm, the math on the tolerance is still tricky, I agree. But cubing it is also not a solution right? If there's a tolerance of 0.01^3 = 0.0001, while any deviation on one axis would give quite a big difference.

Any ideas?

Maybe cube root the volumes and compare them to the normal tolerance.

thank you guys.

i tried to do it by my own, but failed because of my bad vb.net knowledge...

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