I often use SVG-imported beziers to create the geometry, and frequently I have problems with self-intersecting bezier curves.
Most of the problems I can spot and correct in Inkscape (after many minutes of staring at the curves in full zoom-in), but I wish there was a way to do this automatically though, because if it feels like a tedious, repetitive task that could be automated (and optionally human-inspected afterwards).
It's generally this kind of thing - overly stretched bezier handles that result in loops in the path (Inkscape screenshots):
I usually have to do this:
1. Add points on the edge of the loop
2. Reset the inner handles
This sometimes distorts the curve, because the outer handles get affected as well (not sure how to prevent that) but it solves the self-intersection.
I sometimes have to do this many many times, so I wonder if it could be automated somehow. Also sometimes there are errors reported that I can't see while manually inspecting the curves in Inkscape (before importing to FreeCAD).
What do you think?
Auto-fix bezier self-intersections
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
Be nice to others! Read the FreeCAD code of conduct!
Auto-fix bezier self-intersections
Last edited by unfa on Fri Feb 10, 2017 12:10 pm, edited 1 time in total.
- microelly2
- Veteran
- Posts: 4688
- Joined: Tue Nov 12, 2013 4:06 pm
- Contact:
Re: Auto-fix bezier self-intersections
Self intersection of a wire can be at least approximatly detected, so a solution should be possible.
this can be a workaround for some side effects of the offset tool too.
this can be a workaround for some side effects of the offset tool too.
Re: Auto-fix bezier self-intersections
wires have a fix() function that fixes these self-intersections (it cutts the wire into two loops)
- microelly2
- Veteran
- Posts: 4688
- Joined: Tue Nov 12, 2013 4:06 pm
- Contact:
Re: Auto-fix bezier self-intersections
Can you give an example how to use it to repair a wire?yorik wrote:wires have a fix() function that fixes these self-intersections (it cutts the wire into two loops)
- Attachments
-
- bp_365.png (2.99 KiB) Viewed 2677 times
Re: Auto-fix bezier self-intersections
I used it in ArchStructure.py like this (I found that these settings work for me)
The parameters are (prec, mintol, maxtol), I think they come from https://dev.opencascade.org/doc/refman/ ... rance.html
Also, the fix() function works with any shape, not only wire)
Code: Select all
wire.fix(0.1,0,1)
Also, the fix() function works with any shape, not only wire)
Re: Auto-fix bezier self-intersections
Is there a GUI way to fix the shapes?
I'm not to savvy with the Python console.
Maybe something like "Fix errors" in the Part/Check geometry tool would be nice.
I often find myself in trouble when importing freeform shapes from Inkscape - the geometry fails when I try to perform any Boolean operation.
Can there be a way to fix these problems? Maybe show the user exact verticies that are causing trouble and give an option to remove them?
Sometimes my shapes work fine (when they are clean, non-processed paths), sometimes (when I use dynamic offset tool in Inkscape or create paths using bitmap tracing) I have a ton of errors, and most of them I can't even see in Inkscape - what is strange the paths work ok for part extrusion, but fail when doing Booleans. What can I do about this?
I'm not to savvy with the Python console.
Maybe something like "Fix errors" in the Part/Check geometry tool would be nice.
I often find myself in trouble when importing freeform shapes from Inkscape - the geometry fails when I try to perform any Boolean operation.
Can there be a way to fix these problems? Maybe show the user exact verticies that are causing trouble and give an option to remove them?
Sometimes my shapes work fine (when they are clean, non-processed paths), sometimes (when I use dynamic offset tool in Inkscape or create paths using bitmap tracing) I have a ton of errors, and most of them I can't even see in Inkscape - what is strange the paths work ok for part extrusion, but fail when doing Booleans. What can I do about this?