def calc_center(product, ifcfile): productIfc = ifcfile.by_id(product.pid) try: productShape = get_shape(productIfc) center = Common.center_boundingbox(productShape) pnt = Pnt(X=center.Coord()[0], Y=center.Coord()[1], Z=center.Coord()[2]) pnt.save() product.center.add(pnt) product.save() except: pass
def get_centre_bbox(occtopology): """ This function calculates the centre of the bounding box of the OCCtopology. Parameters ---------- occtopology : OCCtopology The OCCtopology to be analysed. OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex Returns ------- centre point : pypt The centre point of the OCCtopology's bounding box. """ occ_midpt = Common.center_boundingbox(occtopology) return (occ_midpt.X(), occ_midpt.Y(), occ_midpt.Z())
def get_centre_bbox(occ_shape): occ_midpt = Common.center_boundingbox(occ_shape) return (occ_midpt.X(), occ_midpt.Y(), occ_midpt.Z())