def set_strip_density_target(self, skey, t): """Set the strip densities based on a target length and the average length of the strip edges. Parameters ---------- skey : hashable A strip key. t : float A target length. """ self.set_strip_density( skey, int( ceil( average([ self.edge_length(u, v) for u, v in self.strip_edges(skey) if u != v ]) / t)))
def face_curvature(self, fkey): """Dimensionless face curvature as the maximum face vertex deviation from the best-fit plane of the face vertices divided by the average lengths of the face vertices to the face centroid. Parameters ---------- fkey : Key The face key. Returns ------- float The dimensionless curvature. """ vertices = self.face_vertices(fkey) points = [self.vertex_coordinates(key) for key in vertices] centroid = self.face_centroid(fkey) plane = bestfit_plane(points) max_deviation = max([distance_point_plane(point, plane) for point in points]) average_distances = average([distance_point_point(point, centroid) for point in points]) return max_deviation / average_distances
mesh_2.collect_strips() #n1 > n2 n1, n2 = mesh_1.number_of_strips(), mesh_2.number_of_strips() print(n1, n2) t = [] for i in range(1): t0 = time.time() results = distance_and_deletion_rules_between_2_meshes(mesh_1, mesh_2) t1 = time.time() t.append(t1 - t0) n0 = n1 - len(results[0][1][mesh_1]) k = n2 - n0 d = results[0][0] nb_submeshes = len(results) dt = average(t) print(n1, n2, n0, k, d, nb_submeshes, dt) non_iso_submeshes = [] for result in results: submesh_1 = mesh_1.copy() strips_1 = result[1][mesh_1] delete_strips(submesh_1, strips_1) add = True for submesh in non_iso_submeshes: if are_meshes_isomorphic(submesh_1, submesh, boundary_edge_data=True): add = False break if add:
def evaluate_pattern(mesh): """Evaluate the properties of a mesh. Parameters ---------- mesh : Mesh The mesh to evaluate. """ while True: metric_type = rs.GetString('evaluate pattern property?', strings=['topology', 'geometry', 'exit']) if metric_type is None or metric_type == 'exit': break if metric_type == 'topology': metric = rs.GetString('evaluate topological property?', strings=['euler', 'genus', 'boundaries']) if metric == 'euler': print('euler: ', mesh.euler()) elif metric == 'genus': print('genus: ', mesh.genus()) elif metric == 'boundaries': print('boundaries: ', len(mesh.boundaries())) elif metric_type == 'geometry': metric = rs.GetString('evaluate geometrical property?', strings=[ 'edge_length', 'face_area', 'face_aspect_ratio', 'face_skewness', 'face_curvature', 'vertex_curvature' ]) aspect = rs.GetString('evaluate geometrical property?', strings=[ 'all', 'min', 'max', 'average', 'standard_deviation', 'specific' ]) if metric == 'edge_length': if aspect == 'specific': guids = rhino_helper.mesh_draw_edges(mesh) edges = rhino_helper.mesh_select_edges(mesh) rs.DeleteObjects(guids) print([mesh.edge_length(*edge) for edge in edges]) else: edge_lengths = [ mesh.edge_length(*edge) for edge in mesh.edges() ] if aspect == 'all': print(edge_lengths) elif aspect == 'min': print(min(edge_lengths)) elif aspect == 'max': print(max(edge_lengths)) elif aspect == 'average': print(average(edge_lengths)) elif aspect == 'standard_deviation': print(standard_deviation(edge_lengths))