polygon_90_set_data.hpp 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989
  1. /*
  2. Copyright 2008 Intel Corporation
  3. Use, modification and distribution are subject to the Boost Software License,
  4. Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  5. http://www.boost.org/LICENSE_1_0.txt).
  6. */
  7. #ifndef BOOST_POLYGON_POLYGON_90_SET_DATA_HPP
  8. #define BOOST_POLYGON_POLYGON_90_SET_DATA_HPP
  9. #include "isotropy.hpp"
  10. #include "point_concept.hpp"
  11. #include "transform.hpp"
  12. #include "interval_concept.hpp"
  13. #include "rectangle_concept.hpp"
  14. #include "segment_concept.hpp"
  15. #include "detail/iterator_points_to_compact.hpp"
  16. #include "detail/iterator_compact_to_points.hpp"
  17. #include "polygon_traits.hpp"
  18. //manhattan boolean algorithms
  19. #include "detail/boolean_op.hpp"
  20. #include "detail/polygon_formation.hpp"
  21. #include "detail/rectangle_formation.hpp"
  22. #include "detail/max_cover.hpp"
  23. #include "detail/property_merge.hpp"
  24. #include "detail/polygon_90_touch.hpp"
  25. #include "detail/iterator_geometry_to_set.hpp"
  26. namespace boost { namespace polygon{
  27. template <typename ltype, typename rtype, typename op_type>
  28. class polygon_90_set_view;
  29. template <typename T>
  30. class polygon_90_set_data {
  31. public:
  32. typedef T coordinate_type;
  33. typedef std::vector<std::pair<coordinate_type, std::pair<coordinate_type, int> > > value_type;
  34. typedef typename std::vector<std::pair<coordinate_type, std::pair<coordinate_type, int> > >::const_iterator iterator_type;
  35. typedef polygon_90_set_data operator_arg_type;
  36. // default constructor
  37. inline polygon_90_set_data() : orient_(HORIZONTAL), data_(), dirty_(false), unsorted_(false) {}
  38. // constructor
  39. inline polygon_90_set_data(orientation_2d orient) : orient_(orient), data_(), dirty_(false), unsorted_(false) {}
  40. // constructor from an iterator pair over vertex data
  41. template <typename iT>
  42. inline polygon_90_set_data(orientation_2d, iT input_begin, iT input_end) :
  43. orient_(HORIZONTAL), data_(), dirty_(false), unsorted_(false) {
  44. dirty_ = true;
  45. unsorted_ = true;
  46. for( ; input_begin != input_end; ++input_begin) { insert(*input_begin); }
  47. }
  48. // copy constructor
  49. inline polygon_90_set_data(const polygon_90_set_data& that) :
  50. orient_(that.orient_), data_(that.data_), dirty_(that.dirty_), unsorted_(that.unsorted_) {}
  51. template <typename ltype, typename rtype, typename op_type>
  52. inline polygon_90_set_data(const polygon_90_set_view<ltype, rtype, op_type>& that);
  53. // copy with orientation change constructor
  54. inline polygon_90_set_data(orientation_2d orient, const polygon_90_set_data& that) :
  55. orient_(orient), data_(), dirty_(false), unsorted_(false) {
  56. insert(that, false, that.orient_);
  57. }
  58. // destructor
  59. inline ~polygon_90_set_data() {}
  60. // assignement operator
  61. inline polygon_90_set_data& operator=(const polygon_90_set_data& that) {
  62. if(this == &that) return *this;
  63. orient_ = that.orient_;
  64. data_ = that.data_;
  65. dirty_ = that.dirty_;
  66. unsorted_ = that.unsorted_;
  67. return *this;
  68. }
  69. template <typename ltype, typename rtype, typename op_type>
  70. inline polygon_90_set_data& operator=(const polygon_90_set_view<ltype, rtype, op_type>& that);
  71. template <typename geometry_object>
  72. inline polygon_90_set_data& operator=(const geometry_object& geometry) {
  73. data_.clear();
  74. insert(geometry);
  75. return *this;
  76. }
  77. // insert iterator range
  78. inline void insert(iterator_type input_begin, iterator_type input_end, orientation_2d orient = HORIZONTAL) {
  79. if(input_begin == input_end || (!data_.empty() && &(*input_begin) == &(*(data_.begin())))) return;
  80. dirty_ = true;
  81. unsorted_ = true;
  82. if(orient == orient_)
  83. data_.insert(data_.end(), input_begin, input_end);
  84. else {
  85. for( ; input_begin != input_end; ++input_begin) {
  86. insert(*input_begin, false, orient);
  87. }
  88. }
  89. }
  90. // insert iterator range
  91. template <typename iT>
  92. inline void insert(iT input_begin, iT input_end, orientation_2d orient = HORIZONTAL) {
  93. if(input_begin == input_end) return;
  94. dirty_ = true;
  95. unsorted_ = true;
  96. for( ; input_begin != input_end; ++input_begin) {
  97. insert(*input_begin, false, orient);
  98. }
  99. }
  100. inline void insert(const polygon_90_set_data& polygon_set) {
  101. insert(polygon_set.begin(), polygon_set.end(), polygon_set.orient());
  102. }
  103. inline void insert(const std::pair<std::pair<point_data<coordinate_type>, point_data<coordinate_type> >, int>& edge, bool is_hole = false,
  104. orientation_2d = HORIZONTAL) {
  105. std::pair<coordinate_type, std::pair<coordinate_type, int> > vertex;
  106. vertex.first = edge.first.first.x();
  107. vertex.second.first = edge.first.first.y();
  108. vertex.second.second = edge.second * (is_hole ? -1 : 1);
  109. insert(vertex, false, VERTICAL);
  110. vertex.first = edge.first.second.x();
  111. vertex.second.first = edge.first.second.y();
  112. vertex.second.second *= -1;
  113. insert(vertex, false, VERTICAL);
  114. }
  115. template <typename geometry_type>
  116. inline void insert(const geometry_type& geometry_object, bool is_hole = false, orientation_2d = HORIZONTAL) {
  117. iterator_geometry_to_set<typename geometry_concept<geometry_type>::type, geometry_type>
  118. begin_input(geometry_object, LOW, orient_, is_hole), end_input(geometry_object, HIGH, orient_, is_hole);
  119. insert(begin_input, end_input, orient_);
  120. }
  121. inline void insert(const std::pair<coordinate_type, std::pair<coordinate_type, int> >& vertex, bool is_hole = false,
  122. orientation_2d orient = HORIZONTAL) {
  123. data_.push_back(vertex);
  124. if(orient != orient_) std::swap(data_.back().first, data_.back().second.first);
  125. if(is_hole) data_.back().second.second *= -1;
  126. dirty_ = true;
  127. unsorted_ = true;
  128. }
  129. inline void insert(coordinate_type major_coordinate, const std::pair<interval_data<coordinate_type>, int>& edge) {
  130. std::pair<coordinate_type, std::pair<coordinate_type, int> > vertex;
  131. vertex.first = major_coordinate;
  132. vertex.second.first = edge.first.get(LOW);
  133. vertex.second.second = edge.second;
  134. insert(vertex, false, orient_);
  135. vertex.second.first = edge.first.get(HIGH);
  136. vertex.second.second *= -1;
  137. insert(vertex, false, orient_);
  138. }
  139. template <typename output_container>
  140. inline void get(output_container& output) const {
  141. get_dispatch(output, typename geometry_concept<typename output_container::value_type>::type());
  142. }
  143. template <typename output_container>
  144. inline void get(output_container& output, size_t vthreshold) const {
  145. get_dispatch(output, typename geometry_concept<typename output_container::value_type>::type(), vthreshold);
  146. }
  147. template <typename output_container>
  148. inline void get_polygons(output_container& output) const {
  149. get_dispatch(output, polygon_90_concept());
  150. }
  151. template <typename output_container>
  152. inline void get_rectangles(output_container& output) const {
  153. clean();
  154. form_rectangles(output, data_.begin(), data_.end(), orient_, rectangle_concept());
  155. }
  156. template <typename output_container>
  157. inline void get_rectangles(output_container& output, orientation_2d slicing_orientation) const {
  158. if(slicing_orientation == orient_) {
  159. get_rectangles(output);
  160. } else {
  161. polygon_90_set_data<coordinate_type> ps(*this);
  162. ps.transform(axis_transformation(axis_transformation::SWAP_XY));
  163. output_container result;
  164. ps.get_rectangles(result);
  165. for(typename output_container::iterator itr = result.begin(); itr != result.end(); ++itr) {
  166. ::boost::polygon::transform(*itr, axis_transformation(axis_transformation::SWAP_XY));
  167. }
  168. output.insert(output.end(), result.begin(), result.end());
  169. }
  170. }
  171. // equivalence operator
  172. inline bool operator==(const polygon_90_set_data& p) const {
  173. if(orient_ == p.orient()) {
  174. clean();
  175. p.clean();
  176. return data_ == p.data_;
  177. } else {
  178. return false;
  179. }
  180. }
  181. // inequivalence operator
  182. inline bool operator!=(const polygon_90_set_data& p) const {
  183. return !((*this) == p);
  184. }
  185. // get iterator to begin vertex data
  186. inline iterator_type begin() const {
  187. return data_.begin();
  188. }
  189. // get iterator to end vertex data
  190. inline iterator_type end() const {
  191. return data_.end();
  192. }
  193. const value_type& value() const {
  194. return data_;
  195. }
  196. // clear the contents of the polygon_90_set_data
  197. inline void clear() { data_.clear(); dirty_ = unsorted_ = false; }
  198. // find out if Polygon set is empty
  199. inline bool empty() const { clean(); return data_.empty(); }
  200. // get the Polygon set size in vertices
  201. inline std::size_t size() const { clean(); return data_.size(); }
  202. // get the current Polygon set capacity in vertices
  203. inline std::size_t capacity() const { return data_.capacity(); }
  204. // reserve size of polygon set in vertices
  205. inline void reserve(std::size_t size) { return data_.reserve(size); }
  206. // find out if Polygon set is sorted
  207. inline bool sorted() const { return !unsorted_; }
  208. // find out if Polygon set is clean
  209. inline bool dirty() const { return dirty_; }
  210. // get the scanline orientation of the polygon set
  211. inline orientation_2d orient() const { return orient_; }
  212. // Start BM
  213. // The problem: If we have two polygon sets with two different scanline orientations:
  214. // I tried changing the orientation of one to coincide with other (If not, resulting boolean operation
  215. // produces spurious results).
  216. // First I tried copying polygon data from one of the sets into another set with corrected orientation
  217. // using one of the copy constructor that takes in orientation (see somewhere above in this file) --> copy constructor throws error
  218. // Then I tried another approach:(see below). This approach also fails to produce the desired results when test case is run.
  219. // Here is the part that beats me: If I comment out the whole section, I can do all the operations (^=, -=, &= )these commented out
  220. // operations perform. So then why do we need them?. Hence, I commented out this whole section.
  221. // End BM
  222. // polygon_90_set_data<coordinate_type>& operator-=(const polygon_90_set_data& that) {
  223. // sort();
  224. // that.sort();
  225. // value_type data;
  226. // std::swap(data, data_);
  227. // applyBooleanBinaryOp(data.begin(), data.end(),
  228. // that.begin(), that.end(), boolean_op::BinaryCount<boolean_op::BinaryNot>());
  229. // return *this;
  230. // }
  231. // polygon_90_set_data<coordinate_type>& operator^=(const polygon_90_set_data& that) {
  232. // sort();
  233. // that.sort();
  234. // value_type data;
  235. // std::swap(data, data_);
  236. // applyBooleanBinaryOp(data.begin(), data.end(),
  237. // that.begin(), that.end(), boolean_op::BinaryCount<boolean_op::BinaryXor>());
  238. // return *this;
  239. // }
  240. // polygon_90_set_data<coordinate_type>& operator&=(const polygon_90_set_data& that) {
  241. // sort();
  242. // that.sort();
  243. // value_type data;
  244. // std::swap(data, data_);
  245. // applyBooleanBinaryOp(data.begin(), data.end(),
  246. // that.begin(), that.end(), boolean_op::BinaryCount<boolean_op::BinaryAnd>());
  247. // return *this;
  248. // }
  249. // polygon_90_set_data<coordinate_type>& operator|=(const polygon_90_set_data& that) {
  250. // insert(that);
  251. // return *this;
  252. // }
  253. void clean() const {
  254. sort();
  255. if(dirty_) {
  256. boolean_op::default_arg_workaround<int>::applyBooleanOr(data_);
  257. dirty_ = false;
  258. }
  259. }
  260. void sort() const{
  261. if(unsorted_) {
  262. polygon_sort(data_.begin(), data_.end());
  263. unsorted_ = false;
  264. }
  265. }
  266. template <typename input_iterator_type>
  267. void set(input_iterator_type input_begin, input_iterator_type input_end, orientation_2d orient) {
  268. data_.clear();
  269. reserve(std::distance(input_begin, input_end));
  270. data_.insert(data_.end(), input_begin, input_end);
  271. orient_ = orient;
  272. dirty_ = true;
  273. unsorted_ = true;
  274. }
  275. void set(const value_type& value, orientation_2d orient) {
  276. data_ = value;
  277. orient_ = orient;
  278. dirty_ = true;
  279. unsorted_ = true;
  280. }
  281. //extents
  282. template <typename rectangle_type>
  283. bool
  284. extents(rectangle_type& extents_rectangle) const {
  285. clean();
  286. if(data_.empty()) return false;
  287. if(orient_ == HORIZONTAL)
  288. set_points(extents_rectangle, point_data<coordinate_type>(data_[0].second.first, data_[0].first),
  289. point_data<coordinate_type>(data_[data_.size() - 1].second.first, data_[data_.size() - 1].first));
  290. else
  291. set_points(extents_rectangle, point_data<coordinate_type>(data_[0].first, data_[0].second.first),
  292. point_data<coordinate_type>(data_[data_.size() - 1].first, data_[data_.size() - 1].second.first));
  293. for(std::size_t i = 1; i < data_.size() - 1; ++i) {
  294. if(orient_ == HORIZONTAL)
  295. encompass(extents_rectangle, point_data<coordinate_type>(data_[i].second.first, data_[i].first));
  296. else
  297. encompass(extents_rectangle, point_data<coordinate_type>(data_[i].first, data_[i].second.first));
  298. }
  299. return true;
  300. }
  301. polygon_90_set_data&
  302. bloat2(typename coordinate_traits<coordinate_type>::unsigned_area_type west_bloating,
  303. typename coordinate_traits<coordinate_type>::unsigned_area_type east_bloating,
  304. typename coordinate_traits<coordinate_type>::unsigned_area_type south_bloating,
  305. typename coordinate_traits<coordinate_type>::unsigned_area_type north_bloating) {
  306. std::vector<rectangle_data<coordinate_type> > rects;
  307. clean();
  308. rects.reserve(data_.size() / 2);
  309. get(rects);
  310. rectangle_data<coordinate_type> convolutionRectangle(interval_data<coordinate_type>(-((coordinate_type)west_bloating),
  311. (coordinate_type)east_bloating),
  312. interval_data<coordinate_type>(-((coordinate_type)south_bloating),
  313. (coordinate_type)north_bloating));
  314. for(typename std::vector<rectangle_data<coordinate_type> >::iterator itr = rects.begin();
  315. itr != rects.end(); ++itr) {
  316. convolve(*itr, convolutionRectangle);
  317. }
  318. clear();
  319. insert(rects.begin(), rects.end());
  320. return *this;
  321. }
  322. static void modify_pt(point_data<coordinate_type>& pt, const point_data<coordinate_type>& prev_pt,
  323. const point_data<coordinate_type>& current_pt, const point_data<coordinate_type>& next_pt,
  324. coordinate_type west_bloating,
  325. coordinate_type east_bloating,
  326. coordinate_type south_bloating,
  327. coordinate_type north_bloating) {
  328. bool pxl = prev_pt.x() < current_pt.x();
  329. bool pyl = prev_pt.y() < current_pt.y();
  330. bool nxl = next_pt.x() < current_pt.x();
  331. bool nyl = next_pt.y() < current_pt.y();
  332. bool pxg = prev_pt.x() > current_pt.x();
  333. bool pyg = prev_pt.y() > current_pt.y();
  334. bool nxg = next_pt.x() > current_pt.x();
  335. bool nyg = next_pt.y() > current_pt.y();
  336. //two of the four if statements will execute
  337. if(pxl)
  338. pt.y(current_pt.y() - south_bloating);
  339. if(pxg)
  340. pt.y(current_pt.y() + north_bloating);
  341. if(nxl)
  342. pt.y(current_pt.y() + north_bloating);
  343. if(nxg)
  344. pt.y(current_pt.y() - south_bloating);
  345. if(pyl)
  346. pt.x(current_pt.x() + east_bloating);
  347. if(pyg)
  348. pt.x(current_pt.x() - west_bloating);
  349. if(nyl)
  350. pt.x(current_pt.x() - west_bloating);
  351. if(nyg)
  352. pt.x(current_pt.x() + east_bloating);
  353. }
  354. static void resize_poly_up(std::vector<point_data<coordinate_type> >& poly,
  355. coordinate_type west_bloating,
  356. coordinate_type east_bloating,
  357. coordinate_type south_bloating,
  358. coordinate_type north_bloating) {
  359. point_data<coordinate_type> first_pt = poly[0];
  360. point_data<coordinate_type> second_pt = poly[1];
  361. point_data<coordinate_type> prev_pt = poly[0];
  362. point_data<coordinate_type> current_pt = poly[1];
  363. for(std::size_t i = 2; i < poly.size(); ++i) {
  364. point_data<coordinate_type> next_pt = poly[i];
  365. modify_pt(poly[i-1], prev_pt, current_pt, next_pt, west_bloating, east_bloating, south_bloating, north_bloating);
  366. prev_pt = current_pt;
  367. current_pt = next_pt;
  368. }
  369. point_data<coordinate_type> next_pt = first_pt;
  370. modify_pt(poly.back(), prev_pt, current_pt, next_pt, west_bloating, east_bloating, south_bloating, north_bloating);
  371. prev_pt = current_pt;
  372. current_pt = next_pt;
  373. next_pt = second_pt;
  374. modify_pt(poly[0], prev_pt, current_pt, next_pt, west_bloating, east_bloating, south_bloating, north_bloating);
  375. remove_colinear_pts(poly);
  376. }
  377. static bool resize_poly_down(std::vector<point_data<coordinate_type> >& poly,
  378. coordinate_type west_shrinking,
  379. coordinate_type east_shrinking,
  380. coordinate_type south_shrinking,
  381. coordinate_type north_shrinking) {
  382. rectangle_data<coordinate_type> extents_rectangle;
  383. set_points(extents_rectangle, poly[0], poly[0]);
  384. point_data<coordinate_type> first_pt = poly[0];
  385. point_data<coordinate_type> second_pt = poly[1];
  386. point_data<coordinate_type> prev_pt = poly[0];
  387. point_data<coordinate_type> current_pt = poly[1];
  388. encompass(extents_rectangle, current_pt);
  389. for(std::size_t i = 2; i < poly.size(); ++i) {
  390. point_data<coordinate_type> next_pt = poly[i];
  391. encompass(extents_rectangle, next_pt);
  392. modify_pt(poly[i-1], prev_pt, current_pt, next_pt, west_shrinking, east_shrinking, south_shrinking, north_shrinking);
  393. prev_pt = current_pt;
  394. current_pt = next_pt;
  395. }
  396. if(delta(extents_rectangle, HORIZONTAL) < std::abs(west_shrinking + east_shrinking))
  397. return false;
  398. if(delta(extents_rectangle, VERTICAL) < std::abs(north_shrinking + south_shrinking))
  399. return false;
  400. point_data<coordinate_type> next_pt = first_pt;
  401. modify_pt(poly.back(), prev_pt, current_pt, next_pt, west_shrinking, east_shrinking, south_shrinking, north_shrinking);
  402. prev_pt = current_pt;
  403. current_pt = next_pt;
  404. next_pt = second_pt;
  405. modify_pt(poly[0], prev_pt, current_pt, next_pt, west_shrinking, east_shrinking, south_shrinking, north_shrinking);
  406. return remove_colinear_pts(poly);
  407. }
  408. static bool remove_colinear_pts(std::vector<point_data<coordinate_type> >& poly) {
  409. bool found_colinear = true;
  410. while(found_colinear && poly.size() >= 4) {
  411. found_colinear = false;
  412. typename std::vector<point_data<coordinate_type> >::iterator itr = poly.begin();
  413. itr += poly.size() - 1; //get last element position
  414. typename std::vector<point_data<coordinate_type> >::iterator itr2 = poly.begin();
  415. typename std::vector<point_data<coordinate_type> >::iterator itr3 = itr2;
  416. ++itr3;
  417. std::size_t count = 0;
  418. for( ; itr3 < poly.end(); ++itr3) {
  419. if(((*itr).x() == (*itr2).x() && (*itr).x() == (*itr3).x()) ||
  420. ((*itr).y() == (*itr2).y() && (*itr).y() == (*itr3).y()) ) {
  421. ++count;
  422. found_colinear = true;
  423. } else {
  424. itr = itr2;
  425. ++itr2;
  426. }
  427. *itr2 = *itr3;
  428. }
  429. itr3 = poly.begin();
  430. if(((*itr).x() == (*itr2).x() && (*itr).x() == (*itr3).x()) ||
  431. ((*itr).y() == (*itr2).y() && (*itr).y() == (*itr3).y()) ) {
  432. ++count;
  433. found_colinear = true;
  434. }
  435. poly.erase(poly.end() - count, poly.end());
  436. }
  437. return poly.size() >= 4;
  438. }
  439. polygon_90_set_data&
  440. bloat(typename coordinate_traits<coordinate_type>::unsigned_area_type west_bloating,
  441. typename coordinate_traits<coordinate_type>::unsigned_area_type east_bloating,
  442. typename coordinate_traits<coordinate_type>::unsigned_area_type south_bloating,
  443. typename coordinate_traits<coordinate_type>::unsigned_area_type north_bloating) {
  444. std::list<polygon_45_with_holes_data<coordinate_type> > polys;
  445. get(polys);
  446. clear();
  447. for(typename std::list<polygon_45_with_holes_data<coordinate_type> >::iterator itr = polys.begin();
  448. itr != polys.end(); ++itr) {
  449. //polygon_90_set_data<coordinate_type> psref;
  450. //psref.insert(view_as<polygon_90_concept>((*itr).self_));
  451. //rectangle_data<coordinate_type> prerect;
  452. //psref.extents(prerect);
  453. resize_poly_up((*itr).self_.coords_, (coordinate_type)west_bloating, (coordinate_type)east_bloating,
  454. (coordinate_type)south_bloating, (coordinate_type)north_bloating);
  455. iterator_geometry_to_set<polygon_90_concept, view_of<polygon_90_concept, polygon_45_data<coordinate_type> > >
  456. begin_input(view_as<polygon_90_concept>((*itr).self_), LOW, orient_, false, true, COUNTERCLOCKWISE),
  457. end_input(view_as<polygon_90_concept>((*itr).self_), HIGH, orient_, false, true, COUNTERCLOCKWISE);
  458. insert(begin_input, end_input, orient_);
  459. //polygon_90_set_data<coordinate_type> pstest;
  460. //pstest.insert(view_as<polygon_90_concept>((*itr).self_));
  461. //psref.bloat2(west_bloating, east_bloating, south_bloating, north_bloating);
  462. //if(!equivalence(psref, pstest)) {
  463. // std::cout << "test failed\n";
  464. //}
  465. for(typename std::list<polygon_45_data<coordinate_type> >::iterator itrh = (*itr).holes_.begin();
  466. itrh != (*itr).holes_.end(); ++itrh) {
  467. //rectangle_data<coordinate_type> rect;
  468. //psref.extents(rect);
  469. //polygon_90_set_data<coordinate_type> psrefhole;
  470. //psrefhole.insert(prerect);
  471. //psrefhole.insert(view_as<polygon_90_concept>(*itrh), true);
  472. //polygon_45_data<coordinate_type> testpoly(*itrh);
  473. if(resize_poly_down((*itrh).coords_,(coordinate_type)west_bloating, (coordinate_type)east_bloating,
  474. (coordinate_type)south_bloating, (coordinate_type)north_bloating)) {
  475. iterator_geometry_to_set<polygon_90_concept, view_of<polygon_90_concept, polygon_45_data<coordinate_type> > >
  476. begin_input2(view_as<polygon_90_concept>(*itrh), LOW, orient_, true, true),
  477. end_input2(view_as<polygon_90_concept>(*itrh), HIGH, orient_, true, true);
  478. insert(begin_input2, end_input2, orient_);
  479. //polygon_90_set_data<coordinate_type> pstesthole;
  480. //pstesthole.insert(rect);
  481. //iterator_geometry_to_set<polygon_90_concept, view_of<polygon_90_concept, polygon_45_data<coordinate_type> > >
  482. // begin_input2(view_as<polygon_90_concept>(*itrh), LOW, orient_, true, true);
  483. //pstesthole.insert(begin_input2, end_input, orient_);
  484. //psrefhole.bloat2(west_bloating, east_bloating, south_bloating, north_bloating);
  485. //if(!equivalence(psrefhole, pstesthole)) {
  486. // std::cout << (winding(testpoly) == CLOCKWISE) << std::endl;
  487. // std::cout << (winding(*itrh) == CLOCKWISE) << std::endl;
  488. // polygon_90_set_data<coordinate_type> c(psrefhole);
  489. // c.clean();
  490. // polygon_90_set_data<coordinate_type> a(pstesthole);
  491. // polygon_90_set_data<coordinate_type> b(pstesthole);
  492. // a.sort();
  493. // b.clean();
  494. // std::cout << "test hole failed\n";
  495. // //std::cout << testpoly << std::endl;
  496. //}
  497. }
  498. }
  499. }
  500. return *this;
  501. }
  502. polygon_90_set_data&
  503. shrink(typename coordinate_traits<coordinate_type>::unsigned_area_type west_shrinking,
  504. typename coordinate_traits<coordinate_type>::unsigned_area_type east_shrinking,
  505. typename coordinate_traits<coordinate_type>::unsigned_area_type south_shrinking,
  506. typename coordinate_traits<coordinate_type>::unsigned_area_type north_shrinking) {
  507. std::list<polygon_45_with_holes_data<coordinate_type> > polys;
  508. get(polys);
  509. clear();
  510. for(typename std::list<polygon_45_with_holes_data<coordinate_type> >::iterator itr = polys.begin();
  511. itr != polys.end(); ++itr) {
  512. //polygon_90_set_data<coordinate_type> psref;
  513. //psref.insert(view_as<polygon_90_concept>((*itr).self_));
  514. //rectangle_data<coordinate_type> prerect;
  515. //psref.extents(prerect);
  516. //polygon_45_data<coordinate_type> testpoly((*itr).self_);
  517. if(resize_poly_down((*itr).self_.coords_, -(coordinate_type)west_shrinking, -(coordinate_type)east_shrinking,
  518. -(coordinate_type)south_shrinking, -(coordinate_type)north_shrinking)) {
  519. iterator_geometry_to_set<polygon_90_concept, view_of<polygon_90_concept, polygon_45_data<coordinate_type> > >
  520. begin_input(view_as<polygon_90_concept>((*itr).self_), LOW, orient_, false, true, COUNTERCLOCKWISE),
  521. end_input(view_as<polygon_90_concept>((*itr).self_), HIGH, orient_, false, true, COUNTERCLOCKWISE);
  522. insert(begin_input, end_input, orient_);
  523. //iterator_geometry_to_set<polygon_90_concept, view_of<polygon_90_concept, polygon_45_data<coordinate_type> > >
  524. // begin_input2(view_as<polygon_90_concept>((*itr).self_), LOW, orient_, false, true, COUNTERCLOCKWISE);
  525. //polygon_90_set_data<coordinate_type> pstest;
  526. //pstest.insert(begin_input2, end_input, orient_);
  527. //psref.shrink2(west_shrinking, east_shrinking, south_shrinking, north_shrinking);
  528. //if(!equivalence(psref, pstest)) {
  529. // std::cout << "test failed\n";
  530. //}
  531. for(typename std::list<polygon_45_data<coordinate_type> >::iterator itrh = (*itr).holes_.begin();
  532. itrh != (*itr).holes_.end(); ++itrh) {
  533. //rectangle_data<coordinate_type> rect;
  534. //psref.extents(rect);
  535. //polygon_90_set_data<coordinate_type> psrefhole;
  536. //psrefhole.insert(prerect);
  537. //psrefhole.insert(view_as<polygon_90_concept>(*itrh), true);
  538. //polygon_45_data<coordinate_type> testpoly(*itrh);
  539. resize_poly_up((*itrh).coords_, -(coordinate_type)west_shrinking, -(coordinate_type)east_shrinking,
  540. -(coordinate_type)south_shrinking, -(coordinate_type)north_shrinking);
  541. iterator_geometry_to_set<polygon_90_concept, view_of<polygon_90_concept, polygon_45_data<coordinate_type> > >
  542. begin_input2(view_as<polygon_90_concept>(*itrh), LOW, orient_, true, true),
  543. end_input2(view_as<polygon_90_concept>(*itrh), HIGH, orient_, true, true);
  544. insert(begin_input2, end_input2, orient_);
  545. //polygon_90_set_data<coordinate_type> pstesthole;
  546. //pstesthole.insert(rect);
  547. //iterator_geometry_to_set<polygon_90_concept, view_of<polygon_90_concept, polygon_45_data<coordinate_type> > >
  548. // begin_input2(view_as<polygon_90_concept>(*itrh), LOW, orient_, true, true);
  549. //pstesthole.insert(begin_input2, end_input, orient_);
  550. //psrefhole.shrink2(west_shrinking, east_shrinking, south_shrinking, north_shrinking);
  551. //if(!equivalence(psrefhole, pstesthole)) {
  552. // std::cout << (winding(testpoly) == CLOCKWISE) << std::endl;
  553. // std::cout << (winding(*itrh) == CLOCKWISE) << std::endl;
  554. // polygon_90_set_data<coordinate_type> c(psrefhole);
  555. // c.clean();
  556. // polygon_90_set_data<coordinate_type> a(pstesthole);
  557. // polygon_90_set_data<coordinate_type> b(pstesthole);
  558. // a.sort();
  559. // b.clean();
  560. // std::cout << "test hole failed\n";
  561. // //std::cout << testpoly << std::endl;
  562. //}
  563. }
  564. }
  565. }
  566. return *this;
  567. }
  568. polygon_90_set_data&
  569. shrink2(typename coordinate_traits<coordinate_type>::unsigned_area_type west_shrinking,
  570. typename coordinate_traits<coordinate_type>::unsigned_area_type east_shrinking,
  571. typename coordinate_traits<coordinate_type>::unsigned_area_type south_shrinking,
  572. typename coordinate_traits<coordinate_type>::unsigned_area_type north_shrinking) {
  573. rectangle_data<coordinate_type> externalBoundary;
  574. if(!extents(externalBoundary)) return *this;
  575. ::boost::polygon::bloat(externalBoundary, 10); //bloat by diferential ammount
  576. //insert a hole that encompasses the data
  577. insert(externalBoundary, true); //note that the set is in a dirty state now
  578. sort(); //does not apply implicit OR operation
  579. std::vector<rectangle_data<coordinate_type> > rects;
  580. rects.reserve(data_.size() / 2);
  581. //begin does not apply implicit or operation, this is a dirty range
  582. form_rectangles(rects, data_.begin(), data_.end(), orient_, rectangle_concept());
  583. clear();
  584. rectangle_data<coordinate_type> convolutionRectangle(interval_data<coordinate_type>(-((coordinate_type)east_shrinking),
  585. (coordinate_type)west_shrinking),
  586. interval_data<coordinate_type>(-((coordinate_type)north_shrinking),
  587. (coordinate_type)south_shrinking));
  588. for(typename std::vector<rectangle_data<coordinate_type> >::iterator itr = rects.begin();
  589. itr != rects.end(); ++itr) {
  590. rectangle_data<coordinate_type>& rect = *itr;
  591. convolve(rect, convolutionRectangle);
  592. //insert rectangle as a hole
  593. insert(rect, true);
  594. }
  595. convolve(externalBoundary, convolutionRectangle);
  596. //insert duplicate of external boundary as solid to cancel out the external hole boundaries
  597. insert(externalBoundary);
  598. clean(); //we have negative values in the set, so we need to apply an OR operation to make it valid input to a boolean
  599. return *this;
  600. }
  601. polygon_90_set_data&
  602. shrink(direction_2d dir, typename coordinate_traits<coordinate_type>::unsigned_area_type shrinking) {
  603. if(dir == WEST)
  604. return shrink(shrinking, 0, 0, 0);
  605. if(dir == EAST)
  606. return shrink(0, shrinking, 0, 0);
  607. if(dir == SOUTH)
  608. return shrink(0, 0, shrinking, 0);
  609. return shrink(0, 0, 0, shrinking);
  610. }
  611. polygon_90_set_data&
  612. bloat(direction_2d dir, typename coordinate_traits<coordinate_type>::unsigned_area_type shrinking) {
  613. if(dir == WEST)
  614. return bloat(shrinking, 0, 0, 0);
  615. if(dir == EAST)
  616. return bloat(0, shrinking, 0, 0);
  617. if(dir == SOUTH)
  618. return bloat(0, 0, shrinking, 0);
  619. return bloat(0, 0, 0, shrinking);
  620. }
  621. polygon_90_set_data&
  622. resize(coordinate_type west, coordinate_type east, coordinate_type south, coordinate_type north);
  623. polygon_90_set_data& move(coordinate_type x_delta, coordinate_type y_delta) {
  624. for(typename std::vector<std::pair<coordinate_type, std::pair<coordinate_type, int> > >::iterator
  625. itr = data_.begin(); itr != data_.end(); ++itr) {
  626. if(orient_ == orientation_2d(VERTICAL)) {
  627. (*itr).first += x_delta;
  628. (*itr).second.first += y_delta;
  629. } else {
  630. (*itr).second.first += x_delta;
  631. (*itr).first += y_delta;
  632. }
  633. }
  634. return *this;
  635. }
  636. // transform set
  637. template <typename transformation_type>
  638. polygon_90_set_data& transform(const transformation_type& transformation) {
  639. direction_2d dir1, dir2;
  640. transformation.get_directions(dir1, dir2);
  641. int sign = dir1.get_sign() * dir2.get_sign();
  642. for(typename std::vector<std::pair<coordinate_type, std::pair<coordinate_type, int> > >::iterator
  643. itr = data_.begin(); itr != data_.end(); ++itr) {
  644. if(orient_ == orientation_2d(VERTICAL)) {
  645. transformation.transform((*itr).first, (*itr).second.first);
  646. } else {
  647. transformation.transform((*itr).second.first, (*itr).first);
  648. }
  649. (*itr).second.second *= sign;
  650. }
  651. if(dir1 != EAST || dir2 != NORTH)
  652. unsorted_ = true; //some mirroring or rotation must have happened
  653. return *this;
  654. }
  655. // scale set
  656. polygon_90_set_data& scale_up(typename coordinate_traits<coordinate_type>::unsigned_area_type factor) {
  657. for(typename std::vector<std::pair<coordinate_type, std::pair<coordinate_type, int> > >::iterator
  658. itr = data_.begin(); itr != data_.end(); ++itr) {
  659. (*itr).first *= (coordinate_type)factor;
  660. (*itr).second.first *= (coordinate_type)factor;
  661. }
  662. return *this;
  663. }
  664. polygon_90_set_data& scale_down(typename coordinate_traits<coordinate_type>::unsigned_area_type factor) {
  665. typedef typename coordinate_traits<coordinate_type>::coordinate_distance dt;
  666. for(typename std::vector<std::pair<coordinate_type, std::pair<coordinate_type, int> > >::iterator
  667. itr = data_.begin(); itr != data_.end(); ++itr) {
  668. (*itr).first = scaling_policy<coordinate_type>::round((dt)((*itr).first) / (dt)factor);
  669. (*itr).second.first = scaling_policy<coordinate_type>::round((dt)((*itr).second.first) / (dt)factor);
  670. }
  671. unsorted_ = true; //scaling down can make coordinates equal that were not previously equal
  672. return *this;
  673. }
  674. template <typename scaling_type>
  675. polygon_90_set_data& scale(const anisotropic_scale_factor<scaling_type>& scaling) {
  676. for(typename std::vector<std::pair<coordinate_type, std::pair<coordinate_type, int> > >::iterator
  677. itr = data_.begin(); itr != data_.end(); ++itr) {
  678. if(orient_ == orientation_2d(VERTICAL)) {
  679. scaling.scale((*itr).first, (*itr).second.first);
  680. } else {
  681. scaling.scale((*itr).second.first, (*itr).first);
  682. }
  683. }
  684. unsorted_ = true;
  685. return *this;
  686. }
  687. template <typename scaling_type>
  688. polygon_90_set_data& scale_with(const scaling_type& scaling) {
  689. for(typename std::vector<std::pair<coordinate_type, std::pair<coordinate_type, int> > >::iterator
  690. itr = data_.begin(); itr != data_.end(); ++itr) {
  691. if(orient_ == orientation_2d(VERTICAL)) {
  692. scaling.scale((*itr).first, (*itr).second.first);
  693. } else {
  694. scaling.scale((*itr).second.first, (*itr).first);
  695. }
  696. }
  697. unsorted_ = true;
  698. return *this;
  699. }
  700. polygon_90_set_data& scale(double factor) {
  701. typedef typename coordinate_traits<coordinate_type>::coordinate_distance dt;
  702. for(typename std::vector<std::pair<coordinate_type, std::pair<coordinate_type, int> > >::iterator
  703. itr = data_.begin(); itr != data_.end(); ++itr) {
  704. (*itr).first = scaling_policy<coordinate_type>::round((dt)((*itr).first) * (dt)factor);
  705. (*itr).second.first = scaling_policy<coordinate_type>::round((dt)((*itr).second.first) * (dt)factor);
  706. }
  707. unsorted_ = true; //scaling make coordinates equal that were not previously equal
  708. return *this;
  709. }
  710. polygon_90_set_data& self_xor() {
  711. sort();
  712. if(dirty_) { //if it is clean it is a no-op
  713. boolean_op::default_arg_workaround<boolean_op::UnaryCount>::applyBooleanOr(data_);
  714. dirty_ = false;
  715. }
  716. return *this;
  717. }
  718. polygon_90_set_data& self_intersect() {
  719. sort();
  720. if(dirty_) { //if it is clean it is a no-op
  721. interval_data<coordinate_type> ivl((std::numeric_limits<coordinate_type>::min)(), (std::numeric_limits<coordinate_type>::max)());
  722. rectangle_data<coordinate_type> rect(ivl, ivl);
  723. insert(rect, true);
  724. clean();
  725. }
  726. return *this;
  727. }
  728. inline polygon_90_set_data& interact(const polygon_90_set_data& that) {
  729. typedef coordinate_type Unit;
  730. if(that.dirty_) that.clean();
  731. typename touch_90_operation<Unit>::TouchSetData tsd;
  732. touch_90_operation<Unit>::populateTouchSetData(tsd, that.data_, 0);
  733. std::vector<polygon_90_data<Unit> > polys;
  734. get(polys);
  735. std::vector<std::set<int> > graph(polys.size()+1, std::set<int>());
  736. for(std::size_t i = 0; i < polys.size(); ++i){
  737. polygon_90_set_data<Unit> psTmp(that.orient_);
  738. psTmp.insert(polys[i]);
  739. psTmp.clean();
  740. touch_90_operation<Unit>::populateTouchSetData(tsd, psTmp.data_, i+1);
  741. }
  742. touch_90_operation<Unit>::performTouch(graph, tsd);
  743. clear();
  744. for(std::set<int>::iterator itr = graph[0].begin(); itr != graph[0].end(); ++itr){
  745. insert(polys[(*itr)-1]);
  746. }
  747. dirty_ = false;
  748. return *this;
  749. }
  750. template <class T2, typename iterator_type_1, typename iterator_type_2>
  751. void applyBooleanBinaryOp(iterator_type_1 itr1, iterator_type_1 itr1_end,
  752. iterator_type_2 itr2, iterator_type_2 itr2_end,
  753. T2 defaultCount) {
  754. data_.clear();
  755. boolean_op::applyBooleanBinaryOp(data_, itr1, itr1_end, itr2, itr2_end, defaultCount);
  756. }
  757. private:
  758. orientation_2d orient_;
  759. mutable value_type data_;
  760. mutable bool dirty_;
  761. mutable bool unsorted_;
  762. private:
  763. //functions
  764. template <typename output_container>
  765. void get_dispatch(output_container& output, rectangle_concept ) const {
  766. clean();
  767. form_rectangles(output, data_.begin(), data_.end(), orient_, rectangle_concept());
  768. }
  769. template <typename output_container>
  770. void get_dispatch(output_container& output, polygon_90_concept tag) const {
  771. get_fracture(output, true, tag);
  772. }
  773. template <typename output_container>
  774. void get_dispatch(output_container& output, polygon_90_concept tag,
  775. size_t vthreshold) const {
  776. get_fracture(output, true, tag, vthreshold);
  777. }
  778. template <typename output_container>
  779. void get_dispatch(output_container& output, polygon_90_with_holes_concept tag) const {
  780. get_fracture(output, false, tag);
  781. }
  782. template <typename output_container>
  783. void get_dispatch(output_container& output, polygon_90_with_holes_concept tag,
  784. size_t vthreshold) const {
  785. get_fracture(output, false, tag, vthreshold);
  786. }
  787. template <typename output_container>
  788. void get_dispatch(output_container& output, polygon_45_concept tag) const {
  789. get_fracture(output, true, tag);
  790. }
  791. template <typename output_container>
  792. void get_dispatch(output_container& output, polygon_45_with_holes_concept tag) const {
  793. get_fracture(output, false, tag);
  794. }
  795. template <typename output_container>
  796. void get_dispatch(output_container& output, polygon_concept tag) const {
  797. get_fracture(output, true, tag);
  798. }
  799. template <typename output_container>
  800. void get_dispatch(output_container& output, polygon_with_holes_concept tag) const {
  801. get_fracture(output, false, tag);
  802. }
  803. template <typename output_container, typename concept_type>
  804. void get_fracture(output_container& container, bool fracture_holes, concept_type tag) const {
  805. clean();
  806. ::boost::polygon::get_polygons(container, data_.begin(), data_.end(), orient_, fracture_holes, tag);
  807. }
  808. template <typename output_container, typename concept_type>
  809. void get_fracture(output_container& container, bool fracture_holes, concept_type tag,
  810. size_t vthreshold) const {
  811. clean();
  812. ::boost::polygon::get_polygons(container, data_.begin(), data_.end(), orient_, fracture_holes, tag, vthreshold);
  813. }
  814. };
  815. template <typename coordinate_type>
  816. polygon_90_set_data<coordinate_type>&
  817. polygon_90_set_data<coordinate_type>::resize(coordinate_type west,
  818. coordinate_type east,
  819. coordinate_type south,
  820. coordinate_type north) {
  821. move(-west, -south);
  822. coordinate_type e_total = west + east;
  823. coordinate_type n_total = south + north;
  824. if((e_total < 0) ^ (n_total < 0)) {
  825. //different signs
  826. if(e_total < 0) {
  827. shrink(0, -e_total, 0, 0);
  828. if(n_total != 0)
  829. return bloat(0, 0, 0, n_total);
  830. else
  831. return (*this);
  832. } else {
  833. shrink(0, 0, 0, -n_total); //shrink first
  834. if(e_total != 0)
  835. return bloat(0, e_total, 0, 0);
  836. else
  837. return (*this);
  838. }
  839. } else {
  840. if(e_total < 0) {
  841. return shrink(0, -e_total, 0, -n_total);
  842. }
  843. return bloat(0, e_total, 0, n_total);
  844. }
  845. }
  846. template <typename coordinate_type, typename property_type>
  847. class property_merge_90 {
  848. private:
  849. std::vector<std::pair<property_merge_point<coordinate_type>, std::pair<property_type, int> > > pmd_;
  850. public:
  851. inline property_merge_90() : pmd_() {}
  852. inline property_merge_90(const property_merge_90& that) : pmd_(that.pmd_) {}
  853. inline property_merge_90& operator=(const property_merge_90& that) { pmd_ = that.pmd_; return *this; }
  854. inline void insert(const polygon_90_set_data<coordinate_type>& ps, const property_type& property) {
  855. merge_scanline<coordinate_type, property_type, polygon_90_set_data<coordinate_type> >::
  856. populate_property_merge_data(pmd_, ps.begin(), ps.end(), property, ps.orient());
  857. }
  858. template <class GeoObjT>
  859. inline void insert(const GeoObjT& geoObj, const property_type& property) {
  860. polygon_90_set_data<coordinate_type> ps;
  861. ps.insert(geoObj);
  862. insert(ps, property);
  863. }
  864. //merge properties of input geometries and store the resulting geometries of regions
  865. //with unique sets of merged properties to polygons sets in a map keyed by sets of properties
  866. // T = std::map<std::set<property_type>, polygon_90_set_data<coordiante_type> > or
  867. // T = std::map<std::vector<property_type>, polygon_90_set_data<coordiante_type> >
  868. template <typename ResultType>
  869. inline void merge(ResultType& result) {
  870. merge_scanline<coordinate_type, property_type, polygon_90_set_data<coordinate_type>, typename ResultType::key_type> ms;
  871. ms.perform_merge(result, pmd_);
  872. }
  873. };
  874. //ConnectivityExtraction computes the graph of connectivity between rectangle, polygon and
  875. //polygon set graph nodes where an edge is created whenever the geometry in two nodes overlap
  876. template <typename coordinate_type>
  877. class connectivity_extraction_90 {
  878. private:
  879. typedef typename touch_90_operation<coordinate_type>::TouchSetData tsd;
  880. tsd tsd_;
  881. unsigned int nodeCount_;
  882. public:
  883. inline connectivity_extraction_90() : tsd_(), nodeCount_(0) {}
  884. inline connectivity_extraction_90(const connectivity_extraction_90& that) : tsd_(that.tsd_),
  885. nodeCount_(that.nodeCount_) {}
  886. inline connectivity_extraction_90& operator=(const connectivity_extraction_90& that) {
  887. tsd_ = that.tsd_;
  888. nodeCount_ = that.nodeCount_; {}
  889. return *this;
  890. }
  891. //insert a polygon set graph node, the value returned is the id of the graph node
  892. inline unsigned int insert(const polygon_90_set_data<coordinate_type>& ps) {
  893. ps.clean();
  894. touch_90_operation<coordinate_type>::populateTouchSetData(tsd_, ps.begin(), ps.end(), nodeCount_);
  895. return nodeCount_++;
  896. }
  897. template <class GeoObjT>
  898. inline unsigned int insert(const GeoObjT& geoObj) {
  899. polygon_90_set_data<coordinate_type> ps;
  900. ps.insert(geoObj);
  901. return insert(ps);
  902. }
  903. //extract connectivity and store the edges in the graph
  904. //graph must be indexable by graph node id and the indexed value must be a std::set of
  905. //graph node id
  906. template <class GraphT>
  907. inline void extract(GraphT& graph) {
  908. touch_90_operation<coordinate_type>::performTouch(graph, tsd_);
  909. }
  910. };
  911. }
  912. }
  913. #endif