Commit Graph

395 Commits

Author SHA1 Message Date
Jeff Young 9cb6df9c38 Don't crash on empty SHAPE_LINE_CHAINs.
Fixes https://gitlab.com/kicad/code/kicad/issues/12407

(cherry picked from commit fc74de81fb)
2022-09-28 13:30:04 +01:00
Seth Hillbrand b324abefe5 Handle cases where Simplify removes all outlines
This could theoretically happen for a fully degenerate polygon

Fixes https://gitlab.com/kicad/code/kicad/issues/12120

(cherry picked from commit 5a37211fdb)
2022-09-06 10:42:02 -07:00
Seth Hillbrand 70b69af313 Hide cursor while warping on Wayland
Based on https://gitlab.freedesktop.org/xorg/xserver/-/issues/734 we
hide the window cursor prior to warping, which allows XWayland to
reposition the cursor.  This is only performed when Wayland is detected;
all other configurations call the standard warp routine

Fixes https://gitlab.com/kicad/code/kicad/issues/9785

(cherry picked from commit a118f20464)
2022-09-06 10:13:40 -07:00
Roberto Fernandez Bautista f92d25e00b Fix SHAPE_LINE_CHAIN::Simplify() when there are only 3 points in the chain
We weren't updating m_shapes properly.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/11695

(cherry picked from commit 1fa1b44d02)
2022-08-19 20:58:28 +01:00
Seth Hillbrand 675a5a6e7b Fix simplify routine
The change in c9c31fcbc2 missed a number of cases.  This reverts back to
the system as it existed before 2be352b9f9
but using the revised method of determining A-B-C distance and avoiding
resizing the arrays
2022-08-01 09:48:29 -07:00
Seth Hillbrand c9c31fcbc2 Don't resize vectors in hot loops
Fixes a slowdown caused by erasing elements from the middle of a vector
during a hot loop in SHAPE_LINE_CHAIN::Simplify().  This gets called
quite a bit when loading boards and updating lines, so it needs to be as
fast as possible

Fixes https://gitlab.com/kicad/code/kicad/issues/12115
2022-07-31 12:48:25 -07:00
Alex ee4e4d0773 Don't recalculate constants at every call in isqrt.
(cherry picked from commit 27869b1a37)
2022-07-29 08:55:43 -07:00
Seth Hillbrand df9cf0a0c3 Fix crash in PNS walkaround
Placing via in walkaround mode and colliding with an arc triggered an
unneeded assertion.

Also fixes the bad assertion format that did not receive strings
2022-07-28 09:36:31 -07:00
Alex 6d26e8e3e8 math: Use intrinsic functions for 64-bit rescale on MSVC.
(cherry picked from commit c107abe247)
2022-07-16 18:05:35 +00:00
Seth Hillbrand 95fcf53353 Handle basic rounding error in schematic import
The fractional part of Altium schematic units is an integer number of
1/10000 mil segments, which is 2.54 nm.  The internal unit of eeschema
is 10 nm, so each fractional unit in Altium is 0.254 base eeschema
units.  To be consistent with
cf33cfcad1
we round to the nearest 10nm for each element

Fixes https://gitlab.com/kicad/code/kicad/issues/11742

(cherry picked from commit 6fef054c51)
2022-07-07 11:14:25 -07:00
Tomasz Wlostowski 2be352b9f9 geometry: more robust colinearity test in SHAPE_LINE_CHAIN::Simplify()
We now test the midpoint (B) of the 3 consecutive polyline points (A, B, C), since (assuming the angle between AB and BC is > 90 degrees) AC is always longer than
AB or BC. This minimizes the distance computation rounding error (in the previous algorithm, taking the point C for colineraity test) if AB is short and BC is very long, the test would
often fail due to rouding error in projection/line distance computation


(cherry picked from commit 3aed13278d)
2022-06-08 16:13:15 +00:00
Tomasz Wlostowski 8afb8190af geometry: use dedicated 64-bit integer square root for distance computations
Guarantees 1 LSB error, while the C++ double type has 55 mantissa bits (meaning for sqrt(X) >~ 2^22.5) the error is not guaranteed.


(cherry picked from commit e6ebc2b9b9)
2022-06-08 16:12:59 +00:00
Seth Hillbrand 2c2f69d05c Initialize area check
Ensure that the max_poly set is zero before using

