KiCad PCB EDA Suite
Loading...
Searching...
No Matches
intersection.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
22#include <variant>
23#include <vector>
24
25#include <math/vector2d.h>
26#include <math/box2.h>
27
28#include <geometry/circle.h>
29#include <geometry/half_line.h>
30#include <geometry/line.h>
31#include <geometry/seg.h>
32#include <geometry/shape_arc.h>
33#include <geometry/shape_rect.h>
34
39using INTERSECTABLE_GEOM = std::variant<LINE, HALF_LINE, SEG, CIRCLE, SHAPE_ARC, BOX2I>;
40
49{
50public:
56 INTERSECTION_VISITOR( const INTERSECTABLE_GEOM& aOtherGeometry,
57 std::vector<VECTOR2I>& aIntersections );
58
59 /*
60 * One of these operator() overloads will be called by std::visit
61 * as needed to visit (i.e. intersect) the geometry with the (stored)
62 * other geometry.
63 */
64 void operator()( const SEG& aSeg ) const;
65 void operator()( const LINE& aLine ) const;
66 void operator()( const HALF_LINE& aLine ) const;
67 void operator()( const CIRCLE& aCircle ) const;
68 void operator()( const SHAPE_ARC& aArc ) const;
69 void operator()( const BOX2I& aArc ) const;
70
71private:
73 std::vector<VECTOR2I>& m_intersections;
74};
BOX2< VECTOR2I > BOX2I
Definition box2.h:918
Represent basic circle geometry with utility geometry functions.
Definition circle.h:33
Definition line.h:32
Definition seg.h:38
std::variant< LINE, HALF_LINE, SEG, CIRCLE, SHAPE_ARC, BOX2I > INTERSECTABLE_GEOM
A variant type that can hold any of the supported geometry types for intersection calculations.
const INTERSECTABLE_GEOM & m_otherGeometry
INTERSECTION_VISITOR(const INTERSECTABLE_GEOM &aOtherGeometry, std::vector< VECTOR2I > &aIntersections)
std::vector< VECTOR2I > & m_intersections
void operator()(const SEG &aSeg) const