Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

bbox_numpy to mesh.aabb method integration or Box class extra features

Aperta
#1,456 1 commento 0 reazioni 1 assegnatario Vedi su GitHub

@tomvanmele ci sta già lavorando.

Dal 10/4/2025.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

Feature Request

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:

  1. Boxes summing or union method
  2. Box surface area
  3. Box centroid

Solution Proposal
I'll paste some rough logic of what is supposed to happen

  1. 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"""
    if isinstance(box, SuperchargedBox):
        all_points = self.points + box.points
            return self.from_points(all_points)
    else:
        raise TypeError("Instances belong to different classes")
  1. Surface are calculations
def compute_surface_area(self):
        return (self.xsize * self.ysize + self.xsize * self.zsize + self.ysize * self.zsize) * 2
  1. Centroid
def centroid(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) / 2
        return Point(*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.

Lingua principale
Python
Stelle
387
Fork
124
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di compas-dev/compas

Tutte le issue di compas-dev/compas

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.