Commit Graph

519 Commits

Author SHA1 Message Date
Tomasz Wlostowski 0a69340953 geometry: fix incorrect 45 degree miter generation (likely a side bug after introduction of EDA_ANGLE) 2022-10-31 11:49:31 +01:00
Tomasz Wlostowski cd29dcf6e0 libs/kimath: SHAPE::Format() can now produce C++ object construction and simple test dump of shapes 2022-10-31 11:17:31 +01:00
Seth Hillbrand 8e97855557 Fix Clipper2 handling of Inflate/Deflate
For unknown reasons, Clipper2 only returns Paths structures from the
ClipperOffset::Execute routine.  Further, the Paths are not properly
ordered (outline->hole in outline, outline2->hole in outline2).
To get proper hierarchy, we need to run an additional pass of the
solution with the paths as Subject in a null union.  This is effectively
a Simplify() call but we keep the data in Clipper format to reduce the
churn/calc time
2022-10-28 17:01:36 -07:00
Seth Hillbrand 546e16a002 Add multi-level fallback in tesselation
Some clipper cases do not get resolved with the `FAST` mode, so in those
cases, do a second pass in the `SIMPLE` mode.  If both fail, return a
broken polygon instead of an infinite loop

Fixes https://gitlab.com/kicad/code/kicad/issues/12761
2022-10-28 10:17:58 -07:00
Seth Hillbrand 4cdf0bd6c9 Clipper2: Handle nested poly/hole/poly returns
In Clipper1, we had a flat tree structure on returns.  Clipper2 nests
these, so we need to properly handle the nesting structure when
importing the polygons
2022-10-21 16:14:34 -07:00
Jeff Young d16b23d16e Name shortening and line-break reduction. 2022-10-21 18:41:39 +01:00
Seth Hillbrand 27add591ec Add Clipper2
Currently this lives behind the advanced config flag `UseClipper2`.
Enabling this flag will route all Clipper-based calls through the
Clipper2 library instead of the older Clipper.  The changes should be
mostly transparent.

Of note, Clipper2 does not utilize the `STRICTLY_SIMPLE` flag because
clipper1 did not actually guarantee a strictly simple polygon.
Currently we ignore this flag but we may decide to run strictly-simple
operations through a second NULL union to simplify the results as much
as possible.

Additionally, the inflation options are slightly different.  We cannot
choose the fallback miter.  The fallback miter is always square.  This
only affects the CHAMFER_ACUTE_CORNERS option in inflate, which does not
appear to be used.

Lastly, we currently utilize the 64-bit integer coordinates for
calculations.  This appears to still be faster than 32-bit calculations
in Clipper1 on a modern x86 system.  This may not be the case for older
systems, particularly 32-bit systems.
2022-10-19 16:25:45 -07:00
Jeff Young e5de56b6cc Fix edge case in arc collision.
SHAPE_ARC::IntersectLine() fails when one of the arcs start points
is on the center point of the other -- in this case we can't extend
the line to the arc intersection because one point does not define
a line....

Fixes https://gitlab.com/kicad/code/kicad/issues/12609
2022-10-09 23:05:15 +01:00
Jeff Young e866dfe137 Avoid trying to draw empty pads.
Fixes https://gitlab.com/kicad/code/kicad/issues/12605
2022-10-09 20:28:54 +01:00
Jeff Young 19d270fe74 Text size sanity checking for TEXT_ITEMS_GRID.
Oh dear, there was a bunch going on here.  Firstly the move from int
to long long int for ValueFromString() means that we were no longer
catching overflows (as we were C-style casting it back to int in many
places).  But even when the overflow is caught, it would run in to
wxWidgets' empty string bug while trying to log it.

