Check if Breps are "Box-like"

Hi all,

Is there a quick way to check some Breps and test if they are “Box-like” or not?

Interestingly, all the box operations in GH seem to apply to the bounding box of the object and not the object itself so even a sphere will give you a box and not an error if you plug it into Deconstruct Box for example… I defined “box” strictly as one whose volume is equal to the product of its edge lengths ( I used face areas actually), so this will only work on items whose edges are at right angles. You can see it doesn’t work on the truncated pyramid, which would be defined as a box in Box Morph for example.

IsBox.gh (130.3 KB)

1 Like

Count vertices on faces? If not equal to four, reject it.

Seems some of those shapes would still yield 4 vertices.

Untitled

Without your geometry to examine, how would I know?

3. Attach minimal versions of all the relevant files

It’s not my geometry. Was just going off the image posted by OP.

Oh, sorry. Still, without examining the geometry myself, I don’t know if my suggestion will fail.

Sorry Joseph I was in a rush hour … below is the file.

What I did was Bounding Box all the Breps at same plane and compare the volume, if not equal then not a box.

This just something came up to my mind quickly, should add “test if solid” “test if 6 faces” and more.

Yet I got like 300 or more breps need to be tested, Bounding Box or Deconstruct Brep these just slow down the whole thing … Hope there’s something like Is Box


box (1).gh (1.3 MB)

I was thinking similarly on my way home :slight_smile:

So you already solved this, great! If all your breps are oriented in ‘World XY’, the code can be simplified:


box_test_2021_Aug4a.gh (1.3 MB)

Counting vertices works for all but two cases. As @ftzuk pointed out, this shape has eight vertices but is not a box.


Oh, here’s an idea that works. Boxes will have at most three different edge lengths.


box_test_2021_Aug4c.gh (1.3 MB)

Edge lengths are rounded to three decimal places.

I’ll add something to RhinoCommon to make this process easier.

https://mcneel.myjetbrains.com/youtrack/issue/RH-65178

– Dale

1 Like

I thought it would be clever to require eight vertices AND no more than three unique edge lengths, but then immediately thought of a shape to fool it. White group generates a ‘Closed Brep’ with eight vertices and only two unique edge lengths (could be only one one) and passes my crude box test.


box_test_2021_Aug4d.gh (20.1 KB)

So your code comparing brep volume to bounding box volume is the most reliable today. Well done.

I would check if the Brep faces have 3 pairs with the same area… Or as an alternative if there are 3 pairs of (co-)linear normal vectors (dot product is 0). Also all 6 face have to be planar.

1 Like

Or whether each face is planar and has a single parallel neighbouring face.

1 Like

You are a wise man (with a good taste on classic Vettes).


2 Likes

I still didn’t manage to buy the corresponding (black) fighter jet… But I’m working hard!

1 Like

The method by @akilli still works in this case.

1 Like

Haven’t seen he hasn’t proposed the same. However, I believe using the dot of the face normal is more efficient than computing the area. (at least if this hasn’t been done before). But then you also need to check the edge tangents or the edge angles to be 90 degrees. Maybe its worth to compare. Checking Surface.IsPlanar() is probably costly as well, so I would rather skip that out before even calling this method. I think the order of operation is important to make it quick. The more you can de-compose the early you can filter out.

Rather the YF22 option of things (i.e. Areas, Normals, Angles etc etc).

Brep_FindBoxLikeBreps_V1.3dm (928.6 KB)
Brep_FindBoxLikeBreps_V1.gh (124.1 KB)

Plan B: if there’s a shortage of millions around … what about a used AH64? (kill and enjoy the good old way).