KiCad PCB EDA Suite
RN_POLY Class Reference

Class RN_POLY Describes a single subpolygon (ZONE_CONTAINER is supposed to contain one or more of those) and performs fast point-inside-polygon test. More...

#include <ratsnest_data.h>

Public Member Functions

 RN_POLY (const SHAPE_POLY_SET *aParent, int aSubpolygonIndex, RN_LINKS &aConnections, const BOX2I &aBBox)
 
const RN_NODE_PTRGetNode () const
 Function GetNode() Returns node representing a polygon (it has the same coordinates as the first point of its bounding polyline. More...
 
RN_NODE_PTRGetNode ()
 
bool HitTest (const RN_NODE_PTR &aNode) const
 Function HitTest() Tests if selected node is located within polygon boundaries. More...
 

Private Attributes

int m_subpolygonIndex
 

Index of the outline in the parent polygon set

More...
 
BOX2I m_bbox
 

Bounding box of the polygon.

More...
 
const SHAPE_POLY_SETm_parentPolyset
 

Polygon set containing the geometry

More...
 
RN_NODE_PTR m_node
 

Node representing a polygon (it has the same coordinates as the first point of its bounding polyline.

More...
 

Friends

bool sortArea (const RN_POLY &aP1, const RN_POLY &aP2)
 

Detailed Description

Class RN_POLY Describes a single subpolygon (ZONE_CONTAINER is supposed to contain one or more of those) and performs fast point-inside-polygon test.

Definition at line 280 of file ratsnest_data.h.

Constructor & Destructor Documentation

RN_POLY::RN_POLY ( const SHAPE_POLY_SET aParent,
int  aSubpolygonIndex,
RN_LINKS aConnections,
const BOX2I aBBox 
)

Definition at line 414 of file ratsnest_data.cpp.

References RN_LINKS::AddNode(), SHAPE_POLY_SET::CVertex(), m_node, VECTOR2< T >::x, and VECTOR2< T >::y.

416  :
417  m_subpolygonIndex( aSubpolygonIndex ),
418  m_bbox( aBBox ),
419  m_parentPolyset( aParent )
420 {
421  const VECTOR2I& p = aParent->CVertex( 0, aSubpolygonIndex, -1 );
422 
423  m_node = aConnections.AddNode( p.x, p.y );
424 
425  // Mark it as not appropriate as a destination of ratsnest edges
426  // (edges coming out from a polygon vertex look weird)
427  m_node->SetNoLine( true );
428 }
const SHAPE_POLY_SET * m_parentPolyset
Polygon set containing the geometry
const VECTOR2I & CVertex(int aIndex, int aOutline, int aHole) const
Returns the index-th vertex in a given hole outline within a given outline
int m_subpolygonIndex
Index of the outline in the parent polygon set
BOX2I m_bbox
Bounding box of the polygon.
RN_NODE_PTR m_node
Node representing a polygon (it has the same coordinates as the first point of its bounding polyline...

Member Function Documentation

const RN_NODE_PTR& RN_POLY::GetNode ( ) const
inline

Function GetNode() Returns node representing a polygon (it has the same coordinates as the first point of its bounding polyline.

Definition at line 292 of file ratsnest_data.h.

References m_node.

293  {
294  return m_node;
295  }
RN_NODE_PTR m_node
Node representing a polygon (it has the same coordinates as the first point of its bounding polyline...
RN_NODE_PTR& RN_POLY::GetNode ( )
inline

Definition at line 297 of file ratsnest_data.h.

References m_node.

298  {
299  return m_node;
300  }
RN_NODE_PTR m_node
Node representing a polygon (it has the same coordinates as the first point of its bounding polyline...
bool RN_POLY::HitTest ( const RN_NODE_PTR aNode) const

Function HitTest() Tests if selected node is located within polygon boundaries.

Parameters
aNodeis a node to be checked.
Returns
True is the node is located within polygon boundaries.

Definition at line 431 of file ratsnest_data.cpp.

References SHAPE_POLY_SET::Contains(), m_parentPolyset, and m_subpolygonIndex.

432 {
433  VECTOR2I p( aNode->GetX(), aNode->GetY() );
434 
436 }
const SHAPE_POLY_SET * m_parentPolyset
Polygon set containing the geometry
int m_subpolygonIndex
Index of the outline in the parent polygon set
bool Contains(const VECTOR2I &aP, int aSubpolyIndex=-1) const
Returns true if a given subpolygon contains the point aP.

Friends And Related Function Documentation

bool sortArea ( const RN_POLY aP1,
const RN_POLY aP2 
)
friend

Definition at line 80 of file ratsnest_data.cpp.

81 {
82  return aP1.m_bbox.GetArea() < aP2.m_bbox.GetArea();
83 }
ecoord_type GetArea() const
Function GetArea returns the area of the rectangle.
Definition: box2.h:391
BOX2I m_bbox
Bounding box of the polygon.

Member Data Documentation

BOX2I RN_POLY::m_bbox
private

Bounding box of the polygon.

Definition at line 316 of file ratsnest_data.h.

Referenced by sortArea().

RN_NODE_PTR RN_POLY::m_node
private

Node representing a polygon (it has the same coordinates as the first point of its bounding polyline.

Definition at line 323 of file ratsnest_data.h.

Referenced by GetNode(), and RN_POLY().

const SHAPE_POLY_SET* RN_POLY::m_parentPolyset
private

Polygon set containing the geometry

Definition at line 319 of file ratsnest_data.h.

Referenced by HitTest().

int RN_POLY::m_subpolygonIndex
private

Index of the outline in the parent polygon set

Definition at line 313 of file ratsnest_data.h.

Referenced by HitTest().


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