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-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 _CPOLYGON2D_H_
31 #define _CPOLYGON2D_H_
32 
33 #include "cobject2d.h"
34 #include "../accelerators/ccontainer2d.h"
36 #include <polygons_defs.h>
37 #include <vector>
38 
39 
40 typedef struct
41 {
46 
47 
48 typedef struct
49 {
53 
54 
55 typedef struct
56 {
61 
62 
63 typedef std::vector< POLYSEGMENT > SEGMENTS;
64 
65 
68 typedef std::vector< SEGMENT_WITH_NORMALS > SEGMENTS_WIDTH_NORMALS;
69 
70 
75 typedef struct
76 {
77  std::vector<SEGMENTS> m_Outers;
78  std::vector<SEGMENTS> m_Holes;
80 
81 
87 class CPOLYGONBLOCK2D : public COBJECT2D
88 {
89 private:
95 
98 
99 public:
100  CPOLYGONBLOCK2D( const SEGMENTS_WIDTH_NORMALS &aOpenSegmentList,
101  const OUTERS_AND_HOLES &aOuter_and_holes,
102  const BOARD_ITEM &aBoardItem );
103 
104  // Imported from COBJECT2D
105  bool Overlaps( const CBBOX2D &aBBox ) const override;
106  bool Intersects( const CBBOX2D &aBBox ) const override;
107  bool Intersect( const RAYSEG2D &aSegRay, float *aOutT, SFVEC2F *aNormalOut ) const override;
108  INTERSECTION_RESULT IsBBoxInside( const CBBOX2D &aBBox ) const override;
109  bool IsPointInside( const SFVEC2F &aPoint ) const override;
110 };
111 
112 
118 class CDUMMYBLOCK2D : public COBJECT2D
119 {
120 
121 public:
122  CDUMMYBLOCK2D( const SFVEC2F &aPbMin,
123  const SFVEC2F &aPbMax,
124  const BOARD_ITEM &aBoardItem );
125 
126  CDUMMYBLOCK2D( const CBBOX2D &aBBox, const BOARD_ITEM &aBoardItem );
127 
128  // Imported from COBJECT2D
129  bool Overlaps( const CBBOX2D &aBBox ) const override;
130  bool Intersects( const CBBOX2D &aBBox ) const override;
131  bool Intersect( const RAYSEG2D &aSegRay, float *aOutT, SFVEC2F *aNormalOut ) const override;
132  INTERSECTION_RESULT IsBBoxInside( const CBBOX2D &aBBox ) const override;
133  bool IsPointInside( const SFVEC2F &aPoint ) const override;
134 };
135 
148  const SHAPE_POLY_SET &aMainPath,
149  CGENERICCONTAINER2D &aDstContainer,
150  float aBiuTo3DunitsScale,
151  float aDivFactor,
152  const BOARD_ITEM &aBoardItem );
153 
154 void Polygon_Calc_BBox_3DU( const SHAPE_POLY_SET &aPolysList,
155  CBBOX2D &aOutBBox,
156  float aBiuTo3DunitsScale );
157 
158 void Polygon_Convert( const KI_POLYGON &aPolygon,
159  ClipperLib::Path &aOutPath,
160  CBBOX2D &aOutBBox,
161  float aBiuTo3DunitsScale );
162 
163 void Polygon2d_TestModule();
164 
165 #endif // _CPOLYGON2D_H_
SFVEC2F m_Start
Definition: cpolygon2d.h:50
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:58
float m_JX_minus_IX
Definition: cpolygon2d.h:44
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:42
bool IsPointInside(const SFVEC2F &aPoint) const override
Definition: cpolygon2d.cpp:274
std::vector< POLYSEGMENT > SEGMENTS
Definition: cpolygon2d.h:63
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:97
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:43
std::vector< SEGMENTS > m_Outers
Definition: cpolygon2d.h:77
This structured will be used to handle a sub set of a polygon.
Definition: cpolygon2d.h:75
std::vector< SEGMENTS > m_Holes
Definition: cpolygon2d.h:78
void Polygon2d_TestModule()
bpl::polygon_data< int > KI_POLYGON
KI_POLYGON defines a single polygon ( boost::polygon_data type.
Definition: polygons_defs.h:49
SFVEC2F m_End
Definition: cpolygon2d.h:51
SEG_NORMALS m_Normals
Definition: cpolygon2d.h:59
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:94
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:118
void Polygon_Convert(const KI_POLYGON &aPolygon, ClipperLib::Path &aOutPath, CBBOX2D &aOutBBox, float aBiuTo3DunitsScale)
Definition: cpolygon2d.cpp:743
std::vector< SEGMENT_WITH_NORMALS > SEGMENTS_WIDTH_NORMALS
This list will be used to test ray2d intersections.
Definition: cpolygon2d.h:68
This class represents a sub polygon block.
Definition: cpolygon2d.h:87
Definition: ray.h:86