polygon.hpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #ifndef POLYGON_HPP
  2. #define POLYGON_HPP
  3. #include <iostream>
  4. #include <string>
  5. #include <vector>
  6. #include "vertex.hpp"
  7. #include "matrix.hpp"
  8. #include "coefficients.hpp"
  9. #include "error.hpp"
  10. using namespace std;
  11. class Polygon{
  12. private:
  13. static Coefficients coefficients;
  14. size_t length;
  15. vector<Vertex> vertices;
  16. unordered_map<Vertex,uint64> indices;
  17. Matrix B;
  18. Matrix C;
  19. Matrix M;
  20. double fp;
  21. void compute_B();
  22. void compute_C();
  23. void compute_M();
  24. void compute_fp();
  25. void add_vertex(const int32& x,const int32& y);
  26. void add_neighbours(const int32& x,const int32& y);
  27. public:
  28. static Coefficients& get_coefficients();
  29. Polygon();
  30. Polygon(string str);
  31. size_t size() const;
  32. size_t graph_size() const;
  33. Vertex vertex(size_t i) const;
  34. double get_coeff_B(size_t i,size_t j) const;
  35. double get_coeff_C(size_t i,size_t j) const;
  36. double get_coeff_M(size_t i,size_t j) const;
  37. double get_fp() const;
  38. };
  39. inline
  40. Polygon::Polygon(){
  41. length=0;
  42. }
  43. inline size_t
  44. Polygon::size() const{
  45. return length;
  46. }
  47. inline size_t
  48. Polygon::graph_size() const{
  49. return vertices.size();
  50. }
  51. inline Vertex
  52. Polygon::vertex(size_t i) const{
  53. return vertices[i];
  54. }
  55. inline Coefficients&
  56. Polygon::get_coefficients(){
  57. return coefficients;
  58. }
  59. inline double
  60. Polygon::get_fp() const{
  61. return fp;
  62. }
  63. inline double
  64. Polygon::get_coeff_B(size_t i,size_t j) const{
  65. return B.get(i,j);
  66. }
  67. inline double
  68. Polygon::get_coeff_C(size_t i,size_t j) const{
  69. return C.get(i,j);
  70. }
  71. inline double
  72. Polygon::get_coeff_M(size_t i,size_t j) const{
  73. return M.get(i,j);
  74. }
  75. #endif