KiCad PCB EDA Suite
Loading...
Searching...
No Matches
oval.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) 2023 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 <vector>
27
28#include <math/box2.h>
29#include <math/vector2d.h>
31#include <geometry/eda_angle.h>
33#include <geometry/seg.h>
34
35
37
44class OVAL
45{
46public:
51 OVAL( const SEG& aSeg, int aWidth );
52
58 OVAL( const VECTOR2I& aOverallSize, const VECTOR2I& aCenter, const EDA_ANGLE& aRotation );
59
63 BOX2I BBox( int aClearance ) const;
64
68 int GetWidth() const { return m_width; }
69
73 int GetLength() const { return m_seg.Length() + m_width; }
74
78 int GetSideLength() const { return m_seg.Length(); }
79
83 VECTOR2I GetCenter() const { return m_seg.Center(); }
84
90 const SEG& GetSegment() const { return m_seg; }
91
97 EDA_ANGLE GetAngle() const { return EDA_ANGLE( m_seg.B - m_seg.A ); }
98
99private:
102};
103
104namespace KIGEOM
105{
106
107SHAPE_LINE_CHAIN ConvertToChain( const OVAL& aOval );
108
109
111{
112 OVAL_CENTER = 1 << 0,
120
121using OVAL_KEY_POINT_FLAGS = unsigned int;
122
138std::vector<TYPED_POINT2I> GetOvalKeyPoints( const OVAL& aOval, OVAL_KEY_POINT_FLAGS aFlags );
139
140} // namespace KIGEOM
Class that represents an oval shape (rectangle with semicircular end caps)
Definition: oval.h:45
SEG m_seg
Definition: oval.h:100
int GetLength() const
Get the overall length of the oval from endcap tip to endcap tip.
Definition: oval.h:73
EDA_ANGLE GetAngle() const
Get the angle of the oval's central segment.
Definition: oval.h:97
int m_width
Definition: oval.h:101
BOX2I BBox(int aClearance) const
Get the bounding box of the oval.
Definition: oval.cpp:58
int GetSideLength() const
Get the side length of the oval (=length between the centers of the semicircles)
Definition: oval.h:78
VECTOR2I GetCenter() const
Get the center point of the oval.
Definition: oval.h:83
const SEG & GetSegment() const
Get the central segment of the oval.
Definition: oval.h:90
int GetWidth() const
Get the width of the oval (diameter of the semicircles)
Definition: oval.h:68
Definition: seg.h:42
VECTOR2I A
Definition: seg.h:49
VECTOR2I B
Definition: seg.h:50
int Length() const
Return the length (this).
Definition: seg.h:333
VECTOR2I Center() const
Definition: seg.h:369
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
std::vector< TYPED_POINT2I > GetOvalKeyPoints(const OVAL &aOval, OVAL_KEY_POINT_FLAGS aFlags)
Get a list of interesting points on an oval (rectangle with semicircular end caps)
Definition: oval.cpp:84
OVAL_KEY_POINTS
Definition: oval.h:111
@ OVAL_SIDE_ENDS
Definition: oval.h:116
@ OVAL_CAP_TIPS
Definition: oval.h:113
@ OVAL_SIDE_MIDPOINTS
Definition: oval.h:115
@ OVAL_ALL_KEY_POINTS
Definition: oval.h:118
@ OVAL_CARDINAL_EXTREMES
Definition: oval.h:117
@ OVAL_CENTER
Definition: oval.h:112
@ OVAL_CAP_CENTERS
Definition: oval.h:114
unsigned int OVAL_KEY_POINT_FLAGS
Definition: oval.h:121
SHAPE_LINE_CHAIN ConvertToChain(const OVAL &aOval)
Definition: oval.cpp:69