fork download
  1. #include <octave/oct.h>
  2. #include <vector>
  3. #include <boost/geometry.hpp>
  4. #include <boost/geometry/geometries/polygon.hpp>
  5. #include <boost/geometry/geometries/adapted/boost_polygon.hpp>
  6.  
  7. using namespace boost::geometry;
  8. typedef boost::polygon::polygon_data<int> polygon;
  9. typedef boost::polygon::polygon_traits<polygon>::point_type point;
  10.  
  11. DEFUN_DLD (ispolycw, args, ,
  12. "Check if the polygon's orientation is clockwise or not")
  13. {
  14. /*
  15.   TODO: Check if args are valid first
  16.   */
  17. std::vector<point> pts;
  18. point p;
  19. for(int j=0;j<args(0).length();j++)
  20. {
  21. p=boost::polygon::construct<point>
  22. (args(0).fast_elem_extract(j).float_value(),args(1).fast_elem_extract(j).float_value());
  23. pts.push_back(p);
  24. }
  25.  
  26. if(pts[0]!=pts[pts.size()-1])
  27. {
  28. pts.push_back(pts[0]);
  29. }
  30.  
  31. polygon poly;
  32. boost::polygon::set_points(poly, pts.begin(), pts.end());
  33. bool iscw=boost::geometry::area(poly)>0?1:0;
  34. return octave_value_list (octave_value(iscw));
  35.  
  36. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:24: fatal error: octave/oct.h: No such file or directory
compilation terminated.
stdout
Standard output is empty