mirror of https://github.com/KLayout/klayout.git
WIP: points as db objects - added tests, bug fixes
This commit is contained in:
parent
4d04cf4fe3
commit
0c89d8fec8
|
|
@ -194,6 +194,9 @@ typedef object_with_properties<DPath> DPathWithProperties;
|
|||
typedef object_with_properties<PathRef> PathRefWithProperties;
|
||||
typedef object_with_properties<DPathRef> DPathRefWithProperties;
|
||||
|
||||
typedef object_with_properties<Point> PointWithProperties;
|
||||
typedef object_with_properties<DPoint> DPointWithProperties;
|
||||
|
||||
typedef object_with_properties<Edge> EdgeWithProperties;
|
||||
typedef object_with_properties<DEdge> DEdgeWithProperties;
|
||||
|
||||
|
|
|
|||
|
|
@ -1394,7 +1394,7 @@ public:
|
|||
{
|
||||
tl_assert (m_type == Point);
|
||||
if (m_stable) {
|
||||
return m_with_props ? &**(((ppoint_iter_type *) m_generic.iter)) : &**(((ppoint_iter_type *) m_generic.iter));
|
||||
return m_with_props ? &**(((ppoint_iter_type *) m_generic.iter)) : &**(((point_iter_type *) m_generic.iter));
|
||||
} else {
|
||||
return m_with_props ? m_generic.ppoint : m_generic.point;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -965,6 +965,8 @@ template class layer_class<db::Shape::edge_type, db::unstable_layer_tag>;
|
|||
template class layer_class<db::object_with_properties<db::Shape::edge_type>, db::unstable_layer_tag>;
|
||||
template class layer_class<db::Shape::edge_pair_type, db::unstable_layer_tag>;
|
||||
template class layer_class<db::object_with_properties<db::Shape::edge_pair_type>, db::unstable_layer_tag>;
|
||||
template class layer_class<db::Shape::point_type, db::unstable_layer_tag>;
|
||||
template class layer_class<db::object_with_properties<db::Shape::point_type>, db::unstable_layer_tag>;
|
||||
template class layer_class<db::Shape::text_type, db::unstable_layer_tag>;
|
||||
template class layer_class<db::object_with_properties<db::Shape::text_type>, db::unstable_layer_tag>;
|
||||
template class layer_class<db::Shape::text_ref_type, db::unstable_layer_tag>;
|
||||
|
|
|
|||
|
|
@ -152,6 +152,7 @@ template DB_PUBLIC layer<db::Shape::short_box_array_type, db::stable_layer_tag>
|
|||
template DB_PUBLIC layer<db::object_with_properties<db::Shape::short_box_array_type>, db::stable_layer_tag> &Shapes::get_layer<db::object_with_properties<db::Shape::short_box_array_type>, db::stable_layer_tag> ();
|
||||
template DB_PUBLIC layer<db::Shape::user_object_type, db::stable_layer_tag> &Shapes::get_layer<db::Shape::user_object_type, db::stable_layer_tag> ();
|
||||
template DB_PUBLIC layer<db::object_with_properties<db::Shape::user_object_type>, db::stable_layer_tag> &Shapes::get_layer<db::object_with_properties<db::Shape::user_object_type>, db::stable_layer_tag> ();
|
||||
|
||||
template DB_PUBLIC layer<db::Shape::polygon_type, db::unstable_layer_tag> &Shapes::get_layer<db::Shape::polygon_type, db::unstable_layer_tag> ();
|
||||
template DB_PUBLIC layer<db::object_with_properties<db::Shape::polygon_type>, db::unstable_layer_tag> &Shapes::get_layer<db::object_with_properties<db::Shape::polygon_type>, db::unstable_layer_tag> ();
|
||||
template DB_PUBLIC layer<db::Shape::simple_polygon_type, db::unstable_layer_tag> &Shapes::get_layer<db::Shape::simple_polygon_type, db::unstable_layer_tag> ();
|
||||
|
|
@ -174,6 +175,8 @@ template DB_PUBLIC layer<db::Shape::edge_type, db::unstable_layer_tag> &Shapes::
|
|||
template DB_PUBLIC layer<db::object_with_properties<db::Shape::edge_type>, db::unstable_layer_tag> &Shapes::get_layer<db::object_with_properties<db::Shape::edge_type>, db::unstable_layer_tag> ();
|
||||
template DB_PUBLIC layer<db::Shape::edge_pair_type, db::unstable_layer_tag> &Shapes::get_layer<db::Shape::edge_pair_type, db::unstable_layer_tag> ();
|
||||
template DB_PUBLIC layer<db::object_with_properties<db::Shape::edge_pair_type>, db::unstable_layer_tag> &Shapes::get_layer<db::object_with_properties<db::Shape::edge_pair_type>, db::unstable_layer_tag> ();
|
||||
template DB_PUBLIC layer<db::Shape::point_type, db::unstable_layer_tag> &Shapes::get_layer<db::Shape::point_type, db::unstable_layer_tag> ();
|
||||
template DB_PUBLIC layer<db::object_with_properties<db::Shape::point_type>, db::unstable_layer_tag> &Shapes::get_layer<db::object_with_properties<db::Shape::point_type>, db::unstable_layer_tag> ();
|
||||
template DB_PUBLIC layer<db::Shape::text_type, db::unstable_layer_tag> &Shapes::get_layer<db::Shape::text_type, db::unstable_layer_tag> ();
|
||||
template DB_PUBLIC layer<db::object_with_properties<db::Shape::text_type>, db::unstable_layer_tag> &Shapes::get_layer<db::object_with_properties<db::Shape::text_type>, db::unstable_layer_tag> ();
|
||||
template DB_PUBLIC layer<db::Shape::text_ref_type, db::unstable_layer_tag> &Shapes::get_layer<db::Shape::text_ref_type, db::unstable_layer_tag> ();
|
||||
|
|
@ -231,6 +234,7 @@ template DB_PUBLIC const layer<db::Shape::short_box_array_type, db::stable_layer
|
|||
template DB_PUBLIC const layer<db::object_with_properties<db::Shape::short_box_array_type>, db::stable_layer_tag> &Shapes::get_layer<db::object_with_properties<db::Shape::short_box_array_type>, db::stable_layer_tag> () const;
|
||||
template DB_PUBLIC const layer<db::Shape::user_object_type, db::stable_layer_tag> &Shapes::get_layer<db::Shape::user_object_type, db::stable_layer_tag> () const;
|
||||
template DB_PUBLIC const layer<db::object_with_properties<db::Shape::user_object_type>, db::stable_layer_tag> &Shapes::get_layer<db::object_with_properties<db::Shape::user_object_type>, db::stable_layer_tag> () const;
|
||||
|
||||
template DB_PUBLIC const layer<db::Shape::polygon_type, db::unstable_layer_tag> &Shapes::get_layer<db::Shape::polygon_type, db::unstable_layer_tag> () const;
|
||||
template DB_PUBLIC const layer<db::object_with_properties<db::Shape::polygon_type>, db::unstable_layer_tag> &Shapes::get_layer<db::object_with_properties<db::Shape::polygon_type>, db::unstable_layer_tag> () const;
|
||||
template DB_PUBLIC const layer<db::Shape::simple_polygon_type, db::unstable_layer_tag> &Shapes::get_layer<db::Shape::simple_polygon_type, db::unstable_layer_tag> () const;
|
||||
|
|
@ -253,6 +257,8 @@ template DB_PUBLIC const layer<db::Shape::edge_type, db::unstable_layer_tag> &Sh
|
|||
template DB_PUBLIC const layer<db::object_with_properties<db::Shape::edge_type>, db::unstable_layer_tag> &Shapes::get_layer<db::object_with_properties<db::Shape::edge_type>, db::unstable_layer_tag> () const;
|
||||
template DB_PUBLIC const layer<db::Shape::edge_pair_type, db::unstable_layer_tag> &Shapes::get_layer<db::Shape::edge_pair_type, db::unstable_layer_tag> () const;
|
||||
template DB_PUBLIC const layer<db::object_with_properties<db::Shape::edge_pair_type>, db::unstable_layer_tag> &Shapes::get_layer<db::object_with_properties<db::Shape::edge_pair_type>, db::unstable_layer_tag> () const;
|
||||
template DB_PUBLIC const layer<db::Shape::point_type, db::unstable_layer_tag> &Shapes::get_layer<db::Shape::point_type, db::unstable_layer_tag> () const;
|
||||
template DB_PUBLIC const layer<db::object_with_properties<db::Shape::point_type>, db::unstable_layer_tag> &Shapes::get_layer<db::object_with_properties<db::Shape::point_type>, db::unstable_layer_tag> () const;
|
||||
template DB_PUBLIC const layer<db::Shape::text_type, db::unstable_layer_tag> &Shapes::get_layer<db::Shape::text_type, db::unstable_layer_tag> () const;
|
||||
template DB_PUBLIC const layer<db::object_with_properties<db::Shape::text_type>, db::unstable_layer_tag> &Shapes::get_layer<db::object_with_properties<db::Shape::text_type>, db::unstable_layer_tag> () const;
|
||||
template DB_PUBLIC const layer<db::Shape::text_ref_type, db::unstable_layer_tag> &Shapes::get_layer<db::Shape::text_ref_type, db::unstable_layer_tag> () const;
|
||||
|
|
|
|||
|
|
@ -35,11 +35,15 @@ TEST(1)
|
|||
EXPECT_EQ (ep == db::EdgePair (db::Edge (), db::Edge ()), true);
|
||||
EXPECT_EQ (ep != db::EdgePair (db::Edge (), db::Edge ()), false);
|
||||
EXPECT_EQ (ep < db::EdgePair (db::Edge (), db::Edge ()), false);
|
||||
EXPECT_EQ (ep.area (), db::EdgePair::area_type (0));
|
||||
EXPECT_EQ (ep.perimeter (), db::EdgePair::perimeter_type (0));
|
||||
|
||||
ep = db::EdgePair (db::Edge (db::Point (10, 30), db::Point (15, 30)), db::Edge (db::Point (0, 30), db::Point (0, 40)));
|
||||
EXPECT_EQ (ep.to_string (), "(10,30;15,30)/(0,30;0,40)");
|
||||
EXPECT_EQ (ep.normalized ().to_string (), "(15,30;10,30)/(0,30;0,40)");
|
||||
EXPECT_EQ (ep.normalized ().normalized ().to_string (), "(15,30;10,30)/(0,30;0,40)");
|
||||
EXPECT_EQ (ep.area (), db::EdgePair::area_type (50)); // weird orientation :(
|
||||
EXPECT_EQ (ep.perimeter (), db::EdgePair::perimeter_type (15));
|
||||
|
||||
ep = db::EdgePair (db::Edge (db::Point (1, 2), db::Point (11, 12)), db::Edge (db::Point (-5, 5), db::Point (5, 15)));
|
||||
EXPECT_EQ (ep.to_string (), "(1,2;11,12)/(-5,5;5,15)");
|
||||
|
|
|
|||
|
|
@ -815,3 +815,136 @@ TEST(8)
|
|||
|
||||
}
|
||||
|
||||
// Edges, EdgePairs, Points
|
||||
TEST(9)
|
||||
{
|
||||
db::Manager m (true);
|
||||
db::Shapes s (&m, 0, db::default_editable_mode ());
|
||||
|
||||
s.insert (db::Point (100, 200));
|
||||
s.insert (db::Edge (db::Point (100, 200), db::Point (200, 400)));
|
||||
s.insert (db::EdgePair (db::Edge (db::Point (100, 200), db::Point (200, 400)), db::Edge (db::Point (0, 300), db::Point (100, 500))));
|
||||
|
||||
db::ShapeIterator si;
|
||||
si = s.begin (db::ShapeIterator::All);
|
||||
|
||||
EXPECT_EQ (si.at_end (), false);
|
||||
EXPECT_EQ (si->is_edge (), true);
|
||||
EXPECT_EQ (si->is_edge_pair (), false);
|
||||
EXPECT_EQ (si->is_point (), false);
|
||||
|
||||
EXPECT_EQ (si->to_string (), "edge (100,200;200,400)");
|
||||
EXPECT_EQ (si->edge ().to_string (), "(100,200;200,400)");
|
||||
|
||||
++si;
|
||||
|
||||
EXPECT_EQ (si.at_end (), false);
|
||||
EXPECT_EQ (si->is_edge (), false);
|
||||
EXPECT_EQ (si->is_edge_pair (), true);
|
||||
EXPECT_EQ (si->is_point (), false);
|
||||
|
||||
EXPECT_EQ (si->to_string (), "edge_pair (100,200;200,400)/(0,300;100,500)");
|
||||
EXPECT_EQ (si->edge_pair ().to_string (), "(100,200;200,400)/(0,300;100,500)");
|
||||
|
||||
++si;
|
||||
|
||||
EXPECT_EQ (si.at_end (), false);
|
||||
EXPECT_EQ (si->is_edge (), false);
|
||||
EXPECT_EQ (si->is_edge_pair (), false);
|
||||
EXPECT_EQ (si->is_point (), true);
|
||||
|
||||
EXPECT_EQ (si->to_string (), "point 100,200");
|
||||
EXPECT_EQ (si->point ().to_string (), "100,200");
|
||||
|
||||
++si;
|
||||
|
||||
EXPECT_EQ (si.at_end (), true);
|
||||
|
||||
|
||||
si = s.begin (db::ShapeIterator::Edges);
|
||||
|
||||
EXPECT_EQ (si.at_end (), false);
|
||||
EXPECT_EQ (si->is_edge (), true);
|
||||
EXPECT_EQ (si->is_edge_pair (), false);
|
||||
EXPECT_EQ (si->is_point (), false);
|
||||
|
||||
EXPECT_EQ (si->to_string (), "edge (100,200;200,400)");
|
||||
EXPECT_EQ (si->edge ().to_string (), "(100,200;200,400)");
|
||||
|
||||
++si;
|
||||
|
||||
EXPECT_EQ (si.at_end (), true);
|
||||
|
||||
|
||||
si = s.begin (db::ShapeIterator::EdgePairs);
|
||||
|
||||
EXPECT_EQ (si.at_end (), false);
|
||||
EXPECT_EQ (si->is_edge (), false);
|
||||
EXPECT_EQ (si->is_edge_pair (), true);
|
||||
EXPECT_EQ (si->is_point (), false);
|
||||
|
||||
EXPECT_EQ (si->to_string (), "edge_pair (100,200;200,400)/(0,300;100,500)");
|
||||
EXPECT_EQ (si->edge_pair ().to_string (), "(100,200;200,400)/(0,300;100,500)");
|
||||
|
||||
++si;
|
||||
|
||||
EXPECT_EQ (si.at_end (), true);
|
||||
|
||||
si = s.begin (db::ShapeIterator::Points);
|
||||
|
||||
EXPECT_EQ (si.at_end (), false);
|
||||
EXPECT_EQ (si->is_edge (), false);
|
||||
EXPECT_EQ (si->is_edge_pair (), false);
|
||||
EXPECT_EQ (si->is_point (), true);
|
||||
|
||||
EXPECT_EQ (si->to_string (), "point 100,200");
|
||||
EXPECT_EQ (si->point ().to_string (), "100,200");
|
||||
|
||||
++si;
|
||||
|
||||
EXPECT_EQ (si.at_end (), true);
|
||||
|
||||
|
||||
s.clear ();
|
||||
s.insert (db::PointWithProperties (db::Point (100, 200), 1));
|
||||
s.insert (db::EdgeWithProperties (db::Edge (db::Point (100, 200), db::Point (200, 400)), 2));
|
||||
s.insert (db::EdgePairWithProperties (db::EdgePair (db::Edge (db::Point (100, 200), db::Point (200, 400)), db::Edge (db::Point (0, 300), db::Point (100, 500))), 3));
|
||||
|
||||
si = s.begin (db::ShapeIterator::All);
|
||||
|
||||
EXPECT_EQ (si.at_end (), false);
|
||||
EXPECT_EQ (si->is_edge (), true);
|
||||
EXPECT_EQ (si->prop_id (), db::properties_id_type (2));
|
||||
EXPECT_EQ (si->is_edge_pair (), false);
|
||||
EXPECT_EQ (si->is_point (), false);
|
||||
|
||||
EXPECT_EQ (si->to_string (), "edge (100,200;200,400) prop_id=2");
|
||||
EXPECT_EQ (si->edge ().to_string (), "(100,200;200,400)");
|
||||
|
||||
++si;
|
||||
|
||||
EXPECT_EQ (si.at_end (), false);
|
||||
EXPECT_EQ (si->is_edge (), false);
|
||||
EXPECT_EQ (si->is_edge_pair (), true);
|
||||
EXPECT_EQ (si->prop_id (), db::properties_id_type (3));
|
||||
EXPECT_EQ (si->is_point (), false);
|
||||
|
||||
EXPECT_EQ (si->to_string (), "edge_pair (100,200;200,400)/(0,300;100,500) prop_id=3");
|
||||
EXPECT_EQ (si->edge_pair ().to_string (), "(100,200;200,400)/(0,300;100,500)");
|
||||
|
||||
++si;
|
||||
|
||||
EXPECT_EQ (si.at_end (), false);
|
||||
EXPECT_EQ (si->is_edge (), false);
|
||||
EXPECT_EQ (si->is_edge_pair (), false);
|
||||
EXPECT_EQ (si->is_point (), true);
|
||||
EXPECT_EQ (si->prop_id (), db::properties_id_type (1));
|
||||
|
||||
EXPECT_EQ (si->to_string (), "point 100,200 prop_id=1");
|
||||
EXPECT_EQ (si->point ().to_string (), "100,200");
|
||||
|
||||
++si;
|
||||
|
||||
EXPECT_EQ (si.at_end (), true);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3406,33 +3406,6 @@ TEST(24c)
|
|||
EXPECT_EQ (shapes_to_string_norm (_this, s1), "");
|
||||
}
|
||||
|
||||
// Bug #107
|
||||
TEST(100)
|
||||
{
|
||||
db::Manager m (true);
|
||||
db::Shapes shapes1 (&m, 0, true);
|
||||
|
||||
m.transaction ("y");
|
||||
shapes1.insert (db::Box (200, -200, 100, -100));
|
||||
m.commit ();
|
||||
|
||||
EXPECT_EQ (shapes_to_string_norm (_this, shapes1),
|
||||
"box (100,-200;200,-100) #0\n"
|
||||
);
|
||||
m.undo ();
|
||||
EXPECT_EQ (shapes_to_string_norm (_this, shapes1),
|
||||
""
|
||||
);
|
||||
m.redo ();
|
||||
EXPECT_EQ (shapes_to_string_norm (_this, shapes1),
|
||||
"box (100,-200;200,-100) #0\n"
|
||||
);
|
||||
m.undo ();
|
||||
EXPECT_EQ (shapes_to_string_norm (_this, shapes1),
|
||||
""
|
||||
);
|
||||
}
|
||||
|
||||
// Shape insert and clear and undo/redo - different layouts
|
||||
TEST(24d)
|
||||
{
|
||||
|
|
@ -3499,6 +3472,33 @@ TEST(24d)
|
|||
EXPECT_EQ (shapes_to_string_norm (_this, s1), "");
|
||||
}
|
||||
|
||||
// Bug #107
|
||||
TEST(100)
|
||||
{
|
||||
db::Manager m (true);
|
||||
db::Shapes shapes1 (&m, 0, true);
|
||||
|
||||
m.transaction ("y");
|
||||
shapes1.insert (db::Box (200, -200, 100, -100));
|
||||
m.commit ();
|
||||
|
||||
EXPECT_EQ (shapes_to_string_norm (_this, shapes1),
|
||||
"box (100,-200;200,-100) #0\n"
|
||||
);
|
||||
m.undo ();
|
||||
EXPECT_EQ (shapes_to_string_norm (_this, shapes1),
|
||||
""
|
||||
);
|
||||
m.redo ();
|
||||
EXPECT_EQ (shapes_to_string_norm (_this, shapes1),
|
||||
"box (100,-200;200,-100) #0\n"
|
||||
);
|
||||
m.undo ();
|
||||
EXPECT_EQ (shapes_to_string_norm (_this, shapes1),
|
||||
""
|
||||
);
|
||||
}
|
||||
|
||||
// Bug #835
|
||||
TEST(101)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@ class DBEdgePair_TestClass < TestBase
|
|||
ep = RBA::EdgePair::new
|
||||
assert_equal(ep.to_s, "(0,0;0,0)/(0,0;0,0)")
|
||||
|
||||
assert_equal(ep.to_s, "(0,0;0,0)/(0,0;0,0)")
|
||||
|
||||
ep.first = RBA::Edge::new(0, 0, 10, 20)
|
||||
assert_equal(ep.to_s, "(0,0;10,20)/(0,0;0,0)")
|
||||
|
||||
|
|
@ -57,6 +59,18 @@ class DBEdgePair_TestClass < TestBase
|
|||
assert_equal(ep.simple_polygon(0).to_s, "(-10,0;-10,30;0,0;10,20)")
|
||||
assert_equal(ep.simple_polygon(0).class.to_s, "RBA::SimplePolygon")
|
||||
|
||||
ep = RBA::EdgePair::new(RBA::Edge::new(0, 0, 10, 0), RBA::Edge::new(0, 20, 0, 0))
|
||||
|
||||
assert_equal(ep.perimeter, 30)
|
||||
assert_equal(ep.area, 100)
|
||||
assert_equal(ep.simple_polygon(0).area, 100)
|
||||
|
||||
ep = RBA::EdgePair::new(RBA::Edge::new(0, 0, 10, 0), RBA::Edge::new(0, 0, 0, 20))
|
||||
|
||||
assert_equal(ep.perimeter, 30)
|
||||
assert_equal(ep.area, 0)
|
||||
assert_equal(ep.simple_polygon(0).area, 0)
|
||||
|
||||
end
|
||||
|
||||
# Basics
|
||||
|
|
@ -92,6 +106,18 @@ class DBEdgePair_TestClass < TestBase
|
|||
assert_equal(ep.simple_polygon(0).to_s, "(-10,0;-10,30;0,0;10,20)")
|
||||
assert_equal(ep.simple_polygon(0).class.to_s, "RBA::DSimplePolygon")
|
||||
|
||||
ep = RBA::DEdgePair::new(RBA::DEdge::new(0, 0, 10, 0), RBA::DEdge::new(0, 20, 0, 0))
|
||||
|
||||
assert_equal(ep.perimeter, 30)
|
||||
assert_equal(ep.area, 100)
|
||||
assert_equal(ep.simple_polygon(0).area, 100)
|
||||
|
||||
ep = RBA::DEdgePair::new(RBA::DEdge::new(0, 0, 10, 0), RBA::DEdge::new(0, 0, 0, 20))
|
||||
|
||||
assert_equal(ep.perimeter, 30)
|
||||
assert_equal(ep.area, 0)
|
||||
assert_equal(ep.simple_polygon(0).area, 0)
|
||||
|
||||
end
|
||||
|
||||
# Fuzzy compare
|
||||
|
|
|
|||
|
|
@ -158,6 +158,9 @@ class DBShapes_TestClass < TestBase
|
|||
shapes.each( RBA::Shapes::SEdges ) { |s| arr.push( s ) }
|
||||
assert_equal( arr.size, 0 )
|
||||
arr = []
|
||||
shapes.each( RBA::Shapes::SPoints ) { |s| arr.push( s ) }
|
||||
assert_equal( arr.size, 0 )
|
||||
arr = []
|
||||
shapes.each( RBA::Shapes::SBoxes ) { |s| arr.push( s ) }
|
||||
assert_equal( arr.size, 1 )
|
||||
assert_equal( arr[0].prop_id, 0 )
|
||||
|
|
@ -166,6 +169,7 @@ class DBShapes_TestClass < TestBase
|
|||
assert_equal( arr[0].type, RBA::Shape::t_box )
|
||||
assert_equal( arr[0].polygon.to_s, "(10,-10;10,40;50,40;50,-10)" )
|
||||
assert_equal( arr[0].simple_polygon.to_s, "(10,-10;10,40;50,40;50,-10)" )
|
||||
assert_equal( arr[0].point.inspect, "nil" )
|
||||
assert_equal( arr[0].edge.inspect, "nil" )
|
||||
assert_equal( arr[0].edge_pair.inspect, "nil" )
|
||||
assert_equal( arr[0].box.to_s, "(10,-10;50,40)" )
|
||||
|
|
@ -190,6 +194,7 @@ class DBShapes_TestClass < TestBase
|
|||
assert_equal( arr[0].is_edge?, true )
|
||||
assert_equal( arr[0].polygon.inspect, "nil" )
|
||||
assert_equal( arr[0].simple_polygon.inspect, "nil" )
|
||||
assert_equal( arr[0].point.inspect, "nil" )
|
||||
assert_equal( arr[0].edge.to_s, "(-1,2;5,2)" )
|
||||
assert_equal( arr[0].edge_pair.inspect, "nil" )
|
||||
assert_equal( arr[0].box.inspect, "nil" )
|
||||
|
|
@ -217,6 +222,7 @@ class DBShapes_TestClass < TestBase
|
|||
assert_equal( arr[0].polygon.inspect, "nil" )
|
||||
assert_equal( arr[0].simple_polygon.inspect, "nil" )
|
||||
assert_equal( arr[0].edge_pair.to_s, "(-1,2;5,2)/(-1,5;5,5)" )
|
||||
assert_equal( arr[0].point.inspect, "nil" )
|
||||
assert_equal( arr[0].edge.inspect, "nil" )
|
||||
assert_equal( arr[0].box.inspect, "nil" )
|
||||
assert_equal( arr[0].path.inspect, "nil" )
|
||||
|
|
@ -228,6 +234,33 @@ class DBShapes_TestClass < TestBase
|
|||
assert_equal( arr.size, 1 )
|
||||
assert_equal( arr[0].is_box?, true )
|
||||
|
||||
# points
|
||||
|
||||
a = RBA::Point::new( -1, 2 )
|
||||
c1.shapes( lindex ).insert( a )
|
||||
arr = []
|
||||
shapes.each( RBA::Shapes::SPoints ) { |s| arr.push( s ) }
|
||||
assert_equal( arr.size, 1 )
|
||||
assert_equal( arr[0].prop_id, 0 )
|
||||
assert_equal( arr[0].has_prop_id?, false )
|
||||
assert_equal( arr[0].is_null?, false )
|
||||
assert_equal( arr[0].type, RBA::Shape::t_point )
|
||||
assert_equal( arr[0].is_point?, true )
|
||||
assert_equal( arr[0].polygon.inspect, "nil" )
|
||||
assert_equal( arr[0].simple_polygon.inspect, "nil" )
|
||||
assert_equal( arr[0].point.to_s, "-1,2" )
|
||||
assert_equal( arr[0].edge.inspect, "nil" )
|
||||
assert_equal( arr[0].edge_pair.inspect, "nil" )
|
||||
assert_equal( arr[0].box.inspect, "nil" )
|
||||
assert_equal( arr[0].path.inspect, "nil" )
|
||||
assert_equal( arr[0].text.inspect, "nil" )
|
||||
assert_equal( arr[0].point == a, true )
|
||||
assert_equal( arr[0].bbox == RBA::Box::new(a, a), true )
|
||||
arr = []
|
||||
shapes.each( RBA::Shapes::SBoxes ) { |s| arr.push( s ) }
|
||||
assert_equal( arr.size, 1 )
|
||||
assert_equal( arr[0].is_box?, true )
|
||||
|
||||
# paths
|
||||
|
||||
a = RBA::Path::new( [ RBA::Point::new( 0, 10 ), RBA::Point::new( 10, 50 ) ], 25 )
|
||||
|
|
@ -486,6 +519,9 @@ class DBShapes_TestClass < TestBase
|
|||
shapes.each( RBA::Shapes::SEdges ) { |s| arr.push( s ) }
|
||||
assert_equal( arr.size, 0 )
|
||||
arr = []
|
||||
shapes.each( RBA::Shapes::SPoints ) { |s| arr.push( s ) }
|
||||
assert_equal( arr.size, 0 )
|
||||
arr = []
|
||||
shapes.each( RBA::Shapes::SBoxes ) { |s| arr.push( s ) }
|
||||
assert_equal( arr.size, 1 )
|
||||
assert_equal( arr[0].prop_id, 0 )
|
||||
|
|
@ -543,6 +579,7 @@ class DBShapes_TestClass < TestBase
|
|||
assert_equal( arr[0].is_edge_pair?, true )
|
||||
assert_equal( arr[0].dpolygon.inspect, "nil" )
|
||||
assert_equal( arr[0].dsimple_polygon.inspect, "nil" )
|
||||
assert_equal( arr[0].dpoint.inspect, "nil" )
|
||||
assert_equal( arr[0].dedge_pair.to_s, "(-0.001,0.002;0.005,0.002)/(-0.001,0.005;0.005,0.005)" )
|
||||
assert_equal( arr[0].dedge.inspect, "nil" )
|
||||
assert_equal( arr[0].dbox.inspect, "nil" )
|
||||
|
|
@ -554,6 +591,32 @@ class DBShapes_TestClass < TestBase
|
|||
assert_equal( arr.size, 1 )
|
||||
assert_equal( arr[0].is_box?, true )
|
||||
|
||||
# points
|
||||
|
||||
a = RBA::DPoint::new( -1, 2 )
|
||||
c1.shapes( lindex ).insert( a )
|
||||
arr = []
|
||||
shapes.each( RBA::Shapes::SPoints ) { |s| arr.push( s ) }
|
||||
assert_equal( arr.size, 1 )
|
||||
assert_equal( arr[0].prop_id, 0 )
|
||||
assert_equal( arr[0].has_prop_id?, false )
|
||||
assert_equal( arr[0].is_null?, false )
|
||||
assert_equal( arr[0].type, RBA::Shape::t_point )
|
||||
assert_equal( arr[0].is_point?, true )
|
||||
assert_equal( arr[0].dpolygon.inspect, "nil" )
|
||||
assert_equal( arr[0].dsimple_polygon.inspect, "nil" )
|
||||
assert_equal( arr[0].dpoint.to_s, "-1,2" )
|
||||
assert_equal( arr[0].dedge.inspect, "nil" )
|
||||
assert_equal( arr[0].dedge_pair.inspect, "nil" )
|
||||
assert_equal( arr[0].dbox.inspect, "nil" )
|
||||
assert_equal( arr[0].dpath.inspect, "nil" )
|
||||
assert_equal( arr[0].dtext.inspect, "nil" )
|
||||
assert_equal( arr[0].dbbox.to_s, "(-1,2;-1,2)" )
|
||||
arr = []
|
||||
shapes.each( RBA::Shapes::SBoxes ) { |s| arr.push( s ) }
|
||||
assert_equal( arr.size, 1 )
|
||||
assert_equal( arr[0].is_box?, true )
|
||||
|
||||
# paths
|
||||
|
||||
a = RBA::DPath::new( [ RBA::DPoint::new( 0, 0.010 ), RBA::DPoint::new( 0.010, 0.050 ) ], 0.025 )
|
||||
|
|
|
|||
Loading…
Reference in New Issue