1 #include "EdaDataFile.h"
5 #include "../../enums.h"
6 #include "../../ProtoBuf/edadatafile.pb.h"
7 #include "ArchiveExtractor.h"
9 #include "../parse_info.h"
10 #include "../parse_error.h"
11 #include "../invalid_odb_error.h"
13 using namespace std::filesystem;
14 using namespace Utils;
16 namespace Odb::Lib::FileModel::Design
18 EdaDataFile::EdaDataFile(
bool logAllLineParsing)
19 : m_logAllLineParsing(logAllLineParsing)
23 EdaDataFile::~EdaDataFile()
26 m_attributeNames.clear();
27 m_attributeTextValues.clear();
29 m_netRecordsByName.clear();
30 m_packageRecords.clear();
31 m_packageRecordsByName.clear();
32 m_featureGroupRecords.clear();
33 m_propertyRecords.clear();
36 const std::filesystem::path& EdaDataFile::GetPath()
const
41 const std::filesystem::path& EdaDataFile::GetDirectory()
const
46 const std::string& EdaDataFile::GetUnits()
const
51 const std::string& EdaDataFile::GetSource()
const
56 EdaDataFile::NetRecord::SubnetRecord::~SubnetRecord()
58 m_featureIdRecords.clear();
61 std::unique_ptr<Odb::Lib::Protobuf::EdaDataFile::NetRecord::SubnetRecord> EdaDataFile::NetRecord::SubnetRecord::to_protobuf()
const
63 std::unique_ptr<Odb::Lib::Protobuf::EdaDataFile::NetRecord::SubnetRecord> pSubnetRecordMessage(
new Odb::Lib::Protobuf::EdaDataFile::NetRecord::SubnetRecord);
64 pSubnetRecordMessage->set_type((Odb::Lib::Protobuf::EdaDataFile::NetRecord::SubnetRecord::Type) type);
65 if (type == Type::Toeprint)
67 pSubnetRecordMessage->set_componentnumber(componentNumber);
68 pSubnetRecordMessage->set_toeprintnumber(toeprintNumber);
69 pSubnetRecordMessage->set_side((Odb::Lib::Protobuf::BoardSide)side);
71 else if (type == Type::Plane)
73 pSubnetRecordMessage->set_filltype((Odb::Lib::Protobuf::EdaDataFile::NetRecord::SubnetRecord::FillType)fillType);
74 pSubnetRecordMessage->set_cutouttype((Odb::Lib::Protobuf::EdaDataFile::NetRecord::SubnetRecord::CutoutType) cutoutType);
75 pSubnetRecordMessage->set_fillsize(fillSize);
78 for (
const auto& featureIdRecord : m_featureIdRecords)
80 auto pFeatureIdRecordMessage = pSubnetRecordMessage->add_featureidrecords();
81 pFeatureIdRecordMessage->CopyFrom(*featureIdRecord->to_protobuf());
83 return pSubnetRecordMessage;
86 void EdaDataFile::NetRecord::SubnetRecord::from_protobuf(
const Odb::Lib::Protobuf::EdaDataFile::NetRecord::SubnetRecord& message)
88 type =
static_cast<Type
>(message.type());
90 if (type == Type::Toeprint)
92 componentNumber = message.componentnumber();
93 toeprintNumber = message.toeprintnumber();
94 side =
static_cast<BoardSide
>(message.side());
96 else if (type == Type::Plane)
98 fillType =
static_cast<FillType
>(message.filltype());
99 cutoutType =
static_cast<CutoutType
>(message.cutouttype());
100 fillSize = message.fillsize();
101 index = message.index();
104 for (
const auto& featureIdRecordMessage : message.featureidrecords())
106 auto pFeatureIdRecord = std::make_shared<FeatureIdRecord>();
107 pFeatureIdRecord->from_protobuf(featureIdRecordMessage);
108 m_featureIdRecords.push_back(pFeatureIdRecord);
112 EdaDataFile::NetRecord::~NetRecord()
114 m_subnetRecords.clear();
115 m_propertyRecords.clear();
118 std::unique_ptr<Odb::Lib::Protobuf::EdaDataFile::NetRecord> EdaDataFile::NetRecord::to_protobuf()
const
120 std::unique_ptr<Odb::Lib::Protobuf::EdaDataFile::NetRecord> pNetRecordMessage(
new Odb::Lib::Protobuf::EdaDataFile::NetRecord);
121 pNetRecordMessage->set_name(name);
123 pNetRecordMessage->set_index(index);
125 for (
const auto& propertyRecord : m_propertyRecords)
127 auto pPropertyRecordMessage = pNetRecordMessage->add_propertyrecords();
128 pPropertyRecordMessage->CopyFrom(*propertyRecord->to_protobuf());
131 for (
const auto& subnetRecord : m_subnetRecords)
133 auto pSubnetRecordMessage = pNetRecordMessage->add_subnetrecords();
134 pSubnetRecordMessage->CopyFrom(*subnetRecord->to_protobuf());
136 for (
const auto& kvAttributeAssignment : m_attributeLookupTable)
138 (*pNetRecordMessage->mutable_attributelookuptable())[kvAttributeAssignment.first] = kvAttributeAssignment.second;
140 return pNetRecordMessage;
143 void EdaDataFile::NetRecord::from_protobuf(
const Odb::Lib::Protobuf::EdaDataFile::NetRecord& message)
145 name = message.name();
147 index = message.index();
149 for (
const auto& propertyRecordMessage : message.propertyrecords())
151 auto pPropertyRecord = std::make_shared<PropertyRecord>();
152 pPropertyRecord->from_protobuf(propertyRecordMessage);
153 m_propertyRecords.push_back(pPropertyRecord);
156 for (
const auto& subnetRecordMessage : message.subnetrecords())
158 auto pSubnetRecord = std::make_shared<SubnetRecord>();
159 pSubnetRecord->from_protobuf(subnetRecordMessage);
160 m_subnetRecords.push_back(pSubnetRecord);
163 for (
const auto& kvAttributeAssignment : message.attributelookuptable())
165 m_attributeLookupTable[kvAttributeAssignment.first] = kvAttributeAssignment.second;
169 std::unique_ptr<Odb::Lib::Protobuf::EdaDataFile::FeatureIdRecord>
170 EdaDataFile::FeatureIdRecord::to_protobuf()
const
172 std::unique_ptr<Odb::Lib::Protobuf::EdaDataFile::FeatureIdRecord> pFeatureIdRecordMessage(
new Odb::Lib::Protobuf::EdaDataFile::FeatureIdRecord);
173 pFeatureIdRecordMessage->set_type((Odb::Lib::Protobuf::EdaDataFile::FeatureIdRecord::Type) type);
174 pFeatureIdRecordMessage->set_layernumber(layerNumber);
175 pFeatureIdRecordMessage->set_featurenumber(featureNumber);
176 return pFeatureIdRecordMessage;
179 void EdaDataFile::FeatureIdRecord::from_protobuf(
const Odb::Lib::Protobuf::EdaDataFile::FeatureIdRecord& message)
181 type =
static_cast<Type
>(message.type());
182 layerNumber = message.layernumber();
183 featureNumber = message.featurenumber();
186 std::unique_ptr<Odb::Lib::Protobuf::EdaDataFile::FeatureGroupRecord>
187 EdaDataFile::FeatureGroupRecord::to_protobuf()
const
189 std::unique_ptr<Odb::Lib::Protobuf::EdaDataFile::FeatureGroupRecord> pFeatureGroupRecordMessage(
new Odb::Lib::Protobuf::EdaDataFile::FeatureGroupRecord);
190 pFeatureGroupRecordMessage->set_type(type);
191 for (
const auto& featureIdRecord : m_featureIdRecords)
193 auto pFeatureIdRecordMessage = pFeatureGroupRecordMessage->add_featureidrecords();
194 pFeatureIdRecordMessage->CopyFrom(*featureIdRecord->to_protobuf());
196 for (
const auto& propertyRecord : m_propertyRecords)
198 auto pPropertyRecordMessage = pFeatureGroupRecordMessage->add_featureidrecords();
199 pPropertyRecordMessage->CopyFrom(*propertyRecord->to_protobuf());
201 return pFeatureGroupRecordMessage;
204 void EdaDataFile::FeatureGroupRecord::from_protobuf(
const Odb::Lib::Protobuf::EdaDataFile::FeatureGroupRecord& message)
206 type = message.type();
207 for (
const auto& featureIdRecordMessage : message.featureidrecords())
209 auto pFeatureIdRecord = std::make_shared<FeatureIdRecord>();
210 pFeatureIdRecord->from_protobuf(featureIdRecordMessage);
211 m_featureIdRecords.push_back(pFeatureIdRecord);
213 for (
const auto& propertyRecordMessage : message.propertyrecords())
215 auto pPropertyRecord = std::make_shared<PropertyRecord>();
216 pPropertyRecord->from_protobuf(propertyRecordMessage);
217 m_propertyRecords.push_back(pPropertyRecord);
221 const std::vector<std::string>& EdaDataFile::GetLayerNames()
const
226 const std::vector<std::string>& EdaDataFile::GetAttributeNames()
const
228 return m_attributeNames;
231 const std::vector<std::string>& EdaDataFile::GetAttributeTextValues()
const
233 return m_attributeTextValues;
236 const EdaDataFile::NetRecord::Vector& EdaDataFile::GetNetRecords()
const
241 const EdaDataFile::NetRecord::StringMap& EdaDataFile::GetNetRecordsByName()
const
243 return m_netRecordsByName;
246 const EdaDataFile::PackageRecord::Vector& EdaDataFile::GetPackageRecords()
const
248 return m_packageRecords;
251 const EdaDataFile::PackageRecord::StringMap& EdaDataFile::GetPackageRecordsByName()
const
253 return m_packageRecordsByName;
256 const EdaDataFile::FeatureGroupRecord::Vector& EdaDataFile::GetFeatureGroupRecords()
const
258 return m_featureGroupRecords;
261 const PropertyRecord::Vector& EdaDataFile::GetPropertyRecords()
const
263 return m_propertyRecords;
266 std::unique_ptr<Odb::Lib::Protobuf::EdaDataFile> EdaDataFile::to_protobuf()
const
268 std::unique_ptr<Odb::Lib::Protobuf::EdaDataFile> pEdaDataFileMessage(
new Odb::Lib::Protobuf::EdaDataFile);
269 pEdaDataFileMessage->set_path(m_path.string());
270 pEdaDataFileMessage->set_units(m_units);
271 pEdaDataFileMessage->set_source(m_source);
272 for (
const auto& layerName : m_layerNames)
274 pEdaDataFileMessage->add_layernames(layerName);
276 for (
const auto& attributeName : m_attributeNames)
278 pEdaDataFileMessage->add_attributenames(attributeName);
280 for (
const auto& attrTextValue : m_attributeTextValues)
282 pEdaDataFileMessage->add_attributetextvalues(attrTextValue);
284 for (
const auto& pNetRecord : m_netRecords)
286 auto pNetRecordMessage = pEdaDataFileMessage->add_netrecords();
287 pNetRecordMessage->CopyFrom(*pNetRecord->to_protobuf());
289 for (
const auto& kvNetRecord : m_netRecordsByName)
291 (*pEdaDataFileMessage->mutable_netrecordsbyname())[kvNetRecord.first] = *kvNetRecord.second->to_protobuf();
293 for (
const auto& pPackageRecord : m_packageRecords)
295 auto pPackageRecordMessage = pEdaDataFileMessage->add_packagerecords();
296 pPackageRecordMessage->CopyFrom(*pPackageRecord->to_protobuf());
298 for (
const auto& kvPackageRecord : m_packageRecordsByName)
300 (*pEdaDataFileMessage->mutable_packagerecordsbyname())[kvPackageRecord.first] = *kvPackageRecord.second->to_protobuf();
302 for (
const auto& pPropertyRecord : m_propertyRecords)
304 auto pPropertyRecordMessage = pEdaDataFileMessage->add_propertyrecords();
305 pPropertyRecordMessage->CopyFrom(*pPropertyRecord->to_protobuf());
307 for (
const auto& pFeatureGroupRecord : m_featureGroupRecords)
309 auto pFeatureGroupRecordMessage = pEdaDataFileMessage->add_featuregrouprecords();
310 pFeatureGroupRecordMessage->CopyFrom(*pFeatureGroupRecord->to_protobuf());
313 return pEdaDataFileMessage;
316 void EdaDataFile::from_protobuf(
const Odb::Lib::Protobuf::EdaDataFile& message)
318 m_path = message.path();
319 m_units = message.units();
320 m_source = message.source();
321 for (
const auto& layerName : message.layernames())
323 m_layerNames.push_back(layerName);
325 for (
const auto& attributeName : message.attributenames())
327 m_attributeNames.push_back(attributeName);
329 for (
const auto& attrTextValue : message.attributetextvalues())
331 m_attributeTextValues.push_back(attrTextValue);
333 for (
const auto& netRecordMessage : message.netrecords())
335 auto pNetRecord = std::make_shared<NetRecord>();
336 pNetRecord->from_protobuf(netRecordMessage);
337 m_netRecords.push_back(pNetRecord);
339 for (
const auto& kvNetRecordMessage : message.netrecordsbyname())
341 auto pNetRecord = std::make_shared<NetRecord>();
342 pNetRecord->from_protobuf(kvNetRecordMessage.second);
343 m_netRecordsByName[kvNetRecordMessage.first] = pNetRecord;
345 for (
const auto& packageRecordMessage : message.packagerecords())
347 auto pPackageRecord = std::make_shared<PackageRecord>();
348 pPackageRecord->from_protobuf(packageRecordMessage);
349 m_packageRecords.push_back(pPackageRecord);
351 for (
const auto& kvPackageRecordMessage : message.packagerecordsbyname())
353 auto pPackageRecord = std::make_shared<PackageRecord>();
354 pPackageRecord->from_protobuf(kvPackageRecordMessage.second);
355 m_packageRecordsByName[kvPackageRecordMessage.first] = pPackageRecord;
357 for (
const auto& propertyRecordMessage : message.propertyrecords())
359 auto pPropertyRecord = std::make_shared<PropertyRecord>();
360 pPropertyRecord->from_protobuf(propertyRecordMessage);
361 m_propertyRecords.push_back(pPropertyRecord);
363 for (
const auto& featureGroupRecordMessage : message.featuregrouprecords())
365 auto pFeatureGroupRecord = std::make_shared<FeatureGroupRecord>();
366 pFeatureGroupRecord->from_protobuf(featureGroupRecordMessage);
367 m_featureGroupRecords.push_back(pFeatureGroupRecord);
371 bool EdaDataFile::Save(std::ostream& os)
376 bool EdaDataFile::Parse(std::filesystem::path path)
378 std::ifstream edaDataFile;
384 loginfo(
"checking for extraction...");
387 m_path = ArchiveExtractor::getUncompressedFilePath(m_directory.string(), EDADATA_FILENAME);
389 if (!std::filesystem::exists(m_path))
391 auto message =
"eda/data file does not exist: [" + m_path.string() +
"]";
392 throw invalid_odb_error(message.c_str());
394 else if (!std::filesystem::is_regular_file(m_path))
396 auto message =
"eda/data is not a file: [" + m_path.string() +
"]";
397 throw invalid_odb_error(message.c_str());
400 loginfo(
"any extraction complete, parsing data...");
402 edaDataFile.open(m_path.string(), std::ios::in);
403 if (!edaDataFile.is_open())
405 auto message =
"unable to open eda/data file: [" + m_path.string() +
"]";
406 throw invalid_odb_error(message.c_str());
409 std::shared_ptr<NetRecord> pCurrentNetRecord;
410 std::shared_ptr<NetRecord::SubnetRecord> pCurrentSubnetRecord;
412 std::shared_ptr<PackageRecord> pCurrentPackageRecord;
413 std::shared_ptr<PackageRecord::PinRecord> pCurrentPinRecord;
415 std::shared_ptr<PackageRecord::OutlineRecord> pCurrentContourOutlineRecord;
416 std::shared_ptr<ContourPolygon> pCurrentContourPolygon;
418 FeatureGroupRecord::shared_ptr pCurrentFeatureGroupRecord;
420 while (std::getline(edaDataFile, line))
426 Utils::str_trim(line);
429 if (m_logAllLineParsing)
431 parse_info pi(m_path, line, lineNumber);
432 logdebug(pi.toString(
"Parsing line..."));
435 std::stringstream lineStream(line);
437 if (line.find(ATTRIBUTE_NAME_TOKEN) == 0 ||
438 line.find(std::string(COMMENT_TOKEN) + ATTRIBUTE_NAME_TOKEN) == 0)
443 if (!std::getline(lineStream, token,
' '))
445 throw_parse_error(m_path, line, token, lineNumber);
447 else if (!std::getline(lineStream, token,
' '))
449 throw_parse_error(m_path, line, token, lineNumber);
451 m_attributeNames.push_back(token);
453 else if (line.find(ATTRIBUTE_VALUE_TOKEN) == 0 ||
454 line.find(std::string(COMMENT_TOKEN) + ATTRIBUTE_VALUE_TOKEN) == 0)
458 if (!std::getline(lineStream, token,
' '))
460 throw_parse_error(m_path, line, token, lineNumber);
462 else if (!std::getline(lineStream, token,
' '))
464 throw_parse_error(m_path, line, token, lineNumber);
466 m_attributeTextValues.push_back(token);
468 else if (line.find(COMMENT_TOKEN) == 0)
473 else if (line.find(UNITS_TOKEN) == 0)
477 if (!std::getline(lineStream, token,
'='))
479 throw_parse_error(m_path, line, token, lineNumber);
481 else if (!std::getline(lineStream, token,
'='))
483 throw_parse_error(m_path, line, token, lineNumber);
487 else if (line.find(HEADER_RECORD_TOKEN) == 0)
493 if (token != HEADER_RECORD_TOKEN)
495 throw_parse_error(m_path, line, token, lineNumber);
499 if (!std::getline(lineStream, m_source))
501 throw_parse_error(m_path, line, token, lineNumber);
504 Utils::str_trim(m_source);
506 else if (line.find(LAYER_NAMES_RECORD_TOKEN) == 0)
512 if (token != LAYER_NAMES_RECORD_TOKEN)
514 throw_parse_error(m_path, line, token, lineNumber);
517 while (lineStream >> token)
519 m_layerNames.push_back(token);
522 else if (line.find(PropertyRecord::RECORD_TOKEN) == 0)
526 if (!(lineStream >> token))
528 throw_parse_error(m_path, line, token, lineNumber);
531 if (token != PropertyRecord::RECORD_TOKEN)
533 throw_parse_error(m_path, line, token, lineNumber);
536 auto pPropertyRecord = std::make_shared<PropertyRecord>();
538 if (!(lineStream >> pPropertyRecord->name))
540 throw_parse_error(m_path, line, token, lineNumber);
543 if (!(lineStream >> token))
545 throw_parse_error(m_path, line, token, lineNumber);
554 if (!(lineStream >> token))
556 throw_parse_error(m_path, line, token, lineNumber);
560 if (token.size() > 0 && token[0] ==
'\'')
566 if (token.size() > 0 && token[token.size() - 1] ==
'\'')
569 token.erase(token.size() - 1);
572 Utils::str_trim(token);
575 pPropertyRecord->value = token;
578 while (lineStream >> f)
580 pPropertyRecord->floatValues.push_back(f);
583 if (pCurrentNetRecord !=
nullptr)
585 pCurrentNetRecord->m_propertyRecords.push_back(pPropertyRecord);
587 else if (pCurrentPackageRecord !=
nullptr)
589 pCurrentPackageRecord->m_propertyRecords.push_back(pPropertyRecord);
591 else if (pCurrentFeatureGroupRecord !=
nullptr)
593 pCurrentFeatureGroupRecord->m_propertyRecords.push_back(pPropertyRecord);
598 m_propertyRecords.push_back(pPropertyRecord);
601 else if (line.find(NET_RECORD_TOKEN) == 0)
606 if (!(lineStream >> token))
608 throw_parse_error(m_path, line, token, lineNumber);
611 if (token != NET_RECORD_TOKEN)
613 throw_parse_error(m_path, line, token, lineNumber);
617 if (pCurrentNetRecord !=
nullptr)
620 if (pCurrentSubnetRecord !=
nullptr)
622 pCurrentNetRecord->m_subnetRecords.push_back(pCurrentSubnetRecord);
623 pCurrentSubnetRecord.reset();
626 m_netRecords.push_back(pCurrentNetRecord);
628 pCurrentNetRecord.reset();
632 if (!std::getline(lineStream, token,
';'))
634 throw_parse_error(m_path, line, token, lineNumber);
641 pCurrentNetRecord = std::make_shared<NetRecord>();
642 pCurrentNetRecord->name = token;
643 pCurrentNetRecord->index =
static_cast<unsigned>(m_netRecords.size());
645 std::string attrIdString;
646 lineStream >> attrIdString;
647 if (!pCurrentNetRecord->ParseAttributeLookupTable(attrIdString))
649 throw_parse_error(m_path, line, token, lineNumber);
652 else if (line.find(NetRecord::SubnetRecord::RECORD_TOKEN) == 0)
658 if (token != NetRecord::SubnetRecord::RECORD_TOKEN)
660 throw_parse_error(m_path, line, token, lineNumber);
663 if (pCurrentNetRecord !=
nullptr)
666 if (pCurrentSubnetRecord !=
nullptr)
668 pCurrentNetRecord->m_subnetRecords.push_back(pCurrentSubnetRecord);
669 pCurrentSubnetRecord.reset();
673 pCurrentSubnetRecord = std::make_shared<NetRecord::SubnetRecord>();
674 pCurrentSubnetRecord->index =
static_cast<unsigned>(pCurrentNetRecord->m_subnetRecords.size());
678 if (token == NetRecord::SubnetRecord::RECORD_TYPE_VIA_TOKEN)
680 pCurrentSubnetRecord->type = NetRecord::SubnetRecord::Type::Via;
682 else if (token == NetRecord::SubnetRecord::RECORD_TYPE_TRACE_TOKEN)
684 pCurrentSubnetRecord->type = NetRecord::SubnetRecord::Type::Trace;
686 else if (token == NetRecord::SubnetRecord::RECORD_TYPE_PLANE_TOKEN)
688 pCurrentSubnetRecord->type = NetRecord::SubnetRecord::Type::Plane;
694 pCurrentSubnetRecord->fillType = NetRecord::SubnetRecord::FillType::Solid;
696 else if (token ==
"O")
698 pCurrentSubnetRecord->fillType = NetRecord::SubnetRecord::FillType::Outline;
702 throw_parse_error(m_path, line, token, lineNumber);
709 pCurrentSubnetRecord->cutoutType = NetRecord::SubnetRecord::CutoutType::Circle;
711 else if (token ==
"R")
713 pCurrentSubnetRecord->cutoutType = NetRecord::SubnetRecord::CutoutType::Rectangle;
715 else if (token ==
"O")
717 pCurrentSubnetRecord->cutoutType = NetRecord::SubnetRecord::CutoutType::Octagon;
719 else if (token ==
"E")
721 pCurrentSubnetRecord->cutoutType = NetRecord::SubnetRecord::CutoutType::Exact;
725 throw_parse_error(m_path, line, token, lineNumber);
729 lineStream >> pCurrentSubnetRecord->fillSize;
731 else if (token == NetRecord::SubnetRecord::RECORD_TYPE_TOEPRINT_TOKEN)
733 pCurrentSubnetRecord->type = NetRecord::SubnetRecord::Type::Toeprint;
739 pCurrentSubnetRecord->side = BoardSide::Top;
741 else if (token ==
"B")
743 pCurrentSubnetRecord->side = BoardSide::Bottom;
747 throw_parse_error(m_path, line, token, lineNumber);
751 lineStream >> pCurrentSubnetRecord->componentNumber;
754 lineStream >> pCurrentSubnetRecord->toeprintNumber;
758 throw_parse_error(m_path, line, token, lineNumber);
761 else if (line.find(FEATURE_ID_RECORD_TOKEN) == 0)
766 if (!(lineStream >> token) || token != FEATURE_ID_RECORD_TOKEN)
768 throw_parse_error(m_path, line, token, lineNumber);
771 auto pFeatureIdRecord = std::make_shared<FeatureIdRecord>();
774 if (!(lineStream >> token))
776 throw_parse_error(m_path, line, token, lineNumber);
781 pFeatureIdRecord->type = FeatureIdRecord::Type::Copper;
783 else if (token ==
"L")
785 pFeatureIdRecord->type = FeatureIdRecord::Type::Laminate;
787 else if (token ==
"H")
789 pFeatureIdRecord->type = FeatureIdRecord::Type::Hole;
793 throw_parse_error(m_path, line, token, lineNumber);
797 if (!(lineStream >> pFeatureIdRecord->layerNumber))
799 throw_parse_error(m_path, line, token, lineNumber);
803 if (!(lineStream >> pFeatureIdRecord->featureNumber))
805 throw_parse_error(m_path, line, token, lineNumber);
808 if (pCurrentNetRecord !=
nullptr &&
809 pCurrentSubnetRecord !=
nullptr)
811 pCurrentSubnetRecord->m_featureIdRecords.push_back(pFeatureIdRecord);
813 else if (pCurrentFeatureGroupRecord !=
nullptr)
815 pCurrentFeatureGroupRecord->m_featureIdRecords.push_back(pFeatureIdRecord);
819 throw_parse_error(m_path, line, token, lineNumber);
822 else if (line.find(PACKAGE_RECORD_TOKEN) == 0)
827 if (!(lineStream >> token) || token != PACKAGE_RECORD_TOKEN)
829 throw_parse_error(m_path, line, token, lineNumber);
833 if (pCurrentNetRecord !=
nullptr)
836 if (pCurrentSubnetRecord !=
nullptr)
838 pCurrentNetRecord->m_subnetRecords.push_back(pCurrentSubnetRecord);
839 pCurrentSubnetRecord.reset();
842 m_netRecords.push_back(pCurrentNetRecord);
844 pCurrentNetRecord.reset();
846 else if (pCurrentPackageRecord !=
nullptr)
849 if (pCurrentPinRecord !=
nullptr)
852 if (pCurrentPackageRecord->m_pinRecords.size() > UINT_MAX)
854 throw_parse_error(m_path, line, token, lineNumber);
856 pCurrentPinRecord->index =
static_cast<unsigned>(pCurrentPackageRecord->m_pinRecords.size());
857 pCurrentPackageRecord->m_pinRecords.push_back(pCurrentPinRecord);
858 pCurrentPinRecord.reset();
862 m_packageRecords.push_back(pCurrentPackageRecord);
864 pCurrentPackageRecord.reset();
867 pCurrentPackageRecord = std::make_shared<PackageRecord>();
868 pCurrentPackageRecord->index =
static_cast<unsigned int>(m_packageRecords.size());
871 if (!(lineStream >> pCurrentPackageRecord->name))
873 throw_parse_error(m_path, line, token, lineNumber);
877 if (!(lineStream >> pCurrentPackageRecord->pitch))
879 throw_parse_error(m_path, line, token, lineNumber);
883 if (!(lineStream >> pCurrentPackageRecord->xMin >> pCurrentPackageRecord->yMin))
885 throw_parse_error(m_path, line, token, lineNumber);
889 if (!(lineStream >> pCurrentPackageRecord->xMax))
891 throw_parse_error(m_path, line, token, lineNumber);
895 if (!std::getline(lineStream, token,
';'))
897 throw_parse_error(m_path, line, token, lineNumber);
901 pCurrentPackageRecord->yMax = std::stof(token);
903 std::string attrIdString;
904 lineStream >> attrIdString;
905 if (!pCurrentPackageRecord->ParseAttributeLookupTable(attrIdString))
907 throw_parse_error(m_path, line, token, lineNumber);
910 else if (line.find(PIN_RECORD_TOKEN) == 0)
915 if (!(lineStream >> token) || token != PIN_RECORD_TOKEN)
917 throw_parse_error(m_path, line, token, lineNumber);
920 if (pCurrentPackageRecord !=
nullptr)
923 if (pCurrentPinRecord !=
nullptr)
926 if (pCurrentPackageRecord->m_pinRecords.size() > UINT_MAX)
928 throw_parse_error(m_path, line, token, lineNumber);
930 pCurrentPinRecord->index =
static_cast<unsigned>(pCurrentPackageRecord->m_pinRecords.size());
931 pCurrentPackageRecord->m_pinRecords.push_back(pCurrentPinRecord);
932 pCurrentPinRecord.reset();
936 pCurrentPinRecord = std::make_shared<PackageRecord::PinRecord>();
940 lineStream >> pCurrentPinRecord->name;
943 if (!(lineStream >> token))
945 throw_parse_error(m_path, line, token, lineNumber);
950 pCurrentPinRecord->type = PackageRecord::PinRecord::Type::ThroughHole;
952 else if (token ==
"B")
954 pCurrentPinRecord->type = PackageRecord::PinRecord::Type::Blind;
956 else if (token ==
"S")
958 pCurrentPinRecord->type = PackageRecord::PinRecord::Type::Surface;
962 logerror(
"unknown pin type: [" + token +
"]");
963 throw_parse_error(m_path, line, token, lineNumber);
967 if (!(lineStream >> pCurrentPinRecord->xCenter >> pCurrentPinRecord->yCenter))
969 throw_parse_error(m_path, line, token, lineNumber);
973 if (!(lineStream >> pCurrentPinRecord->finishedHoleSize))
975 throw_parse_error(m_path, line, token, lineNumber);
979 if (!(lineStream >> token))
981 throw_parse_error(m_path, line, token, lineNumber);
986 pCurrentPinRecord->electricalType = PackageRecord::PinRecord::ElectricalType::Electrical;
988 else if (token ==
"M")
990 pCurrentPinRecord->electricalType = PackageRecord::PinRecord::ElectricalType::NonElectrical;
992 else if (token ==
"U")
994 pCurrentPinRecord->electricalType = PackageRecord::PinRecord::ElectricalType::Undefined;
998 logerror(
"unknown pin electrical type: [" + token +
"]");
999 throw_parse_error(m_path, line, token, lineNumber);
1003 if (!(lineStream >> token))
1005 throw_parse_error(m_path, line, token, lineNumber);
1010 pCurrentPinRecord->mountType = PackageRecord::PinRecord::MountType::Smt;
1012 else if (token ==
"D")
1014 pCurrentPinRecord->mountType = PackageRecord::PinRecord::MountType::RecommendedSmtPad;
1016 else if (token ==
"T")
1018 pCurrentPinRecord->mountType = PackageRecord::PinRecord::MountType::MT_ThroughHole;
1020 else if (token ==
"R")
1022 pCurrentPinRecord->mountType = PackageRecord::PinRecord::MountType::RecommendedThroughHole;
1024 else if (token ==
"P")
1026 pCurrentPinRecord->mountType = PackageRecord::PinRecord::MountType::Pressfit;
1028 else if (token ==
"N")
1030 pCurrentPinRecord->mountType = PackageRecord::PinRecord::MountType::NonBoard;
1032 else if (token ==
"H")
1034 pCurrentPinRecord->mountType = PackageRecord::PinRecord::MountType::Hole;
1036 else if (token ==
"U")
1038 pCurrentPinRecord->mountType = PackageRecord::PinRecord::MountType::MT_Undefined;
1042 logerror(
"unknown pin mount type: [" + token +
"]");
1043 throw_parse_error(m_path, line, token, lineNumber);
1048 if (lineStream >> token)
1050 std::stringstream idStream(token);
1051 if (!std::getline(idStream, token,
'=') || token !=
"ID")
1053 throw_parse_error(m_path, line, token, lineNumber);
1056 idStream >> pCurrentPinRecord->id;
1061 #define SIMULATE_PARSE_ERROR 0
1062 #if SIMULATE_PARSE_ERROR
1063 throw_parse_error(m_path, line, token, lineNumber);
1066 pCurrentPinRecord->id = UINT_MAX;
1069 else if (line.find(FEATURE_GROUP_RECORD_TOKEN) == 0)
1074 if (!(lineStream >> token))
1076 throw_parse_error(m_path, line, token, lineNumber);
1079 if (token != FEATURE_GROUP_RECORD_TOKEN)
1081 throw_parse_error(m_path, line, token, lineNumber);
1085 if (pCurrentNetRecord !=
nullptr)
1088 if (pCurrentSubnetRecord !=
nullptr)
1090 pCurrentNetRecord->m_subnetRecords.push_back(pCurrentSubnetRecord);
1091 pCurrentSubnetRecord.reset();
1094 m_netRecords.push_back(pCurrentNetRecord);
1096 pCurrentNetRecord.reset();
1098 else if (pCurrentPackageRecord !=
nullptr)
1101 if (pCurrentPinRecord !=
nullptr)
1104 if (pCurrentPackageRecord->m_pinRecords.size() > UINT_MAX)
1106 throw_parse_error(m_path, line, token, lineNumber);
1108 pCurrentPinRecord->index =
static_cast<unsigned>(pCurrentPackageRecord->m_pinRecords.size());
1109 pCurrentPackageRecord->m_pinRecords.push_back(pCurrentPinRecord);
1110 pCurrentPinRecord.reset();
1114 m_packageRecords.push_back(pCurrentPackageRecord);
1116 pCurrentPackageRecord.reset();
1118 else if (pCurrentFeatureGroupRecord !=
nullptr)
1120 m_featureGroupRecords.push_back(pCurrentFeatureGroupRecord);
1121 pCurrentFeatureGroupRecord.reset();
1124 pCurrentFeatureGroupRecord = std::make_shared<FeatureGroupRecord>();
1126 if (!(lineStream >> pCurrentFeatureGroupRecord->type))
1128 throw_parse_error(m_path, line, token, lineNumber);
1131 else if (line.find(PackageRecord::OutlineRecord::RECTANGLE_RECORD_TOKEN) == 0)
1134 if (!(lineStream >> token))
1136 throw_parse_error(m_path, line, token, lineNumber);
1139 if (token != PackageRecord::OutlineRecord::RECTANGLE_RECORD_TOKEN)
1141 throw_parse_error(m_path, line, token, lineNumber);
1144 auto pOutlineRecord = std::make_shared<PackageRecord::OutlineRecord>();
1145 pOutlineRecord->type = PackageRecord::OutlineRecord::Type::Rectangle;
1147 if (!(lineStream >> pOutlineRecord->lowerLeftX))
1149 throw_parse_error(m_path, line, token, lineNumber);
1152 if (!(lineStream >> pOutlineRecord->lowerLeftY))
1154 throw_parse_error(m_path, line, token, lineNumber);
1157 if (!(lineStream >> pOutlineRecord->width))
1159 throw_parse_error(m_path, line, token, lineNumber);
1162 if (!(lineStream >> pOutlineRecord->height))
1164 throw_parse_error(m_path, line, token, lineNumber);
1167 if (pCurrentPackageRecord !=
nullptr)
1169 if (pCurrentPinRecord !=
nullptr)
1171 pCurrentPinRecord->m_outlineRecords.push_back(pOutlineRecord);
1175 pCurrentPackageRecord->m_outlineRecords.push_back(pOutlineRecord);
1180 throw_parse_error(m_path, line, token, lineNumber);
1183 else if (line.find(PackageRecord::OutlineRecord::CIRCLE_RECORD_TOKEN) == 0)
1186 if (!(lineStream >> token))
1188 throw_parse_error(m_path, line, token, lineNumber);
1191 if (token != PackageRecord::OutlineRecord::CIRCLE_RECORD_TOKEN)
1193 throw_parse_error(m_path, line, token, lineNumber);
1196 auto pOutlineRecord = std::make_shared<PackageRecord::OutlineRecord>();
1197 pOutlineRecord->type = PackageRecord::OutlineRecord::Type::Circle;
1199 if (!(lineStream >> pOutlineRecord->xCenter))
1201 throw_parse_error(m_path, line, token, lineNumber);
1204 if (!(lineStream >> pOutlineRecord->yCenter))
1206 throw_parse_error(m_path, line, token, lineNumber);
1209 if (!(lineStream >> pOutlineRecord->radius))
1211 throw_parse_error(m_path, line, token, lineNumber);
1214 if (pCurrentPackageRecord !=
nullptr)
1216 if (pCurrentPinRecord !=
nullptr)
1218 pCurrentPinRecord->m_outlineRecords.push_back(pOutlineRecord);
1222 pCurrentPackageRecord->m_outlineRecords.push_back(pOutlineRecord);
1227 throw_parse_error(m_path, line, token, lineNumber);
1230 else if (line.find(PackageRecord::OutlineRecord::SQUARE_RECORD_TOKEN) == 0)
1233 if (!(lineStream >> token))
1235 throw_parse_error(m_path, line, token, lineNumber);
1238 if (token != PackageRecord::OutlineRecord::SQUARE_RECORD_TOKEN)
1240 throw_parse_error(m_path, line, token, lineNumber);
1243 auto pOutlineRecord = std::make_shared<PackageRecord::OutlineRecord>();
1244 pOutlineRecord->type = PackageRecord::OutlineRecord::Type::Square;
1246 if (!(lineStream >> pOutlineRecord->xCenter))
1248 throw_parse_error(m_path, line, token, lineNumber);
1251 if (!(lineStream >> pOutlineRecord->yCenter))
1253 throw_parse_error(m_path, line, token, lineNumber);
1256 if (!(lineStream >> pOutlineRecord->halfSide))
1258 throw_parse_error(m_path, line, token, lineNumber);
1261 if (pCurrentPackageRecord !=
nullptr)
1263 if (pCurrentPinRecord !=
nullptr)
1265 pCurrentPinRecord->m_outlineRecords.push_back(pOutlineRecord);
1269 pCurrentPackageRecord->m_outlineRecords.push_back(pOutlineRecord);
1274 throw_parse_error(m_path, line, token, lineNumber);
1277 else if (line.find(PackageRecord::OutlineRecord::CONTOUR_BEGIN_RECORD_TOKEN) == 0)
1280 if (!(lineStream >> token))
1282 throw_parse_error(m_path, line, token, lineNumber);
1285 if (token != PackageRecord::OutlineRecord::CONTOUR_BEGIN_RECORD_TOKEN)
1287 throw_parse_error(m_path, line, token, lineNumber);
1290 pCurrentContourOutlineRecord = std::make_shared<PackageRecord::OutlineRecord>();
1291 pCurrentContourOutlineRecord->type = PackageRecord::OutlineRecord::Type::Contour;
1293 else if (line.find(PackageRecord::OutlineRecord::CONTOUR_END_RECORD_TOKEN) == 0)
1296 if (!(lineStream >> token))
1298 throw_parse_error(m_path, line, token, lineNumber);
1301 if (token != PackageRecord::OutlineRecord::CONTOUR_END_RECORD_TOKEN)
1303 throw_parse_error(m_path, line, token, lineNumber);
1306 if (pCurrentPackageRecord !=
nullptr)
1308 if (pCurrentPinRecord !=
nullptr)
1310 pCurrentPinRecord->m_outlineRecords.push_back(pCurrentContourOutlineRecord);
1314 pCurrentPackageRecord->m_outlineRecords.push_back(pCurrentContourOutlineRecord);
1319 throw_parse_error(m_path, line, token, lineNumber);
1322 pCurrentContourOutlineRecord.reset();
1324 else if (line.find(ContourPolygon::BEGIN_RECORD_TOKEN) == 0)
1327 if (!(lineStream >> token))
1329 throw_parse_error(m_path, line, token, lineNumber);
1332 if (token != ContourPolygon::BEGIN_RECORD_TOKEN)
1334 throw_parse_error(m_path, line, token, lineNumber);
1337 pCurrentContourPolygon = std::make_shared<ContourPolygon>();
1339 if (!(lineStream >> pCurrentContourPolygon->xStart))
1341 throw_parse_error(m_path, line, token, lineNumber);
1344 if (!(lineStream >> pCurrentContourPolygon->yStart))
1346 throw_parse_error(m_path, line, token, lineNumber);
1349 if (!(lineStream >> token))
1351 throw_parse_error(m_path, line, token, lineNumber);
1354 if (token == ContourPolygon::ISLAND_TYPE_TOKEN)
1356 pCurrentContourPolygon->type = ContourPolygon::Type::Island;
1358 else if (token == ContourPolygon::HOLE_TYPE_TOKEN)
1360 pCurrentContourPolygon->type = ContourPolygon::Type::Hole;
1364 throw_parse_error(m_path, line, token, lineNumber);
1367 else if (line.find(ContourPolygon::END_RECORD_TOKEN) == 0)
1370 if (!(lineStream >> token))
1372 throw_parse_error(m_path, line, token, lineNumber);
1375 if (token != ContourPolygon::END_RECORD_TOKEN)
1377 throw_parse_error(m_path, line, token, lineNumber);
1380 if (pCurrentContourOutlineRecord !=
nullptr)
1382 pCurrentContourOutlineRecord->m_contourPolygons.push_back(pCurrentContourPolygon);
1383 pCurrentContourPolygon.reset();
1387 throw_parse_error(m_path, line, token, lineNumber);
1390 else if (line.find(ContourPolygon::PolygonPart::ARC_RECORD_TOKEN) == 0)
1393 if (!(lineStream >> token))
1395 throw_parse_error(m_path, line, token, lineNumber);
1398 if (token != ContourPolygon::PolygonPart::ARC_RECORD_TOKEN)
1400 throw_parse_error(m_path, line, token, lineNumber);
1403 auto pPolygonPart = std::make_shared<ContourPolygon::PolygonPart>();
1404 pPolygonPart->type = ContourPolygon::PolygonPart::Type::Arc;
1406 if (!(lineStream >> pPolygonPart->endX))
1408 throw_parse_error(m_path, line, token, lineNumber);
1411 if (!(lineStream >> pPolygonPart->endY))
1413 throw_parse_error(m_path, line, token, lineNumber);
1416 if (!(lineStream >> pPolygonPart->xCenter))
1418 throw_parse_error(m_path, line, token, lineNumber);
1421 if (!(lineStream >> pPolygonPart->yCenter))
1423 throw_parse_error(m_path, line, token, lineNumber);
1426 if (!(lineStream >> token))
1428 throw_parse_error(m_path, line, token, lineNumber);
1431 if (token ==
"y" || token ==
"Y")
1433 pPolygonPart->isClockwise =
true;
1435 else if (token ==
"n" || token ==
"N")
1437 pPolygonPart->isClockwise =
false;
1441 throw_parse_error(m_path, line, token, lineNumber);
1444 if (pCurrentContourPolygon !=
nullptr)
1446 pCurrentContourPolygon->m_polygonParts.push_back(pPolygonPart);
1450 throw_parse_error(m_path, line, token, lineNumber);
1453 else if (line.find(ContourPolygon::PolygonPart::SEGMENT_RECORD_TOKEN) == 0)
1456 if (!(lineStream >> token))
1458 throw_parse_error(m_path, line, token, lineNumber);
1461 if (token != ContourPolygon::PolygonPart::SEGMENT_RECORD_TOKEN)
1463 throw_parse_error(m_path, line, token, lineNumber);
1466 auto pPolygonPart = std::make_shared<ContourPolygon::PolygonPart>();
1467 pPolygonPart->type = ContourPolygon::PolygonPart::Type::Segment;
1469 if (!(lineStream >> pPolygonPart->endX))
1471 throw_parse_error(m_path, line, token, lineNumber);
1474 if (!(lineStream >> pPolygonPart->endY))
1476 throw_parse_error(m_path, line, token, lineNumber);
1479 if (pCurrentContourPolygon !=
nullptr)
1481 pCurrentContourPolygon->m_polygonParts.push_back(pPolygonPart);
1485 throw_parse_error(m_path, line, token, lineNumber);
1491 parse_info pi(m_path, line, lineNumber);
1492 logwarn(pi.toString(
"unrecognized record line in EDADATA file:"));
1504 if (pCurrentNetRecord !=
nullptr)
1508 if (pCurrentSubnetRecord !=
nullptr)
1510 pCurrentNetRecord->m_subnetRecords.push_back(pCurrentSubnetRecord);
1511 pCurrentSubnetRecord.reset();
1514 m_netRecords.push_back(pCurrentNetRecord);
1516 pCurrentNetRecord.reset();
1518 else if (pCurrentPackageRecord !=
nullptr)
1521 if (pCurrentPinRecord !=
nullptr)
1524 if (pCurrentPackageRecord->m_pinRecords.size() > UINT_MAX)
1526 throw_parse_error(m_path, line,
"", lineNumber);
1528 pCurrentPinRecord->index =
static_cast<unsigned>(pCurrentPackageRecord->m_pinRecords.size());
1529 pCurrentPackageRecord->m_pinRecords.push_back(pCurrentPinRecord);
1530 pCurrentPinRecord.reset();
1534 m_packageRecords.push_back(pCurrentPackageRecord);
1536 pCurrentPackageRecord.reset();
1538 else if (pCurrentFeatureGroupRecord !=
nullptr)
1540 m_featureGroupRecords.push_back(pCurrentFeatureGroupRecord);
1541 pCurrentFeatureGroupRecord.reset();
1544 edaDataFile.close();
1546 catch (parse_error& pe)
1548 auto m = pe.toString(
"Parse Error:");
1551 edaDataFile.close();
1554 catch (std::exception& e)
1556 parse_info pi(m_path, line, lineNumber);
1557 const auto m = pi.toString();
1558 logexception_msg(e, m);
1560 edaDataFile.close();
1568 std::unique_ptr<Odb::Lib::Protobuf::EdaDataFile::PackageRecord>
1569 EdaDataFile::PackageRecord::to_protobuf()
const
1571 std::unique_ptr<Odb::Lib::Protobuf::EdaDataFile::PackageRecord> pPackageRecordMessage(
new Odb::Lib::Protobuf::EdaDataFile::PackageRecord);
1572 pPackageRecordMessage->set_name(name);
1573 pPackageRecordMessage->set_pitch(pitch);
1574 pPackageRecordMessage->set_xmin(xMin);
1575 pPackageRecordMessage->set_ymin(yMin);
1576 pPackageRecordMessage->set_xmax(xMax);
1577 pPackageRecordMessage->set_ymax(yMax);
1579 for (
const auto& pinRecord : m_pinRecords)
1581 auto pPinRecordMessage = pPackageRecordMessage->add_pinrecords();
1582 pPinRecordMessage->CopyFrom(*pinRecord->to_protobuf());
1584 for (
const auto& kvPinRecord : m_pinRecordsByName)
1586 (*pPackageRecordMessage->mutable_pinrecordsbyname())[kvPinRecord.first] = *kvPinRecord.second->to_protobuf();
1588 for (
const auto& propertyRecord : m_propertyRecords)
1590 auto pPropertyRecordMessage = pPackageRecordMessage->add_propertyrecords();
1591 pPropertyRecordMessage->CopyFrom(*propertyRecord->to_protobuf());
1593 for (
const auto& outlineRecord : m_outlineRecords)
1595 auto pOutlineRecordMessage = pPackageRecordMessage->add_outlinerecords();
1596 pOutlineRecordMessage->CopyFrom(*outlineRecord->to_protobuf());
1598 for (
const auto& kvAttributeAssignment : m_attributeLookupTable)
1600 (*pPackageRecordMessage->mutable_attributelookuptable())[kvAttributeAssignment.first] = kvAttributeAssignment.second;
1602 return pPackageRecordMessage;
1605 void EdaDataFile::PackageRecord::from_protobuf(
const Odb::Lib::Protobuf::EdaDataFile::PackageRecord& message)
1607 name = message.name();
1608 pitch = message.pitch();
1609 xMin = message.xmin();
1610 yMin = message.ymin();
1611 xMax = message.xmax();
1612 yMax = message.ymax();
1615 for (
const auto& pinRecordMessage : message.pinrecords())
1617 auto pPinRecord = std::make_shared<PinRecord>();
1618 pPinRecord->from_protobuf(pinRecordMessage);
1619 m_pinRecords.push_back(pPinRecord);
1622 for (
const auto& kvPinRecordMessage : message.pinrecordsbyname())
1624 auto pPinRecord = std::make_shared<PinRecord>();
1625 pPinRecord->from_protobuf(kvPinRecordMessage.second);
1626 m_pinRecordsByName[kvPinRecordMessage.first] = pPinRecord;
1629 for (
const auto& propertyRecordMessage : message.propertyrecords())
1631 auto pPropertyRecord = std::make_shared<PropertyRecord>();
1632 pPropertyRecord->from_protobuf(propertyRecordMessage);
1633 m_propertyRecords.push_back(pPropertyRecord);
1636 for (
const auto& outlineRecordMessage : message.outlinerecords())
1638 auto pOutlineRecord = std::make_shared<OutlineRecord>();
1639 pOutlineRecord->from_protobuf(outlineRecordMessage);
1640 m_outlineRecords.push_back(pOutlineRecord);
1643 for (
const auto& kvAttributeAssignment : message.attributelookuptable())
1645 m_attributeLookupTable[kvAttributeAssignment.first] = kvAttributeAssignment.second;
1650 std::unique_ptr<Odb::Lib::Protobuf::EdaDataFile::PackageRecord::OutlineRecord> EdaDataFile::PackageRecord::OutlineRecord::to_protobuf()
const
1652 std::unique_ptr<Odb::Lib::Protobuf::EdaDataFile::PackageRecord::OutlineRecord> pOutlineRecordMessage(
new Odb::Lib::Protobuf::EdaDataFile::PackageRecord::OutlineRecord);
1653 pOutlineRecordMessage->set_type((Odb::Lib::Protobuf::EdaDataFile::PackageRecord::OutlineRecord::Type)type);
1654 pOutlineRecordMessage->set_lowerleftx(lowerLeftX);
1655 pOutlineRecordMessage->set_lowerlefty(lowerLeftY);
1656 pOutlineRecordMessage->set_width(width);
1657 pOutlineRecordMessage->set_height(height);
1658 pOutlineRecordMessage->set_xcenter(xCenter);
1659 pOutlineRecordMessage->set_ycenter(yCenter);
1660 pOutlineRecordMessage->set_radius(radius);
1661 pOutlineRecordMessage->set_halfside(halfSide);
1662 for (
const auto& contourPolygon : m_contourPolygons)
1664 auto pContourPolygonMessage = pOutlineRecordMessage->add_contourpolygons();
1665 pContourPolygonMessage->CopyFrom(*contourPolygon->to_protobuf());
1667 return pOutlineRecordMessage;
1670 void EdaDataFile::PackageRecord::OutlineRecord::from_protobuf(
const Odb::Lib::Protobuf::EdaDataFile::PackageRecord::OutlineRecord& message)
1672 type = (Type)message.type();
1673 lowerLeftX = message.lowerleftx();
1674 lowerLeftY = message.lowerlefty();
1675 width = message.width();
1676 height = message.height();
1677 xCenter = message.xcenter();
1678 yCenter = message.ycenter();
1679 radius = message.radius();
1680 halfSide = message.halfside();
1681 for (
const auto& contourPolygonMessage : message.contourpolygons())
1683 auto pContourPolygon = std::make_shared<ContourPolygon>();
1684 pContourPolygon->from_protobuf(contourPolygonMessage);
1685 m_contourPolygons.push_back(pContourPolygon);
1690 std::unique_ptr<Odb::Lib::Protobuf::EdaDataFile::PackageRecord::PinRecord>
1691 EdaDataFile::PackageRecord::PinRecord::to_protobuf()
const
1693 std::unique_ptr<Odb::Lib::Protobuf::EdaDataFile::PackageRecord::PinRecord> pPinRecordMessage(
new Odb::Lib::Protobuf::EdaDataFile::PackageRecord::PinRecord);
1694 pPinRecordMessage->set_name(name);
1695 pPinRecordMessage->set_type((Odb::Lib::Protobuf::EdaDataFile::PackageRecord::PinRecord::Type)type);
1696 pPinRecordMessage->set_xcenter(xCenter);
1697 pPinRecordMessage->set_ycenter(yCenter);
1698 pPinRecordMessage->set_finishedholesize(finishedHoleSize);
1699 pPinRecordMessage->set_electricaltype((Odb::Lib::Protobuf::EdaDataFile::PackageRecord::PinRecord::ElectricalType)electricalType);
1700 pPinRecordMessage->set_mounttype((Odb::Lib::Protobuf::EdaDataFile::PackageRecord::PinRecord::MountType)mountType);
1701 pPinRecordMessage->set_id(
id);
1702 pPinRecordMessage->set_index(index);
1703 return pPinRecordMessage;
1706 void EdaDataFile::PackageRecord::PinRecord::from_protobuf(
const Odb::Lib::Protobuf::EdaDataFile::PackageRecord::PinRecord& message)
1708 name = message.name();
1709 type = (Type)message.type();
1710 xCenter = message.xcenter();
1711 yCenter = message.ycenter();
1712 finishedHoleSize = message.finishedholesize();
1713 electricalType = (ElectricalType)message.electricaltype();
1714 mountType = (MountType)message.mounttype();
1716 index = message.index();