(cherry picked from commit 2a9d7314ca)
2022-05-26 08:20:15 -07:00
Seth Hillbrand 1fe956c069 Handle hand-drawn holes in unfracture
We can't know that all holes will be ccw when entering unfracture.
Instead, we set the largest polyline to be the outline and the others to
be the holes.
2022-05-25 13:19:07 -07:00
jean-pierre charras c07ac8b3db Gerbview: seriously speed up the calculation time to draw polygons on OpenGL.
Mainly CacheTriangulation() was creating triangles using partition mode.
But this mode is optimized for Pcbnew and Gerbview and different internal units.
Now CacheTriangulation() is used in no partition, much faster in GERBVIEW_PAINTER.
From Master branch
2022-05-13 18:33:53 +02:00
dsa-t fdfe5a813e Clamp cursor to limits of coordinates representation
Also improves large distance handling.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/8846

(cherry picked from commit 68655540eb)
2022-04-04 13:38:50 -07:00
Seth Hillbrand 207820e112 Avoid duplicate points in trapezoid pads
Duplicate points can be either positive-facing or negative facing, so
test absolutes

Fixes https://gitlab.com/kicad/code/kicad/issues/11025
2022-03-22 13:30:22 -07:00
Jeff Young 0070a4686e Cherry-pick the short-arc-is-really-a-segment fix from master.
Fixes https://gitlab.com/kicad/code/kicad/issues/11119
2022-03-16 15:15:15 +00:00
Jeff Young 53bd87d792 Performance fixes for the board from hell....
(cherry picked from commit e4b56ab7f1)
2022-03-16 15:14:51 +00:00
jean-pierre charras 70514be11f Fix CMakeLists.txt syntax error and msys2 compatibility. 2022-03-13 12:50:26 +01:00
Marek Roszko 7558dad915 Don't use the ANSI version of SetDllDirectory 2022-03-12 21:45:14 -05:00
Marek Roszko 5e9b982ddf Plant the ability to verify code signing signatures when trying to load kifaces
Off by default and intended for use in released builds only
2022-03-12 21:44:36 -05:00
Marek Roszko 17539a564e Two very minor win32 calls to lock down dll/exe search paths from cwd 2022-03-12 15:47:48 -05:00
Marek Roszko ae01dc8ef1 Set SetErrorMode on Debug build
(cherry picked from commit d3ca857af7)
2022-03-12 01:57:45 +00:00
Marek Roszko 2874688281 Set some error flags for win32
(cherry picked from commit afaff022d7)
2022-03-11 01:17:50 +00:00
Seth Hillbrand 9ca35cbcee Rework of a24cdcb3f0
Inflate with linked holes needs to account for fractured polygons,
otherwise inflating with positive value will create rounded divots where
overlapping fracture lines meet and inflating with negative value will
create spaces between fracture lines.

Calling Simplify before Inflate takes an inordinate amount of time as
the Clipper healing routine is rather slow.  Our own Unfracture is meant
to heal the results of our Fracture routine and works much more quickly.
After healing, we still call the Simplify routine
2022-03-10 09:14:13 -08:00
Seth Hillbrand a24cdcb3f0 Always return simplified polygons
Clipper can handle complex input polygons but we will sometimes struggle
dealing with outputs from the inflate routine that have degenerate or
overlapping points.  Calling Simplify after the inflate keeps our
polygons easier to handle

Fixes https://gitlab.com/kicad/code/kicad/issues/11036
2022-03-09 16:19:15 -08:00
Seth Hillbrand a940607524 Adds uncertainty propagation to center point calc
Since we use center points to move back and forth for angle and
adjustments, we want to ensure that our center point is stable.

Rounding using integers introduces a 0.5 int uncertainty in each
measurement.  These are combined together multiple times to calculate
the center point, which combines the uncertainty.  Propagating the
uncertainty to the final calculation allows us to assign a range of true
values and pick the value that is most likely the correct value.

Fixes https://gitlab.com/kicad/code/kicad/issues/10739

(cherry picked from commit ed7222b1e7)
2022-03-08 10:34:41 -08:00
Tomasz Wlostowski 680163f8a8 Cherry-pick commits from Master and about SVG import:
*Fixes in the SVG import polygon postprocessing:
- don't drop subsequent polys when a non-filled primitive is imported 'in between'
- fix missing holes (also related to the interleaving of stroke and filled shapes, depending on the software that wrote the SVG file)

*GRAPHICS_IMPORTER_BUFFER: forgot to store the indices of the paths belonging to a compound shape

*pcbnew: GRAPHICS_IMPORTER can now recognize multi-path shapes (and postprocess polygons with holes into Kicad-compatible fractured polysets)

*SHAPE_POLY_SET: polysets can now be built from a bunch of arbitraily ordered oriented outlines.
Used by the SVG hole support

*SVG_IMPORT_PLUGIN: enable postprocessing of polygons with degeneracy and holes

