def determineLatticeType(part_dict: dict) -> EnumType: """Guess the lattice type based on the sum of the vector distances between VHs and the closest lattice position. Args: part_dict: the ``dict`` corresponding to the part to be imported Returns: ``GridEnum.HONEYCOMB`` or ``GridEnum.SQUARE`` or ``GridEnum.NONE`` """ grid_type = part_dict.get('grid_type') if grid_type is not None: return grid_type vh_id_list = part_dict.get('vh_list') origins = part_dict.get('origins') square_delta_x = 0. square_delta_y = 0. honeycomb_delta_x = 0. honeycomb_delta_y = 0. for vh_id, _ in vh_id_list: vh_x, vh_y = origins[vh_id] hcd, honeycomb_guess_coordinates = HoneycombDnaPart.distanceFromClosestLatticeCoord( DEFAULT_RADIUS, vh_x, vh_y) sqd, square_guess_coordinates = SquareDnaPart.distanceFromClosestLatticeCoord( DEFAULT_RADIUS, vh_x, vh_y) honeycomb_guess_x, honeycomb_guess_y = HoneycombDnaPart.latticeCoordToQtXY( DEFAULT_RADIUS, honeycomb_guess_coordinates[0], honeycomb_guess_coordinates[1]) square_guess_x, square_guess_y = SquareDnaPart.latticeCoordToQtXY( DEFAULT_RADIUS, square_guess_coordinates[0], square_guess_coordinates[1]) honeycomb_delta_x += (vh_x - honeycomb_guess_x) honeycomb_delta_y += (vh_y - honeycomb_guess_y) square_delta_x += (vh_x - square_guess_x) square_delta_y += (vh_y - square_guess_y) sum_honeycomb_distance = (honeycomb_delta_x**2 + honeycomb_delta_y**2)**0.5 sum_square_distance = (square_delta_x**2 + square_delta_y**2)**0.5 if abs(sum_honeycomb_distance) < abs(sum_square_distance): return GridEnum.HONEYCOMB else: return GridEnum.SQUARE
def determineLatticeType(part_dict: dict) -> EnumType: """Guess the lattice type based on the sum of the vector distances between VHs and the closest lattice position. Args: part_dict: the ``dict`` corresponding to the part to be imported Returns: ``GridEnum.HONEYCOMB`` or ``GridEnum.SQUARE`` or ``GridEnum.NONE`` """ grid_type = part_dict.get('grid_type') if grid_type is not None: return grid_type vh_id_list = part_dict.get('vh_list') origins = part_dict.get('origins') square_delta_x = 0. square_delta_y = 0. honeycomb_delta_x = 0. honeycomb_delta_y = 0. for vh_id, _ in vh_id_list: vh_x, vh_y = origins[vh_id] hcd, honeycomb_guess_coordinates = HoneycombDnaPart.distanceFromClosestLatticeCoord(DEFAULT_RADIUS, vh_x, vh_y) sqd, square_guess_coordinates = SquareDnaPart.distanceFromClosestLatticeCoord(DEFAULT_RADIUS, vh_x, vh_y) honeycomb_guess_x, honeycomb_guess_y = HoneycombDnaPart.latticeCoordToQtXY(DEFAULT_RADIUS, honeycomb_guess_coordinates[0], honeycomb_guess_coordinates[1]) square_guess_x, square_guess_y = SquareDnaPart.latticeCoordToQtXY(DEFAULT_RADIUS, square_guess_coordinates[0], square_guess_coordinates[1]) honeycomb_delta_x += (vh_x - honeycomb_guess_x) honeycomb_delta_y += (vh_y - honeycomb_guess_y) square_delta_x += (vh_x - square_guess_x) square_delta_y += (vh_y - square_guess_y) sum_honeycomb_distance = (honeycomb_delta_x**2 + honeycomb_delta_y**2)**0.5 sum_square_distance = (square_delta_x**2 + square_delta_y**2)**0.5 if abs(sum_honeycomb_distance) < abs(sum_square_distance): return GridEnum.HONEYCOMB else: return GridEnum.SQUARE
def determineSliceViewType(document, part_dict, grid_type): THRESHOLD = 0.0005 vh_id_list = part_dict.get('vh_list') origins = part_dict.get('origins') for vh_id, size in vh_id_list: vh_x, vh_y = origins[vh_id] if grid_type is GridType.HONEYCOMB: distance, point = HoneycombDnaPart.distanceFromClosestLatticeCoord(vh_x, vh_y, DEFAULT_RADIUS) if distance > THRESHOLD: return SliceViewType.GRID elif grid_type is GridType.SQUARE: if SquareDnaPart.distanceFromClosestLatticeCoord(vh_x, vh_y, DEFAULT_RADIUS)[0] > THRESHOLD: return SliceViewType.GRID return SliceViewType.SLICE
def determineOrthoViewType(part_dict: dict, grid_type: EnumType): THRESHOLD = 0.0005 vh_id_list = part_dict.get('vh_list') origins = part_dict.get('origins') for vh_id, size in vh_id_list: vh_x, vh_y = origins[vh_id] if grid_type == GridEnum.HONEYCOMB: distance, point = HoneycombDnaPart.distanceFromClosestLatticeCoord( radius=DEFAULT_RADIUS, x=vh_x, y=vh_y) if distance > THRESHOLD: return OrthoViewEnum.GRID elif grid_type == GridEnum.SQUARE: if SquareDnaPart.distanceFromClosestLatticeCoord( radius=DEFAULT_RADIUS, x=vh_x, y=vh_y)[0] > THRESHOLD: return OrthoViewEnum.GRID return OrthoViewEnum.GRID