layout_database.hpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. Copyright 2010 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. //layout_database.hpp
  8. #ifndef BOOST_POLYGON_TUTORIAL_LAYOUT_DATABASE_HPP
  9. #define BOOST_POLYGON_TUTORIAL_LAYOUT_DATABASE_HPP
  10. #include <boost/polygon/polygon.hpp>
  11. #include <map>
  12. #include "layout_rectangle.hpp"
  13. typedef std::map<std::string, boost::polygon::polygon_90_set_data<int> > layout_database;
  14. //map the layout rectangle data type to the boost::polygon::rectangle_concept
  15. namespace boost { namespace polygon{
  16. template <>
  17. struct rectangle_traits<layout_rectangle> {
  18. typedef int coordinate_type;
  19. typedef interval_data<int> interval_type;
  20. static inline interval_type get(const layout_rectangle& rectangle, orientation_2d orient) {
  21. if(orient == HORIZONTAL)
  22. return interval_type(rectangle.xl, rectangle.xh);
  23. return interval_type(rectangle.yl, rectangle.yh);
  24. }
  25. };
  26. template <>
  27. struct geometry_concept<layout_rectangle> { typedef rectangle_concept type; };
  28. }}
  29. //insert layout rectangles into a layout database
  30. inline void populate_layout_database(layout_database& layout, std::vector<layout_rectangle>& rects) {
  31. for(std::size_t i = 0; i < rects.size(); ++i) {
  32. layout[rects[i].layer].insert(rects[i]);
  33. }
  34. }
  35. #endif