123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- //
- // contourdata.hpp
- // Test
- //
- // Created by 高慕白 on 2024/12/3.
- //
- #ifndef contourdata_hpp
- #define contourdata_hpp
- // 定义轮廓数据 by wf 2024-11-13
- #include "ajson5.h"
- #include <fstream>
- #include <vector>
- #include <string>
- using std::string;
- using std::vector;
- using std::ifstream;
- class ContourData
- {
- public:
- struct Point {
- float x,y;
- };
- ContourData();
- //从json读取点数据
- bool readFromJsonFile(string jsonfilename);
- bool readFromJsonFile(string jsonfilename,float scalex,float scaley);
- bool readFromJsonFile(string jsonfilename,int translateX, int translateY, float scalex,float scaley);
-
- //点数据
- vector<Point> _points ;
- //计算包围盒子
- bool getBoundingBox( float& xmin,float& ymin, float& xmax, float& ymax ) ;
-
- //新建一个副本并进行缩放然后返回
- ContourData copyAndScale(float scalex,float scaley) ;
- //旋转轮廓多边形
- void rotate( float rotdeg ) ;
- //旋转一个点
- Point rotateOnePoint( ContourData::Point pt0, float rotateAng);
- //切换点序,顺时针逆时针
- void togglePointOrder() ;
- };
- #endif /* contourdata_hpp */
|