| 850 | } |
| 851 | |
| 852 | Shape::box_type Shape::rectangle () const |
| 853 | { |
| 854 | if (is_box ()) { |
| 855 | return box (); |
| 856 | } |
| 857 | |
| 858 | switch (m_type) { |
| 859 | case db::Shape::Polygon: |
| 860 | return polygon ().is_box () ? polygon ().box () : box_type (); |
| 861 | case db::Shape::PolygonRef: |
| 862 | case db::Shape::PolygonPtrArrayMember: |
| 863 | return polygon_ref ().is_box () ? polygon_ref ().box () : box_type (); |
| 864 | case db::Shape::SimplePolygon: |
| 865 | return simple_polygon ().is_box () ? simple_polygon ().box () : box_type (); |
| 866 | case db::Shape::SimplePolygonRef: |
| 867 | case db::Shape::SimplePolygonPtrArrayMember: |
| 868 | return simple_polygon_ref ().is_box () ? simple_polygon_ref ().box () : box_type (); |
| 869 | case db::Shape::Path: |
| 870 | { |
| 871 | const path_type &p = path (); |
| 872 | if (! p.round () && p.points () <= 2 && p.points () > 0) { |
| 873 | point_type p1 = *p.begin (); |
| 874 | point_type p2 = p1; |
| 875 | if (p.points () == 2) { |
| 876 | p2 = *++p.begin (); |
| 877 | } |
| 878 | if (p1.x () == p2.x () || p1.y () == p2.y ()) { |
| 879 | return p.box (); |
| 880 | } |
| 881 | } |
| 882 | } |
| 883 | break; |
| 884 | case db::Shape::PathRef: |
| 885 | case db::Shape::PathPtrArrayMember: |
| 886 | { |
| 887 | const path_ref_type &p = path_ref (); |
| 888 | if (! p.ptr ()->round () && p.ptr ()->points () <= 2 && p.ptr ()->points () > 0) { |
| 889 | point_type p1 = *p.begin (); |
| 890 | point_type p2 = p1; |
| 891 | if (p.ptr ()->points () == 2) { |
| 892 | p2 = *++p.begin (); |
| 893 | } |
| 894 | if (p1.x () == p2.x () || p1.y () == p2.y ()) { |
| 895 | return p.box (); |
| 896 | } |
| 897 | } |
| 898 | } |
| 899 | break; |
| 900 | default: |
| 901 | break; |
| 902 | } |
| 903 | |
| 904 | return box_type (); |
| 905 | } |
| 906 | |
| 907 | size_t |
| 908 | Shape::hash_value () const |