| 110 | return values, sol_grads; |
| 111 | |
| 112 | def fit_into_unit_sphere(mesh): |
| 113 | bbox_min, bbox_max = mesh.bbox; |
| 114 | bbox_radius = numpy.linalg.norm(bbox_max - bbox_min) * 0.5; |
| 115 | bbox_center = 0.5 * (bbox_min + bbox_max); |
| 116 | if bbox_radius == 0.0: |
| 117 | raise IOError("Input mesh is degenerate to a single point."); |
| 118 | |
| 119 | vertices = mesh.vertices; |
| 120 | tris = mesh.faces; |
| 121 | tets = mesh.voxels; |
| 122 | vertices = (vertices - bbox_center) / bbox_radius; |
| 123 | return pymesh.form_mesh(vertices, tris, tets); |
| 124 | |
| 125 | def main(): |
| 126 | args = parse_args(); |