KiCad PCB EDA Suite
triangle_2d.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 <[email protected]>
5  * Copyright (C) 1992-2020 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 
29 #ifndef _TRIANGLE_2D_H_
30 #define _TRIANGLE_2D_H_
31 
32 #include "object_2d.h"
33 #include "../accelerators/container_2d.h"
36 #include <clipper.hpp>
37 
38 class TRIANGLE_2D : public OBJECT_2D
39 {
40 public:
41  TRIANGLE_2D( const SFVEC2F& aV1, const SFVEC2F& aV2, const SFVEC2F& aV3,
42  const BOARD_ITEM& aBoardItem );
43 
44  const SFVEC2F& GetP1() const { return p1; }
45  const SFVEC2F& GetP2() const { return p2; }
46  const SFVEC2F& GetP3() const { return p3; }
47 
48  bool Overlaps( const BBOX_2D& aBBox ) const override;
49  bool Intersects( const BBOX_2D& aBBox ) const override;
50  bool Intersect( const RAYSEG2D& aSegRay, float* aOutT, SFVEC2F* aNormalOut ) const override;
51  INTERSECTION_RESULT IsBBoxInside( const BBOX_2D& aBBox ) const override;
52  bool IsPointInside( const SFVEC2F& aPoint ) const override;
53 
54 private:
58 
64 };
65 
66 
67 void ConvertPolygonToTriangles( SHAPE_POLY_SET& aPolyList, CONTAINER_2D_BASE& aDstContainer,
68  float aBiuTo3dUnitsScale, const BOARD_ITEM& aBoardItem );
69 #endif // _TRIANGLE_2D_H_
const SFVEC2F & GetP1() const
Definition: triangle_2d.h:44
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
const SFVEC2F & GetP2() const
Definition: triangle_2d.h:45
bool IsPointInside(const SFVEC2F &aPoint) const override
Definition: triangle_2d.cpp:96
SFVEC2F p2
Definition: triangle_2d.h:56
void ConvertPolygonToTriangles(SHAPE_POLY_SET &aPolyList, CONTAINER_2D_BASE &aDstContainer, float aBiuTo3dUnitsScale, const BOARD_ITEM &aBoardItem)
bool Overlaps(const BBOX_2D &aBBox) const override
Test if the box overlaps the object.
Definition: triangle_2d.cpp:73
glm::vec2 SFVEC2F
Definition: xv3d_types.h:42
float m_p3x_minus_p2x
Definition: triangle_2d.h:61
INTERSECTION_RESULT
Definition: object_2d.h:36
Represent a set of closed polygons.
bool Intersects(const BBOX_2D &aBBox) const override
a.Intersects(b) ⇔ !a.Disjoint(b) ⇔ !(a ∩ b = ∅)
Definition: triangle_2d.cpp:63
Manage a bounding box defined by two SFVEC2F min max points.
Definition: bbox_2d.h:41
SFVEC2F p3
Definition: triangle_2d.h:57
bool Intersect(const RAYSEG2D &aSegRay, float *aOutT, SFVEC2F *aNormalOut) const override
Definition: triangle_2d.cpp:80
float m_p3y_minus_p1y
Definition: triangle_2d.h:62
TRIANGLE_2D(const SFVEC2F &aV1, const SFVEC2F &aV2, const SFVEC2F &aV3, const BOARD_ITEM &aBoardItem)
Definition: triangle_2d.cpp:36
INTERSECTION_RESULT IsBBoxInside(const BBOX_2D &aBBox) const override
Test this object if it's completely outside, intersects, or is completely inside aBBox.
Definition: triangle_2d.cpp:86
const SFVEC2F & GetP3() const
Definition: triangle_2d.h:46
float m_p2y_minus_p3y
Definition: triangle_2d.h:60
float m_inv_denominator
Definition: triangle_2d.h:59
float m_p1x_minus_p3x
Definition: triangle_2d.h:63
SFVEC2F p1
Definition: triangle_2d.h:55
Definition: ray.h:105