示例#1
0
    def __add__(self, other):
        """(+).

        Function to unite an object or shift the present object 
        """

        if type(other) == types.ListType:                 # shift the new object
            shift = other
            new_obj = mesh_objects.mesh_obj(self.dim)     # create new object
            new_obj.obj = self.obj                        # copy present object in the new one
            new_obj.shift(shifting=shift)                 # update new object
            return new_obj
            
        elif type(other.obj) == type(self.obj):           # unite the new object to the present one
            other_obj = other
            new_obj = mesh_objects.mesh_obj(self.dim)     # create new object
            new_obj.obj = self.obj                        # copy present object in the new one
            new_obj.unite(other_obj)                          # update new object
            return new_obj
                
        else:
            raise TypeError, "Cannot handle object type"
示例#2
0
    def __sub__(self, obj):
        """ (-).

        Function to take the difference between two objects
        """

        try:
            if type(obj.obj) == type(self.obj):
                other_obj = obj
        except:
            raise TypeError("Type mismatch for object difference")
            
        new_obj = mesh_objects.mesh_obj(self.dim)         # create new object
        new_obj.obj = self.obj                            # update new object 
        new_obj.difference(other_obj)          
        return new_obj