1 #pragma once
2 #include "common/common.hpp"
3 #include <iostream>
4 #include <fstream>
5 #include <map>
6 #include <deque>
7 #include "pool/padstack.hpp"
8 #include "util/placement.hpp"
9 
10 namespace horizon {
11 
12 class ExcellonWriter {
13 public:
14     ExcellonWriter(const std::string &filename);
15     void write_line(const std::string &s);
16     void close();
17     void write_format();
18     void write_header();
19     void write_holes();
20     void draw_hole(const Coordi &pos, uint64_t diameter);
21     void draw_slot(const Coordi &pos, uint64_t diameter, uint64_t length, int angle);
22     const std::string &get_filename();
23 
24 
25 private:
26     std::map<uint64_t, unsigned int> tools;
27     unsigned int tool_n = 1;
28     unsigned int get_tool_for_diameter(uint64_t dia);
29 
30     std::deque<std::pair<Coordi, unsigned int>> holes;
31     std::deque<std::tuple<Coordi, Coordi, unsigned int>> slots;
32 
33 
34     std::ofstream ofs;
35     std::string out_filename;
36     void check_open();
37 };
38 } // namespace horizon
39