KiCad PCB EDA Suite
cpolygon2d.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-2018 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 _CPOLYGON2D_H_
31 #define _CPOLYGON2D_H_
32 
33 #include "cobject2d.h"
34 #include "../accelerators/ccontainer2d.h"
36 #include <vector>
37 
38 
39 typedef struct
40 {
45 
46 
47 typedef struct
48 {
52 
53 
54 typedef struct
55 {
60 
61 
62 typedef std::vector< POLYSEGMENT > SEGMENTS;
63 
64 
67 typedef std::vector< SEGMENT_WITH_NORMALS > SEGMENTS_WIDTH_NORMALS;
68 
69 
74 typedef struct
75 {
76  std::vector<SEGMENTS> m_Outers;
77  std::vector<SEGMENTS> m_Holes;
79 
80 
86 class CPOLYGONBLOCK2D : public COBJECT2D
87 {
88 private:
94 
97 
98 public:
99  CPOLYGONBLOCK2D( const SEGMENTS_WIDTH_NORMALS &aOpenSegmentList,
100  const OUTERS_AND_HOLES &aOuter_and_holes,
101  const BOARD_ITEM &aBoardItem );
102 
103  // Imported from COBJECT2D
104  bool Overlaps( const CBBOX2D &aBBox ) const override;
105  bool Intersects( const CBBOX2D &aBBox ) const override;
106  bool Intersect( const RAYSEG2D &aSegRay, float *aOutT, SFVEC2F *aNormalOut ) const override;
107  INTERSECTION_RESULT IsBBoxInside( const CBBOX2D &aBBox ) const override;
108  bool IsPointInside( const SFVEC2F &aPoint ) const override;
109 };
110 
111 
117 class CDUMMYBLOCK2D : public COBJECT2D
118 {
119 
120 public:
121  CDUMMYBLOCK2D( const SFVEC2F &aPbMin,
122  const SFVEC2F &aPbMax,
123  const BOARD_ITEM &aBoardItem );
124 
125  CDUMMYBLOCK2D( const CBBOX2D &aBBox, const BOARD_ITEM &aBoardItem );
126 
127  // Imported from COBJECT2D
128  bool Overlaps( const CBBOX2D &aBBox ) const override;
129  bool Intersects( const CBBOX2D &aBBox ) const override;
130  bool Intersect( const RAYSEG2D &aSegRay, float *aOutT, SFVEC2F *aNormalOut ) const override;
131  INTERSECTION_RESULT IsBBoxInside( const CBBOX2D &aBBox ) const override;
132  bool IsPointInside( const SFVEC2F &aPoint ) const override;
133 };
134 
147  const SHAPE_POLY_SET &aMainPath,
148  CGENERICCONTAINER2D &aDstContainer,
149  float aBiuTo3DunitsScale,
150  float aDivFactor,
151  const BOARD_ITEM &aBoardItem );
152 
153 void Polygon_Calc_BBox_3DU( const SHAPE_POLY_SET &aPolysList,
154  CBBOX2D &aOutBBox,
155  float aBiuTo3DunitsScale );
156 
157 void Polygon2d_TestModule();
158 
159 #endif // _CPOLYGON2D_H_
SFVEC2F m_Start
Definition: cpolygon2d.h:49
INTERSECTION_RESULT
Definition: cobject2d.h:38
void Polygon_Calc_BBox_3DU(const SHAPE_POLY_SET &aPolysList, CBBOX2D &aOutBBox, float aBiuTo3DunitsScale)
Definition: cpolygon2d.cpp:714
bool Overlaps(const CBBOX2D &aBBox) const override
Function Overlaps.
Definition: cpolygon2d.cpp:250
SFVEC2F m_Precalc_slope
Definition: cpolygon2d.h:57
float m_JX_minus_IX
Definition: cpolygon2d.h:43
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
bool Intersect(const RAYSEG2D &aSegRay, float *aOutT, SFVEC2F *aNormalOut) const override
Function Intersect.
Definition: cpolygon2d.cpp:257
Class CBBOX manages a bounding box defined by two SFVEC2F min max points.
Definition: cbbox2d.h:40
INTERSECTION_RESULT IsBBoxInside(const CBBOX2D &aBBox) const override
Function IsBBoxInside.
Definition: cpolygon2d.cpp:267
void Convert_path_polygon_to_polygon_blocks_and_dummy_blocks(const SHAPE_POLY_SET &aMainPath, CGENERICCONTAINER2D &aDstContainer, float aBiuTo3DunitsScale, float aDivFactor, const BOARD_ITEM &aBoardItem)
Convert_path_polygon_to_polygon_blocks_and_dummy_blocks This function will use a polygon in the forma...
Definition: cpolygon2d.cpp:406
SFVEC2F m_Start
Definition: cpolygon2d.h:41
bool IsPointInside(const SFVEC2F &aPoint) const override
Definition: cpolygon2d.cpp:274
std::vector< POLYSEGMENT > SEGMENTS
Definition: cpolygon2d.h:62
bool Intersect(const RAYSEG2D &aSegRay, float *aOutT, SFVEC2F *aNormalOut) const override
Function Intersect.
Definition: cpolygon2d.cpp:131
bool Overlaps(const CBBOX2D &aBBox) const override
Function Overlaps.
Definition: cpolygon2d.cpp:124
OUTERS_AND_HOLES m_outers_and_holes
A polygon block can have multiple polygon and holes.
Definition: cpolygon2d.h:96
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
bool IsPointInside(const SFVEC2F &aPoint) const override
Definition: cpolygon2d.cpp:197
INTERSECTION_RESULT IsBBoxInside(const CBBOX2D &aBBox) const override
Function IsBBoxInside.
Definition: cpolygon2d.cpp:190
Class SHAPE_POLY_SET.
float m_inv_JY_minus_IY
Definition: cpolygon2d.h:42
std::vector< SEGMENTS > m_Outers
Definition: cpolygon2d.h:76
This structured will be used to handle a sub set of a polygon.
Definition: cpolygon2d.h:74
std::vector< SEGMENTS > m_Holes
Definition: cpolygon2d.h:77
void Polygon2d_TestModule()
SFVEC2F m_End
Definition: cpolygon2d.h:50
SEG_NORMALS m_Normals
Definition: cpolygon2d.h:58
bool Intersects(const CBBOX2D &aBBox) const override
Function Intersects.
Definition: cpolygon2d.cpp:244
CDUMMYBLOCK2D(const SFVEC2F &aPbMin, const SFVEC2F &aPbMax, const BOARD_ITEM &aBoardItem)
Definition: cpolygon2d.cpp:224
SEGMENTS_WIDTH_NORMALS m_open_segments
This is the outter part of the polygon.
Definition: cpolygon2d.h:93
CPOLYGONBLOCK2D(const SEGMENTS_WIDTH_NORMALS &aOpenSegmentList, const OUTERS_AND_HOLES &aOuter_and_holes, const BOARD_ITEM &aBoardItem)
Definition: cpolygon2d.cpp:73
bool Intersects(const CBBOX2D &aBBox) const override
Function Intersects.
Definition: cpolygon2d.cpp:114
This dummy block will be defined by a 2d box size.
Definition: cpolygon2d.h:117
std::vector< SEGMENT_WITH_NORMALS > SEGMENTS_WIDTH_NORMALS
This list will be used to test ray2d intersections.
Definition: cpolygon2d.h:67
This class represents a sub polygon block.
Definition: cpolygon2d.h:86
Definition: ray.h:86