You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bbox_numpy to mesh.aabb method integration or Box class extra features #1456
Hello everyone, I'd like to implement some extra features as a developer to Box so the mesh.aabb returns more flexible object. Ideal case would be a box that is fully based on numpy and represented simply as 2 diagonal points (2 numpy arrays). Maybe some flag could be added to mesh.aabb so we can choose which sort of a box we expect.
Details
Problem statement
I'm playing with compas_model bvh.from_meshes method and trying to implement bvh based on aabb nodes. To calculate parameters like SAH (Surface Are Heuristic) the following box methods are required:
Boxes summing or union method
Box surface area
Box centroid
Solution Proposal
I'll paste some rough logic of what is supposed to happen
add method or "union" which will allow to sum 2 instances of a Box class
def__add__(self, box):
"""Returns a 3D summary box that contains both of summed boxes"""ifisinstance(box, SuperchargedBox):
all_points=self.points+box.pointsreturnself.from_points(all_points)
else:
raiseTypeError("Instances belong to different classes")
defcentroid(self) ->Point:
"""Returns a Centroid of the Box"""arr_max=np.asarray([self.xmax, self.ymax, self.zmax])
arr_min=np.asarray([self.xmin, self.ymin, self.zmin])
res= (arr_max+arr_min) /2returnPoint(*res)
Alternatives
If the box is represented as 2 numpy arrays (2 points of the diagonal). So none of the extra calculations called on constructors methods. It'll also allow to make infinitely small box and infinitely big boxes for summing/union operations.
Also, as I mentioned, some sort of flexibility when making calling a mesh.aabb would be useful.
Mesh.aabb(numpy_box=True) ->bbox_numpy
Or these changes could be made in compas_model. I'd appreciate your feedback on these changes.
Activity
tomvanmele commentedon Apr 10, 2025
hi @2twenity
i will have a look at your proposal asap (probably not before early next week though)
best,
tom