bugfixing contour scanner

This commit is contained in:
Mario Voigt 2022-11-07 23:45:00 +01:00
parent 1c9bd9e355
commit c13e2e2cff
5 changed files with 2817 additions and 2 deletions

View File

@ -0,0 +1,188 @@
<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<name>Contour Scanner And Trimmer</name>
<id>fablabchemnitz.de.contour_scanner_and_trimmer</id>
<param name="nb_main" type="notebook">
<page name="tab_settings_and_actions" gui-text="Settings and Actions">
<param name="nb_settings_and_actions" type="notebook">
<page name="tab_settings" gui-text="Settings">
<label appearance="header">General input/output</label>
<param name="show_debug" type="bool" gui-text="Show debug infos">false</param>
<param name="break_apart" type="bool" gui-text="Break apart input" gui-description="Break apart input paths into sub paths. Modifies original paths: converts to absolute paths and might create additional new path elements.">false</param>
<param name="handle_groups" type="bool" gui-text="Handle groups" gui-description="Also looks for paths in groups which are in the current selection. Note: The generated results have a different structure (less granularity due to grouping and conversion of absolute paths to relative paths) than directly selected paths. The colorization for non-intersected paths will be different too.">false</param>
<param name="flattenbezier" type="bool" gui-text="Quantization (flatten bezier curves to (poly)lines)" gui-description="Convert bezier curves to (poly)lines.">true</param>
<param name="flatness" type="float" min="0.001" max="99999.000" precision="3" gui-text="Flatness (tolerance)" gui-description="Minimum flatness = 0.001. The smaller the value the more fine segments you will get (quantization). Large values might destroy the line continuity (default: 0.1).">0.100</param>
<param name="decimals" type="int" min="0" max="16" gui-text="Decimals" gui-description="Accuracy for sub split lines / lines trimmed by shapely (default: 3)">3</param>
<param name="snap_tolerance" type="float" min="0.01" max="10.0" gui-text="Snap tolerance" gui-description="Snap tolerance for intersection points on paths (default: 0.1)">0.1</param>
<param name="collinear_filter_epsilon" type="float" min="0.000000001" max="1.0" precision="9" gui-text="Epsilon for collinear line filter" gui-description="default: 0.01">0.01</param>
<label appearance="header">General style</label>
<param name="strokewidth" min="0.0" max="10000.0" precision="3" gui-text="Stroke width (px)" gui-description="Applies For sub split lines and trimmed lines" type="float">1.0</param>
<param name="dotsize_intersections" type="int" min="0" max="10000" gui-text="Intersection dot size (px)" gui-description="For self-intersecting and global intersection points">30</param>
<param name="removefillsetstroke" type="bool" gui-text="Remove fill and define stroke" gui-description="Modifies original path style">false</param>
<param name="subsplit_style" type="optiongroup" appearance="combo" gui-text="Sub split line style">
<option value="default">Use default sub split style</option>
<option value="apply_from_highlightings">Apply highlighting styles</option>
<option value="apply_from_original">Apply original path styles</option>
</param>
<param name="trimmed_style" type="optiongroup" appearance="combo" gui-text="Trimmed line style">
<option value="apply_from_trimmed">Apply default trimming styles</option>
<option value="apply_from_original">Apply original path styles</option>
</param>
</page>
<page name="tab_removing" gui-text="Removing">
<label appearance="header">Applying to original paths and sub split lines</label>
<param name="remove_relative" type="bool" gui-text="relative cmd">false</param>
<param name="remove_absolute" type="bool" gui-text="absolute cmd">false</param>
<param name="remove_rel_abs_mixed" type="bool" gui-text="mixed rel/abs cmd" gui-description="combined relative and absolute">false</param>
<param name="remove_polylines" type="bool" gui-text="(poly)lines">false</param>
<param name="remove_beziers" type="bool" gui-text="beziers">false</param>
<param name="remove_poly_bez_mixed" type="bool" gui-text="mixed cmd (poly)line/bezier paths" gui-description="combined (poly)line and bezier">false</param>
<param name="remove_opened" type="bool" gui-text="opened">false</param>
<param name="remove_closed" type="bool" gui-text="closed">false</param>
<param name="remove_self_intersecting" type="bool" gui-text="self-intersecting">false</param>
<label appearance="header">Applying to sub split lines only</label>
<param name="filter_subsplit_collinear" type="bool" gui-text="Filter collinear overlapping lines" gui-description="Removes any duplicates by merging (multiple) overlapping line segments into longer lines. Not possible to apply for original paths because this routine does not support bezier type paths.">true</param>
<param name="filter_subsplit_collinear_action" type="optiongroup" appearance="combo" gui-text="What to do with collinear overlapping lines?">
<option value="remove">remove</option>
<option value="separate_group">put to separate group</option>
</param>
<label appearance="header">Applying to original paths only</label>
<param name="delete_original_after_split_trim" type="bool" gui-text="Delete original paths after sub splitting / trimming">false</param>
</page>
<page name="tab_highlighting" gui-text="Highlighting">
<label appearance="header">Applying to original paths and sub split lines</label>
<param name="highlight_relative" type="bool" gui-text="relative cmd">false</param>
<param name="highlight_absolute" type="bool" gui-text="absolute cmd">false</param>
<param name="highlight_rel_abs_mixed" type="bool" gui-text="mixed rel/abs cmd" gui-description="combined relative and absolute">false</param>
<param name="highlight_polylines" type="bool" gui-text="(poly)lines">false</param>
<param name="highlight_beziers" type="bool" gui-text="beziers">false</param>
<param name="highlight_poly_bez_mixed" type="bool" gui-text="mixed cmd (poly)line/bezier paths" gui-description="combined (poly)line and bezier">false</param>
<param name="highlight_opened" type="bool" gui-text="opened">false</param>
<param name="highlight_closed" type="bool" gui-text="closed">false</param>
<param name="highlight_self_intersecting" type="bool" gui-text="self-intersecting" gui-description="Requires enabled 'Draw sub split lines' option (will auto-enable). Will override other highlighting colors (if those options are enabled)">false</param>
<label appearance="header">Applying to sub split lines only</label>
<param name="draw_subsplit" type="bool" gui-text="Draw sub split lines" gui-description="Draws (poly)lines which are generated from all input paths">false</param>
<param name="highlight_duplicates" type="bool" gui-text="duplicates">false</param>
<param name="highlight_merges" type="bool" gui-text="merges" gui-description="Requires enabled 'Remove collinear overlapping lines' option (will auto-enable)">false</param>
<label appearance="header">Intersection points</label>
<param name="visualize_self_intersections" type="bool" gui-text="self-intersecting path points" gui-description="Will put into background (z-Index) by global intersection points and trimmed lines (if enabled)">false</param>
<param name="visualize_global_intersections" type="bool" gui-text="global intersection points" gui-description="Will also contain self-intersecting points! Global intersections will only show if 'Draw trimmed lines' is enabled!">false</param>
</page>
<page name="tab_trimming" gui-text="Trimming">
<label appearance="header">General trimming settings</label>
<param name="trimming_path_types" type="optiongroup" appearance="combo" gui-text="Trimming selection" gui-description="Process open paths by other open paths, closed paths by other closed paths, or all paths by all other paths. This selection does not apply for paths which intersect themselves!">
<option value="both">all:all paths</option>
<option value="open_paths">open:open paths</option>
<option value="closed_paths">closed:closed paths</option>
</param>
<param name="draw_trimmed" type="bool" gui-text="Draw trimmed lines">false</param>
<separator/>
<param name="combine_nonintersects" type="bool" gui-text="Chain + combine non-intersected lines" gui-description="This will colorize all paths segments which were not intersected ('non-intersected lines'). If the whole path was not intersected at all, it will get another color ('non-intersected paths').">true</param>
<param name="remove_trim_duplicates" type="bool" gui-text="Remove duplicate trim lines" gui-description="Has no effect if option 'Filter collinear overlapping lines' is enabled because duplicates get pre-filtered.">true</param>
<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>
</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" gui-description="Will automatically enable 'Show debug infos'">false</param>
<param name="bent_ott_use_paranoid" type="bool" gui-text="Paranoid checks">false</param>
<param name="bent_ott_use_vertical" type="bool" gui-text="Support vertical segments">true</param>
<param name="bent_ott_number_type" type="optiongroup" appearance="combo" gui-text="Number type">
<option value="native">native (default)</option>
<option value="numpy">numpy</option>
</param>
</page>
<page name="tab_colors" gui-text="Colors">
<hbox>
<vbox>
<label appearance="header">Sub split lines</label>
<param name="color_subsplit" type="color" appearance="colorbutton" gui-text="sub split lines">1630897151</param>
<label appearance="header">Path structure</label>
<param name="color_relative" type="color" appearance="colorbutton" gui-text="relative cmd paths">3419879935</param>
<param name="color_absolute" type="color" appearance="colorbutton" gui-text="absolute cmd paths">1592519679</param>
<param name="color_rel_abs_mixed" type="color" appearance="colorbutton" gui-text="mixed cmd rel/abs paths" gui-description="combined relative and absolute">3351636735</param>
<param name="color_polyline" type="color" appearance="colorbutton" gui-text="(poly)line paths">4289703935</param>
<param name="color_bezier" type="color" appearance="colorbutton" gui-text="bezier paths">258744063</param>
<param name="color_poly_bez_mixed" type="color" appearance="colorbutton" gui-text="mixed (poly)line/bezier paths" gui-description="combined (poly)line and bezier">4118348031</param>
<param name="color_opened" type="color" appearance="colorbutton" gui-text="opened paths">4012452351</param>
<param name="color_closed" type="color" appearance="colorbutton" gui-text="closed paths">2330080511</param>
</vbox>
<separator/>
<vbox>
<label appearance="header">Duplicates and merges</label>
<param name="color_duplicates" type="color" appearance="colorbutton" gui-text="duplicates" gui-description="Color for overlapping line segments / duplicated lines)">897901823</param>
<param name="color_merges" type="color" appearance="colorbutton" gui-text="merges" gui-description="Color for replaced merges">869366527</param>
<label appearance="header">Intersections</label>
<param name="color_self_intersecting_paths" type="color" appearance="colorbutton" gui-text="self-intersecting paths">2593756927</param>
<param name="color_self_intersections" type="color" appearance="colorbutton" gui-text="self-intersecting paths points">6320383</param>
<param name="color_global_intersections" type="color" appearance="colorbutton" gui-text="global intersection points">4239343359</param>
<label appearance="header">Trimming</label>
<param name="color_trimmed" type="color" appearance="colorbutton" gui-text="trimmed lines">3227634687</param>
<param name="color_combined" type="color" appearance="colorbutton" gui-text="non-intersected lines" gui-description="Colorize non-trimmed lines differently than the trimmed ones. Does not apply if 'Original style for trimmed lines' is enabled">1923076095</param>
<param name="color_nonintersected" type="color" appearance="colorbutton" gui-text="non-intersected paths" gui-description="Colorize the complete path in case it does not contain any trim. Does not apply if 'Original style for trimmed lines' is enabled">3045284607</param>
</vbox>
</hbox>
</page>
</param>
</page>
<page name="tab_tips" gui-text="Tips">
<label xml:space="preserve"> - Allows to separate different contour types by colors
- Finds overlapping / collinear / (self-)intersecting
(using Bentley-Ottmann algorithm) lines
- Works with paths which have Live Path Effects (LPE)
Tips:
- If nothings is selected, the whole document will be processed, regardless of groups. In contrast, if you made a custom selection, check to handle or not to handle groups.
- Convert your strokes and objects to paths before
- Does not work for clones. You will need to unlink them before
- Use extensions to filter short/unrequired paths
- Use extensions to purge or repair invalid paths
- Use 'Path > Simplify' or hit 'CTRL + L' to simplify the trimmed result. With a fine quantization setting the simplified paths will be nearly identical to the original path (except the position of control points)</label>
<label appearance="header">Do not select too much paths at once if you have got a fine settings for quantization. This extension is slow and might calculate hours on ultra high configurations.</label>
</page>
<page name="tab_about" gui-text="About">
<label appearance="header">Contour Scanner And Trimmer</label>
<label>A utility to scan, flatten, split and trim lines.</label>
<label>2020 - 2022 / written by Mario Voigt (Stadtfabrikanten e.V. / FabLab Chemnitz)</label>
<spacer/>
<label appearance="header">Online Documentation</label>
<label appearance="url">https://y.stadtfabrikanten.org/contourscannerandtrimmer</label>
<spacer/>
<label appearance="header">Contributing</label>
<label appearance="url">https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.X</label>
<label appearance="url">mailto:mario.voigt@stadtfabrikanten.org</label>
<spacer/>
<label appearance="header">Third Party Modules</label>
<label appearance="url">https://github.com/ideasman42/isect_segments-bentley_ottmann</label>
<label appearance="url">https://gist.github.com/sbma44/dc34e5005d9827aa7b1c8c11e68b0c6b</label>
<spacer/>
<label appearance="header">MightyScape Extension Collection</label>
<label>This piece of software is part of the MightyScape for Inkscape Extension Collection and is licensed under GNU GPL v3</label>
<label appearance="url">https://y.stadtfabrikanten.org/mightyscape-overview</label>
</page>
<page name="tab_donate" gui-text="Donate">
<label appearance="header">Coffee + Pizza</label>
<label>We are the Stadtfabrikanten, running the FabLab Chemnitz since 2016. A FabLab is an open workshop that gives people access to machines and digital tools like 3D printers, laser cutters and CNC milling machines.</label>
<spacer/>
<label>You like our work and want to support us? You can donate to our non-profit organization by different ways:</label>
<label appearance="url">https://y.stadtfabrikanten.org/donate</label>
<spacer/>
<label>Thanks for using our extension and helping us!</label>
<image>../000_about_fablabchemnitz.svg</image>
</page>
</param>
<effect needs-live-preview="true">
<object-type>all</object-type>
<effects-menu>
<submenu name="FabLab Chemnitz">
<submenu name="Paths - Cut/Intersect/Purge" />
</submenu>
</effects-menu>
</effect>
<script>
<command location="inx" interpreter="python">contour_scanner_and_trimmer.py</command>
</script>
</inkscape-extension>

