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)
Count vertices on faces? If not equal to four, reject it.
Seems some of those shapes would still yield 4 vertices.
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
I was thinking similarly on my way home
So you already solved this, great! If all your breps are oriented in ‘World XY’, the code can be simplified:
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.
Edge lengths are rounded to three decimal places.
I’ll add something to RhinoCommon to make this process easier.
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.
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.
Or whether each face is planar and has a single parallel neighbouring face.
I still didn’t manage to buy the corresponding (black) fighter jet… But I’m working hard!
The method by @akilli still works in this case.
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.