Introduction

Getting Started

Programming Guides

API Reference

Additional Resources

Line.h
1 #pragma once
2 #include <vector>
3 #include <unordered_map>
4 
5 namespace hio_html_internal
6 {
8  class Line
9  {
10  public:
12  Line(int front_index, int back_index);
13 
15  int front() const { return point_indices[0]; }
16 
18  int back() const { return point_indices[1]; }
19 
21  Line Flip() const;
22 
23  private:
24  int point_indices[2];
25  };
26 
27  class LineChain
28  {
29  public:
30  LineChain(Line const & line);
31 
32  bool Attach(Line const & line);
33  bool Attach(LineChain const & lineChain);
34 
35  std::vector<Line> GetLines() const;
36 
37  int front() const;
38  int back() const;
39 
40  size_t size() const;
41 
42  private:
43  std::vector<Line> headLines;
44  std::vector<Line> tailLines;
45  };
46 
47  class LineChainer
48  {
49  public:
50  std::vector<LineChain> Run(std::vector<Line> const & lines);
51 
52  private:
53  void Purge(LineChain * lineChain);
54  void Push(LineChain * lineChain);
55 
56  LineChain * Pop(int point, LineChain * ignore);
57  LineChain * Pop(Line const & line, LineChain * ignore);
58  LineChain * Pop(LineChain const & lineChain, LineChain * ignore);
59 
60  private:
61  std::unordered_map<int, std::vector<LineChain *>> chainFingers;
62  };
63 
64  std::vector<std::vector<Line>> ChainLines(
65  std::vector<Line> const & lines);
66 }
Line(int front_index, int back_index)
Constructs a line with the provided indices.
Definition: Line.h:27
Definition: Line.h:47
Line Flip() const
Returns a line with the current line's indices flipped.
A class used to denote a line segment by its front and back indices.
Definition: Line.h:8
int front() const
Returns the line's front index.
Definition: Line.h:15
int back() const
Returns the line's back index.
Definition: Line.h:18