From d5f484bf9249bd0e2339a1a608416ff6460a493a Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Tue, 5 Dec 2023 22:09:57 +0100 Subject: [PATCH] Added EdgePair#distance --- src/db/db/gsiDeclDbEdgePair.cc | 8 ++++++++ testdata/ruby/dbEdgePairTest.rb | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/db/db/gsiDeclDbEdgePair.cc b/src/db/db/gsiDeclDbEdgePair.cc index 3d90abefe..4fb90d763 100644 --- a/src/db/db/gsiDeclDbEdgePair.cc +++ b/src/db/db/gsiDeclDbEdgePair.cc @@ -169,6 +169,14 @@ struct edge_pair_defs method ("bbox", &C::bbox, "@brief Gets the bounding box of the edge pair\n" ) + + method ("distance", &C::distance, + "@brief Gets the distance of the edges in the edge pair\n" + "\n" + "The distance between the two edges is defined as the minimum distance between any " + "two points on the two edges.\n" + "\n" + "This attribute has been introduced in version 0.28.14." + ) + method ("perimeter", &C::perimeter, "@brief Gets the perimeter of the edge pair\n" "\n" diff --git a/testdata/ruby/dbEdgePairTest.rb b/testdata/ruby/dbEdgePairTest.rb index 7e6502495..3fa8c757f 100644 --- a/testdata/ruby/dbEdgePairTest.rb +++ b/testdata/ruby/dbEdgePairTest.rb @@ -61,6 +61,7 @@ class DBEdgePair_TestClass < TestBase ep = RBA::EdgePair::new(RBA::Edge::new(0, 0, 10, 0), RBA::Edge::new(0, 20, 0, 0)) + assert_equal(ep.distance, 0) assert_equal(ep.perimeter, 30) assert_equal(ep.area, 100) assert_equal(ep.simple_polygon(0).area, 100) @@ -71,6 +72,10 @@ class DBEdgePair_TestClass < TestBase assert_equal(ep.area, 0) assert_equal(ep.simple_polygon(0).area, 0) + ep = RBA::EdgePair::new(RBA::Edge::new(0, 0, 10, 0), RBA::Edge::new(-10, 10, 20, 10)) + + assert_equal(ep.distance, 10) + end # Basics @@ -108,6 +113,7 @@ class DBEdgePair_TestClass < TestBase ep = RBA::DEdgePair::new(RBA::DEdge::new(0, 0, 10, 0), RBA::DEdge::new(0, 20, 0, 0)) + assert_equal(ep.distance, 0) assert_equal(ep.perimeter, 30) assert_equal(ep.area, 100) assert_equal(ep.simple_polygon(0).area, 100) @@ -118,6 +124,10 @@ class DBEdgePair_TestClass < TestBase assert_equal(ep.area, 0) assert_equal(ep.simple_polygon(0).area, 0) + ep = RBA::DEdgePair::new(RBA::DEdge::new(0, 0, 10, 0), RBA::DEdge::new(-10, 10, 20, 10)) + + assert_equal(ep.distance, 10) + end # Fuzzy compare