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 (C) 2024 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, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#pragma once
25
26#include <variant>
27#include <vector>
28
29#include <math/vector2d.h>
30#include <math/box2.h>
31
32#include <geometry/circle.h>
33#include <geometry/half_line.h>
34#include <geometry/line.h>
35#include <geometry/seg.h>
36#include <geometry/shape_arc.h>
37#include <geometry/shape_rect.h>
38
43using INTERSECTABLE_GEOM = std::variant<LINE, HALF_LINE, SEG, CIRCLE, SHAPE_ARC, BOX2I>;
44
53{
54public:
60 INTERSECTION_VISITOR( const INTERSECTABLE_GEOM& aOtherGeometry,
61 std::vector<VECTOR2I>& aIntersections );
62
63 /*
64 * One of these operator() overloads will be called by std::visit
65 * as needed to visit (i.e. intersect) the geometry with the (stored)
66 * other geometry.
67 */
68 void operator()( const SEG& aSeg ) const;
69 void operator()( const LINE& aLine ) const;
70 void operator()( const HALF_LINE& aLine ) const;
71 void operator()( const CIRCLE& aCircle ) const;
72 void operator()( const SHAPE_ARC& aArc ) const;
73 void operator()( const BOX2I& aArc ) const;
74
75private:
77 std::vector<VECTOR2I>& m_intersections;
78};
Represent basic circle geometry with utility geometry functions.
Definition: circle.h:33
Definition: line.h:36
Definition: seg.h:42
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.
Definition: intersection.h:43
A visitor that visits INTERSECTABLE_GEOM variant objects with another (which is held as state: m_othe...
Definition: intersection.h:53
const INTERSECTABLE_GEOM & m_otherGeometry
Definition: intersection.h:76
std::vector< VECTOR2I > & m_intersections
Definition: intersection.h:77
void operator()(const SEG &aSeg) const