def shape_drain(): ''' output shape: TopoDS_Shape face_map: {TopoDS_Face: int} id_map: {TopoDS_Face: int} shape_name: '' ''' # print('shape_drain') random.seed() # step1, create the base base = shape_base_drain() # step2, create wires for holes wlist, wire_name = list_wire_random() # step3, add hole feature from wire shape, name_map, feat_name = shape_multiple_hole_feats(base, wlist) shape_name = feat_name + '-' + wire_name fid = 0 fset = occ_utils.list_face(shape) id_map = {} for shape_face in fset: id_map[shape_face] = fid fid += 1 return shape, name_map, id_map, shape_name
def map_from_shape_and_name(fmap, old_map, new_shape, new_name): ''' input fmap: {TopoDS_Face: TopoDS_Face}, old_map: {TopoDS_Face: int} new_shape: TopoDS_Shape new_name: string output new_map: {TopoDS_Face: int} ''' new_map = {} new_faces = occ_utils.list_face(new_shape) for oldf in fmap: old_name = old_map[oldf] for samef in fmap[oldf]: samef = same_shape_in_list(samef, new_faces) if samef is None: print('no same face') continue new_map[samef] = old_name new_faces.remove(samef) for n_face in new_faces: new_map[n_face] = new_name return new_map
def map_face_before_and_after_feat(base, feature_maker): ''' input base: TopoDS_Shape feature_maker: BRepFeat_MakePrism output fmap: {TopoDS_Face:TopoDS_Face} ''' fmap = {} base_faces = occ_utils.list_face(base) for face in base_faces: if feature_maker.IsDeleted(face): continue fmap[face] = [] modified = feature_maker.Modified(face) if modified.IsEmpty(): fmap[face].append(face) continue occ_it = TopTools_ListIteratorOfListOfShape(modified) while occ_it.More(): a_shape = occ_it.Value() assert a_shape.ShapeType() == TopAbs_FACE fmap[face].append(topods.Face(a_shape)) occ_it.Next() return fmap
def map_from_name(shape, name): ''' input shape: TopoDS_Shape name: string output name_map: {TopoDS_Face: int} ''' name_map = {} faces = occ_utils.list_face(shape) for one_face in faces: name_map[one_face] = name return name_map
def face_bottom(shape): ''' input s: TopoDS_Shape output f: TopoDS_Face ''' f_list = occ_utils.list_face(shape) face = None for face in f_list: normal = occ_utils.normal_to_face_center(face) if normal.IsEqual(DRAIN_RCS.Direction(), 0.01): break return face