def __init__(self, coords=[],shifting=[], outer_box = [], sc = True): """bbox(coords:[float list, float list], shifting:float list, outer_box:[float list, float list], sc:bool). Creates a box given the coordinates of the lower-left and upper_right vertices. The box is shifted to the position shifting wrt the origin of coordinates system. If sc = False, the shift is wrt the centre of the box. """ mesh_obj.__init__(self) if coords == [] and shifting != []: # only shifting is given tmp0_list = [] tmp1_list = [] for i in range(len(shifting)): tmp0_list.append(0.0) tmp1_list.append(1.0) coords = [tmp0_list, tmp1_list] elif coords != [] and shifting == []: # only coords is given for i in range(len(coords[0])): shifting.append(0.0) elif coords == [] and shifting == []: # default: 2D tmp0_list = [] tmp1_list = [] for i in range(2): tmp0_list.append(0.0) tmp1_list.append(1.0) shifting.append(0.0) coords = [tmp0_list, tmp1_list] else: pass print "box" print coords, shifting if sc: # system coordinates self.obj.append(ocaml.body_shifted_sc(ocaml.body_box(coords[0],coords[1]),shifting)) else: # body coordinates self.obj.append(ocaml.body_shifted_bc(ocaml.body_box(coords[0],coords[1]),shifting)) min_coords = [] # create bounding box max_coords = [] for i in range(len(shifting)): if outer_box == []: min_coords.append(min(coords[0][i]+shifting[i],coords[1][i]+shifting[i])) max_coords.append(max(coords[0][i]+shifting[i],coords[1][i]+shifting[i])) else: min_coords.append(min(coords[0][i]+shifting[i],coords[1][i]+shifting[i], outer_box[0][i], outer_box[1][i])) max_coords.append(max(coords[0][i]+shifting[i],coords[1][i]+shifting[i],outer_box[0][i], outer_box[1][i])) self.bbox = [min_coords, max_coords] # update bounding box print "bbox" print self.bbox print "box.\n"
def __init__(self, coords, transform=[], fixed_points=[], sc = True): """box( coords:[float list, float list], transform:(string, transformation_data) list, fixed_points: float list list , sc:bool ). Creates a box given the coordinates of the lower-left and upper_right vertices. The box is transformed following the order of the transformations specified in the transform list. Calling ai (i = 1,2,...) the axis of the space where the object is defined, examples of these transformations are: - ("shift", [a1,a2,a3,..]) - ("scale", [a1,a2,a3,...]) - ("rotate", [a1,a2], phi) - ("rotate2d", phi) - ("rotate3d", [a1,a2,a3], phi) If sc = False the transformations are made wrt the body coordinates, wrt the system coordinates otherwise. """ dim = len(coords[0]) mesh_obj.__init__(self, dim, fixed_points) print "create box" self.obj = ocaml.body_box(coords[0],coords[1]) self.transformations(transform,sc)