KiCad PCB EDA Suite
Loading...
Searching...
No Matches
POLYGON_2D Class Reference

Represent a sub polygon block. More...

#include <polygon_2d.h>

Inheritance diagram for POLYGON_2D:
OBJECT_2D

Public Member Functions

 POLYGON_2D (const SEGMENTS_WIDTH_NORMALS &aOpenSegmentList, const OUTERS_AND_HOLES &aOuterAndHoles, const BOARD_ITEM &aBoardItem)
 
bool Overlaps (const BBOX_2D &aBBox) const override
 Test if the box overlaps the object.
 
bool Intersects (const BBOX_2D &aBBox) const override
 a.Intersects(b) ⇔ !a.Disjoint(b) ⇔ !(a ∩ b = ∅)
 
bool Intersect (const RAYSEG2D &aSegRay, float *aOutT, SFVEC2F *aNormalOut) const override
 
INTERSECTION_RESULT IsBBoxInside (const BBOX_2D &aBBox) const override
 Test this object if it's completely outside, intersects, or is completely inside aBBox.
 
bool IsPointInside (const SFVEC2F &aPoint) const override
 
const BOARD_ITEMGetBoardItem () const
 
const BBOX_2DGetBBox () const
 
const SFVEC2FGetCentroid () const
 
OBJECT_2D_TYPE GetObjectType () const
 

Protected Attributes

BBOX_2D m_bbox
 
SFVEC2F m_centroid
 
OBJECT_2D_TYPE m_obj_type
 
const BOARD_ITEMm_boardItem
 

Private Attributes

SEGMENTS_WIDTH_NORMALS m_open_segments
 The outer part of the polygon.
 
OUTERS_AND_HOLES m_outers_and_holes
 

Detailed Description

Represent a sub polygon block.

This polygon block was created from a general polygon definition that was sub divided and to create blocks of polygons. This polygon class represent a sub part of that main polygon. There is information for the contours (used to test the ray2d intersection) and a close definition of the block polygon to test if a point is inside.

Definition at line 93 of file polygon_2d.h.

Constructor & Destructor Documentation

◆ POLYGON_2D()

Member Function Documentation

◆ GetBBox()

◆ GetBoardItem()

const BOARD_ITEM & OBJECT_2D::GetBoardItem ( ) const
inlineinherited

Definition at line 66 of file object_2d.h.

References OBJECT_2D::m_boardItem.

Referenced by RENDER_3D_RAYTRACE_BASE::createItemsFromContainer().

◆ GetCentroid()

const SFVEC2F & OBJECT_2D::GetCentroid ( ) const
inlineinherited

◆ GetObjectType()

◆ Intersect()

bool POLYGON_2D::Intersect ( const RAYSEG2D aSegRay,
float *  aOutT,
SFVEC2F aNormalOut 
) const
overridevirtual
Parameters
aOutTa value between 0.0 and 1.0 in relation to the time of the hit of the segment.

Implements OBJECT_2D.

Definition at line 120 of file polygon_2d.cpp.

References RAYSEG2D::m_End_minus_start, m_open_segments, and RAYSEG2D::m_Start.

◆ Intersects()

bool POLYGON_2D::Intersects ( const BBOX_2D aBBox) const
overridevirtual

a.Intersects(b) ⇔ !a.Disjoint(b) ⇔ !(a ∩ b = ∅)

Implements OBJECT_2D.

Definition at line 103 of file polygon_2d.cpp.

References BBOX_2D::Intersects(), and OBJECT_2D::m_bbox.

◆ IsBBoxInside()

INTERSECTION_RESULT POLYGON_2D::IsBBoxInside ( const BBOX_2D aBBox) const
overridevirtual

Test this object if it's completely outside, intersects, or is completely inside aBBox.

Returns
INTERSECTION_RESULT

Implements OBJECT_2D.

Definition at line 179 of file polygon_2d.cpp.

◆ IsPointInside()

bool POLYGON_2D::IsPointInside ( const SFVEC2F aPoint) const
overridevirtual

◆ Overlaps()

bool POLYGON_2D::Overlaps ( const BBOX_2D aBBox) const
overridevirtual

Test if the box overlaps the object.

Conformance Implements the Overlaps function from the OGC Simple Feature Specification at http://www.opengeospatial.org/standards/sfa. a.Overlaps(b) ⇔ ( dim(I(a)) = dim(I(b)) = dim(I(a)I(b))) ∧ (a ∩ b ≠ a) ∧ (a ∩ b ≠ b) It means that the result dimension of an overlap is the same dimensions of the bounding box (so the overlap cannot be a point or a line) and one of the boxes cannot full contain the other box.

Parameters
aBBoxis the bounding box to test.
Returns
true if the BBox intersects the object or is inside it.

Implements OBJECT_2D.

Definition at line 113 of file polygon_2d.cpp.

Member Data Documentation

◆ m_bbox

◆ m_boardItem

const BOARD_ITEM& OBJECT_2D::m_boardItem
protectedinherited

Definition at line 114 of file object_2d.h.

Referenced by OBJECT_2D::GetBoardItem().

◆ m_centroid

◆ m_obj_type

OBJECT_2D_TYPE OBJECT_2D::m_obj_type
protectedinherited

Definition at line 112 of file object_2d.h.

Referenced by OBJECT_2D::GetObjectType(), and OBJECT_2D::OBJECT_2D().

◆ m_open_segments

SEGMENTS_WIDTH_NORMALS POLYGON_2D::m_open_segments
private

The outer part of the polygon.

This list is used to test a ray intersection with the boundaries of this sub polygon. It contains also the interpolated normals that are passed from the main polygon. A polygon block can have multiple polygon and holes

Definition at line 112 of file polygon_2d.h.

Referenced by Intersect(), and POLYGON_2D().

◆ m_outers_and_holes

OUTERS_AND_HOLES POLYGON_2D::m_outers_and_holes
private

Definition at line 115 of file polygon_2d.h.

Referenced by IsPointInside(), and POLYGON_2D().


The documentation for this class was generated from the following files: