Commit Graph

164 Commits

Author SHA1 Message Date
Tomasz Wlostowski 7994c59169 libs/kimath: POLY_GRID_PARTITION must use truncating (round-to-zero) rescale function for correct grid generation. 2021-01-10 00:04:57 +01:00
Seth Hillbrand a342bb9ab3 Standardize rounding in 64-bit rescale
32-bit rescale still uses truncation until we can determine how this
affects poly_grid_partition
2021-01-07 11:21:05 -08:00
Seth Hillbrand 77acf85310 Revert "Standardize rescale"
poly_grid_partition appears to depend on integer calculation for large
scaling

This reverts commit eef16fe717.
2021-01-07 10:36:06 -08:00
hoijui 6ca9a42251 Removes 3 other instances of a potential encoding problem
Signed-off-by: hoijui <hoijui.quaero@gmail.com>
2021-01-07 17:36:49 +00:00
Seth Hillbrand eef16fe717 Standardize rescale
Rescale was returning differing results based on 32-bit vs 64-bit
implementations.  Speed difference here appears to be positive.
2021-01-06 17:52:14 -08:00
Jon Evans 7431d5c985 PNS: First pass at updating meander placers for arcs
Fixes https://gitlab.com/kicad/code/kicad/-/issues/6464
2021-01-05 17:57:21 -05:00
Jon Evans 8619086cf2 PNS: re-enable optimization of colinear segs in lines with arcs 2021-01-05 17:57:21 -05:00
Jon Evans 8901e71fc8 PNS: Fix loop removal, make walkaround less broken for arcs 2021-01-05 17:57:21 -05:00
Jon Evans aebb571dc9 Short-circuit arc generation if we are on a diagonal 2021-01-05 17:57:21 -05:00
Seth Hillbrand 5a97764319 Make segment contain its edge
This allows segment snapping along its diagonals to the grid.

Fixes https://gitlab.com/kicad/code/kicad/issues/6924
2021-01-03 12:47:33 -08:00
Jon Evans eaffacbc85 PNS: construct initial lines with arcs more precisely 2021-01-02 23:57:09 -05:00
Jon Evans af4c6393bb Fix arc collisions to account for width
This was causing arcs to be really hard to start routing from
2021-01-02 22:01:05 -05:00
Jon Evans 111c644a82 Don't append zero-length arcs 2020-12-31 13:05:43 -05:00
Jon Evans fbdf31d35a Prevent creating arcs with slightly offset endpoints 2020-12-31 13:05:43 -05:00
Jon Evans 23c9eddf2d Cleanup 2020-12-30 18:29:41 -05:00
Jon Evans 79502a0d88 PNS: A new approach to arc placement
Fixes https://gitlab.com/kicad/code/kicad/-/issues/6334
2020-12-30 18:23:24 -05:00
Jon Evans ea351fde69 Recache polygon triangulation when mirroring
Fixes https://gitlab.com/kicad/code/kicad/-/issues/6265
2020-12-20 10:45:24 -05:00
Jeff Young bc484784fc Make sure zones are triangulated for DRC.
Normally this happens as a side-effect of rendering them but if done
from a script (or test case) this won't happen.

Fixes https://gitlab.com/kicad/code/kicad/issues/6635
2020-12-12 15:27:46 +00:00
Jeff Young f08b7f098f Cleanup. 2020-12-12 15:27:46 +00:00
Jeff Young 807eef1208 Better error reporting to try and catch 6635. 2020-12-12 12:22:52 +00:00
Ian McInerney be4b6ec06a Cleanup compiler warnings 2020-12-09 23:13:33 +00:00
Jeff Young 37178e3751 Formatting. 2020-11-29 14:02:46 +00:00
jean-pierre charras 68625494f3 specctra_export: fix an issue with custom and chamfered/round rect pads.
Is some cases a created pad stack name had the same name as an other pad stack
having a slightly different shape, thus creating pads with a incorrect shape on board.

Fixes #6495
https://gitlab.com/kicad/code/kicad/issues/6495
2020-11-25 13:57:46 +01:00
Jeff Young 9c7c05c161 Mostly formatting cleanup but a few type-casting cleanups too. 2020-11-24 22:16:41 +00:00
Werni 0e44f5128c Add const specifiers 2020-11-18 19:50:36 +00:00
jean-pierre charras 7265f84358 fix PAD::TransformShapeWithClearanceToPolygon() incorrect calculation in some cases.
For round rect pads, when the arc error was OUTSIDE, the shape was too big and creates
bad shape for chamfered round rect pads.
For chamfered pads, when the clearance value was not 0, the chamfer was not at the
right place.
2020-11-14 08:50:58 +01:00
Jeff Young 791a50b493 Remove work-around in favour of real fix in Clipper. 2020-11-04 11:21:45 +00:00
Jeff Young 55c25f3cc4 Work around a round-off bug in Clipper.
Fixes https://gitlab.com/kicad/code/kicad/issues/6260
2020-11-02 17:43:13 +00:00
jean-pierre charras d6f91c810f Fix a few compil and Coverity warnings. 2020-10-25 10:02:07 +01:00
Jeff Young 59f3fefd17 When polygonizing arcs don't use synthesized center and angle.
Start, mid and end are the "real" properties and come with less
error.

Also collapses two arc polygonization routines into one.

Also fixes DRC checks to be cognizant of arc approximation error.

Fixes https://gitlab.com/kicad/code/kicad/issues/6039
2020-10-23 23:55:45 +01:00
Jeff Young 1cb7fbaab1 Fix errors in arc polygonization and test case.
1) Tests can't expect accuracies around 1 to work.  PCBNew defaults
to 5000.
2) Tests shouldn't artifically expand tolerance just to match the
results.
3) Tests should guarantee that end point is on arc, not just close
to it.
4) Standard polygonization of a circle is inside so splitting the
error needs to increase radius, not decrease.
5) Special-case first and last points so that they're exact.
2020-10-23 23:55:45 +01:00
Seth Hillbrand 19bf594aa0 Remove unused point in polygon test
There can be only one.
2020-10-23 12:13:09 -07:00
Jeff Young 58c006bc45 Register properties for ARC elements so we can get their netclass.
Also improves GAL arc drawing and polygonization.

Fixes https://gitlab.com/kicad/code/kicad/issues/6039
2020-10-23 14:27:36 +01:00
Tomasz Wlostowski 5b4f463c38 kimath: SHAPE_POLY_SET::Format() outputs C++-like code now, like other shapes 2020-10-23 01:18:01 +02:00
Wayne Stambaugh 8185a416b9 Fix broken build on Linux with gcc. 2020-10-22 08:36:28 -04:00
Jeff Young 9ff49277e1 Add implicit rule generation for keepout areas.
Also implements collision detection for SHAPE_POLY_SET.

Fixes https://gitlab.com/kicad/code/kicad/issues/6105
2020-10-22 10:41:21 +01:00
Jeff Young bfd04926b5 Performance improvement for polyset fracture. 2020-10-20 22:26:47 +01:00
Roberto Fernandez Bautista 006c462d8f ADDED: Fillet Tracks tool in pcbnew
Select two or more track segments and run the "Fillet Tracks" tool.
2020-10-20 21:23:05 +00:00
Jeff Young bbe7573d1c Performance enhancements to roundrect pads and clearance outlines.
Aka: avoid Clipper at all costs.

Fixes https://gitlab.com/kicad/code/kicad/issues/5900
2020-10-14 15:56:43 +01:00
Jeff Young 54dc91a623 Account for segment width in aActual calculation.
Fixes https://gitlab.com/kicad/code/kicad/issues/5990
2020-10-14 15:56:32 +01:00
Jeff Young 1703729269 Require explicit decl of maxError and errorLocations.
This should reduce both performance issues and clearance issues.
2020-10-13 13:49:07 +01:00
Ian McInerney 48a5907412 Remove extraneous debug statements 2020-10-08 17:56:54 +01:00
Tomasz Wlostowski db9e111838 kimath: SHAPE_POLY_SET should re-parent triangulated polygons when copied/cloned 2020-10-08 15:22:17 +02:00
Jeff Young 2f49db49bf Fix fly-off arc handles and move Arc Properties to start/end/angle.
Fixes https://gitlab.com/kicad/code/kicad/issues/5791
2020-10-08 11:33:32 +01:00
Ian McInerney 16374e9ae1 Ensure string is chosen correctly 2020-10-07 23:23:43 +01:00
Tomasz Wlostowski 8fb154e04e geometry: SHAPE_RECT: use SquaredDistance() for collision detection 2020-10-07 16:36:37 +02:00
Tomasz Wlostowski d6fa81036b geometry: SEG::NearestPoint(SEG) now returns points only on (this) segment 2020-10-07 16:36:37 +02:00
Tomasz Wlostowski 1ef120ff4f geometry: SHAPE::Format() now outputs C-like code for easy test cases... 2020-10-07 16:36:37 +02:00
Jeff Young 18a3c4c1db Fix some fairly catastrophic bugs in shape collision optimization.
I did a little too much copy & paste last time around....
2020-10-05 22:32:07 +01:00
Mark Roszko a28a0e14ba Fix conversion warnings 2020-10-05 10:41:14 +00:00
Jeff Young 8dd7777108 Handle closed shape-line-chain with circle collisions. 2020-10-04 19:40:18 +01:00
Jeff Young f9cfd31351 0 is always a collision (whether clearance is 0 or not). 2020-10-04 13:21:01 +01:00
Jeff Young f4f578b755 Add closed-shape handling to SHAPE_LINE_CHAIN collision routines. 2020-10-04 13:21:01 +01:00
Jeff Young bf67648562 Support optional location reporting in SHAPE collisions.
Also fixes a few bugs in the collision routines.
2020-09-28 23:28:33 +01:00
Tomasz Wlostowski 482767a850 libs/kimath: implement indexable subshape support for SHAPE_COMPOUND and SHAPE_POLY_SET 2020-09-27 16:45:46 +02:00
Jeff Young d402d93487 Implement shape routines for DIMENSION_Ts.
This allows them to participate in DRC and PNS.

Fixes https://gitlab.com/kicad/code/kicad/issues/5712
2020-09-19 14:16:00 +01:00
Jeff Young 0f3d2147aa Performance enhancements for DRC. 2020-09-17 20:13:39 +01:00
jean-pierre charras 9f85730987 Make SHAPE_POLY_SET::CacheTriangulation() behavior same as previously.
Previously, SHAPE_POLY_SET::CacheTriangulation() was able to handle polygons
with holes.
Due to recent changes, CacheTriangulation( true ) handle polygons with holes,
but CacheTriangulation( false ) did not handle polygons with holes, due to a
missing call to Fracture(), lost in latest changes.
This is now fixed.

Fixes #5606
https://gitlab.com/kicad/code/kicad/issues/5606
2020-09-13 17:55:59 +02:00
Seth Hillbrand 03f510ff0d Ensure segmented polys have outlines
In the event the calculation removes outlines, we need to keep the
original polygon

Fixes https://gitlab.com/kicad/code/kicad/issues/5594
2020-09-11 08:45:11 -07:00
Jeff Young 6b4a6f4d3e Restore min seg limit for rounded-corner pads.
It suffered from a cacophony of errors, starting with an errant
comment that made it later look like a bug.  Sigh.
2020-09-11 14:41:45 +01:00
Jeff Young e2bc7557cc Clean up arc/circle polygonization.
1) For a while now we've been using a calculated seg count from a given
maxError, and a correction factor to push the radius out so that all
the error is outside the arc/circle.  However, the second calculation
(which pre-dates the first) is pretty much just the inverse of the first
(and yields nothing more than maxError back). This is particularly
sub-optimal given the cost of trig functions.

2) There are a lot of old optimizations to reduce segcounts in certain
situations, someting that our error-based calculation compensates for
 anyway.  (Smaller radii need fewer segments to meet the maxError
condition.) But perhaps more importantly we now surface maxError in the
UI and we don't really want to call it "Max deviation except when it's
not".

3) We were also clamping the segCount twice: once in the calculation
routine and once in most of it's callers.  Furthermore, the caller
clamping was inconsistent (both in being done and in the clamping
value). We now clamp only in the calculation routine.

4) There's no reason to use the correction factors in the 3Dviewer;
it's just a visualization and whether the polygonization error is
inside or outside the shape isn't really material.

5) The arc-correction-disabling stuff (used for solder mask layer) was
somewhat fragile in that it depended on the caller to turn it back on
afterwards.  It's now only exposed as a RAII object which  automatically
cleans up when it goes out of scope.

6) There were also bugs in a couple of the polygonization routines where
we'd accumulate round-off error in adding up the segments and end up with
an overly long last segment (which of course would voilate the error
max). This was the cause of the linked bug and also some issues with vias
that we had fudged in the past with extra clearance.

Fixes https://gitlab.com/kicad/code/kicad/issues/5567
2020-09-11 11:23:49 +01:00
Seth Hillbrand 08d4e91f3b Change partitions to fixed size
Partititioning small polygons causes excessive partitions when we use a
fixed number of cells per side.  Partitioning by size keeps the
partition count limited and speeds the calculations.