Fixes https://gitlab.com/kicad/code/kicad/issues/12577
2022-10-06 13:19:08 +01:00
Tomasz Wlostowski 26b2fd36d4 libs/kimath: fix divide by 0 for 0-length segments 2022-10-05 22:40:47 +02:00
Alex 6e0d940b98 kiplatform: Add quotes to restart registration command line. 2022-10-05 20:30:46 +03:00
Tomasz Wlostowski f80b48e1b0 libs/kimath: consider signed distances in parallelity check 2022-10-05 14:38:05 +02:00
Tomasz Wlostowski 6ed3618ce5 libs/kimath: improve numerical robustness of ApproxParallel/ApproxCollinear for segments of largely different lengths 2022-10-04 20:55:08 +02:00
jean-pierre charras ca5d87e46d disable CONIN$ and CONOUT$ redirection on mingw. it creates issues
(nothing printed on the console)
It is probably not needed on mingw/msys.
2022-10-04 19:51:52 +02:00
Mark Roszko fb8a4c10f7 Shove kicad2step into pcbnew itself with a new cli 2022-10-04 01:53:37 +00:00
Marek Roszko 2b42163379 Bind stdout and stderr for windows so that the console can get output 2022-09-29 18:51:01 -04:00
Jonathan Haas 9d45b5a197 Change implementation of Box2::FarthestPointTo to actually return the farthest point. 2022-09-27 22:40:55 +00:00
Alex 796e44d1e6 Fix a mistake in BOX2::Inflate. 2022-09-25 08:33:52 +03:00
Alex 58b03b0a1c Small optimizations. 2022-09-22 17:22:04 +00:00
Jeff Young 7e97dc6974 Fix typo found by dsa-t. 2022-09-20 10:50:22 +01:00
Marek Roszko 3d5913c825 Remove convert_to_biu.h, merge contents to base_units.h 2022-09-16 21:09:28 -04:00
Jeff Young 281b9d405a ADDED ability to specify where pad number (& net name) go on custom shaped pads.
Fixes https://gitlab.com/kicad/code/kicad/issues/6627
2022-09-14 11:37:20 +01:00
Jeff Young fc74de81fb Don't crash on empty SHAPE_LINE_CHAINs.
Fixes https://gitlab.com/kicad/code/kicad/issues/12407
2022-09-13 13:28:00 +01:00
Jeff Young 9188838e50 RIP EDA_RECT. 2022-08-31 23:57:24 +01:00
Jeff Young b4492e0bd2 More EDA_RECE yeetage. 2022-08-31 17:19:50 +01:00
Jeff Young f17a865593 Move EDA_ITEM hitTest to BOX2I. 2022-08-31 17:18:45 +01:00
Jeff Young c7036ae076 Beef up BOX2's API so it can replace EDA_RECT. 2022-08-31 00:44:33 +01:00
Seth Hillbrand b736460e71 Move optional access from value() to *operator
`value()` throws.  Where we check for existence, we don't need to use
the throwing version and should just use the unprotected variant
2022-08-30 13:59:39 -07:00
Seth Hillbrand df8b7a8fef Fix RemoveNullSegments 2022-08-29 17:08:01 -07:00
Seth Hillbrand a7f978daf6 Fix typo 2022-08-26 16:58:21 -07:00
Seth Hillbrand 5a37211fdb 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
2022-08-26 16:41:57 -07:00
Seth Hillbrand 146495672e Utilize our combine_hash routine for multiple hash
We should be using the one routine every time we want to build a hash
from indepedent values rather than rebuilding it differently in multiple
places
2022-08-26 08:45:13 -07:00
Seth Hillbrand 06786c34d7 Blacklist hashes for 2d integer elements
The hash table for integer hashes is extremely limited and places most
elements in the same buckets.  This leads to a linear search time for
structures built on this.

This blocks hashes, directing the coder to utilize std::set or std::map
structures instead of hash tables for implementing integer-based
lookups.
2022-08-26 08:43:37 -07:00
Seth Hillbrand f1261e71d4 Replace boost::optional with std::optional 2022-08-25 15:50:47 -07:00
Marek Roszko f63a099fad Remove unused function to squash warning 2022-08-21 18:23:28 -04:00
Roberto Fernandez Bautista 1fa1b44d02 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
2022-08-19 20:49:49 +01:00
Jeff Young 96f01d33c8 Performance improvements.
1) Move a bunch of std::map's to std::unordered_map to get constant-time
look-ups
2) Lengthen progress-reporting intervals to spend more time doing work
and less time talking about it
3) Reverse order of SHAPE_LINE_CHAINs in thermal intersection checks to
make (much) better use of bbox caches
4) Don't re-generate bboxes we already have
5) Fix some autos that weren't by reference (and were therefore copying
large datasets)
6) Rename delta progressDelta so it's easier to search for in future
7) Get rid of a few more autos (because I don't like them)
8) Pass large items to lambdas by reference

Fixes https://gitlab.com/kicad/code/kicad/issues/12130
2022-08-03 11:59:42 +01:00
Seth Hillbrand 3594a06475 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

(cherry picked from commit 675a5a6e7b)
2022-08-01 09:50:17 -07:00
Seth Hillbrand 2039a1bc8b 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

(cherry picked from commit c9c31fcbc2)
2022-07-31 12:48:52 -07:00
Seth Hillbrand f6d2164cb0 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

(cherry picked from commit df9cf0a0c3)
2022-07-28 09:40:41 -07:00
jean-pierre charras 81d9524e03 Fix missing header. 2022-07-25 18:41:38 +02:00
jean-pierre charras 130723ebac VECTOR2D CalcArcCenter( VECTOR2D& aStart, VECTOR2D& aEnd, EDA_ANGLE& aAngle ):
fix broken calculation of arc center for arcs > 180 degrees.
Fixes #11708
https://gitlab.com/kicad/code/kicad/issues/11708
2022-07-25 18:23:52 +02:00
Jeff Young 032708860b Include both text shapes and border shapes in textbox.
Fixes https://gitlab.com/kicad/code/kicad/issues/11806
2022-07-25 16:10:08 +01:00
Seth Hillbrand 00f0d229bf Fix incorrect comment in previous commit 2022-07-21 15:52:54 -07:00
Seth Hillbrand 16e3d40552 ADDED: Display calculated clearance in status bar
In addition to showing resolved clearance, we also show the calculated
clearance in the same method as is used for DRC.  This will allow users
to better examine their system while working.

Fixes https://gitlab.com/kicad/code/kicad/issues/7934
2022-07-21 15:44:48 -07:00
Jeff Young b727bfc16d Performance: avoid sqrt at all costs. 2022-07-16 18:42:32 +01:00
Alex c107abe247 math: Use intrinsic functions for 64-bit rescale on MSVC. 2022-07-16 17:37:50 +00:00
Seth Hillbrand eccbb374a0 Add debug message to VECTOR3 check 2022-07-16 17:28:40 +00:00
Marco Langer 1606bfc9f8 fixed a runtime divide by zero crash for integral type template instanciations and made the class trivial copyable to increase performance 2022-07-16 17:28:40 +00:00