2013-09-18 19:55:16 +02:00
|
|
|
/*
|
|
|
|
* KiRouter - a push-and-(sometimes-)shove PCB router
|
|
|
|
*
|
2014-05-14 15:53:54 +02:00
|
|
|
* Copyright (C) 2013-2014 CERN
|
2025-01-01 13:30:11 -08:00
|
|
|
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
2013-09-18 19:55:16 +02:00
|
|
|
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
2013-09-26 23:53:54 +02:00
|
|
|
*
|
2013-09-18 19:55:16 +02:00
|
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
* option) any later version.
|
2013-09-26 23:53:54 +02:00
|
|
|
*
|
2013-09-18 19:55:16 +02:00
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
2013-09-26 23:53:54 +02:00
|
|
|
*
|
2013-09-18 19:55:16 +02:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
2014-05-14 15:53:54 +02:00
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
2013-09-18 19:55:16 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __PNS_UTILS_H
|
|
|
|
#define __PNS_UTILS_H
|
|
|
|
|
|
|
|
#include <math/vector2d.h>
|
2015-02-18 01:29:54 +01:00
|
|
|
#include <math/box2.h>
|
2013-09-18 19:55:16 +02:00
|
|
|
#include <geometry/shape_line_chain.h>
|
2014-05-14 15:53:54 +02:00
|
|
|
#include <geometry/shape_segment.h>
|
|
|
|
#include <geometry/shape_rect.h>
|
2020-01-07 17:12:59 +00:00
|
|
|
#include <geometry/shape_simple.h>
|
2014-05-14 15:53:54 +02:00
|
|
|
|
2016-08-29 16:38:11 +02:00
|
|
|
namespace PNS {
|
|
|
|
|
|
|
|
constexpr int HULL_MARGIN = 10;
|
2013-09-18 19:55:16 +02:00
|
|
|
|
2016-08-29 19:31:13 +02:00
|
|
|
class ITEM;
|
2016-08-30 17:28:35 +02:00
|
|
|
class LINE;
|
2025-02-02 18:41:04 +01:00
|
|
|
class DEBUG_DECORATOR;
|
|
|
|
class NODE;
|
2013-09-18 19:55:16 +02:00
|
|
|
/** Various utility functions */
|
|
|
|
|
2019-05-16 17:13:21 -07:00
|
|
|
const SHAPE_LINE_CHAIN ArcHull( const SHAPE_ARC& aSeg, int aClearance, int aWalkaroundThickness );
|
|
|
|
|
2013-09-26 23:53:54 +02:00
|
|
|
const SHAPE_LINE_CHAIN OctagonalHull( const VECTOR2I& aP0, const VECTOR2I& aSize,
|
2014-05-16 13:37:31 +02:00
|
|
|
int aClearance, int aChamfer );
|
2013-09-18 19:55:16 +02:00
|
|
|
|
2015-07-02 16:11:15 +02:00
|
|
|
const SHAPE_LINE_CHAIN SegmentHull( const SHAPE_SEGMENT& aSeg, int aClearance,
|
|
|
|
int aWalkaroundThickness );
|
2014-05-14 15:53:54 +02:00
|
|
|
|
2015-07-02 16:09:43 +02:00
|
|
|
/**
|
|
|
|
* Function ConvexHull()
|
|
|
|
*
|
|
|
|
* Creates an octagonal hull around a convex polygon.
|
2017-06-22 09:01:29 +02:00
|
|
|
* @param aConvex The convex polygon.
|
|
|
|
* @param aClearance The minimum distance between polygon and hull.
|
2015-07-02 16:09:43 +02:00
|
|
|
* @return A closed line chain describing the octagon.
|
|
|
|
*/
|
2018-05-03 10:52:42 -07:00
|
|
|
const SHAPE_LINE_CHAIN ConvexHull( const SHAPE_SIMPLE& aConvex, int aClearance );
|
2015-07-02 16:09:43 +02:00
|
|
|
|
2014-05-14 15:53:54 +02:00
|
|
|
SHAPE_RECT ApproximateSegmentAsRect( const SHAPE_SEGMENT& aSeg );
|
|
|
|
|
2016-08-30 17:28:35 +02:00
|
|
|
OPT_BOX2I ChangedArea( const ITEM* aItemA, const ITEM* aItemB );
|
|
|
|
OPT_BOX2I ChangedArea( const LINE& aLineA, const LINE& aLineB );
|
2016-08-15 17:16:48 +02:00
|
|
|
|
2021-05-27 23:57:28 +02:00
|
|
|
void HullIntersection( const SHAPE_LINE_CHAIN& hull, const SHAPE_LINE_CHAIN& line,
|
|
|
|
SHAPE_LINE_CHAIN::INTERSECTIONS& ips );
|
|
|
|
|
2022-08-30 13:52:34 +01:00
|
|
|
const SHAPE_LINE_CHAIN BuildHullForPrimitiveShape( const SHAPE* aShape, int aClearance,
|
|
|
|
int aWalkaroundThickness );
|
2015-02-18 01:29:54 +01:00
|
|
|
|
2025-02-02 18:41:04 +01:00
|
|
|
void NodeStats( DEBUG_DECORATOR* aDbg, wxString aLabel, NODE *aNode );
|
|
|
|
|
2016-08-29 16:38:11 +02:00
|
|
|
}
|
|
|
|
|
2025-02-02 18:41:04 +01:00
|
|
|
|
2013-09-26 23:53:54 +02:00
|
|
|
#endif // __PNS_UTILS_H
|