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 The 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, see <https://www.gnu.org/licenses/>.
19 */
20
24
25#ifndef _CPOLYGON2D_H_
26#define _CPOLYGON2D_H_
27
28#include "object_2d.h"
31#include <vector>
32
33
35{
37 float m_inv_JY_minus_IY = 0.0;
38 float m_JX_minus_IX = 0.0;
39};
40
41
47
48
55
56
57typedef std::vector< POLYSEGMENT > SEGMENTS;
58
59
65typedef std::vector< SEGMENT_WITH_NORMALS > SEGMENTS_WIDTH_NORMALS;
66
67
75{
76 std::vector<SEGMENTS> m_Outers;
77 std::vector<SEGMENTS> m_Holes;
78};
79
80
89class POLYGON_2D : public OBJECT_2D
90{
91public:
92 POLYGON_2D( const SEGMENTS_WIDTH_NORMALS& aOpenSegmentList,
93 const OUTERS_AND_HOLES& aOuterAndHoles, const BOARD_ITEM& aBoardItem );
94
95 bool Overlaps( const BBOX_2D& aBBox ) const override;
96 bool Intersects( const BBOX_2D& aBBox ) const override;
97 bool Intersect( const RAYSEG2D& aSegRay, float* aOutT, SFVEC2F* aNormalOut ) const override;
98 INTERSECTION_RESULT IsBBoxInside( const BBOX_2D& aBBox ) const override;
99 bool IsPointInside( const SFVEC2F& aPoint ) const override;
100
101private:
109
112};
113
114
123{
124public:
125 DUMMY_BLOCK_2D( const SFVEC2F& aPbMin, const SFVEC2F& aPbMax, const BOARD_ITEM& aBoardItem );
126
127 DUMMY_BLOCK_2D( const BBOX_2D& aBBox, const BOARD_ITEM& aBoardItem );
128
129 bool Overlaps( const BBOX_2D& aBBox ) const override;
130 bool Intersects( const BBOX_2D& aBBox ) const override;
131 bool Intersect( const RAYSEG2D& aSegRay, float* aOutT, SFVEC2F* aNormalOut ) const override;
132 INTERSECTION_RESULT IsBBoxInside( const BBOX_2D& aBBox ) const override;
133 bool IsPointInside( const SFVEC2F& aPoint ) const override;
134};
135
136
147void ConvertPolygonToBlocks( const SHAPE_POLY_SET& aMainPath, CONTAINER_2D_BASE& aDstContainer,
148 float aBiuTo3dUnitsScale, float aDivFactor,
149 const BOARD_ITEM& aBoardItem, int aPolyIndex );
150
151
152#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:81
bool Intersect(const RAYSEG2D &aSegRay, float *aOutT, SFVEC2F *aNormalOut) const override
bool IsPointInside(const SFVEC2F &aPoint) const override
bool Intersects(const BBOX_2D &aBBox) const override
a.Intersects(b) ⇔ !a.Disjoint(b) ⇔ !(a ∩ b = ∅)
bool Overlaps(const BBOX_2D &aBBox) const override
Test if the box overlaps the object.
INTERSECTION_RESULT IsBBoxInside(const BBOX_2D &aBBox) const override
Test this object if it's completely outside, intersects, or is completely inside aBBox.
DUMMY_BLOCK_2D(const SFVEC2F &aPbMin, const SFVEC2F &aPbMax, const BOARD_ITEM &aBoardItem)
OBJECT_2D(OBJECT_2D_TYPE aObjType, const BOARD_ITEM &aBoardItem)
Definition object_2d.cpp:27
OUTERS_AND_HOLES m_outers_and_holes
Definition polygon_2d.h:111
bool Intersects(const BBOX_2D &aBBox) const override
a.Intersects(b) ⇔ !a.Disjoint(b) ⇔ !(a ∩ b = ∅)
INTERSECTION_RESULT IsBBoxInside(const BBOX_2D &aBBox) const override
Test this object if it's completely outside, intersects, or is completely inside aBBox.
bool Intersect(const RAYSEG2D &aSegRay, float *aOutT, SFVEC2F *aNormalOut) const override
bool IsPointInside(const SFVEC2F &aPoint) const override
POLYGON_2D(const SEGMENTS_WIDTH_NORMALS &aOpenSegmentList, const OUTERS_AND_HOLES &aOuterAndHoles, const BOARD_ITEM &aBoardItem)
SEGMENTS_WIDTH_NORMALS m_open_segments
The outer part of the polygon.
Definition polygon_2d.h:108
bool Overlaps(const BBOX_2D &aBBox) const override
Test if the box overlaps the object.
Represent a set of closed polygons.
INTERSECTION_RESULT
Definition object_2d.h:33
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...
std::vector< SEGMENT_WITH_NORMALS > SEGMENTS_WIDTH_NORMALS
List used to test ray2d intersections.
Definition polygon_2d.h:65
std::vector< POLYSEGMENT > SEGMENTS
Definition polygon_2d.h:57
Manage a bounding box defined by two SFVEC2F min max points.
Definition bbox_2d.h:38
Handle a subset of a polygon.
Definition polygon_2d.h:75
std::vector< SEGMENTS > m_Holes
Definition polygon_2d.h:77
std::vector< SEGMENTS > m_Outers
Definition polygon_2d.h:76
SFVEC2F m_Start
Definition polygon_2d.h:36
float m_inv_JY_minus_IY
Definition polygon_2d.h:37
float m_JX_minus_IX
Definition polygon_2d.h:38
SEG_NORMALS m_Normals
Definition polygon_2d.h:53
SFVEC2F m_Start
Definition polygon_2d.h:44
SFVEC2F m_End
Definition polygon_2d.h:45
glm::vec2 SFVEC2F
Definition xv3d_types.h:38