*pcbnew: SVG importer support for even-odd fill rule
2022-02-21 10:50:05 +01:00
Jeff Young 9c48707c88 For Coverity. 2022-02-17 14:30:47 +00:00
Jeff Young ff21a16f7d Formatting. 2022-02-17 14:30:47 +00:00
Wayne Stambaugh 54f91a0221 Wide characterize libs and bitmap2component source. 2022-02-09 09:01:53 -05:00
Seth Hillbrand 8fc831cbc2 Validate arc output when editing
Handles checking output of the arc to ensure we don't end up generating
an invalid arc.  Also keeps the limit of the arc angle to be (360,360)
excluding 0.

Fixes https://gitlab.com/kicad/code/kicad/issues/10070
2022-02-06 17:18:04 -08:00
Alex 73d0d7796c Allow overlay scrolling on GTK, except for GAL canvases.
This prevents glitches when both scrollbars
are visible and scrolling to the end.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/10559

Fixes https://gitlab.com/kicad/code/kicad/-/issues/9988

(cherry picked from commit 4c4089e836)
2022-01-31 15:43:31 -05:00
Seth Hillbrand 857683d372 Remove unneeded distance calc 2022-01-18 15:58:20 -08:00
Marek Roszko 1e05732f55 Add std::hash specialization for VECTOR2I
(cherry picked from commit 589a03afcd)

Fixes https://gitlab.com/kicad/code/kicad/issues/10275
2022-01-05 20:32:46 -08:00
Jeff Young 1b033d56a7 Improve clean up tracks & vias algorithm for neck-downs.
Fixes https://gitlab.com/kicad/code/kicad/issues/10098

(cherry picked from commit d5a5928e5a)
2021-12-23 17:01:39 +00:00
Roberto Fernandez Bautista 4de4347baa SHAPE_ARC::Collide( aSeg ) must check segment end points as candidates
The edge case is when the segment is completely contained inside the arc
(This partially reverts b4835c8208 and
adds the missing test cases)
2021-12-14 16:14:56 +00:00
Roberto Fernandez Bautista b4835c8208 Add test case for SHAPE_ARC::Collide( seg ) + remove unneeded candidates
Followup to commit 01068e0d41
2021-12-13 18:06:11 +00:00
Seth Hillbrand 1b1bf8a17b Better handling of escaped characters in STEP parser
Fixes https://gitlab.com/kicad/code/kicad/issues/9897
2021-12-08 15:55:42 -08:00
Tomasz Wlostowski 01068e0d41 geometry: fix SHAPE_ARC/SEG collision
The arc2segment collision should at also include the arc endpoint projections on the segment being tested. Not sure it covers all possible cases, though.

Fixes: https://gitlab.com/kicad/code/kicad/-/issues/9023
2021-12-09 00:37:58 +01:00
jean-pierre charras 0dad504e91 POLY_GRID_PARTITION: detect a divide by 0, set a wxASSERT and avoid the crash. 2021-12-08 16:07:11 +01:00
Roberto Fernandez Bautista 2d1ad52212 SHAPE_LINE_CHAIN: Fix arc indices rotation after merging duplicate points
Fixes https://gitlab.com/kicad/code/kicad/-/issues/9843
2021-12-05 15:12:09 +00:00
Roberto Fernandez Bautista c463818b57 SHAPE_LINE_CHAIN: Only fix up arc indices if last pt is part of an arc
Fixes https://gitlab.com/kicad/code/kicad/-/issues/9843
2021-12-03 22:04:55 +00:00
Jon Evans 0570c22732 Use point collision test for zero-length segments
SEG::SquaredDistance( SEG& ) does not do the right thing
for segments with zero length at the moment.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/9791
2021-11-27 09:08:34 -05:00
Jon Evans b4342d813b Fix SHAPE_LINE_CHAIN::Slice when end is an arc followed by a point
Fixes https://gitlab.com/kicad/code/kicad/-/issues/9770
2021-11-25 10:05:33 -05:00
Tomasz Wlostowski 5d2f3257da libs/kimath: user-settable distance threshold for SEG::ApproxParallel() 2021-11-22 01:35:12 +01:00
Roberto Fernandez Bautista 1026c24c65 SHAPE_LINE_CHAIN fix rotation of indices after going through Clipper
Clipper might mess up the rotation of the indices such that an arc can be split between
the end point and wrap around to the start point. Detect if this happened and fix it as
required.

Also, handle arcs at the last segment of the chain correctly, meaning we can have arcs
towards the end of the chain that finish at the starting point of the chain.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/9670
2021-11-20 16:47:08 +00:00
Roberto Fernandez Bautista d47bd3a04d Rewrite broken collision routine SHAPE_ARC::Collide( SEG& aSeg ) 2021-11-15 14:04:37 +00:00
Roberto Fernandez Bautista cb7e57fb43 CIRCLE::IntersectLine fix incorrect algorithm documentation comments 2021-11-15 14:04:37 +00:00