def fit_function(X, **fkwargs): print('X', X) mesh = fkwargs['mesh'] orders = [2] + [int(x) for x in X] mesh_2 = mesh.copy() walker = Walker(mesh_2) walker.start() print('orders', orders) out = walker.interpret_orders(orders) polyedge = walker.polyedge print('polyedge', polyedge) add_strip(mesh_2, polyedge) # if out == None: # fit_value = float('inf') fit_value = mesh_2.number_of_faces() return fit_value
def editing_topology(coarse_pseudo_quad_mesh): """Edit the topology of a pattern, i.e. its singularities, via its strips. Parameters ---------- coarse_pseudo_quad_mesh : CoarsePseudoQuadMesh The pattern to edit. """ while True: # update drawing rs.EnableRedraw(False) artist = rhino_artist.MeshArtist(coarse_pseudo_quad_mesh) guid = artist.draw_mesh() rs.EnableRedraw(True) # choose operation operation = rs.GetString('edit strip topology?', strings=['add', 'delete', 'split', 'exit']) # stop if asked if operation is None or operation == 'exit': rs.DeleteObject(guid) break # apply operation if operation == 'add': skey = add_strip(coarse_pseudo_quad_mesh, select_mesh_polyedge(coarse_pseudo_quad_mesh))[0] coarse_pseudo_quad_mesh.set_strip_density(skey, 1) elif operation == 'delete': skeys = set(select_quad_mesh_strips(coarse_pseudo_quad_mesh)) skey_to_skeys = delete_strips(coarse_pseudo_quad_mesh, skeys) if skey_to_skeys is not None: for skey_0, skeys in skey_to_skeys.items(): d = int( ceil( float( coarse_pseudo_quad_mesh.get_strip_density( skey_0)) / 2.)) coarse_pseudo_quad_mesh.set_strips_density(d, skeys) elif operation == 'split': skey = select_quad_mesh_strip(coarse_pseudo_quad_mesh) n = rs.GetInteger('number of splits', number=2, minimum=2) skeys = split_strip(coarse_pseudo_quad_mesh, skey, n=n) # update data d = int( ceil( float(coarse_pseudo_quad_mesh.get_strip_density(skey)) / float(n))) coarse_pseudo_quad_mesh.set_strips_density(d, skeys) # delete drawing rs.DeleteObject(guid)
def add_strip_toggle(self): if len(self.polyedge) == 0: self.polyedge.append(self.tail) else: self.added_polyedges.append(self.polyedge.copy()) old_vkeys_to_new_vkeys = add_strip(self.mesh, self.polyedge) self.head = old_vkeys_to_new_vkeys[self.tail][0] self.tail = old_vkeys_to_new_vkeys[self.tail][1] self.polyedge = []
def stop(self): add_strip(self.mesh, self. polyedge) self.added_polyedges.append(self.polyedge) self.polyedge = []