contourdata.h 1.1 KB

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