Also adds an option to not partition the grid for elements (like 3d
raytracing) that do not need it.

Fixes https://gitlab.com/kicad/code/kicad/issues/5579
2020-09-10 09:31:20 -07:00
Seth Hillbrand 37e268c162 Remove incorrect short-circuit of rotate 2020-09-08 14:10:23 -07:00
Seth Hillbrand efb03b7482 Optimize loading new footprints
When loading footprints, we need to skip the triangulation trigger in
rotate.  If the triangulation cache is invalid when starting the
rotation, do not retriangulate after the rotation.
2020-09-08 11:17:50 -07:00
Tomasz Wlostowski aee06e46b0 SHAPE_POLY_SET: split polygons into rectangular cell grids to obtain more regular triangulations 2020-09-08 01:31:42 +02:00
Tomasz Wlostowski 74623b8c98 geometry: derive SHAPE_LINE_CHAIN, SHAPE_SIMPLE and SHAPE_POLY_SET::TRIANGULATED_POLYGON::TRI from a common base class allowing to simplify collision detection 2020-09-08 01:31:42 +02:00
Tomasz Wlostowski eb6e1c4f90 geometry: handle collisions of null shapes 2020-09-08 01:31:42 +02:00
Jon Evans fa8655511e Enable converting segments to arcs
Fixes https://gitlab.com/kicad/code/kicad/-/issues/1957
2020-08-29 12:13:51 -04:00
Wayne Stambaugh ede39780e2 Remove all debugging output that cannot be disabled.
The use of printf, wxLogDebug, and std::err/std::out causes excessive
debugging output which makes finding specific debugging messages more
difficult than it needs to be.

There is still some debugging output in test code that really needs to
be moved into a unit test.

Add debugging output section to the coding policy regarding debugging
output.
2020-08-18 10:17:36 -04:00
Jeff Young 463100d67f Remove a long-standing hack to keep divots out of adjacent zones.
The new algorithm unions any adjacent zones before doing the
chamfer/fillet and then subtracts the other zones back out afterwards.

Fixes https://gitlab.com/kicad/code/kicad/issues/3812
2020-08-12 22:20:08 +01:00
Seth Hillbrand 7c455f2357 First pass at DRC RTree functionality
This implements a copper-layer RTree with functions for iterating over
the elements in a copper layer and providing Nearest Neighbor returns
for BOARD_CONNECTED_ITEMS
2020-08-11 16:52:29 -07:00
jean-pierre charras 265f28afe1 Fix a minor compil warning and a Coverity warning 2020-07-30 10:40:51 +02:00
Tomasz Wlostowski 32bd31a1b8 libs/kimath: implement BBox() and Size() methods in SHAPE_COMPOUND 2020-07-29 23:14:03 +02:00
Tomasz Wlostowski 747f2eb948 kimath: fix MTV and actual clearance calculation for SHAPE_COMPOUNDs 2020-07-29 23:14:03 +02:00
Tomasz Wlostowski 48f87dedc9 Implement collisions for SHAPE_COMPOUND 2020-07-29 23:14:03 +02:00
Tomasz Wlostowski b03044d3d1 kimath/geometry: starting with SHAPE_COMPOUND 2020-07-29 23:14:03 +02:00
Ian McInerney d5ff02ad55 Fix compiler warning - those extra brackets aren't needed 2020-07-18 23:55:27 +01:00
Seth Hillbrand 3aeb3c8f99 Fix case of 360° arc handling
A 360° arc will have the mid point on the opposite side of the circle
from both the start and end points.  This will make both slopes the
same, leading to a degeneracy in the calculation.  We address this by
noting that the center will be halfway between the midpoint and the
start point.
2020-07-18 13:03:39 -07:00
Seth Hillbrand 854e7a4928 SHAPE_POLY_SET: AddHole should return the hole idx
Returning the poly index is not useful as it does not allow the use of
other SHAPE_POLY_SET Hole* functions that expect to get the indices of
holes rather than the outline
2020-07-18 13:03:22 -07:00
jean-pierre charras 5d5706b8be Fix incorrect Rotate() functions for shapes circles and arcs.
VECTOR2I::Rotate( double aAngle ) returns a rotated point, but does change
the object itself.

Fixes #4810
https://gitlab.com/kicad/code/kicad/issues/4810
2020-07-06 13:50:55 +02:00
Jeff Young 5bc6389477 Comments. 2020-07-05 19:53:04 +01:00
jean-pierre charras 82da739786 Better calculations in TransformRoundChamferedRectToPolygon().
the old calculations was creating a slightly too small shape for rounded corners.