View File

@ -0,0 +1,20 @@
[
{
"name": "Contour Scanner And Trimmer",
"id": "fablabchemnitz.de.contour_scanner_and_trimmer",
"path": "contour_scanner_and_trimmer",
"dependent_extensions": null,
"original_name": "Contour Scanner And Trimmer",
"original_id": "fablabchemnitz.de.contour_scanner_and_trimmer",
"license": "GNU GPL v3",
"license_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.X/src/branch/master/LICENSE",
"comment": "Written by Mario Voigt from scratch with a lot of help using other extensions as template",
"source_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.X/src/branch/master/extensions/fablabchemnitz/contour_scanner_and_trimmer",
"fork_url": null,
"documentation_url": "https://stadtfabrikanten.org/display/IFM/Contour+Scanner+And+Trimmer",
"inkscape_gallery_url": "https://inkscape.org/de/~MarioVoigt/%E2%98%85contour-scanner-and-trimmer",
"main_authors": [
"github.com/vmario89"
]
}
]

File diff suppressed because it is too large Load Diff

View File

@ -114,8 +114,8 @@ class inkpacking(inkex.EffectExtension):
box_id = self.svg.get_unique_id('box') box_id = self.svg.get_unique_id('box')
self.box = g = etree.SubElement(self.svg.get_current_layer(), 'g', {'id':box_id}) self.box = g = etree.SubElement(self.svg.get_current_layer(), 'g', {'id':box_id})
cut_line_style = str(inkex.Style(({ 'stroke': '#000000', 'fill': 'none', 'stroke-width':'0.3px' }))) cut_line_style = str(inkex.Style(({ 'stroke': '#000000', 'fill': 'none', 'stroke-width':'1px' })))
engrave_line_style = str(inkex.Style(({ 'stroke': '#ff0000', 'fill': 'none', 'stroke-width':'0.3px' }))) engrave_line_style = str(inkex.Style(({ 'stroke': '#ff0000', 'fill': 'none', 'stroke-width':'1px' })))
gflapoffy = (gflapsize / sin( (gflapangle / 360) * 6.28 )) * sin( ((90 - gflapangle) / 360 ) * 6.28) gflapoffy = (gflapsize / sin( (gflapangle / 360) * 6.28 )) * sin( ((90 - gflapangle) / 360 ) * 6.28)