MCPcopy Create free account
hub / github.com/KLayout/klayout / rectangle

Method rectangle

src/db/db/dbShape.cc:852–905  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

850}
851
852Shape::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
907size_t
908Shape::hash_value () const

Callers 5

test_7_LayoutMethod · 0.80
dbShapeTests.ccFile · 0.80
instance_is_coveredMethod · 0.80
get_rectangleFunction · 0.80
get_drectangleFunction · 0.80

Calls 13

polygon_refClass · 0.85
path_refClass · 0.85
yMethod · 0.80
is_boxFunction · 0.70
boxFunction · 0.70
polygonFunction · 0.70
simple_polygonFunction · 0.70
pathFunction · 0.70
is_boxMethod · 0.45
boxMethod · 0.45
beginMethod · 0.45
xMethod · 0.45

Tested by 1

test_7_LayoutMethod · 0.64