Now the polygon is outside the perfect shape (as required to create a shape with clearance)

Fixes #4805
https://gitlab.com/kicad/code/kicad/issues/4805
2020-07-05 19:32:07 +02:00
Jeff Young 2cfd6ba978 Fix a couple of integer overflows. 2020-07-02 22:52:37 +01:00
Jeff Young 9940931b0f Fix null dereference in DRC checking. 2020-07-02 22:23:28 +01:00
Jeff Young eb1ff80d57 SHAPE collision fixes.
1) An actual distance of 0 is still a collision, even if the allowed
distance is 0.
2) Be consitent about edges and interiors.  Everyone expect the edge
of a RECT to be part of the RECT; same with a CIRCLE.  SHAPE_POLY_SET
shouldn't be any different.  (And SHAPE_LINE_CHAIN was a split-
personality with the edge considered part of it for Collide() but not
for PointInside()).
2020-07-02 21:38:37 +01:00
Jeff Young 441dfa30f0 Return individual custom pad shapes instead of a SHAPE_POLY_SET.
Also implements an optional pointer to return the actual distance
from all the SHAPE collision routines.

Fixes https://gitlab.com/kicad/code/kicad/issues/4774
2020-07-02 17:09:15 +01:00
Jon Evans 32b7b0c617 Fix filled zone rotation and move operations 2020-06-30 22:26:30 -04:00
Jeff Young da2b7071b4 WYSISYG custom pad editor.
Fixes https://gitlab.com/kicad/code/kicad/issues/2153

Fixes https://gitlab.com/kicad/code/kicad/issues/2305
2020-06-27 14:37:01 +01:00
Jeff Young d01b29ab37 Cleanup pad geometry handling.
There were a lot of plotters, exporters, etc. that were rolling their
own implementations.

This also introduces a lazily-built set of SHAPE objects for doing
collision detection and some forms of rendering (and later DRC).
2020-06-22 22:28:37 +01:00
Jeff Young d89f8407e0 Const fixes. 2020-06-22 20:36:54 +01:00
Seth Hillbrand 08c61e6788 Ensure triangulation follows moving zone
Dragging filled zones in OpenGL was extremely slow due to the
invalidated triangulation cache.  Moving the zone should also move the
triangles and keep the cache valid.
2020-06-17 19:43:11 -07:00
Seth Hillbrand a5500973a2 Fix SHAPE_ARC hittest and adjust radius return
The hittest needs to use distance calc rather than squared distance.
This also adjusts the radius value to be double as to avoid unneeded
loss of precision
2020-06-13 11:23:21 -07:00
Seth Hillbrand a8ab668122 Move SHAPE_ARC to start->mid->end format
The arc shapes need to connect with their adjacent points.  By storing
the relevant points, we allow exact point matching on both ends of the
arc as well as localize point storage.
2020-06-13 11:23:14 -07:00
Jeff Young 13493437d0 Add hole-inside-courtyard DRC checks.
One for NPTH and one for PTH; both default to "ignore".

Fixes https://gitlab.com/kicad/code/kicad/issues/3434
2020-05-14 22:02:47 +01:00
Jeff Young dfe4a00d43 Add distance reporting for copper item DRC tests.
Also adds some performance improvements.
2020-05-01 18:49:42 +01:00
Jeff Young a56191b658 Add distances to a bunch of DRC violation reports. 2020-05-01 18:49:42 +01:00
jean-pierre charras 25d7c0cae2 Opencascade: fix min version: OCE=0.18, OCC=6.9.0
Fix also a few minor Coverity warnings.
2020-04-16 10:22:20 +02:00
Tomasz Wlostowski 88d0092e43 libs: added POINT_INSIDE_TRACKER, a state-based class to track if a point is inside/outisde a dynamically built closed polyline 2020-04-15 13:00:48 +02:00
Tomasz Wlostowski 9b2fbae706 geometry: don't copy stuff in SHAPE_POLY_SET::GetRelativeIndices. Huge performance improvement for large polygons 2020-04-15 13:00:48 +02:00
Ian McInerney 37a4dd927b Allow deletion of zone cutout areas
ADDED: Ability to delete zone cutout areas

Fixes https://gitlab.com/kicad/code/kicad/issues/4188
2020-04-14 17:57:47 +01:00