Exemple #1
0
    def check_lengths(self, geometry: shapely.geometry.base.BaseGeometry,
                      kind: str, component_name: str, **other_options):
        """If user wants to fillet, check the line-segments to see if it is too
        short for fillet.

        Args:
            geometry (shapely.geometry.base.BaseGeometry): The LineString to investigate.
            kind (str): Name of table, i.e. 'path', 'poly', 'junction, etc
            component_name (str): Is an integer id.
        """

        if 'fillet' in other_options.keys():

            fillet = other_options['fillet']

            for key, geom in geometry.items():
                if isinstance(geom, shapely.geometry.LineString):
                    coords = list(geom.coords)
                    qdesign_precision = self.design.template_options.PRECISION
                    range_vertex_of_short_segments = get_range_of_vertex_to_not_fillet(
                        coords, fillet, qdesign_precision, add_endpoints=False)

                    if len(range_vertex_of_short_segments) > 0:
                        range_string = ""
                        for item in range_vertex_of_short_segments:

                            range_string += f'({ item[0]}-{item[1]}) '
                        text_id = self.design._components[component_name]._name
                        self.logger.warning(
                            f'For {kind} table, component={text_id}, key={key}'
                            f' has short segments that could cause issues with fillet. Values in {range_string} '
                            f'are index(es) in shapely geometry.')
 def test_utility_get_range_of_vertex_to_not_fillet(self):
     """Test functionality of get_range_of_vertex_to_not_fillet in
     utility_functions.py."""
     my_list = [(1, 1), (1, 2), (1, 2), (2, 2), (5, 5), (3, 2), (11, 11),
                (11, 11), (11, 21), (12, 21)]
     result = utility_functions.get_range_of_vertex_to_not_fillet(
         my_list, 0.25)
     self.assertEqual(result, [(0, 2), (6, 7)])
    def check_lengths(self, geometry: shapely.geometry.base.BaseGeometry,
                      kind: str, component_name: str, layer: Union[int, str],
                      chip: str, **other_options):
        """If user wants to fillet, check the line-segments to see if it is too
        short for fillet.

        Args:
            geometry (shapely.geometry.base.BaseGeometry): The LineString to investigate.
            kind (str): Name of table, i.e. 'path', 'poly', 'junction, etc
            component_name (str): Is an integer id.
            layer (Union[int, str]): Should be int, but getting a float, will cast to int when used.
            chip (str): Name of chip, i.e. 'main'.
        """

        if 'fillet' in other_options.keys():
            # fillet_scalar = 2.0    #Depreciated, moved to toolbox_python.utility_functions
            # fillet_comparison_precision = 9  # used for np.round #Depreciated, moved to toolbox_python.utility_functions

            # For now, don't let front end user edit this.
            # if 'fillet_comparison_precision' in other_options.keys():
            #     # The parse_value converts all ints to floats.
            #     fillet_comparison_precision = int(self.parse_value(
            #         other_options['fillet_comparison_precision']))

            # Depreciated, moved to toolbox_python.utility_functions
            # if 'fillet_scalar' in other_options.keys():
            #     fillet_scalar = self.parse_value(
            #         other_options['fillet_scalar'])

            fillet = other_options['fillet']

            for key, geom in geometry.items():
                if isinstance(geom, shapely.geometry.LineString):
                    coords = list(geom.coords)
                    qdesign_precision = self.design.template_options.PRECISION
                    range_vertex_of_short_segments = get_range_of_vertex_to_not_fillet(
                        coords, fillet, qdesign_precision, add_endpoints=False)

                    if len(range_vertex_of_short_segments) > 0:
                        range_string = ""
                        for item in range_vertex_of_short_segments:

                            range_string += f'({ item[0]}-{item[1]}) '
                        text_id = self.design._components[component_name]._name
                        self.logger.warning(
                            f'For {kind} table, component={text_id}, key={key}'
                            f' has short segments that could cause issues with fillet. Values in {range_string} '
                            f'are index(es) in shapley geometry.')