KiCad PCB EDA Suite
Loading...
Searching...
No Matches
polygon_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 _CPOLYGON2D_H_
30#define _CPOLYGON2D_H_
31
32#include "object_2d.h"
33#include "../accelerators/container_2d.h"
35#include <vector>
36
37
39{
41 float m_inv_JY_minus_IY = 0.0;
42 float m_JX_minus_IX = 0.0;
43};
44
45
47{
50};
51
52
54{
58};
59
60
61typedef std::vector< POLYSEGMENT > SEGMENTS;
62
63
69typedef std::vector< SEGMENT_WITH_NORMALS > SEGMENTS_WIDTH_NORMALS;
70
71
79{
80 std::vector<SEGMENTS> m_Outers;
81 std::vector<SEGMENTS> m_Holes;
82};
83
84
93class POLYGON_2D : public OBJECT_2D
94{
95public:
96 POLYGON_2D( const SEGMENTS_WIDTH_NORMALS& aOpenSegmentList,
97 const OUTERS_AND_HOLES& aOuterAndHoles, const BOARD_ITEM& aBoardItem );
98
99 bool Overlaps( const BBOX_2D& aBBox ) const override;
100 bool Intersects( const BBOX_2D& aBBox ) const override;
101 bool Intersect( const RAYSEG2D& aSegRay, float* aOutT, SFVEC2F* aNormalOut ) const override;
102 INTERSECTION_RESULT IsBBoxInside( const BBOX_2D& aBBox ) const override;
103 bool IsPointInside( const SFVEC2F& aPoint ) const override;
104
105private:
113
116};
117
118
127{
128public:
129 DUMMY_BLOCK_2D( const SFVEC2F& aPbMin, const SFVEC2F& aPbMax, const BOARD_ITEM& aBoardItem );
130
131 DUMMY_BLOCK_2D( const BBOX_2D& aBBox, const BOARD_ITEM& aBoardItem );
132
133 bool Overlaps( const BBOX_2D& aBBox ) const override;
134 bool Intersects( const BBOX_2D& aBBox ) const override;
135 bool Intersect( const RAYSEG2D& aSegRay, float* aOutT, SFVEC2F* aNormalOut ) const override;
136 INTERSECTION_RESULT IsBBoxInside( const BBOX_2D& aBBox ) const override;
137 bool IsPointInside( const SFVEC2F& aPoint ) const override;
138};
139
140
151void ConvertPolygonToBlocks( const SHAPE_POLY_SET& aMainPath, CONTAINER_2D_BASE& aDstContainer,
152 float aBiuTo3dUnitsScale, float aDivFactor,
153 const BOARD_ITEM& aBoardItem, int aPolyIndex );
154
156
157#endif // _CPOLYGON2D_H_
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:77
A dummy block defined by a 2d box size.
Definition: polygon_2d.h:127
bool Intersect(const RAYSEG2D &aSegRay, float *aOutT, SFVEC2F *aNormalOut) const override
Definition: polygon_2d.cpp:242
bool IsPointInside(const SFVEC2F &aPoint) const override
Definition: polygon_2d.cpp:257
bool Intersects(const BBOX_2D &aBBox) const override
a.Intersects(b) ⇔ !a.Disjoint(b) ⇔ !(a ∩ b = ∅)
Definition: polygon_2d.cpp:229
bool Overlaps(const BBOX_2D &aBBox) const override
Test if the box overlaps the object.
Definition: polygon_2d.cpp:235
INTERSECTION_RESULT IsBBoxInside(const BBOX_2D &aBBox) const override
Test this object if it's completely outside, intersects, or is completely inside aBBox.
Definition: polygon_2d.cpp:250
Represent a sub polygon block.
Definition: polygon_2d.h:94
OUTERS_AND_HOLES m_outers_and_holes
Definition: polygon_2d.h:115
bool Intersects(const BBOX_2D &aBBox) const override
a.Intersects(b) ⇔ !a.Disjoint(b) ⇔ !(a ∩ b = ∅)
Definition: polygon_2d.cpp:103
INTERSECTION_RESULT IsBBoxInside(const BBOX_2D &aBBox) const override
Test this object if it's completely outside, intersects, or is completely inside aBBox.
Definition: polygon_2d.cpp:179
bool Intersect(const RAYSEG2D &aSegRay, float *aOutT, SFVEC2F *aNormalOut) const override
Definition: polygon_2d.cpp:120
bool IsPointInside(const SFVEC2F &aPoint) const override
Definition: polygon_2d.cpp:186
SEGMENTS_WIDTH_NORMALS m_open_segments
The outer part of the polygon.
Definition: polygon_2d.h:112
bool Overlaps(const BBOX_2D &aBBox) const override
Test if the box overlaps the object.
Definition: polygon_2d.cpp:113
Represent a set of closed polygons.
INTERSECTION_RESULT
Definition: object_2d.h:37
void ConvertPolygonToBlocks(const SHAPE_POLY_SET &aMainPath, CONTAINER_2D_BASE &aDstContainer, float aBiuTo3dUnitsScale, float aDivFactor, const BOARD_ITEM &aBoardItem, int aPolyIndex)
Use a polygon in the format of the ClipperLib::Path and process it and create multiple 2d objects (PO...
Definition: polygon_2d.cpp:378
std::vector< SEGMENT_WITH_NORMALS > SEGMENTS_WIDTH_NORMALS
List used to test ray2d intersections.
Definition: polygon_2d.h:69
std::vector< POLYSEGMENT > SEGMENTS
Definition: polygon_2d.h:61
void Polygon2d_TestModule()
Manage a bounding box defined by two SFVEC2F min max points.
Definition: bbox_2d.h:42
Handle a subset of a polygon.
Definition: polygon_2d.h:79
std::vector< SEGMENTS > m_Holes
Definition: polygon_2d.h:81
std::vector< SEGMENTS > m_Outers
Definition: polygon_2d.h:80
SFVEC2F m_Start
Definition: polygon_2d.h:40
float m_inv_JY_minus_IY
Definition: polygon_2d.h:41
float m_JX_minus_IX
Definition: polygon_2d.h:42
Definition: ray.h:106
SEG_NORMALS m_Normals
Definition: polygon_2d.h:57
SFVEC2F m_Precalc_slope
Definition: polygon_2d.h:56
SFVEC2F m_Start
Definition: polygon_2d.h:48
SFVEC2F m_End
Definition: polygon_2d.h:49
glm::vec2 SFVEC2F
Definition: xv3d_types.h:42