KiCad PCB EDA Suite
cpolygon4pts2d.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) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
5  * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
30 #ifndef _CPOLYGON4PTS2D_H_
31 #define _CPOLYGON4PTS2D_H_
32 
33 #include "cobject2d.h"
34 
40 class CPOLYGON4PTS2D : public COBJECT2D
41 {
42 private:
46 
47 public:
48  CPOLYGON4PTS2D( const SFVEC2F &v1,
49  const SFVEC2F &v2,
50  const SFVEC2F &v3,
51  const SFVEC2F &v4,
52  const BOARD_ITEM &aBoardItem );
53 
54  const SFVEC2F &GetV0() const { return m_segments[0]; }
55  const SFVEC2F &GetV1() const { return m_segments[1]; }
56  const SFVEC2F &GetV2() const { return m_segments[2]; }
57  const SFVEC2F &GetV3() const { return m_segments[3]; }
58 
59  const SFVEC2F &GetN0() const { return m_seg_normal[0]; }
60  const SFVEC2F &GetN1() const { return m_seg_normal[1]; }
61  const SFVEC2F &GetN2() const { return m_seg_normal[2]; }
62  const SFVEC2F &GetN3() const { return m_seg_normal[3]; }
63 
64  // Imported from COBJECT2D
65  bool Overlaps( const CBBOX2D &aBBox ) const override;
66  bool Intersects( const CBBOX2D &aBBox ) const override;
67  bool Intersect( const RAYSEG2D &aSegRay, float *aOutT, SFVEC2F *aNormalOut ) const override;
68  INTERSECTION_RESULT IsBBoxInside( const CBBOX2D &aBBox ) const override;
69  bool IsPointInside( const SFVEC2F &aPoint ) const override;
70 };
71 
72 
73 #endif // _CPOLYGON4PTS2D_H_
INTERSECTION_RESULT
Definition: cobject2d.h:38
bool Overlaps(const CBBOX2D &aBBox) const override
Function Overlaps.
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
const SFVEC2F & GetN2() const
const SFVEC2F & GetN3() const
Class CBBOX manages a bounding box defined by two SFVEC2F min max points.
Definition: cbbox2d.h:40
SFVEC2F m_segments[4]
const SFVEC2F & GetN1() const
const SFVEC2F & GetV2() const
const SFVEC2F & GetV3() const
const SFVEC2F & GetV1() const
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
SFVEC2F m_seg_normal[4]
bool Intersect(const RAYSEG2D &aSegRay, float *aOutT, SFVEC2F *aNormalOut) const override
Function Intersect.
const SFVEC2F & GetN0() const
SFVEC2F m_precalc_slope[4]
bool Intersects(const CBBOX2D &aBBox) const override
Function Intersects.
This handles simple polygons with 4 points.
CPOLYGON4PTS2D(const SFVEC2F &v1, const SFVEC2F &v2, const SFVEC2F &v3, const SFVEC2F &v4, const BOARD_ITEM &aBoardItem)
const SFVEC2F & GetV0() const
INTERSECTION_RESULT IsBBoxInside(const CBBOX2D &aBBox) const override
Function IsBBoxInside.
Definition: ray.h:86
bool IsPointInside(const SFVEC2F &aPoint) const override