Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
svandenb-dev committed Jul 24, 2024
2 parents 6065327 + e2a49a0 commit a62b8f8
Show file tree
Hide file tree
Showing 6 changed files with 1,265 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/pyedb/dotnet/edb_core/edb_data/layer_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,9 @@ def name(self, name):
layer_clone.SetName(name)
self._pedb.stackup._set_layout_stackup(layer_clone, "change_name", self._name)
self._name = name
for padstack_def in list(self._pedb.padstacks.definitions.values()):
padstack_def._update_layer_names(old_name=old_name, updated_name=name)
if self.type == "signal":
for padstack_def in list(self._pedb.padstacks.definitions.values()):
padstack_def._update_layer_names(old_name=old_name, updated_name=name)

@property
def type(self):
Expand Down
3 changes: 2 additions & 1 deletion src/pyedb/dotnet/edb_core/stackup.py
Original file line number Diff line number Diff line change
Expand Up @@ -1838,7 +1838,8 @@ def _import_dict(self, json_dict, rename=False):
for lay_ind in range(len(list(temp.keys()))):
if not config_file_layers[lay_ind] == layout_layers[lay_ind]:
renamed_layers[layout_layers[lay_ind]] = config_file_layers[lay_ind]
for name in list(self.stackup_layers.keys()):
layers_names = list(self.stackup_layers.keys())[::]
for name in layers_names:
layer = None
if name in temp:
layer = temp[name]
Expand Down
32 changes: 29 additions & 3 deletions src/pyedb/modeler/geometry_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -2019,7 +2019,7 @@ def mirror_point(start, reference, vector): # pragma: no cover

@staticmethod
def find_points_along_lines(
points, minimum_number_of_points=3, distance_threshold=None, return_additional_info=False
points, minimum_number_of_points=3, distance_threshold=None, selected_angles=None, return_additional_info=False
):
"""Detect all points that are placed along lines.
Expand All @@ -2040,6 +2040,15 @@ def find_points_along_lines(
distance_threshold : float, None, optional
If two points in a line are separated by a distance larger than `distance_threshold`,
the line is divided in two parts. Default is ``None``, in which case the control is not performed.
selected_angles : list, None, optional
Specify a list of angles in degrees. If specified, the method returns only the lines which
have one of the specified angles.
The angle is defined as the positive angle of the infinite line with respect to the x-axis
It is positive, and between 0 and 180 degrees.
For example, ``[90]`` indicated vertical lines parallel to the y-axis,
``[0]`` or ``[180]`` identifies horizontal lines parallel to the x-axis,
``45`` identifies lines parallel to the first quadrant bisector.
Default is ``None``, in which case all lines are returned.
return_additional_info : bool, optional
Whether to return additional information about the number of elements processed.
The default is ``True``.
Expand All @@ -2062,6 +2071,11 @@ def find_points_along_lines(
# Parameters
min_num_points = max(3, int(minimum_number_of_points))
cluster_lines_flag = False if distance_threshold is None else True
if selected_angles is not None:
if 0 in selected_angles or 180 in selected_angles:
selected_angles.extend([0, 180])
selected_angles = set(selected_angles)
selected_angles = np.deg2rad(np.array(list(selected_angles)))
tol_rad = 1e-10

# Converts the input
Expand All @@ -2087,7 +2101,9 @@ def find_points_along_lines(

# Calculate the angle in radians with the x-axis
angle_rad = np.arctan2(dy, dx)
if angle_rad < 0:
if abs(angle_rad - np.pi) < tol_rad:
angles[i].append(0.0)
elif angle_rad < 0:
angles[i].append(angle_rad + np.pi)
else:
angles[i].append(angle_rad)
Expand Down Expand Up @@ -2118,8 +2134,18 @@ def bin_float(value, bin_size):
# this two points already belong to a line, no need to store them again
continue
new_lines[angle].update((i, j))

# Depending on user choice, it checks if the angle is among the desired angles
if selected_angles is not None:
selected_lines = []
for ang, v in new_lines.items():
if any(abs(sa - ang) < tol_rad for sa in selected_angles):
selected_lines.append(v)
else:
selected_lines = [l for l in new_lines.values()]

# considering only lines with at least 3 points
lines_to_add = [l for l in new_lines.values() if len(l) >= 3]
lines_to_add = [l for l in selected_lines if len(l) >= 3]
detected_lines_idx.extend(lines_to_add)

# Discard the lines with less than min_num_points
Expand Down
Loading

0 comments on commit a62b8f8

Please sign in to comment.