123456789101112131415161718192021222324252627282930 |
- //
- // contourdatatools.cpp
- // auto_fill_jewel_v3
- //
- // Created by Red on 2024/11/25.
- //
- #include "contourdatatools.hpp"
- ContourData ContourDataTools::convex_hull(ContourData& cd)
- {
- BoostGeometryTools::BoostPolygon poly ;
- for(int i=0;i<cd._points.size();++i ) {
- BoostGeometryTools::BoostPoint bpt ;
- bpt.set<0>(cd._points[i].x) ;
- bpt.set<1>(cd._points[i].y) ;
- poly.outer().push_back( bpt ) ;
- }
- BoostGeometryTools::BoostPolygon hull = BoostGeometryTools::convex_hull(poly);
- ContourData newCd ;
- for(int i=0;i<hull.outer().size();++i ) {
- ContourData::Point cpt ;
- cpt.x = hull.outer()[i].get<0>() ;
- cpt.y = hull.outer()[i].get<1>() ;
- newCd._points.push_back( cpt );
- }
- return newCd ;
- }
|