OdbDesign
OdbDesign ODB++ Parser - C++ library, gRPC/REST server, CLI, tests
 
Loading...
Searching...
No Matches
StepHdrFile.h
Go to the documentation of this file.
1#pragma once
2
3#include "../../odbdesign_export.h"
4#include <string>
5#include <vector>
6#include <map>
7#include <memory>
8#include "../../IProtoBuffable.h"
9#include "stephdrfile.pb.h"
10#include "../OdbFile.h"
11#include "../IStreamSaveable.h"
12
14{
15 class ODBDESIGN_EXPORT StepHdrFile : public OdbFile, public IProtoBuffable<Odb::Lib::Protobuf::StepHdrFile>, public IStreamSaveable
16 {
17 public:
18 virtual ~StepHdrFile();
19
20 struct StepRepeatRecord : public IProtoBuffable<Odb::Lib::Protobuf::StepHdrFile::StepRepeatRecord>
21 {
22 std::string name;
23 double x = 0.0;
24 double y = 0.0;
25 double dx = 0.0;
26 double dy = 0.0;
27 int nx = 0;
28 int ny = 0;
29 double angle = 0.0;
30 bool flip = false;
31 bool mirror = false;
32
33 typedef std::vector<std::shared_ptr<StepRepeatRecord>> Vector;
34
35 constexpr static const char* ARRAY_HEADER_TOKEN = "STEP-REPEAT";
36
37 // Inherited via IProtoBuffable
38 std::unique_ptr<Odb::Lib::Protobuf::StepHdrFile::StepRepeatRecord> to_protobuf() const override;
39 void from_protobuf(const Odb::Lib::Protobuf::StepHdrFile::StepRepeatRecord& message) override;
40 };
41
42 bool Parse(std::filesystem::path path) override;
43 // Inherited via IStreamSaveable
44 bool Save(std::ostream& os) override;
45
46 // Inherited via IProtoBuffable
47 std::unique_ptr<Odb::Lib::Protobuf::StepHdrFile> to_protobuf() const override;
48 void from_protobuf(const Odb::Lib::Protobuf::StepHdrFile& message) override;
49
50 private:
51 // POD members carry in-class initializers: ODB++ makes every stephdr
52 // attribute optional, and to_protobuf() serializes whatever an unset
53 // member holds. An uninitialized bool read in optimized builds puts a
54 // non-0/1 raw byte on the wire as a multi-byte varint, desyncing the
55 // whole serialized stream (the Turbot GetDesign corruption).
56 std::string m_units;
57 double xDatum = 0.0;
58 double yDatum = 0.0;
59 unsigned id = 0;
60 double xOrigin = 0.0;
61 double yOrigin = 0.0;
62 double topActive = 0.0;
63 double bottomActive = 0.0;
64 double rightActive = 0.0;
65 double leftActive = 0.0;
66 std::string affectingBom;
67 bool affectingBomChanged = false;
68 std::map<std::string, std::string> m_onlineValues;
69
70 StepRepeatRecord::Vector m_stepRepeatRecords;
71
72 };
73}
74
#define ODBDESIGN_EXPORT
std::vector< std::shared_ptr< StepRepeatRecord > > Vector
Definition StepHdrFile.h:33