def subtract(self,obj): """subtract( obj ). Function to take the difference between the present object and the object obj. The present object is updated in-place. """ try: if type(obj.obj) == type(self.obj): other_obj = obj except: raise TypeError("Type mismatch for object difference") self.obj = ocaml.body_difference(self.obj,[other_obj.obj])
def __sub__(self, other): """ (-). Function to take the difference between two objects """ new_obj = mesh.mesh_obj() # create new object for sub_obj in other.obj: for obj in self.obj: new_obj.obj.append( ocaml.body_difference(obj,[sub_obj])) for i in range(len(self.bbox[0])): # update bounding box new_obj.bbox[0].append(self.bbox[0][i]) new_obj.bbox[1].append(self.bbox[1][i]) return new_obj