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>
34#include <geometry/shape_rect.h>
35
40using INTERSECTABLE_GEOM = std::variant<LINE, HALF_LINE, SEG, CIRCLE, SHAPE_ARC, SHAPE_ELLIPSE, BOX2I>;
41
51{
53 bool m_Tangent = false;
54
57 bool m_Overlapping = false;
58};
59
68{
69public:
75 INTERSECTION_VISITOR( const INTERSECTABLE_GEOM& aOtherGeometry,
76 std::vector<VECTOR2I>& aIntersections );
77
82 INTERSECTION_VISITOR( const INTERSECTABLE_GEOM& aOtherGeometry, std::vector<VECTOR2I>& aIntersections,
83 INTERSECTION_CONTACT& aContact );
84
85 /*
86 * One of these operator() overloads will be called by std::visit
87 * as needed to visit (i.e. intersect) the geometry with the (stored)
88 * other geometry.
89 */
90 void operator()( const SEG& aSeg ) const;
91 void operator()( const LINE& aLine ) const;
92 void operator()( const HALF_LINE& aLine ) const;
93 void operator()( const CIRCLE& aCircle ) const;
94 void operator()( const SHAPE_ARC& aArc ) const;
95 void operator()( const SHAPE_ELLIPSE& aEllipse ) const;
96 void operator()( const BOX2I& aArc ) const;
97
98private:
100 std::vector<VECTOR2I>& m_intersections;
102};
BOX2< VECTOR2I > BOX2I
Definition box2.h:927
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, SHAPE_ELLIPSE, BOX2I > INTERSECTABLE_GEOM
A variant type that can hold any of the supported geometry types for intersection calculations.
How two geometries meet, beyond where they cross.
bool m_Tangent
Touch at one point, no crossing.
bool m_Overlapping
Collinear or concentric, more than one point shared.
INTERSECTION_CONTACT * m_contact
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