mirror of https://github.com/KLayout/klayout.git
Refactoring of EdgePairs/Edges API to avoid ambiguities
This commit is contained in:
parent
753f2cd164
commit
f68fd4f8d0
|
|
@ -430,16 +430,30 @@ static db::EdgePairs with_length_both2 (const db::EdgePairs *r, const tl::Varian
|
|||
return r->filtered (ef);
|
||||
}
|
||||
|
||||
static db::EdgePairs with_angle1 (const db::EdgePairs *r, double a, bool inverse, bool absolute)
|
||||
static db::EdgePairs with_angle1 (const db::EdgePairs *r, double a, bool inverse)
|
||||
{
|
||||
db::EdgeOrientationFilter f (a, inverse, absolute);
|
||||
db::EdgeOrientationFilter f (a, inverse, false);
|
||||
db::EdgeFilterBasedEdgePairFilter ef (&f, true /*one must match*/);
|
||||
return r->filtered (ef);
|
||||
}
|
||||
|
||||
static db::EdgePairs with_angle2 (const db::EdgePairs *r, double amin, double amax, bool inverse, bool include_amin, bool include_amax, bool absolute)
|
||||
static db::EdgePairs with_angle2 (const db::EdgePairs *r, double amin, double amax, bool inverse, bool include_amin, bool include_amax)
|
||||
{
|
||||
db::EdgeOrientationFilter f (amin, include_amin, amax, include_amax, inverse, absolute);
|
||||
db::EdgeOrientationFilter f (amin, include_amin, amax, include_amax, inverse, false);
|
||||
db::EdgeFilterBasedEdgePairFilter ef (&f, true /*one must match*/);
|
||||
return r->filtered (ef);
|
||||
}
|
||||
|
||||
static db::EdgePairs with_abs_angle1 (const db::EdgePairs *r, double a, bool inverse)
|
||||
{
|
||||
db::EdgeOrientationFilter f (a, inverse, true);
|
||||
db::EdgeFilterBasedEdgePairFilter ef (&f, true /*one must match*/);
|
||||
return r->filtered (ef);
|
||||
}
|
||||
|
||||
static db::EdgePairs with_abs_angle2 (const db::EdgePairs *r, double amin, double amax, bool inverse, bool include_amin, bool include_amax)
|
||||
{
|
||||
db::EdgeOrientationFilter f (amin, include_amin, amax, include_amax, inverse, true);
|
||||
db::EdgeFilterBasedEdgePairFilter ef (&f, true /*one must match*/);
|
||||
return r->filtered (ef);
|
||||
}
|
||||
|
|
@ -451,16 +465,30 @@ static db::EdgePairs with_angle3 (const db::EdgePairs *r, db::SpecialEdgeOrienta
|
|||
return r->filtered (ef);
|
||||
}
|
||||
|
||||
static db::EdgePairs with_angle_both1 (const db::EdgePairs *r, double a, bool inverse, bool absolute)
|
||||
static db::EdgePairs with_angle_both1 (const db::EdgePairs *r, double a, bool inverse)
|
||||
{
|
||||
db::EdgeOrientationFilter f (a, inverse, absolute);
|
||||
db::EdgeOrientationFilter f (a, inverse, false);
|
||||
db::EdgeFilterBasedEdgePairFilter ef (&f, false /*both must match*/);
|
||||
return r->filtered (ef);
|
||||
}
|
||||
|
||||
static db::EdgePairs with_angle_both2 (const db::EdgePairs *r, double amin, double amax, bool inverse, bool include_amin, bool include_amax, bool absolute)
|
||||
static db::EdgePairs with_angle_both2 (const db::EdgePairs *r, double amin, double amax, bool inverse, bool include_amin, bool include_amax)
|
||||
{
|
||||
db::EdgeOrientationFilter f (amin, include_amin, amax, include_amax, inverse, absolute);
|
||||
db::EdgeOrientationFilter f (amin, include_amin, amax, include_amax, inverse, false);
|
||||
db::EdgeFilterBasedEdgePairFilter ef (&f, false /*both must match*/);
|
||||
return r->filtered (ef);
|
||||
}
|
||||
|
||||
static db::EdgePairs with_abs_angle_both1 (const db::EdgePairs *r, double a, bool inverse)
|
||||
{
|
||||
db::EdgeOrientationFilter f (a, inverse, true);
|
||||
db::EdgeFilterBasedEdgePairFilter ef (&f, false /*both must match*/);
|
||||
return r->filtered (ef);
|
||||
}
|
||||
|
||||
static db::EdgePairs with_abs_angle_both2 (const db::EdgePairs *r, double amin, double amax, bool inverse, bool include_amin, bool include_amax)
|
||||
{
|
||||
db::EdgeOrientationFilter f (amin, include_amin, amax, include_amax, inverse, true);
|
||||
db::EdgeFilterBasedEdgePairFilter ef (&f, false /*both must match*/);
|
||||
return r->filtered (ef);
|
||||
}
|
||||
|
|
@ -926,16 +954,12 @@ Class<db::EdgePairs> decl_EdgePairs (decl_dbShapeCollection, "db", "EdgePairs",
|
|||
"\n"
|
||||
"This method has been added in version 0.27.1.\n"
|
||||
) +
|
||||
method_ext ("with_angle", with_angle1, gsi::arg ("angle"), gsi::arg ("inverse"), gsi::arg ("absolute_angle", false),
|
||||
method_ext ("with_angle", with_angle1, gsi::arg ("angle"), gsi::arg ("inverse"),
|
||||
"@brief Filter the edge pairs by orientation of their edges\n"
|
||||
"Filters the edge pairs in the edge pair collection by orientation. If \"inverse\" is false, only "
|
||||
"edge pairs with at least one edge having the given angle to the x-axis are returned. If \"inverse\" is true, "
|
||||
"edge pairs not fulfilling this criterion are returned.\n"
|
||||
"\n"
|
||||
"With 'absolute_angle' set to false (the default), the angle against the x axis can be negative or positive. "
|
||||
"Edges pointing 'down' make negative angles while edges pointing 'up' make positive angles. With "
|
||||
"'absolute_angle' set to true, the angles are always positive.\n"
|
||||
"\n"
|
||||
"This will filter edge pairs with at least one horizontal edge:\n"
|
||||
"\n"
|
||||
"@code\n"
|
||||
|
|
@ -950,9 +974,9 @@ Class<db::EdgePairs> decl_EdgePairs (decl_dbShapeCollection, "db", "EdgePairs",
|
|||
"others = edge_pairs.with_angle_both(0, true)\n"
|
||||
"@/code\n"
|
||||
"\n"
|
||||
"This method has been added in version 0.27.1. 'absolute_angle' has been introduced in version 0.29.1.\n"
|
||||
"This method has been added in version 0.27.1.\n"
|
||||
) +
|
||||
method_ext ("with_angle", with_angle2, gsi::arg ("min_angle"), gsi::arg ("max_angle"), gsi::arg ("inverse"), gsi::arg ("include_min_angle", true), gsi::arg ("include_max_angle", false), gsi::arg ("absolute_angle", false),
|
||||
method_ext ("with_angle", with_angle2, gsi::arg ("min_angle"), gsi::arg ("max_angle"), gsi::arg ("inverse"), gsi::arg ("include_min_angle", true), gsi::arg ("include_max_angle", false),
|
||||
"@brief Filter the edge pairs by orientation of their edges\n"
|
||||
"Filters the edge pairs in the edge pair collection by orientation. If \"inverse\" is false, only "
|
||||
"edge pairs with at least one edge having an angle between min_angle and max_angle are returned. If \"inverse\" is true, "
|
||||
|
|
@ -961,10 +985,6 @@ Class<db::EdgePairs> decl_EdgePairs (decl_dbShapeCollection, "db", "EdgePairs",
|
|||
"With \"include_min_angle\" set to true (the default), the minimum angle is included in the criterion while with false, the "
|
||||
"minimum angle itself is not included. Same for \"include_max_angle\" where the default is false, meaning the maximum angle is not included in the range.\n"
|
||||
"\n"
|
||||
"With 'absolute_angle' set to false (the default), the angle against the x axis can be negative or positive. "
|
||||
"Edges pointing 'down' make negative angles while edges pointing 'up' make positive angles. With "
|
||||
"'absolute_angle' set to true, the angles are always positive.\n"
|
||||
"\n"
|
||||
"Note that the inverse @b result @/b of \\with_angle is delivered by \\with_angle_both with the inverse flag set as edge pairs are unselected when both edges fail to meet the criterion.\n"
|
||||
"I.e\n"
|
||||
"\n"
|
||||
|
|
@ -973,7 +993,23 @@ Class<db::EdgePairs> decl_EdgePairs (decl_dbShapeCollection, "db", "EdgePairs",
|
|||
"others = edge_pairs.with_angle_both(0, 45, true)\n"
|
||||
"@/code\n"
|
||||
"\n"
|
||||
"This method has been added in version 0.27.1. 'absolute_angle' has been introduced in version 0.29.1.\n"
|
||||
"This method has been added in version 0.27.1.\n"
|
||||
) +
|
||||
method_ext ("with_abs_angle", with_abs_angle1, gsi::arg ("angle"), gsi::arg ("inverse"),
|
||||
"@brief Filter the edge pairs by orientation of their edges\n"
|
||||
"\n"
|
||||
"This method behaves like \\with_angle, but angles are always positive - i.e. there is no "
|
||||
"differentiation between edges sloping 'down' vs. edges sloping 'up.\n"
|
||||
"\n"
|
||||
"This method has been added in version 0.29.1.\n"
|
||||
) +
|
||||
method_ext ("with_abs_angle", with_abs_angle2, gsi::arg ("min_angle"), gsi::arg ("max_angle"), gsi::arg ("inverse"), gsi::arg ("include_min_angle", true), gsi::arg ("include_max_angle", false),
|
||||
"@brief Filter the edge pairs by orientation of their edges\n"
|
||||
"\n"
|
||||
"This method behaves like \\with_angle, but angles are always positive - i.e. there is no "
|
||||
"differentiation between edges sloping 'down' vs. edges sloping 'up.\n"
|
||||
"\n"
|
||||
"This method has been added in version 0.29.1.\n"
|
||||
) +
|
||||
method_ext ("with_angle", with_angle3, gsi::arg ("type"), gsi::arg ("inverse"),
|
||||
"@brief Filter the edge pairs by orientation of their edges\n"
|
||||
|
|
@ -994,7 +1030,7 @@ Class<db::EdgePairs> decl_EdgePairs (decl_dbShapeCollection, "db", "EdgePairs",
|
|||
"\n"
|
||||
"This method has been added in version 0.28.\n"
|
||||
) +
|
||||
method_ext ("with_angle_both", with_angle_both1, gsi::arg ("angle"), gsi::arg ("inverse"), gsi::arg ("absolute_angle", false),
|
||||
method_ext ("with_angle_both", with_angle_both1, gsi::arg ("angle"), gsi::arg ("inverse"),
|
||||
"@brief Filter the edge pairs by orientation of both of their edges\n"
|
||||
"Filters the edge pairs in the edge pair collection by orientation. If \"inverse\" is false, only "
|
||||
"edge pairs with both edges having the given angle to the x-axis are returned. If \"inverse\" is true, "
|
||||
|
|
@ -1016,7 +1052,7 @@ Class<db::EdgePairs> decl_EdgePairs (decl_dbShapeCollection, "db", "EdgePairs",
|
|||
"\n"
|
||||
"This method has been added in version 0.27.1.\n"
|
||||
) +
|
||||
method_ext ("with_angle_both", with_angle_both2, gsi::arg ("min_angle"), gsi::arg ("max_angle"), gsi::arg ("inverse"), gsi::arg ("include_min_angle", true), gsi::arg ("include_max_angle", false), gsi::arg ("absolute_angle", false),
|
||||
method_ext ("with_angle_both", with_angle_both2, gsi::arg ("min_angle"), gsi::arg ("max_angle"), gsi::arg ("inverse"), gsi::arg ("include_min_angle", true), gsi::arg ("include_max_angle", false),
|
||||
"@brief Filter the edge pairs by orientation of both of their edges\n"
|
||||
"Filters the edge pairs in the edge pair collection by orientation. If \"inverse\" is false, only "
|
||||
"edge pairs with both edges having an angle between min_angle and max_angle are returned. If \"inverse\" is true, "
|
||||
|
|
@ -1025,10 +1061,6 @@ Class<db::EdgePairs> decl_EdgePairs (decl_dbShapeCollection, "db", "EdgePairs",
|
|||
"With \"include_min_angle\" set to true (the default), the minimum angle is included in the criterion while with false, the "
|
||||
"minimum angle itself is not included. Same for \"include_max_angle\" where the default is false, meaning the maximum angle is not included in the range.\n"
|
||||
"\n"
|
||||
"With 'absolute_angle' set to false (the default), the angle against the x axis can be negative or positive. "
|
||||
"Edges pointing 'down' make negative angles while edges pointing 'up' make positive angles. With "
|
||||
"'absolute_angle' set to true, the angles are always positive.\n"
|
||||
"\n"
|
||||
"Note that the inverse @b result @/b of \\with_angle_both is delivered by \\with_angle with the inverse flag set as edge pairs are unselected when one edge fails to meet the criterion.\n"
|
||||
"I.e\n"
|
||||
"\n"
|
||||
|
|
@ -1037,7 +1069,22 @@ Class<db::EdgePairs> decl_EdgePairs (decl_dbShapeCollection, "db", "EdgePairs",
|
|||
"others = edge_pairs.with_angle(0, 45, true)\n"
|
||||
"@/code\n"
|
||||
"\n"
|
||||
"This method has been added in version 0.27.1. 'absolute_angle' has been introduced in version 0.29.1.\n"
|
||||
"This method has been added in version 0.27.1.\n"
|
||||
) +
|
||||
method_ext ("with_abs_angle_both", with_abs_angle_both1, gsi::arg ("angle"), gsi::arg ("inverse"),
|
||||
"@brief Filter the edge pairs by orientation of both of their edges\n"
|
||||
"\n"
|
||||
"This method behaves like \\with_angle_both, but angles are always positive - i.e. there is no "
|
||||
"differentiation between edges sloping 'down' vs. edges sloping 'up.\n"
|
||||
"\n"
|
||||
"This method has been added in version 0.29.1.\n"
|
||||
) +
|
||||
method_ext ("with_abs_angle_both", with_abs_angle_both2, gsi::arg ("min_angle"), gsi::arg ("max_angle"), gsi::arg ("inverse"), gsi::arg ("include_min_angle", true), gsi::arg ("include_max_angle", false),
|
||||
"\n"
|
||||
"This method behaves like \\with_angle_both, but angles are always positive - i.e. there is no "
|
||||
"differentiation between edges sloping 'down' vs. edges sloping 'up.\n"
|
||||
"\n"
|
||||
"This method has been added in version 0.29.1.\n"
|
||||
) +
|
||||
method_ext ("with_angle_both", with_angle_both3, gsi::arg ("type"), gsi::arg ("inverse"),
|
||||
"@brief Filter the edge pairs by orientation of their edges\n"
|
||||
|
|
|
|||
|
|
@ -438,15 +438,27 @@ static db::Edges with_length2 (const db::Edges *r, const tl::Variant &min, const
|
|||
return r->filtered (f);
|
||||
}
|
||||
|
||||
static db::Edges with_angle1 (const db::Edges *r, double a, bool inverse, bool absolute)
|
||||
static db::Edges with_angle1 (const db::Edges *r, double a, bool inverse)
|
||||
{
|
||||
db::EdgeOrientationFilter f (a, inverse, absolute);
|
||||
db::EdgeOrientationFilter f (a, inverse, false);
|
||||
return r->filtered (f);
|
||||
}
|
||||
|
||||
static db::Edges with_angle2 (const db::Edges *r, double amin, double amax, bool inverse, bool include_amin, bool include_amax, bool absolute)
|
||||
static db::Edges with_angle2 (const db::Edges *r, double amin, double amax, bool inverse, bool include_amin, bool include_amax)
|
||||
{
|
||||
db::EdgeOrientationFilter f (amin, include_amin, amax, include_amax, inverse, absolute);
|
||||
db::EdgeOrientationFilter f (amin, include_amin, amax, include_amax, inverse, false);
|
||||
return r->filtered (f);
|
||||
}
|
||||
|
||||
static db::Edges with_abs_angle1 (const db::Edges *r, double a, bool inverse)
|
||||
{
|
||||
db::EdgeOrientationFilter f (a, inverse, true);
|
||||
return r->filtered (f);
|
||||
}
|
||||
|
||||
static db::Edges with_abs_angle2 (const db::Edges *r, double amin, double amax, bool inverse, bool include_amin, bool include_amax)
|
||||
{
|
||||
db::EdgeOrientationFilter f (amin, include_amin, amax, include_amax, inverse, true);
|
||||
return r->filtered (f);
|
||||
}
|
||||
|
||||
|
|
@ -901,25 +913,19 @@ Class<db::Edges> decl_Edges (decl_dbShapeCollection, "db", "Edges",
|
|||
"\n"
|
||||
"If you don't want to specify a lower or upper limit, pass nil to that parameter.\n"
|
||||
) +
|
||||
method_ext ("with_angle", with_angle1, gsi::arg ("angle"), gsi::arg ("inverse"), gsi::arg ("absolute_angle", false),
|
||||
method_ext ("with_angle", with_angle1, gsi::arg ("angle"), gsi::arg ("inverse"),
|
||||
"@brief Filters the edges by orientation\n"
|
||||
"Filters the edges in the edge collection by orientation. If \"inverse\" is false, only "
|
||||
"edges which have the given angle to the x-axis are returned. If \"inverse\" is true, "
|
||||
"edges not having the given angle are returned.\n"
|
||||
"\n"
|
||||
"With 'absolute_angle' set to false (the default), the angle against the x axis can be negative or positive. "
|
||||
"Edges pointing 'down' make negative angles while edges pointing 'up' make positive angles. With "
|
||||
"'absolute_angle' set to true, the angles are always positive.\n"
|
||||
"\n"
|
||||
"This will select horizontal edges:\n"
|
||||
"\n"
|
||||
"@code\n"
|
||||
"horizontal = edges.with_angle(0, false)\n"
|
||||
"@/code\n"
|
||||
"\n"
|
||||
"'absolute_angle' has been introduced in version 0.29.1."
|
||||
) +
|
||||
method_ext ("with_angle", with_angle2, gsi::arg ("min_angle"), gsi::arg ("max_angle"), gsi::arg ("inverse"), gsi::arg ("include_min_angle", true), gsi::arg ("include_max_angle", false), gsi::arg ("absolute_angle", false),
|
||||
method_ext ("with_angle", with_angle2, gsi::arg ("min_angle"), gsi::arg ("max_angle"), gsi::arg ("inverse"), gsi::arg ("include_min_angle", true), gsi::arg ("include_max_angle", false),
|
||||
"@brief Filters the edges by orientation\n"
|
||||
"Filters the edges in the edge collection by orientation. If \"inverse\" is false, only "
|
||||
"edges which have an angle to the x-axis larger or equal to \"min_angle\" (depending on \"include_min_angle\") and equal or less than \"max_angle\" (depending on \"include_max_angle\") are "
|
||||
|
|
@ -929,12 +935,23 @@ Class<db::Edges> decl_Edges (decl_dbShapeCollection, "db", "Edges",
|
|||
"With \"include_min_angle\" set to true (the default), the minimum angle is included in the criterion while with false, the "
|
||||
"minimum angle itself is not included. Same for \"include_max_angle\" where the default is false, meaning the maximum angle is not included in the range.\n"
|
||||
"\n"
|
||||
"With 'absolute_angle' set to false (the default), the angle against the x axis can be negative or positive. "
|
||||
"Edges pointing 'down' make negative angles while edges pointing 'up' make positive angles. With "
|
||||
"'absolute_angle' set to true, the angles are always positive.\n"
|
||||
"The two \"include..\" arguments have been added in version 0.27.\n"
|
||||
) +
|
||||
method_ext ("with_abs_angle", with_abs_angle1, gsi::arg ("angle"), gsi::arg ("inverse"),
|
||||
"@brief Filter the edges by orientation\n"
|
||||
"\n"
|
||||
"The two \"include..\" arguments have been added in version 0.27. "
|
||||
"'absolute_angle' has been introduced in version 0.29.1."
|
||||
"This method behaves like \\with_angle, but angles are always positive - i.e. there is no "
|
||||
"differentiation between edges sloping 'down' vs. edges sloping 'up.\n"
|
||||
"\n"
|
||||
"This method has been added in version 0.29.1.\n"
|
||||
) +
|
||||
method_ext ("with_abs_angle", with_abs_angle2, gsi::arg ("min_angle"), gsi::arg ("max_angle"), gsi::arg ("inverse"), gsi::arg ("include_min_angle", true), gsi::arg ("include_max_angle", false),
|
||||
"@brief Filter the edges by orientation\n"
|
||||
"\n"
|
||||
"This method behaves like \\with_angle, but angles are always positive - i.e. there is no "
|
||||
"differentiation between edges sloping 'down' vs. edges sloping 'up.\n"
|
||||
"\n"
|
||||
"This method has been added in version 0.29.1.\n"
|
||||
) +
|
||||
method_ext ("with_angle", with_angle3, gsi::arg ("type"), gsi::arg ("inverse"),
|
||||
"@brief Filters the edges by orientation type\n"
|
||||
|
|
|
|||
|
|
@ -1007,15 +1007,15 @@ CODE
|
|||
|
||||
self.data.is_a?(RBA::Region) || self.data.is_a?(RBA::Edges) || self.data.is_a?(RBA::EdgePairs) || raise("Requires an edge, edge pair or polygon layer")
|
||||
|
||||
f = :with_angle
|
||||
absolute = self.data.is_a?(RBA::Region) ? nil : false
|
||||
absolute = false
|
||||
both = false
|
||||
|
||||
args = args.select do |a|
|
||||
if a.is_a?(DRCBothEdges)
|
||||
if !self.data.is_a?(RBA::EdgePairs)
|
||||
raise("'both' keyword is only available for edge pair layers")
|
||||
end
|
||||
f = :with_angle_both
|
||||
both = true
|
||||
false
|
||||
elsif a.is_a?(DRCAbsoluteMode)
|
||||
if self.data.is_a?(RBA::Region)
|
||||
|
|
@ -1028,33 +1028,27 @@ CODE
|
|||
end
|
||||
end
|
||||
|
||||
if both
|
||||
f = absolute ? :with_abs_angle_both : :with_angle_both
|
||||
else
|
||||
f = absolute ? :with_abs_angle : :with_angle
|
||||
end
|
||||
|
||||
result_class = self.data.is_a?(RBA::Edges) ? RBA::Edges : RBA::EdgePairs
|
||||
if args.size == 1
|
||||
a = args[0]
|
||||
if a.is_a?(Range)
|
||||
args = [ a.begin, a.end, #{inv.inspect} ]
|
||||
if absolute != nil
|
||||
args += [ true, false, absolute ]
|
||||
end
|
||||
DRCLayer::new(@engine, @engine._tcmd(self.data, 0, result_class, f, *args))
|
||||
DRCLayer::new(@engine, @engine._tcmd(self.data, 0, result_class, f, a.begin, a.end, #{inv.inspect}))
|
||||
elsif a.is_a?(DRCOrthoEdges) || a.is_a?(DRCDiagonalOnlyEdges) || a.is_a?(DRCDiagonalEdges)
|
||||
if self.data.is_a?(RBA::Region)
|
||||
raise("'ortho', 'diagonal' or 'diagonal_only' keyword is only available for edge or edge pair layers")
|
||||
end
|
||||
DRCLayer::new(@engine, @engine._tcmd(self.data, 0, result_class, f, a.value, #{inv.inspect}))
|
||||
else
|
||||
args = [ @engine._make_numeric_value(a), #{inv.inspect} ]
|
||||
if absolute != nil
|
||||
args += [ absolute ]
|
||||
end
|
||||
DRCLayer::new(@engine, @engine._tcmd(self.data, 0, result_class, f, *args))
|
||||
DRCLayer::new(@engine, @engine._tcmd(self.data, 0, result_class, f, @engine._make_numeric_value(a), #{inv.inspect}))
|
||||
end
|
||||
elsif args.size == 2
|
||||
args = [ @engine._make_numeric_value(args[0]), @engine._make_numeric_value(args[1]), #{inv.inspect} ]
|
||||
if absolute != nil
|
||||
args += [ true, false, absolute ]
|
||||
end
|
||||
DRCLayer::new(@engine, @engine._tcmd(self.data, 0, result_class, f, *args))
|
||||
DRCLayer::new(@engine, @engine._tcmd(self.data, 0, result_class, f, @engine._make_numeric_value(args[0]), @engine._make_numeric_value(args[1]), #{inv.inspect}))
|
||||
else
|
||||
raise("Invalid number of range arguments (1 or 2 expected)")
|
||||
end
|
||||
|
|
|
|||
|
|
@ -294,6 +294,7 @@ class DBEdgePairs_TestClass < TestBase
|
|||
ep4 = RBA::EdgePair::new(RBA::Edge::new(0, 0, 0, 10), RBA::Edge::new(10, 0, 10, 10))
|
||||
|
||||
r1 = RBA::EdgePairs::new([ ep1, ep2, ep3, ep4 ])
|
||||
assert_equal(r1.with_angle(0, 90, false).to_s, "") # @@@
|
||||
|
||||
assert_equal(r1.with_distance(10, false).to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.with_distance(5, 20, false).to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
|
|
@ -310,15 +311,25 @@ class DBEdgePairs_TestClass < TestBase
|
|||
assert_equal(r1.with_length_both(10, true).to_s, "(0,0;0,20)/(10,20;10,0)")
|
||||
|
||||
assert_equal(r1.with_angle(0, false).to_s, "")
|
||||
assert_equal(r1.with_abs_angle(0, false).to_s, "")
|
||||
assert_equal(r1.with_angle(0, true).to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.with_abs_angle(0, true).to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.with_angle(90, false).to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.with_abs_angle(90, false).to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.with_angle(0, 90, false).to_s, "")
|
||||
assert_equal(r1.with_abs_angle(0, 90, false).to_s, "")
|
||||
assert_equal(r1.with_angle(0, 90, false, true, true).to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.with_abs_angle(0, 90, false, true, true).to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.with_angle_both(0, false).to_s, "")
|
||||
assert_equal(r1.with_abs_angle_both(0, false).to_s, "")
|
||||
assert_equal(r1.with_angle_both(0, true).to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.with_abs_angle_both(0, true).to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.with_angle_both(90, false).to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.with_abs_angle_both(90, false).to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.with_angle_both(0, 90, false).to_s, "")
|
||||
assert_equal(r1.with_abs_angle_both(0, 90, false).to_s, "")
|
||||
assert_equal(r1.with_angle_both(0, 90, false, true, true).to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.with_abs_angle_both(0, 90, false, true, true).to_s, "(0,0;0,10)/(10,20;10,0);(0,0;0,10)/(10,0;10,20);(0,0;0,20)/(10,20;10,0);(0,0;0,10)/(10,0;10,10)")
|
||||
|
||||
assert_equal(r1.with_area(0, false).to_s, "(0,0;0,10)/(10,0;10,10)")
|
||||
assert_equal(r1.with_area(150, false).to_s, "(0,0;0,10)/(10,20;10,0)")
|
||||
|
|
|
|||
|
|
@ -585,12 +585,19 @@ class DBEdges_TestClass < TestBase
|
|||
r.insert(RBA::Edge::new(0, 0, 100, 0))
|
||||
r.insert(RBA::Edge::new(100, 0, 100, 50))
|
||||
assert_equal(r.with_angle(0, false).to_s, "(0,0;100,0)")
|
||||
assert_equal(r.with_abs_angle(0, false).to_s, "(0,0;100,0)")
|
||||
assert_equal(r.with_angle(0, true).to_s, "(100,0;100,50)")
|
||||
assert_equal(r.with_abs_angle(0, true).to_s, "(100,0;100,50)")
|
||||
assert_equal(r.with_angle(90, false).to_s, "(100,0;100,50)")
|
||||
assert_equal(r.with_abs_angle(90, false).to_s, "(100,0;100,50)")
|
||||
assert_equal(r.with_angle(90, true).to_s, "(0,0;100,0)")
|
||||
assert_equal(r.with_abs_angle(90, true).to_s, "(0,0;100,0)")
|
||||
assert_equal(r.with_angle(-10, 10, false).to_s, "(0,0;100,0)")
|
||||
assert_equal(r.with_abs_angle(-10, 10, false).to_s, "(0,0;100,0)")
|
||||
assert_equal(r.with_angle(-10, 10, true).to_s, "(100,0;100,50)")
|
||||
assert_equal(r.with_abs_angle(-10, 10, true).to_s, "(100,0;100,50)")
|
||||
assert_equal(r.with_angle(80, 100, false).to_s, "(100,0;100,50)")
|
||||
assert_equal(r.with_abs_angle(80, 100, false).to_s, "(100,0;100,50)")
|
||||
assert_equal(r.with_length(100, false).to_s, "(0,0;100,0)")
|
||||
assert_equal(r.with_length(100, true).to_s, "(100,0;100,50)")
|
||||
assert_equal(r.with_length(50, false).to_s, "(100,0;100,50)")
|
||||
|
|
|
|||
Loading…
Reference in New Issue