MCPcopy Create free account
hub / github.com/PyMesh/PyMesh / repousse_all

Function repousse_all

scripts/repousse.py:278–321  ·  view source on GitHub ↗
(mesh, logger)

Source from the content-addressed store, hash-verified

276 return mesh;
277
278def repousse_all(mesh, logger):
279 cell_ids = mesh.get_attribute("cell").ravel().astype(int);
280 mesh.add_attribute("edge_length");
281 tol = np.amax(mesh.get_attribute("edge_length")) * 0.1;
282
283 out_mesh, info = pymesh.remove_degenerated_triangles(mesh, 100);
284 cell_ids = cell_ids[info["ori_face_indices"]].ravel();
285 mesh, info = pymesh.split_long_edges(out_mesh, tol);
286 cell_ids = cell_ids[info["ori_face_indices"]].ravel();
287
288 mesh.enable_connectivity();
289 is_border = [len(np.unique(cell_ids[mesh.get_vertex_adjacent_faces(vi)])) > 1
290 for vi in range(mesh.num_vertices)];
291
292 start_time = time();
293 dof = mesh.num_vertices;
294 assembler = pymesh.Assembler(mesh);
295 L = assembler.assemble("laplacian");
296 M = assembler.assemble("mass");
297
298 L_rhs = M * np.ones(dof) * -1 * 1e-1;
299 bd_indices = np.arange(mesh.num_vertices, dtype=int)[is_border];
300 n = len(bd_indices);
301 C = scipy.sparse.coo_matrix((np.ones(n),
302 (np.arange(n, dtype=int), bd_indices)), shape=(n, dof));
303 C_rhs = np.zeros(n);
304
305 A = scipy.sparse.bmat([
306 [-L, C.T],
307 [C, None]
308 ]);
309 rhs = np.concatenate((L_rhs.ravel(), C_rhs));
310
311 solver = pymesh.SparseSolver.create("SparseLU");
312 solver.compute(A);
313 x = solver.solve(rhs);
314 z = x[:dof].reshape((-1, 1));
315 vertices = np.hstack((mesh.vertices, z));
316
317 finish_time = time();
318 t = finish_time - start_time;
319 logger.info("Repousse running time: {}".format(t));
320
321 return pymesh.form_mesh(vertices, mesh.faces);
322
323def repousse(mesh, logger):
324 cell_ids = mesh.get_attribute("cell").ravel().astype(int);

Callers

nothing calls this directly

Calls 10

assembleMethod · 0.95
split_long_edgesMethod · 0.80
get_attributeMethod · 0.45
add_attributeMethod · 0.45
enable_connectivityMethod · 0.45
createMethod · 0.45
computeMethod · 0.45
solveMethod · 0.45
form_meshMethod · 0.45

Tested by

no test coverage detected