Virtual Testbed
Ship dynamics simulator for extreme conditions
graphics.hh
1 #ifndef VTESTBED_IGES_GRAPHICS_HH
2 #define VTESTBED_IGES_GRAPHICS_HH
3 
4 #include <istream>
5 #include <limits>
6 #include <memory>
7 #include <ostream>
8 #include <string>
9 #include <vector>
10 
11 #include <vtestbed/iges/directory_entry.hh>
12 #include <vtestbed/iges/section.hh>
13 #include <vtestbed/iges/string.hh>
14 #include <vtestbed/iges/timestamp.hh>
15 #include <vtestbed/iges/types.hh>
16 #include <vtestbed/iges/unit.hh>
17 #include <vtestbed/iges/entity.hh>
18 
19 namespace vtb {
20 
21  namespace iges {
22 
30  class Graphics {
31 
32  private:
33  typedef Double Real;
34  typedef timestamp::time_point time_point;
36 
37  private:
38  std::string _prologue;
39  char _parameter_delimiter = ',';
40  char _record_delimiter = ';';
41  string _senderproduct, _receiverproduct, _filename, _software, _preprocessor;
42  Integer _nbits = std::numeric_limits<Integer>::digits;
43  Integer _single_maxexp10 = std::numeric_limits<Single>::max_exponent10;
44  Integer _single_maxdigits10 = std::numeric_limits<Single>::max_digits10;
45  Integer _double_maxexp10 = std::numeric_limits<Double>::max_exponent10;
46  Integer _double_maxdigits10 = std::numeric_limits<Double>::max_digits10;
47  Integer _maxlineweightgradations{1};
48  Real _scale{1}, _lineweight{1}, _minresolution{0}, _maxcoord{0};
49  Unit _unit = Unit::Inches;
50  string _unitname{"IN"}, _author, _organisation;
51  timestamp _created, _modified;
52  Integer _version{3}, _draft{0};
53  string _protocol;
55  std::vector<entity_ptr> _entities;
56  std::string _real_filename;
57 
58  public:
59 
60  Graphics() = default;
61  ~Graphics() = default;
62  Graphics(const Graphics&) = default;
63  Graphics& operator=(const Graphics&) = default;
64  Graphics(Graphics&&) = default;
65  Graphics& operator=(Graphics&&) = default;
66 
67  void read(std::istream& in);
68  void write(std::ostream& out) const;
69  void clear();
70 
71  inline const std::string& prologue() const noexcept { return this->_prologue; }
72  inline const std::string& author() const noexcept { return this->_author; }
73  inline const std::string& organisation() const { return this->_organisation; }
74  inline const time_point& created() const noexcept { return this->_created; }
75  inline const time_point& modified() const noexcept { return this->_modified; }
76  inline const std::string& real_filename() const { return this->_real_filename; }
77 
78  inline void unit(Unit rhs) { this->unit(rhs, unit_name(rhs)); }
79 
80  inline void
81  unit(Unit rhs, const string& name) {
82  this->_unit = rhs;
83  this->_unitname = name;
84  }
85 
86  inline void max_coordinate(Real rhs) { this->_maxcoord = rhs; }
87  inline void prologue(const std::string& rhs) { this->_prologue = rhs; }
88  inline void created(const timestamp& rhs) { this->_created = rhs; }
89  inline void modified(const timestamp& rhs) { this->_modified = rhs; }
90  inline void real_filename(const std::string& rhs) { this->_real_filename = rhs; }
91 
92  void dump(std::ostream& out);
93 
94  inline void
95  emplace_back(entity_ptr&& ptr) {
96  this->_entities.emplace_back(std::forward<entity_ptr>(ptr));
97  }
98 
99  inline void
100  push_back(const entity_ptr& ptr) {
101  this->_entities.push_back(ptr);
102  }
103 
104  private:
105 
106  void
107  validate_section(Section last, Section current);
108 
109  void
110  parse_global_section(const std::string& text);
111 
112  void
113  parse_directory_entry_section(const std::vector<std::string>& text);
114 
115  void
116  parse_parameter_data_section(const std::vector<std::string>& text);
117 
118  void
119  parse_terminate_section(const std::string& text);
120 
121  };
122 
123  inline std::istream&
124  operator>>(std::istream& in, Graphics& rhs) {
125  rhs.read(in); return in;
126  }
127 
128  inline std::ostream&
129  operator<<(std::ostream& out, const Graphics& rhs) {
130  rhs.write(out); return out;
131  }
132 
133  }
134 
135 }
136 
137 #endif // vim:filetype=cpp
IGES importer.
Definition: graphics.hh:30
Main namespace.
Definition: convert.hh:9
Section
Section codes.
Definition: section.hh:9
IGES timestamp.
Definition: timestamp.hh:14