(model, name, element)
| 26 | |
| 27 | |
| 28 | def get_element_data(model, name, element): |
| 29 | if element["geometry_type"] == "Edge": |
| 30 | for i, cell_block in enumerate(model.cells): |
| 31 | if cell_block.type == "line": |
| 32 | cell_tags = model.cell_data["cell_tags"][i] |
| 33 | break |
| 34 | rows = [] |
| 35 | for i_row, i in enumerate(cell_tags): |
| 36 | if i == 0: |
| 37 | continue |
| 38 | tags = model.cell_tags[i] |
| 39 | for tag in tags: |
| 40 | if tag == name: |
| 41 | # print(i_row, i) |
| 42 | rows.append(i_row) |
| 43 | break |
| 44 | |
| 45 | points = list(set(flatten([cell_block.data[c] for c in rows]))) |
| 46 | points.sort(key=lambda p: np.linalg.norm(model.points[p] - np.array(element["origin"]))) |
| 47 | coords = [np.round(model.points[p], 4).tolist() for p in points] |
| 48 | local_coords = [ |
| 49 | [float(round(np.linalg.norm(model.points[p] - np.array(element["origin"])), 4))] for p in points |
| 50 | ] |
| 51 | |
| 52 | return { |
| 53 | "name": name, |
| 54 | "points": points, |
| 55 | "coords": coords, |
| 56 | "local_coords": local_coords, |
| 57 | } |
| 58 | |
| 59 | elif element["geometry_type"] == "Face": |
| 60 | triangle_cell_tags = None |
| 61 | quad_cell_tags = None |
| 62 | for i, cell_block in enumerate(model.cells): |
| 63 | if cell_block.type == "triangle": |
| 64 | triangle_cell_tags = model.cell_data["cell_tags"][i] |
| 65 | break |
| 66 | |
| 67 | if triangle_cell_tags is not None: |
| 68 | rows = [] |
| 69 | for i_row, i in enumerate(triangle_cell_tags): |
| 70 | if i == 0: |
| 71 | continue |
| 72 | tags = model.cell_tags[i] |
| 73 | for tag in tags: |
| 74 | if tag == name: |
| 75 | # print(i_row, i) |
| 76 | rows.append(i_row) |
| 77 | break |
| 78 | if not len(rows): |
| 79 | points = [] |
| 80 | else: |
| 81 | points = list(flatten([cell_block.data[c] for c in rows])) |
| 82 | |
| 83 | for i, cell_block in enumerate(model.cells): |
| 84 | if cell_block.type == "quad": |
| 85 | quad_cell_tags = model.cell_data["cell_tags"][i] |
no test coverage detected