def copy(self): new_obj = mesh.mesh_obj() # create new object new_obj.obj = self.obj[:] # update new object new_obj.bbox[0] = self.bbox[0][:] # update bounding box new_obj.bbox[1] = self.bbox[1][:] # print new_obj.bbox return new_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
def unite(self,other): """unite( obj ). Function to take the union of the mesh object obj with the present object. """ new_obj = mesh.mesh_obj() # create new object for other_obj in other.obj: for obj in self.obj: new_obj.obj.append(ocaml.body_union([obj,other_obj])) for i in range(len(self.bbox[0])): # update bounding box new_obj.bbox[0] = self.bbox[0][:] new_obj.bbox[1] = self.bbox[1][:] # print new_obj.bbox return new_obj
def __mul__(self, other): import Numeric new_obj = mesh.mesh_obj() # create new object new_obj.obj = self.obj[:] # copy current object 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]) if type(other) == type(0) and other >= 1: # add another object for times in range(1,other): shift_list = list(times*Numeric.array(self.shifting)) tmp_obj = self.copy() tmp_obj.shift(shifting=shift_list) for add_obj in tmp_obj.obj: new_obj.obj.append(add_obj) else: raise TypeError('Cannot handle type') return new_obj
def __add__(self, other): """(+). Function to add an object or shift the present object """ new_obj = mesh.mesh_obj() # create new object new_obj.obj = self.obj[:] # copy current object 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]) if type(other) == type([0.0,0.0]): # shift the new object new_obj.shift(shifting=other) elif type(other.obj[0]) == type(self.obj[0]):# add another object for other_obj in other.obj: # update new object new_obj.obj.append(other_obj) else: raise TypeError('Cannot handle type') return new_obj