contourdatatools.cpp 782 B

123456789101112131415161718192021222324252627282930
  1. //
  2. // contourdatatools.cpp
  3. // auto_fill_jewel_v3
  4. //
  5. // Created by Red on 2024/11/25.
  6. //
  7. #include "contourdatatools.hpp"
  8. ContourData ContourDataTools::convex_hull(ContourData& cd)
  9. {
  10. BoostGeometryTools::BoostPolygon poly ;
  11. for(int i=0;i<cd._points.size();++i ) {
  12. BoostGeometryTools::BoostPoint bpt ;
  13. bpt.set<0>(cd._points[i].x) ;
  14. bpt.set<1>(cd._points[i].y) ;
  15. poly.outer().push_back( bpt ) ;
  16. }
  17. BoostGeometryTools::BoostPolygon hull = BoostGeometryTools::convex_hull(poly);
  18. ContourData newCd ;
  19. for(int i=0;i<hull.outer().size();++i ) {
  20. ContourData::Point cpt ;
  21. cpt.x = hull.outer()[i].get<0>() ;
  22. cpt.y = hull.outer()[i].get<1>() ;
  23. newCd._points.push_back( cpt );
  24. }
  25. return newCd ;
  26. }