()
| 15 | return parser.parse_args(); |
| 16 | |
| 17 | def main(): |
| 18 | args = parse_args(); |
| 19 | # Config 0 Config 1 Config 2 Config 3 |
| 20 | # 1 +----+ 2 3 +----+ 2 1 +----+ 0 3 + + 0 |
| 21 | # | | | | | | |
| 22 | # 0 + + 3 0 +----+ 1 2 +----+ 3 2 +----+ 1 |
| 23 | configs = np.array([ |
| 24 | [[0, 3],[1, 2]], |
| 25 | [[0, 1],[3, 2]], |
| 26 | [[2, 3],[1, 0]], |
| 27 | [[2, 1],[3, 0]] ], dtype=int); |
| 28 | config_transform = np.array([ |
| 29 | [1, 0, 0, 2], |
| 30 | [0, 1, 1, 3], |
| 31 | [3, 2, 2, 0], |
| 32 | [2, 3, 3, 1] ], dtype=int); |
| 33 | |
| 34 | pts = np.zeros((4**args.resolution, 2)); |
| 35 | |
| 36 | for x in range(2**args.resolution): |
| 37 | for y in range(2**args.resolution): |
| 38 | X = x; |
| 39 | Y = y; |
| 40 | p = np.copy([x,y]); |
| 41 | quadrant = 0; |
| 42 | index = 0; |
| 43 | for order in range(args.resolution): |
| 44 | exp = args.resolution-order-1; |
| 45 | mask = 1 << exp; |
| 46 | step = 2**(args.resolution-order-1); |
| 47 | i = (X & mask) >> exp; |
| 48 | j = (Y & mask) >> exp; |
| 49 | local_index = configs[quadrant][i][j]; |
| 50 | quadrant = config_transform[quadrant][local_index]; |
| 51 | index += local_index * step*step; |
| 52 | X >> 1; |
| 53 | Y >> 1; |
| 54 | pts[index,:] = p; |
| 55 | |
| 56 | vertices = np.array(pts); |
| 57 | edges = np.array([[i, i+1] for i in range(4**args.resolution - 1)]); |
| 58 | wires = pymesh.wires.WireNetwork.create_from_data(vertices, edges); |
| 59 | wires.write_to_file("tmp.obj"); |
| 60 | inflator = pymesh.wires.Inflator(wires); |
| 61 | inflator.inflate(0.2); |
| 62 | |
| 63 | mesh = inflator.mesh; |
| 64 | pymesh.save_mesh(args.output_mesh, mesh); |
| 65 | |
| 66 | if __name__ == "__main__": |
| 67 | main(); |
no test coverage detected