Merge branch 'master' of https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.X
This commit is contained in:
commit
15d697b272
@ -42,10 +42,10 @@ class ApplyTransformations(inkex.EffectExtension):
|
||||
style = element.attrib.get('style')
|
||||
style = dict(Style.parse_str(style))
|
||||
update = False
|
||||
|
||||
if 'stroke-width' in style:
|
||||
try:
|
||||
stroke_width = float(style.get('stroke-width').strip().replace("px", ""))
|
||||
#stroke_width = float(style.get('stroke-width').strip().replace("px", ""))
|
||||
stroke_width = self.svg.uutounit(style.get('stroke-width').strip())
|
||||
stroke_width *= math.sqrt(abs(transf.a * transf.d))
|
||||
style['stroke-width'] = str(stroke_width)
|
||||
update = True
|
||||
|
@ -81,7 +81,9 @@
|
||||
<param name="reverse_trim_removal_order" type="bool" gui-text="Reverse trim line removal order" gui-description="Reverses the order of removal. Relevant for keeping certain styles of elements">false</param>
|
||||
<param name="remove_subsplit_after_trimming" type="bool" gui-text="Remove sub split lines after trimming" gui-description="Recommended if option 'Filter collinear overlapping lines' is enabled">true</param>
|
||||
<param name="bezier_trimming" type="bool" gui-text="Trim original beziers (not working yet)" gui-description="If enabled we try to split the original bezier paths at the intersections points by finding the correct bezier segments and calculating t parameters from trimmed sub split lines. Not working yet. Will just print debug info if debug is enabled.">true</param>
|
||||
<label appearance="header">Bentley-Ottmann sweep line settings</label>
|
||||
</page>
|
||||
<page name="tab_bentleyottmann" gui-text="Bentley-Ottmann">
|
||||
<label appearance="header">Sweep line settings</label>
|
||||
<param name="bent_ott_use_ignore_segment_endings" type="bool" gui-text="Ignore segment endings" gui-description="Whether to ignore intersections of line segments when both their end points form the intersection point">true</param>
|
||||
<param name="bent_ott_use_debug" type="bool" gui-text="Debug">false</param>
|
||||
<param name="bent_ott_use_verbose" type="bool" gui-text="Verbose">false</param>
|
||||
|
@ -845,6 +845,32 @@ class ContourScannerAndTrimmer(inkex.EffectExtension):
|
||||
selfIntersectingPathStyle = {'stroke': str(so.color_self_intersecting_paths), 'fill': 'none', 'stroke-width': so.strokewidth}
|
||||
basicSubSplitLineStyle = {'stroke': str(so.color_subsplit), 'fill': 'none', 'stroke-width': so.strokewidth}
|
||||
|
||||
#some config for Bentley Ottmann - applies to highlighting, removing, trimming
|
||||
poly_point_isect.USE_IGNORE_SEGMENT_ENDINGS = so.bent_ott_use_ignore_segment_endings
|
||||
poly_point_isect.USE_DEBUG = so.bent_ott_use_debug
|
||||
poly_point_isect.USE_VERBOSE = so.bent_ott_use_verbose
|
||||
if so.show_debug is False:
|
||||
poly_point_isect.USE_VERBOSE = False
|
||||
poly_point_isect.USE_PARANOID = so.bent_ott_use_paranoid
|
||||
poly_point_isect.USE_VERTICAL = so.bent_ott_use_vertical
|
||||
NUMBER_TYPE = so.bent_ott_number_type
|
||||
if NUMBER_TYPE == 'native':
|
||||
Real = float
|
||||
NUM_EPS = Real("1e-10")
|
||||
NUM_INF = Real(float("inf"))
|
||||
elif NUMBER_TYPE == 'numpy':
|
||||
import numpy
|
||||
Real = numpy.float64
|
||||
del numpy
|
||||
NUM_EPS = Real("1e-10")
|
||||
NUM_INF = Real(float("inf"))
|
||||
poly_point_isect.Real = Real
|
||||
poly_point_isect.NUM_EPS = NUM_EPS
|
||||
poly_point_isect.NUM_INF = NUM_INF
|
||||
poly_point_isect.NUM_EPS_SQ = NUM_EPS * NUM_EPS
|
||||
poly_point_isect.NUM_ZERO = Real(0.0)
|
||||
poly_point_isect.NUM_ONE = Real(1.0)
|
||||
|
||||
#get all paths which are within selection or in document and generate sub split lines
|
||||
pathElements = self.get_path_elements()
|
||||
|
||||
@ -1021,25 +1047,26 @@ class ContourScannerAndTrimmer(inkex.EffectExtension):
|
||||
|
||||
#check for self intersections using Bentley-Ottmann algorithm.
|
||||
isSelfIntersecting = False
|
||||
selfIntersectionPoints = isect_segments(subSplitLines, validate=True)
|
||||
if len(selfIntersectionPoints) > 0:
|
||||
isSelfIntersecting = True
|
||||
if so.show_debug is True:
|
||||
self.msg("{} in {} intersects itself with {} intersections!".format(subSplitId, originalPathId, len(selfIntersectionPoints)))
|
||||
if so.highlight_self_intersecting is True:
|
||||
for subSplitLine in subSplitLineGroup:
|
||||
subSplitLine.style = selfIntersectingPathStyle #adjusts line color
|
||||
#delete cosmetic sub split lines if desired
|
||||
if so.remove_self_intersecting:
|
||||
subSplitLineGroup.delete()
|
||||
if so.visualize_self_intersections is True: #draw points (circles)
|
||||
selfIntersectionGroup = self.visualize_self_intersections(pathElement, selfIntersectionPoints)
|
||||
if so.highlight_self_intersecting is True or so.remove_self_intersecting or so.visualize_self_intersections:
|
||||
selfIntersectionPoints = isect_segments(subSplitLines, validate=True)
|
||||
if len(selfIntersectionPoints) > 0:
|
||||
isSelfIntersecting = True
|
||||
if so.show_debug is True:
|
||||
self.msg("{} in {} intersects itself with {} intersections!".format(subSplitId, originalPathId, len(selfIntersectionPoints)))
|
||||
if so.highlight_self_intersecting is True:
|
||||
for subSplitLine in subSplitLineGroup:
|
||||
subSplitLine.style = selfIntersectingPathStyle #adjusts line color
|
||||
#delete cosmetic sub split lines if desired
|
||||
if so.remove_self_intersecting:
|
||||
subSplitLineGroup.delete()
|
||||
if so.visualize_self_intersections is True: #draw points (circles)
|
||||
selfIntersectionGroup = self.visualize_self_intersections(pathElement, selfIntersectionPoints)
|
||||
|
||||
#delete self-intersecting sub split lines and orginal paths
|
||||
if so.remove_self_intersecting:
|
||||
subSplitLineArray = subSplitLineArray[:len(subSplitLineArray) - len(segs) - 1] #remove all last added lines
|
||||
pathElement.delete() #and finally delete the orginal path
|
||||
continue
|
||||
#delete self-intersecting sub split lines and orginal paths
|
||||
if so.remove_self_intersecting:
|
||||
subSplitLineArray = subSplitLineArray[:len(subSplitLineArray) - len(segs) - 1] #remove all last added lines
|
||||
pathElement.delete() #and finally delete the orginal path
|
||||
continue
|
||||
|
||||
#adjust the style of original paths if desired. Has influence to the finally trimmed lines style results too!
|
||||
if so.removefillsetstroke is True:
|
||||
@ -1169,33 +1196,6 @@ class ContourScannerAndTrimmer(inkex.EffectExtension):
|
||||
'''
|
||||
if so.draw_trimmed is True:
|
||||
try:
|
||||
#some config for Bentley Ottmann
|
||||
poly_point_isect.USE_IGNORE_SEGMENT_ENDINGS = so.bent_ott_use_ignore_segment_endings
|
||||
poly_point_isect.USE_DEBUG = so.bent_ott_use_debug
|
||||
poly_point_isect.USE_VERBOSE = so.bent_ott_use_verbose
|
||||
if so.show_debug is False:
|
||||
poly_point_isect.USE_VERBOSE = False
|
||||
poly_point_isect.USE_PARANOID = so.bent_ott_use_paranoid
|
||||
poly_point_isect.USE_VERTICAL = so.bent_ott_use_vertical
|
||||
NUMBER_TYPE = so.bent_ott_number_type
|
||||
if NUMBER_TYPE == 'native':
|
||||
Real = float
|
||||
NUM_EPS = Real("1e-10")
|
||||
NUM_INF = Real(float("inf"))
|
||||
elif NUMBER_TYPE == 'numpy':
|
||||
import numpy
|
||||
Real = numpy.float64
|
||||
del numpy
|
||||
NUM_EPS = Real("1e-10")
|
||||
NUM_INF = Real(float("inf"))
|
||||
poly_point_isect.Real = Real
|
||||
poly_point_isect.NUM_EPS = NUM_EPS
|
||||
poly_point_isect.NUM_INF = NUM_INF
|
||||
poly_point_isect.NUM_EPS_SQ = NUM_EPS * NUM_EPS
|
||||
poly_point_isect.NUM_ZERO = Real(0.0)
|
||||
poly_point_isect.NUM_ONE = Real(1.0)
|
||||
|
||||
|
||||
allSubSplitLineStrings = []
|
||||
allSubSplitLineStringsTransformed = []
|
||||
for subSplitLine in subSplitLineArray:
|
||||
|
Reference in New Issue
Block a user