KiCad PCB EDA Suite
KI_TEST::CommonTestData Struct Reference

Common data for some of the SHAPE_POLY_SET tests: More...

#include <fixtures_geometry.h>

Public Member Functions

 CommonTestData ()
 Constructor. More...
 
 ~CommonTestData ()
 

Public Attributes

SHAPE_POLY_SET emptyPolySet
 
SHAPE_POLY_SET uniqueVertexPolySet
 
SHAPE_POLY_SET solidPolySet
 
SHAPE_POLY_SET holeyPolySet
 
std::vector< VECTOR2IuniquePoints
 
std::vector< VECTOR2IholeyPoints
 
std::vector< SEGholeySegments
 

Detailed Description

Common data for some of the SHAPE_POLY_SET tests:

  1. holeyPolySet: A polyset containing one single squared outline with two holes: a non-convex pentagon and a triangle. 2.solidPolySet: A polyset with three empty outlines and no holes.
  2. uniqueVertexPolySet: A polyset with one single outline that contains just one vertex.
  3. emptyPolySet: A polyset with no outlines.

Definition at line 42 of file fixtures_geometry.h.

Constructor & Destructor Documentation

◆ CommonTestData()

KI_TEST::CommonTestData::CommonTestData ( )
inline

Constructor.

Definition at line 58 of file fixtures_geometry.h.

59  {
60  // UniqueVertexPolySet shall have a unique vertex
61  uniquePoints.emplace_back( 100, 50 );
62 
63  // Populate the holey polygon set points with 12 points
64 
65  // Square
66  holeyPoints.emplace_back( 100, 100 );
67  holeyPoints.emplace_back( 0, 100 );
68  holeyPoints.emplace_back( 0, 0 );
69  holeyPoints.emplace_back( 100, 0 );
70 
71  // Pentagon
72  holeyPoints.emplace_back( 10, 10 );
73  holeyPoints.emplace_back( 10, 20 );
74  holeyPoints.emplace_back( 15, 15 );
75  holeyPoints.emplace_back( 20, 20 );
76  holeyPoints.emplace_back( 20, 10 );
77 
78  // Triangle
79  holeyPoints.emplace_back( 40, 10 );
80  holeyPoints.emplace_back( 40, 20 );
81  holeyPoints.emplace_back( 60, 10 );
82 
83  // Save the segments of the holeyPolySet.
84  holeySegments.emplace_back( holeyPoints[0], holeyPoints[1] );
85  holeySegments.emplace_back( holeyPoints[1], holeyPoints[2] );
86  holeySegments.emplace_back( holeyPoints[2], holeyPoints[3] );
87  holeySegments.emplace_back( holeyPoints[3], holeyPoints[0] );
88 
89  // Pentagon segments
90  holeySegments.emplace_back( holeyPoints[4], holeyPoints[5] );
91  holeySegments.emplace_back( holeyPoints[5], holeyPoints[6] );
92  holeySegments.emplace_back( holeyPoints[6], holeyPoints[7] );
93  holeySegments.emplace_back( holeyPoints[7], holeyPoints[8] );
94  holeySegments.emplace_back( holeyPoints[8], holeyPoints[4] );
95 
96  // Triangle segments
97  holeySegments.emplace_back( holeyPoints[9], holeyPoints[10] );
98  holeySegments.emplace_back( holeyPoints[10], holeyPoints[11] );
99  holeySegments.emplace_back( holeyPoints[11], holeyPoints[9] );
100 
101  // Auxiliary variables to store the contours that will be added to the polygons
102  SHAPE_LINE_CHAIN polyLine, hole;
103 
104  // Create a polygon set with a unique vertex
105  polyLine.Append( uniquePoints[0] );
106  polyLine.SetClosed( true );
107  uniqueVertexPolySet.AddOutline( polyLine );
108 
109  // Create a polygon set without holes
113 
114  // Create a polygon set with holes
115 
116  // Adds a new squared outline
117  polyLine.Clear();
118 
119  for( int i = 0; i < 4; i++ )
120  polyLine.Append( holeyPoints[i] );
121 
122  polyLine.SetClosed( true );
123 
124  holeyPolySet.AddOutline( polyLine );
125 
126  // Adds a new hole (a pentagon)
127  for( int i = 4; i < 9; i++ )
128  hole.Append( holeyPoints[i] );
129 
130  hole.SetClosed( true );
131  holeyPolySet.AddHole( hole );
132 
133 
134  // Adds a new hole (a triangle)
135  hole.Clear();
136  for( int i = 9; i < 12; i++ )
137  hole.Append( holeyPoints[i] );
138 
139  hole.SetClosed( true );
140  holeyPolySet.AddHole( hole );
141  }
void Append(int aX, int aY, bool aAllowDuplication=false)
Function Append()
void SetClosed(bool aClosed)
Function SetClosed()
std::vector< VECTOR2I > uniquePoints
std::vector< VECTOR2I > holeyPoints
int NewOutline()
Creates a new empty polygon in the set and returns its index
int AddHole(const SHAPE_LINE_CHAIN &aHole, int aOutline=-1)
Adds a new hole to the given outline (default: last) and returns its index
SHAPE_POLY_SET uniqueVertexPolySet
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new outline to the set and returns its index
std::vector< SEG > holeySegments
SHAPE_LINE_CHAIN.
void Clear()
Function Clear() Removes all points from the line chain.

References SHAPE_POLY_SET::AddHole(), SHAPE_POLY_SET::AddOutline(), SHAPE_LINE_CHAIN::Append(), SHAPE_LINE_CHAIN::Clear(), holeyPoints, holeyPolySet, holeySegments, SHAPE_POLY_SET::NewOutline(), SHAPE_LINE_CHAIN::SetClosed(), solidPolySet, uniquePoints, and uniqueVertexPolySet.

◆ ~CommonTestData()

KI_TEST::CommonTestData::~CommonTestData ( )
inline

Definition at line 143 of file fixtures_geometry.h.

144  {
145  }

Member Data Documentation

◆ emptyPolySet

SHAPE_POLY_SET KI_TEST::CommonTestData::emptyPolySet

Definition at line 45 of file fixtures_geometry.h.

◆ holeyPoints

std::vector<VECTOR2I> KI_TEST::CommonTestData::holeyPoints

Definition at line 52 of file fixtures_geometry.h.

Referenced by CommonTestData().

◆ holeyPolySet

SHAPE_POLY_SET KI_TEST::CommonTestData::holeyPolySet

Definition at line 48 of file fixtures_geometry.h.

Referenced by CommonTestData().

◆ holeySegments

std::vector<SEG> KI_TEST::CommonTestData::holeySegments

Definition at line 53 of file fixtures_geometry.h.

Referenced by CommonTestData().

◆ solidPolySet

SHAPE_POLY_SET KI_TEST::CommonTestData::solidPolySet

Definition at line 47 of file fixtures_geometry.h.

Referenced by CommonTestData().

◆ uniquePoints

std::vector<VECTOR2I> KI_TEST::CommonTestData::uniquePoints

Definition at line 51 of file fixtures_geometry.h.

Referenced by CommonTestData().

◆ uniqueVertexPolySet

SHAPE_POLY_SET KI_TEST::CommonTestData::uniqueVertexPolySet

Definition at line 46 of file fixtures_geometry.h.

Referenced by CommonTestData().


The documentation for this struct was generated from the following file: