kopia lustrzana https://github.com/inkstitch/inkstitch
remove constants
rodzic
672bded125
commit
469c32a497
|
@ -1,52 +0,0 @@
|
|||
import math
|
||||
|
||||
# Used in the simplify routine of shapely
|
||||
simplification_threshold = 0.01
|
||||
|
||||
# If a line segment is shorter than this threshold it is handled as a single point
|
||||
line_lengh_seen_as_one_point = 0.05
|
||||
|
||||
# E.g. to check whether a point is already present in a point list,
|
||||
# the point is allowed to be this value in distance apart
|
||||
point_spacing_to_be_considered_equal = 0.05
|
||||
|
||||
# Adjacent geometry should have points closer than
|
||||
# offset*offset_factor_for_adjacent_geometry to be considered adjacent
|
||||
offset_factor_for_adjacent_geometry = 1.5
|
||||
|
||||
# Transfer point distance is used for projecting points from already
|
||||
# rastered geometry to adjacent geometry
|
||||
# (max spacing transfer_point_distance_factor*offset)
|
||||
# to get a more regular pattern
|
||||
transfer_point_distance_factor = 1.5
|
||||
|
||||
# Used to handle numerical inaccuracies during comparisons
|
||||
eps = 1e-3
|
||||
|
||||
# When entering and leaving a child from a parent we introduce an offset of
|
||||
# abs_offset*factor_offset_starting_points
|
||||
# so that entering and leaving points are not lying above each other.
|
||||
factor_offset_starting_points = 0.5
|
||||
|
||||
# if points are closer than abs_offset*factor_offset_remove_points one of it is removed
|
||||
factor_offset_remove_points = 0.5
|
||||
|
||||
# decides whether the point belongs to a hard edge (must use this point during sampling)
|
||||
# or soft edge (do not necessarily need to use this point)
|
||||
limiting_angle = math.pi * 15 / 180.0
|
||||
|
||||
# angles straighter (smaller) than this are considered as more or less straight
|
||||
# (no concrete edges required for path segments having only angles <= this value)
|
||||
limiting_angle_straight = math.pi * 0.5 / 180.0
|
||||
|
||||
# if a point distance to the connected line of its two neighbors is smaller than
|
||||
# abs_offset times this factor, this point will be removed if the stitching distance will not be exceeded
|
||||
factor_offset_remove_dense_points = 0.2
|
||||
|
||||
# if a soft edge is closer to a forbidden point than abs_offset*this factor it will be marked as forbidden.
|
||||
factor_offset_forbidden_point = 1.0
|
||||
|
||||
# usually overnext projected points are preferred.
|
||||
# If an overnext projected point would create a much smaller segment than a direct
|
||||
# projected point we might prefer the direct projected point
|
||||
factor_segment_length_direct_preferred_over_overnext = 0.5
|
|
@ -10,9 +10,7 @@ from shapely.ops import nearest_points
|
|||
from shapely.ops import polygonize
|
||||
|
||||
from .running_stitch import running_stitch
|
||||
from ..i18n import _
|
||||
from ..stitch_plan import Stitch
|
||||
from ..stitches import constants
|
||||
from ..utils import DotDict
|
||||
from ..utils.geometry import cut, reverse_line_string, roll_linear_ring
|
||||
from ..utils.geometry import ensure_geometry_collection, ensure_multi_polygon
|
||||
|
@ -48,9 +46,8 @@ nearest_neighbor_tuple = namedtuple(
|
|||
def _offset_linear_ring(ring, offset, resolution, join_style, mitre_limit):
|
||||
result = Polygon(ring).buffer(-offset, resolution, cap_style=2, join_style=join_style, mitre_limit=mitre_limit, single_sided=True)
|
||||
result = ensure_multi_polygon(result)
|
||||
|
||||
rings = GeometryCollection([poly.exterior for poly in result.geoms])
|
||||
rings = rings.simplify(constants.simplification_threshold, False)
|
||||
rings = rings.simplify(0.01, False)
|
||||
|
||||
return _take_only_valid_linear_rings(rings)
|
||||
|
||||
|
@ -197,7 +194,6 @@ def _convert_polygon_to_nodes(tree, polygon, parent_polygon, child_holes):
|
|||
if polygon.area < 0.1:
|
||||
return None, None
|
||||
|
||||
polygon = polygon.simplify(constants.simplification_threshold, False)
|
||||
valid_rings = _take_only_valid_linear_rings(polygon.exterior)
|
||||
|
||||
try:
|
||||
|
@ -257,8 +253,7 @@ def _get_nearest_points_closer_than_thresh(travel_line, next_line, threshold):
|
|||
return nearest_points(parent_point, next_line)
|
||||
|
||||
|
||||
def _create_nearest_points_list(
|
||||
travel_line, tree, children, threshold, threshold_hard):
|
||||
def _create_nearest_points_list(travel_line, tree, children, threshold, threshold_hard):
|
||||
"""Determine the best place to enter each of parent's children
|
||||
|
||||
Arguments:
|
||||
|
@ -297,8 +292,7 @@ def _create_nearest_points_list(
|
|||
return children_nearest_points
|
||||
|
||||
|
||||
def _find_path_inner_to_outer(tree, node, offset, starting_point,
|
||||
avoid_self_crossing, forward=True):
|
||||
def _find_path_inner_to_outer(tree, node, offset, starting_point, avoid_self_crossing, forward=True):
|
||||
"""Find a stitch path for this ring and its children.
|
||||
|
||||
Strategy: A connection from parent to child is made as fast as possible to
|
||||
|
@ -338,8 +332,8 @@ def _find_path_inner_to_outer(tree, node, offset, starting_point,
|
|||
current_ring,
|
||||
tree,
|
||||
tree[node],
|
||||
constants.offset_factor_for_adjacent_geometry * offset,
|
||||
2.05 * offset
|
||||
threshold=1.5 * offset,
|
||||
threshold_hard=2.05 * offset
|
||||
)
|
||||
nearest_points_list.sort(key=lambda tup: tup.proj_distance_parent)
|
||||
|
||||
|
@ -451,7 +445,7 @@ def _interpolate_linear_rings(ring1, ring2, max_stitch_length, start=None):
|
|||
points = (ring1_resampled * (1.0 - weights)) + (ring2_resampled * weights)
|
||||
result = LineString(points)
|
||||
|
||||
return result.simplify(constants.simplification_threshold, False)
|
||||
return result.simplify(0.1, False)
|
||||
|
||||
|
||||
def _check_and_prepare_tree_for_valid_spiral(tree):
|
||||
|
|
Ładowanie…
Reference in New Issue