mirror of https://github.com/KLayout/klayout.git
Merge pull request #790 from KLayout/cut_point-for-edges
Cut point for edges
This commit is contained in:
commit
43df24edee
|
|
@ -82,6 +82,16 @@ struct edge_defs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static tl::Variant cut_point (const C *e, const C &ee)
|
||||||
|
{
|
||||||
|
std::pair<bool, point_type> ip = e->cut_point (ee);
|
||||||
|
if (ip.first) {
|
||||||
|
return tl::Variant (ip.second);
|
||||||
|
} else {
|
||||||
|
return tl::Variant ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static point_type crossing_point (const C *e, const C &ee)
|
static point_type crossing_point (const C *e, const C &ee)
|
||||||
{
|
{
|
||||||
return e->crossed_by_point (ee).second;
|
return e->crossed_by_point (ee).second;
|
||||||
|
|
@ -494,7 +504,7 @@ struct edge_defs
|
||||||
method_ext ("intersection_point", &intersect_point, gsi::arg ("e"),
|
method_ext ("intersection_point", &intersect_point, gsi::arg ("e"),
|
||||||
"@brief Returns the intersection point of two edges. \n"
|
"@brief Returns the intersection point of two edges. \n"
|
||||||
"\n"
|
"\n"
|
||||||
"This method delivers the intersection point. If the edges do not intersect, the result is undefined.\n"
|
"This method delivers the intersection point. If the edges do not intersect, the result will be nil.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"@param e The edge to test.\n"
|
"@param e The edge to test.\n"
|
||||||
"@return The point where the edges intersect.\n"
|
"@return The point where the edges intersect.\n"
|
||||||
|
|
@ -502,6 +512,17 @@ struct edge_defs
|
||||||
"This method has been introduced in version 0.19.\n"
|
"This method has been introduced in version 0.19.\n"
|
||||||
"From version 0.26.2, this method will return nil in case of non-intersection.\n"
|
"From version 0.26.2, this method will return nil in case of non-intersection.\n"
|
||||||
) +
|
) +
|
||||||
|
method_ext ("cut_point", &cut_point, gsi::arg ("e"),
|
||||||
|
"@brief Returns the intersection point of the lines through the two edges.\n"
|
||||||
|
"\n"
|
||||||
|
"This method delivers the intersection point between the lines through the two edges. If the lines are parallel and do not intersect, the result will be nil.\n"
|
||||||
|
"In contrast to \\intersection_point, this method will regard the edges as infinitely extended and intersection is not confined to the edge span.\n"
|
||||||
|
"\n"
|
||||||
|
"@param e The edge to test.\n"
|
||||||
|
"@return The point where the lines intersect.\n"
|
||||||
|
"\n"
|
||||||
|
"This method has been introduced in version 0.27.1.\n"
|
||||||
|
) +
|
||||||
method_ext ("clipped", &clipped, gsi::arg ("box"),
|
method_ext ("clipped", &clipped, gsi::arg ("box"),
|
||||||
"@brief Returns the edge clipped at the given box\n"
|
"@brief Returns the edge clipped at the given box\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
|
|
||||||
|
|
@ -105,6 +105,9 @@ class DBEdge_TestClass < TestBase
|
||||||
assert_equal( a.intersect?( RBA::DEdge::new( -1, -1, 1, 5 ) ), true )
|
assert_equal( a.intersect?( RBA::DEdge::new( -1, -1, 1, 5 ) ), true )
|
||||||
assert_equal( a.intersection_point( RBA::DEdge::new( -1, -1, 1, 5 ) ).to_s, "0,2" )
|
assert_equal( a.intersection_point( RBA::DEdge::new( -1, -1, 1, 5 ) ).to_s, "0,2" )
|
||||||
assert_equal( a.intersection_point( RBA::DEdge::new( -1, 3, 1, 5 ) ) == nil, true )
|
assert_equal( a.intersection_point( RBA::DEdge::new( -1, 3, 1, 5 ) ) == nil, true )
|
||||||
|
assert_equal( a.cut_point( RBA::DEdge::new( -1, -1, 1, 5 ) ).to_s, "0,2" )
|
||||||
|
assert_equal( a.cut_point( RBA::DEdge::new( -1, 3, -1, 5 ) ).to_s, "-1,2" )
|
||||||
|
assert_equal( a.cut_point( RBA::DEdge::new( -1, 3, 1, 3 ) ) == nil, true )
|
||||||
assert_equal( a.intersect?( RBA::DEdge::new( -1, 11, 1, 15 ) ), false )
|
assert_equal( a.intersect?( RBA::DEdge::new( -1, 11, 1, 15 ) ), false )
|
||||||
assert_equal( a.distance( RBA::DPoint::new( 3, 3 ) ), 1.0 )
|
assert_equal( a.distance( RBA::DPoint::new( 3, 3 ) ), 1.0 )
|
||||||
assert_equal( a.distance( RBA::DPoint::new( 3, 1 ) ), -1.0 )
|
assert_equal( a.distance( RBA::DPoint::new( 3, 1 ) ), -1.0 )
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue