def decouple_outout_cutin_fn(outer_mesh, inner_mesh): from forward.mesh import (check_intersecting_fn, cut_inner_fn, decouple_outout_fn, clean_mesh_fn) intersections = check_intersecting_fn(outer_mesh, inner_mesh) while(intersections): outer_mesh = decouple_outout_fn(outer_mesh, inner_mesh) outer_mesh = cut_inner_fn(outer_mesh, inner_mesh) outer_mesh = clean_mesh_fn(outer_mesh) intersections = check_intersecting_fn(outer_mesh, inner_mesh) return outer_mesh
def decouple_ventricles_fn(ventricles, white_matter): from forward.mesh import (check_intersecting_fn, cut_outer_fn, decouple_inin_fn, clean_mesh_fn) intersections = check_intersecting_fn(white_matter, ventricles) while(intersections): ventricles = decouple_inin_fn(ventricles, white_matter) ventricles = cut_outer_fn(ventricles, white_matter) ventricles = clean_mesh_fn(ventricles) intersections = check_intersecting_fn(white_matter, ventricles) return ventricles
def decouple_input_from_GM_fn(mesh_file, gray_matter): from forward.mesh import (check_intersecting_fn, cut_outer_fn, decouple_outin_fn, clean_mesh_fn) intersections = check_intersecting_fn(gray_matter, mesh_file) while(intersections): mesh_file = decouple_outin_fn(mesh_file, gray_matter) mesh_file = cut_outer_fn(mesh_file, gray_matter) mesh_file = clean_mesh_fn(mesh_file) intersections = check_intersecting_fn(gray_matter, mesh_file) return mesh_file
def iter_decoupling_fn(outer_mesh, inner_mesh): from forward.mesh import (check_intersecting_fn, cut_inner_fn, decouple_outout_fn, clean_mesh_fn) intersections = check_intersecting_fn(outer_mesh, inner_mesh) while(intersections): for i in range(0, 3): intersections = check_intersecting_fn(outer_mesh, inner_mesh) if intersections: outer_mesh = decouple_outout_fn(outer_mesh, inner_mesh) else: break outer_mesh = cut_inner_fn(outer_mesh, inner_mesh) outer_mesh = clean_mesh_fn(outer_mesh) return outer_mesh
def iter_remove_throats_fn(outer_mesh, inner_mesh, iterations=5): # This function loops until there are no # intersections between two surfaces. # It cuts away the inner surface and # uses decouple_outout: # # "Treat 1st file as outer, 2nd file as inner component. ## "Resolve overlaps by moving outers triangles outwards." ## "Constrain the min distance between the components > d." # # and cut-inner: # ## "Remove triangles of 1st that are inside of the 2nd shell." ## "Dilate 2nd by d; Fill holes and keep only 1st afterwards." # # at each iteration. from forward.mesh import (check_intersecting_fn, decouple_and_cut_inner_fn) for i in range(0, iterations): intersections = check_intersecting_fn(outer_mesh, inner_mesh) if intersections: outer_mesh = decouple_and_cut_inner_fn(outer_mesh, inner_mesh) else: break return outer_mesh
def remove_spikes_fn(outer_mesh, inner_mesh): from forward.mesh import (check_intersecting_fn, cut_outer_fn, decouple_inin_fn, clean_mesh_fn) intersections = check_intersecting_fn(outer_mesh, inner_mesh) if intersections: inner_mesh = cut_outer_fn(inner_mesh, outer_mesh) inner_mesh = clean_mesh_fn(inner_mesh) for i in xrange(0, 3): intersections = check_intersecting_fn(outer_mesh, inner_mesh) if intersections: inner_mesh = decouple_inin_fn(inner_mesh, outer_mesh) inner_mesh = clean_mesh_fn(inner_mesh) else: break return inner_mesh
def iter_push_out_fn(outer_mesh, inner_mesh, iterations=5): # This function loops until there are no # intersections between two surfaces. # It cuts away the inner surface and # uses decouple_outout: # # "Treat 1st file as outer, 2nd file as inner component. ## "Resolve overlaps by moving outers triangles outwards." ## "Constrain the min distance between the components > d." # # at each iteration. from forward.mesh import (check_intersecting_fn, decouple_outout_fn) for i in range(0, iterations): intersecting = check_intersecting_fn(outer_mesh, inner_mesh) if intersecting: outer_mesh = decouple_outout_fn(outer_mesh, inner_mesh) else: break return outer_mesh
def decouple_surfaces_fn(outer_mesh, inner_mesh): # This function loops until outer_mesh and inner_mesh # have no intersections. # At each iteration it pushes outer_mesh out, cuts parts of # the inner_mesh away, and cleans the mesh. # The pushing out is also iterative. # from forward.mesh import ( iter_push_out_fn, check_intersecting_fn, cut_inner_fn, clean_mesh_fn) for i in range(0, 2): intersections = check_intersecting_fn(outer_mesh, inner_mesh) if intersections: outer_mesh = iter_push_out_fn(outer_mesh, inner_mesh, iterations=3) outer_mesh = cut_inner_fn(outer_mesh, inner_mesh) outer_mesh = clean_mesh_fn(outer_mesh) else: break return outer_mesh