contourdata.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //
  2. // contourdata.hpp
  3. // Test
  4. //
  5. // Created by 高慕白 on 2024/12/3.
  6. //
  7. #ifndef contourdata_hpp
  8. #define contourdata_hpp
  9. // 定义轮廓数据 by wf 2024-11-13
  10. #include "ajson5.h"
  11. #include <fstream>
  12. #include <vector>
  13. #include <string>
  14. using std::string;
  15. using std::vector;
  16. using std::ifstream;
  17. class ContourData
  18. {
  19. public:
  20. struct Point {
  21. float x,y;
  22. };
  23. ContourData();
  24. //从json读取点数据
  25. bool readFromJsonFile(string jsonfilename);
  26. bool readFromJsonFile(string jsonfilename,float scalex,float scaley);
  27. bool readFromJsonFile(string jsonfilename,int translateX, int translateY, float scalex,float scaley);
  28. //点数据
  29. vector<Point> _points ;
  30. //计算包围盒子
  31. bool getBoundingBox( float& xmin,float& ymin, float& xmax, float& ymax ) ;
  32. //新建一个副本并进行缩放然后返回
  33. ContourData copyAndScale(float scalex,float scaley) ;
  34. //旋转轮廓多边形
  35. void rotate( float rotdeg ) ;
  36. //旋转一个点
  37. Point rotateOnePoint( ContourData::Point pt0, float rotateAng);
  38. //切换点序,顺时针逆时针
  39. void togglePointOrder() ;
  40. };
  41. #endif /* contourdata_hpp */