KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_io_kicad_sexpr_parser.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) 2012 CERN
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
25
26#ifndef _PCBNEW_PARSER_H_
27#define _PCBNEW_PARSER_H_
28
29#include <eda_units.h>
30#include <core/wx_stl_compat.h>
31#include <line_ending.h>
32#include <hashtables.h>
33#include <lib_id.h>
34#include <layer_ids.h> // PCB_LAYER_ID
35#include <lset.h>
36#include <pcb_lexer.h>
37#include <kiid.h>
38#include <math/box2.h>
39#include <optional>
41#include <drill/drill_span.h>
42#include <string_any_map.h>
43#include <padstack.h>
45
46#include <chrono>
47#include <memory>
48#include <set>
49#include <unordered_map>
50#include <utility>
51#include <vector>
52
53#include <boost/ptr_container/clone_allocator.hpp>
54
55
56class PCB_ARC;
57class BOARD;
58class BOARD_ITEM;
59class ZONE_SETTINGS;
62class PAD;
65class PCB_SHAPE;
67class EDA_TEXT;
68class PCB_TEXT;
69class PCB_TEXTBOX;
70class PCB_TRACK;
71class PCB_TABLE;
73class PCB_DRILL_MAP;
74class PCB_TABLECELL;
75class FOOTPRINT;
76class PCB_GROUP;
77class PCB_POINT;
78class PCB_TARGET;
79class PCB_GRID_ITEM;
80class PCB_VIA;
81class ZONE;
83class PCB_BARCODE;
84class FP_3DMODEL;
86struct LAYER;
89class FP_CACHE_ENTRY;
90
91
92namespace boost { template<class Key, class T, class Compare, class CloneAllocator, class Allocator>
93 class ptr_map; }
94
99class PCB_IO_KICAD_SEXPR_PARSER : public PCB_LEXER
100{
101public:
102
103 typedef std::unordered_map< std::string, PCB_LAYER_ID > LAYER_ID_MAP;
104 typedef std::unordered_map< std::string, LSET > LSET_MAP;
105 typedef std::unordered_map< wxString, KIID > KIID_MAP;
106
108 std::function<bool( wxString, int, wxString, wxString )> aQueryUserCallback,
109 PROGRESS_REPORTER* aProgressReporter = nullptr, unsigned aLineCount = 0,
110 bool aPreserveDestinationStackup = false, bool aAppendToExisting = false ) :
111 PCB_LEXER( aReader ),
112 m_board( aBoard ),
113 m_appendToExisting( aAppendToExisting ),
114 m_preserveDestinationStackup( aPreserveDestinationStackup ),
115 m_progressReporter( aProgressReporter ),
116 m_lastProgressTime( std::chrono::steady_clock::now() ),
117 m_lineCount( aLineCount ),
118 m_queryUserCallback( std::move( aQueryUserCallback ) )
119 {
120 init();
121 }
122
123 // ~PCB_IO_KICAD_SEXPR_PARSER() {}
124
125 BOARD_ITEM* Parse();
126
133 FOOTPRINT* parseFOOTPRINT( wxArrayString* aInitialComments = nullptr );
134
146 std::less<wxString>,
147 boost::heap_clone_allocator,
148 std::allocator<std::pair<const wxString,void*>>>& aFootprints );
149
154 {
155 return m_tooRecent;
156 }
157
162 wxString GetRequiredVersion();
163
168 bool IsValidBoardHeader();
169
174 const std::vector<wxString>& GetParseWarnings() const { return m_parseWarnings; }
175
177 void SetLayerMappingHandler( LAYER_MAPPING_HANDLER aHandler ) { m_layerMappingHandler = std::move( aHandler ); }
178
179private:
180
181 // Group membership info refers to other Uuids in the file.
182 // We don't want to rely on group declarations being last in the file, so
183 // we store info about the group declarations here during parsing and then resolve
184 // them into BOARD_ITEM* after we've parsed the rest of the file.
186 {
187 virtual ~GROUP_INFO() = default; // Make polymorphic
188
190 wxString name;
191 bool locked;
194 std::vector<KIID> memberUuids;
195 std::map<wxString, wxString> customProperties;
196 };
197
199 {
201 wxString genType;
203
209 std::vector<std::pair<wxString, std::unique_ptr<BOARD_ITEM>>> templates;
210
211 // The unique_ptr in `templates` makes this struct move-only. std::vector resize
212 // requires a noexcept move-ctor to move (rather than copy, which is deleted), so
213 // declare the move/copy operations explicitly.
214 GENERATOR_INFO() = default;
215 GENERATOR_INFO( GENERATOR_INFO&& ) noexcept = default;
216 GENERATOR_INFO& operator=( GENERATOR_INFO&& ) noexcept = default;
217 GENERATOR_INFO( const GENERATOR_INFO& ) = delete;
218 GENERATOR_INFO& operator=( const GENERATOR_INFO& ) = delete;
219 };
220
224 {
225 BOARD_ITEM* parent = nullptr;
228 std::vector<CONSTRAINT_MEMBER> members;
229 std::optional<double> value;
230 bool driving = true;
231 std::map<wxString, wxString> customProperties;
232 };
233
236 inline int getNetCode( int aNetCode )
237 {
238 if( ( aNetCode >= 0 ) && ( aNetCode < (int) m_netCodes.size() ) )
239 return m_netCodes[aNetCode];
240
241 return aNetCode;
242 }
243
252 void pushValueIntoMap( int aIndex, int aValue );
253
260 void init();
261
262 void checkpoint();
263
271 void createOldLayerMapping( std::unordered_map< std::string, std::string >& aMap );
272
277 void skipCurrent();
278
279 void parseHeader();
280 void parseGeneralSection();
281 void parsePAGE_INFO();
282 void parseTITLE_BLOCK();
283
284 void parseLayers();
285
287 void remapAppendedLayers( const std::vector<LAYER>& aSourceLayers, const LSET& aDestInitialEnabled,
288 int aDestInitialCopperCount );
289 void parseLayer( LAYER* aLayer );
290
291 void parseBoardStackup();
292
293 void parseSetup();
294
296 void parseDefaults( BOARD_DESIGN_SETTINGS& aSettings );
297 void parseDefaultTextDims( BOARD_DESIGN_SETTINGS& aSettings, int aLayer );
298 void parseNETINFO_ITEM();
299 void parseNETCLASS();
301
303
304 void parseTextBoxContent( PCB_TEXTBOX* aTextBox );
305
306 void bakeTextBoxLib( PCB_TEXTBOX* aTextBox );
307
313 void parseLineEnding( LINE_ENDING& aEnding );
314
316 PCB_TEXT* parsePCB_TEXT( BOARD_ITEM* aParent, PCB_TEXT* aBaseText = nullptr );
317 bool parsePCB_TEXT_effects( PCB_TEXT* aText, PCB_TEXT* aBaseText = nullptr );
329 bool parseTableBodyToken( PCB_TABLE* aTable, PCB_KEYS_T::T aToken,
330 bool aAllowIdentity );
331 void parseTableBody( PCB_TABLE* aTable, bool aAllowIdentity );
332
337 PCB_GENERATED_TABLE* parseGeneratedTable( std::unique_ptr<PCB_GENERATED_TABLE> aTable );
338
342 bool parseGeneratedTableExtra( PCB_GENERATED_TABLE* aTable, PCB_KEYS_T::T aToken );
343
347
348 // Parse a footprint, but do not replace PARSE_ERROR with FUTURE_FORMAT_ERROR automatically.
349 FOOTPRINT* parseFOOTPRINT_unchecked( wxArrayString* aInitialComments = nullptr );
350 void parseFootprintStackup( FOOTPRINT& aFootprint );
351
352 PAD* parsePAD( FOOTPRINT* aParent = nullptr );
353 void parsePAD_primitives( PAD* aPad, PCB_LAYER_ID aLayer );
354 void parsePAD_option( PAD* aPad, PCB_LAYER_ID aLayer );
356 void parsePadstack( PAD* aPad );
357
361 void parseViastack( PCB_VIA* aVia );
366 BOARD* parseBOARD();
367 void parseGROUP_members( GROUP_INFO& aGroupInfo );
368 void parseGROUP( BOARD_ITEM* aParent );
369 void parseCONSTRAINT( BOARD_ITEM* aParent );
370 void parseGENERATOR( BOARD_ITEM* aParent );
372
373 // Parse a board, but do not replace PARSE_ERROR with FUTURE_FORMAT_ERROR automatically.
375
384 PCB_LAYER_ID lookUpLayer( const LAYER_ID_MAP& aMap, bool aAllowUndefined = false );
385 LSET lookUpLayerSet( const LSET_MAP& aMap );
386
395
404
414
426
427 void parseXY( int* aX, int* aY );
428
429 void parseMargins( int& aLeft, int& aTop, int& aRight, int& aBottom );
430
431 void parseZoneDefaults( std::map<PCB_LAYER_ID, ZONE_LAYER_PROPERTIES>& aProperties );
432
433 void parseZoneLayerProperty( std::map<PCB_LAYER_ID, ZONE_LAYER_PROPERTIES>& aProperties );
434
435 std::pair<wxString, wxString> parseBoardProperty();
436
437 void parseCustomProperty( EDA_ITEM* aItem );
438 void parseCustomProperty( std::map<wxString, wxString>& aProps );
439
440 void parseVariants();
441 void parseFootprintVariant( FOOTPRINT* aFootprint );
442
451
458 void parseEDA_TEXT( EDA_TEXT* aText );
459
466 void parseRenderCache( EDA_TEXT* aText );
467
468 FP_3DMODEL* parse3DModel( bool aFileNameAlreadyParsed = false );
469
477
478 int parseBoardUnits();
479
480 int parseBoardUnits( const char* aExpected, EDA_DATA_TYPE aDataType );
481
482 inline int parseBoardUnits( const PCB_KEYS_T::T aToken, const EDA_DATA_TYPE aDataType = EDA_DATA_TYPE::DISTANCE )
483 {
484 return parseBoardUnits( GetTokenText( aToken ), aDataType );
485 }
486
487 inline int parseInt()
488 {
489 return (int)strtol( CurText(), nullptr, 10 );
490 }
491
492 inline int parseInt( const char* aExpected )
493 {
494 NeedNUMBER( aExpected );
495 return parseInt();
496 }
497
498 inline long parseHex()
499 {
500 NextTok();
501 return strtol( CurText(), nullptr, 16 );
502 }
503
504 bool parseBool();
505
506 std::optional<bool> parseOptBool();
507
518 bool parseMaybeAbsentBool( bool aDefaultValue );
519
520 std::pair<std::optional<bool>, std::optional<bool>> parseFrontBackOptBool( bool aAllowLegacyFormat = false );
521
522 void parseNet( BOARD_CONNECTED_ITEM* aItem );
523
524 /*
525 * @return if m_appendToExisting, returns new KIID(), otherwise returns CurStr() as KIID.
526 */
528
533 void resolveGroups( BOARD_ITEM* aParent );
534 void resolveConstraints( BOARD_ITEM* aParent );
535
537 void finishItem( BOARD_ITEM* aItem );
538
540 using TIMEOUT = std::chrono::milliseconds;
541
543 using CLOCK = std::chrono::steady_clock;
544
546 using TIME_PT = std::chrono::time_point<CLOCK>;
547
551 std::set<wxString> m_undefinedLayers;
552 std::vector<int> m_netCodes;
559
562 std::set<KIID> m_linkedZones;
563
566
569 unsigned m_lineCount;
570
571 std::vector<GROUP_INFO> m_groupInfos;
572 std::vector<GENERATOR_INFO> m_generatorInfos;
573 std::vector<CONSTRAINT_INFO> m_constraintInfos;
574
575 std::function<bool( wxString aTitle, int aIcon, wxString aMsg, wxString aAction )> m_queryUserCallback;
576
577 std::vector<wxString> m_parseWarnings;
578};
579
580
581#endif // _PCBNEW_PARSER_H_
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
Container for design settings for a BOARD object.
Abstract interface for BOARD_ITEMs capable of storing other items inside.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:99
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:411
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:98
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition eda_text.h:94
Helper class for creating a footprint library cache.
Definition kiid.h:46
A logical library item identifier and consists of various portions much like a URI.
Definition lib_id.h:45
Decorative shape (arrowhead, circle, square) at the start or end of a graphic line,...
Definition line_ending.h:62
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Definition richio.h:65
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
Definition pad.h:61
Abstract dimension API.
Turns on drill symbols at the holes, for one layer.
A table whose cell text is derived from the board and rebuilt whenever it goes stale.
A set of BOARD_ITEMs (i.e., without duplicates).
Definition pcb_group.h:51
void parseCONSTRAINT(BOARD_ITEM *aParent)
wxString m_generatorVersion
Set to the generator version this board requires.
PCB_TABLECELL * parsePCB_TABLECELL(BOARD_ITEM *aParent)
void parseGENERATOR_templates(GENERATOR_INFO &aGenInfo)
std::unordered_map< std::string, PCB_LAYER_ID > LAYER_ID_MAP
std::vector< int > m_netCodes
net codes mapping for boards being loaded
void parseOutlinePoints(SHAPE_LINE_CHAIN &aPoly)
Parses possible outline points and stores them into aPoly.
std::set< wxString > m_undefinedLayers
set of layers not defined in layers section
LAYER_MAPPING_HANDLER m_layerMappingHandler
optional remap of appended layers onto dest
std::vector< CONSTRAINT_INFO > m_constraintInfos
void parseZoneLayerProperty(std::map< PCB_LAYER_ID, ZONE_LAYER_PROPERTIES > &aProperties)
PROGRESS_REPORTER * m_progressReporter
optional; may be nullptr
int getNetCode(int aNetCode)
Convert net code using the mapping table if available, otherwise returns unchanged net code if < 0 or...
void parseFootprintStackup(FOOTPRINT &aFootprint)
PCB_GENERATED_TABLE * parseGeneratedTable(std::unique_ptr< PCB_GENERATED_TABLE > aTable)
The body every generated table shares.
void createOldLayerMapping(std::unordered_map< std::string, std::string > &aMap)
Create a mapping from the (short-lived) bug where layer names were translated.
bool parseTableBodyToken(PCB_TABLE *aTable, PCB_KEYS_T::T aToken, bool aAllowIdentity)
aAllowIdentity is false inside a drill chart's table_data, where the enclosing form owns uuid,...
void parseZoneDefaults(std::map< PCB_LAYER_ID, ZONE_LAYER_PROPERTIES > &aProperties)
std::unordered_map< std::string, LSET > LSET_MAP
void parseEDA_TEXT(EDA_TEXT *aText)
Parse the common settings for any object derived from EDA_TEXT.
int parseInt(const char *aExpected)
bool m_tooRecent
true if version parses as later than supported
void remapAppendedLayers(const std::vector< LAYER > &aSourceLayers, const LSET &aDestInitialEnabled, int aDestInitialCopperCount)
Remap the appended layers onto the destination using m_layerMappingHandler, on mismatch.
PCB_REFERENCE_IMAGE * parsePCB_REFERENCE_IMAGE(BOARD_ITEM *aParent)
LAYER_ID_MAP m_layerIndices
map layer name to it's index
const std::vector< wxString > & GetParseWarnings() const
Return any non-fatal parse warnings that occurred during parsing.
void parsePostMachining(PADSTACK::POST_MACHINING_PROPS &aProps)
void parseTableBody(PCB_TABLE *aTable, bool aAllowIdentity)
FP_3DMODEL * parse3DModel(bool aFileNameAlreadyParsed=false)
void parseTextBoxContent(PCB_TEXTBOX *aTextBox)
FOOTPRINT * parseFOOTPRINT(wxArrayString *aInitialComments=nullptr)
void parseLineEnding(LINE_ENDING &aEnding)
Parse a line ending definition from the token stream.
void pushValueIntoMap(int aIndex, int aValue)
Add aValue value in netcode mapping (m_netCodes) at aIndex.
void parseRenderCache(EDA_TEXT *aText)
Parse the render cache for any object derived from EDA_TEXT.
bool m_preserveDestinationStackup
append keeps destination stackup
std::set< KIID > m_linkedZones
Zones read with a link set or anchor.
std::chrono::steady_clock CLOCK
The clock used for the timestamp (guaranteed to be monotonic).
void init()
Clear and re-establish m_layerMap with the default layer names.
std::pair< std::optional< bool >, std::optional< bool > > parseFrontBackOptBool(bool aAllowLegacyFormat=false)
void skipCurrent()
Skip the current token level, i.e search for the RIGHT parenthesis which closes the current descripti...
void parseMargins(int &aLeft, int &aTop, int &aRight, int &aBottom)
PCB_LAYER_ID parseBoardItemLayer()
Parse the layer definition of a BOARD_ITEM object.
LSET parseLayersForCuItemWithSoldermask()
Parse the layers definition of a BOARD_ITEM object that has a single copper layer and optional solder...
void parseGENERATOR(BOARD_ITEM *aParent)
PCB_LAYER_ID lookUpLayer(const LAYER_ID_MAP &aMap, bool aAllowUndefined=false)
Parse the current token for the layer definition of a BOARD_ITEM object.
std::chrono::milliseconds TIMEOUT
The type of progress bar timeout.
void parsePAD_option(PAD *aPad, PCB_LAYER_ID aLayer)
LSET parseBoardItemLayersAsMask()
Parse the layers definition of a BOARD_ITEM object.
void finishItem(BOARD_ITEM *aItem)
Resolve the fonts, groups and constraints of a fully parsed board or footprint.
void resolveGroups(BOARD_ITEM *aParent)
Called after parsing a footprint definition or board to build the group membership lists.
void parseDefaultTextDims(BOARD_DESIGN_SETTINGS &aSettings, int aLayer)
std::vector< GROUP_INFO > m_groupInfos
ZONE * parseZONE(BOARD_ITEM_CONTAINER *aParent)
PCB_TABLE * parsePCB_TABLE(BOARD_ITEM *aParent)
std::vector< GENERATOR_INFO > m_generatorInfos
PCB_TEXTBOX * parsePCB_TEXTBOX(BOARD_ITEM *aParent)
std::chrono::time_point< CLOCK > TIME_PT
The type of the time stamps.
PCB_TEXT * parsePCB_TEXT(BOARD_ITEM *aParent, PCB_TEXT *aBaseText=nullptr)
unsigned m_lineCount
for progress reporting
VECTOR2I parseXY()
Parse a coordinate pair (xy X Y) in board units (mm).
void parseTEARDROP_PARAMETERS(TEARDROP_PARAMETERS *tdParams)
int m_requiredVersion
set to the KiCad format version this board requires
PAD * parsePAD(FOOTPRINT *aParent=nullptr)
void resolveConstraints(BOARD_ITEM *aParent)
std::function< bool(wxString aTitle, int aIcon, wxString aMsg, wxString aAction)> m_queryUserCallback
void parseNet(BOARD_CONNECTED_ITEM *aItem)
FOOTPRINT * parseFOOTPRINT_unchecked(wxArrayString *aInitialComments=nullptr)
void SetLayerMappingHandler(LAYER_MAPPING_HANDLER aHandler)
Handler to remap an appended board's layers onto the destination board, used on mismatch.
PCB_IO_KICAD_SEXPR_PARSER(LINE_READER *aReader, BOARD *aBoard, std::function< bool(wxString, int, wxString, wxString)> aQueryUserCallback, PROGRESS_REPORTER *aProgressReporter=nullptr, unsigned aLineCount=0, bool aPreserveDestinationStackup=false, bool aAppendToExisting=false)
PCB_DRILL_MAP * parsePCB_DRILL_MAP(BOARD_ITEM *aParent)
int parseBoardUnits(const PCB_KEYS_T::T aToken, const EDA_DATA_TYPE aDataType=EDA_DATA_TYPE::DISTANCE)
TIME_PT m_lastProgressTime
for progress reporting
void parseGROUP_members(GROUP_INFO &aGroupInfo)
bool IsTooRecent()
Return whether a version number, if any was parsed, was too recent.
bool IsValidBoardHeader()
Partially parse the input and check if it matches expected header.
void parseFootprintVariant(FOOTPRINT *aFootprint)
void ParseFootprintLib(boost::ptr_map< wxString, FP_CACHE_ENTRY, std::less< wxString >, boost::heap_clone_allocator, std::allocator< std::pair< const wxString, void * > > > &aFootprints)
Parse a footprint library file.
std::pair< wxString, wxString > parseBoardProperty()
LSET_MAP m_layerMasks
map layer names to their masks
bool parseMaybeAbsentBool(bool aDefaultValue)
Parses a boolean flag inside a list that existed before boolean normalization.
int parseBoardUnits()
Parse the current token as an ASCII numeric string with possible leading whitespace into a double pre...
bool parsePCB_TEXT_effects(PCB_TEXT *aText, PCB_TEXT *aBaseText=nullptr)
KIID_MAP m_resetKIIDMap
if resetting UUIDs, record new ones to update groups with.
void bakeTextBoxLib(PCB_TEXTBOX *aTextBox)
Lift disk-parsed values into PCB_TEXTBOX lib storage for new format files.
std::unordered_map< wxString, KIID > KIID_MAP
PCB_DIMENSION_BASE * parseDIMENSION(BOARD_ITEM *aParent)
LSET lookUpLayerSet(const LSET_MAP &aMap)
std::vector< wxString > m_parseWarnings
Non-fatal warnings collected during parsing.
bool m_appendToExisting
reading into an existing board; reset UUIDs
bool parseGeneratedTableExtra(PCB_GENERATED_TABLE *aTable, PCB_KEYS_T::T aToken)
One token only aTable's kind carries.
void parsePAD_primitives(PAD *aPad, PCB_LAYER_ID aLayer)
PCB_SHAPE * parsePCB_SHAPE(BOARD_ITEM *aParent)
void parseDefaults(BOARD_DESIGN_SETTINGS &aSettings)
wxString GetRequiredVersion()
Return a string representing the version of KiCad required to open this file.
PCB_BARCODE * parsePCB_BARCODE(BOARD_ITEM *aParent)
A PCB_POINT is a 0-dimensional point that is used to mark a position on a PCB, or more usually a foot...
Definition pcb_point.h:39
Object to handle a bitmap image that can be inserted in a PCB.
A progress reporter interface for use in multi-threaded environments.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
A name/value tuple with unique names and wxAny values.
TEARDROP_PARAMETARS is a helper class to handle parameters needed to build teardrops for a board thes...
Handle zones parameters.
Handle a list of polygons defining a copper zone.
Definition zone.h:70
Hole classification and drill span, shared by the drill model and the drill writers.
#define LAYER(n, l)
EDA_DATA_TYPE
The type of unit.
Definition eda_units.h:34
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
STL namespace.
PCB_CONSTRAINT_TYPE
The geometric relationship a PCB_CONSTRAINT enforces between its members.
std::function< std::map< wxString, PCB_LAYER_ID >(const std::vector< INPUT_LAYER_DESC > &)> LAYER_MAPPING_HANDLER
Pointer to a function that takes a map of source and KiCad layers and returns a re-mapped version.
Deferred constraint, resolved against the parsed items once the whole file is read,...
GENERATOR_INFO(GENERATOR_INFO &&) noexcept=default
std::vector< std::pair< wxString, std::unique_ptr< BOARD_ITEM > > > templates
Named template items parsed from the generator's (templates …) section.
std::map< wxString, wxString > customProperties
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708