Added "transformed" method to several shape primitives

The new version will transform double-coordinate types to
integer-coordinate types through a "VCplxTrans".
This commit is contained in:
Matthias Koefferlein 2017-07-17 21:05:38 +02:00
parent db5ac31ada
commit 703a0ee85d
14 changed files with 119 additions and 1 deletions

View File

@ -488,7 +488,7 @@ Class<db::Box> decl_Box ("Box",
"This method has been introduced in version 0.25."
) +
method ("transformed", &db::Box::transformed<db::ICplxTrans>,
"@brief Transform the box with the given complex transformation\n"
"@brief Transforms the box with the given complex transformation\n"
"\n"
"@args t\n"
"\n"
@ -543,6 +543,16 @@ Class<db::DBox> decl_DBox ("DBox",
"\n"
"This method has been introduced in version 0.25."
) +
method ("transformed", &db::DBox::transformed<db::VCplxTrans>,
"@brief Transforms the box with the given complex transformation\n"
"\n"
"@args t\n"
"\n"
"@param t The magnifying transformation to apply\n"
"@return The transformed box (in this case an integer coordinate box)\n"
"\n"
"This method has been introduced in version 0.25.\n"
) +
box_defs<db::DBox>::methods (),
"@brief A box class with floating-point coordinates\n"
"\n"

View File

@ -661,6 +661,16 @@ Class<db::DEdge> decl_DEdge ("DEdge",
"\n"
"This method has been introduced in version 0.25."
) +
method ("transformed", &db::DEdge::transformed<db::VCplxTrans>,
"@brief Transforms the edge with the given complex transformation\n"
"\n"
"@args t\n"
"\n"
"@param t The magnifying transformation to apply\n"
"@return The transformed edge (in this case an integer coordinate edge)\n"
"\n"
"This method has been introduced in version 0.25.\n"
) +
edge_defs<db::DEdge>::methods (),
"@brief An edge class\n"
"\n"

View File

@ -265,6 +265,16 @@ Class<db::DEdgePair> decl_DEdgePair ("DEdgePair",
"\n"
"This method has been introduced in version 0.25."
) +
method ("transformed", &db::DEdgePair::transformed<db::VCplxTrans>,
"@brief Transforms the edge pair with the given complex transformation\n"
"\n"
"@args t\n"
"\n"
"@param t The magnifying transformation to apply\n"
"@return The transformed edge pair (in this case an integer coordinate edge pair)\n"
"\n"
"This method has been introduced in version 0.25.\n"
) +
edge_pair_defs<db::DEdgePair>::methods (),
"@brief An edge pair (a pair of two edges)\n"
"Edge pairs are objects representing two edges or parts of edges. They play a role mainly in the context "

View File

@ -1425,6 +1425,13 @@ Class<db::Edges> dec_Edges ("Edges",
gsi::iterator ("each", &db::Edges::begin,
"@brief Returns each edge of the region\n"
) +
gsi::iterator ("each_merged", &db::Edges::begin_merged,
"@brief Returns each edge of the region\n"
"\n"
"In contrast to \\each, this method delivers merged edges if merge semantics applies while \\each delivers the original edges only.\n"
"\n"
"This method has been introduced in version 0.25."
) +
method ("[]", &db::Edges::nth,
"@brief Returns the nth edge of the edge collection\n"
"@args n\n"

View File

@ -447,6 +447,16 @@ Class<db::DPath> decl_DPath ("DPath",
"\n"
"This method has been introduced in version 0.25."
) +
method ("transformed", &db::DPath::transformed<db::VCplxTrans>,
"@brief Transforms the polygon with the given complex transformation\n"
"\n"
"@args t\n"
"\n"
"@param t The magnifying transformation to apply\n"
"@return The transformed path (in this case an integer coordinate path)\n"
"\n"
"This method has been introduced in version 0.25.\n"
) +
path_defs<db::DPath>::methods (),
"@brief A path class\n"
"\n"

View File

@ -659,6 +659,11 @@ static db::SimplePolygon dspolygon_to_spolygon (const db::DSimplePolygon *p, dou
return db::SimplePolygon (*p * (1.0 / dbu), false);
}
static db::SimplePolygon transformed_vplx_sp (const db::DSimplePolygon *p, const db::VCplxTrans &t)
{
return p->transformed (t, false /*no compression*/);
}
Class<db::DSimplePolygon> decl_DSimplePolygon ("DSimplePolygon",
constructor ("new|#from_ipoly", &dspolygon_from_ispolygon, gsi::arg ("polygon"),
"@brief Creates a floating-point coordinate polygon from an integer coordinate polygon"
@ -685,6 +690,16 @@ Class<db::DSimplePolygon> decl_DSimplePolygon ("DSimplePolygon",
"\n"
"This method has been introduced in version 0.24.\n"
) +
method_ext ("transformed", &transformed_vplx_sp,
"@brief Transforms the polygon with the given complex transformation\n"
"\n"
"@args t\n"
"\n"
"@param t The magnifying transformation to apply\n"
"@return The transformed polygon (in this case an integer coordinate polygon)\n"
"\n"
"This method has been introduced in version 0.25.\n"
) +
simple_polygon_defs<db::DSimplePolygon>::methods (),
"@brief A simple polygon class\n"
"\n"
@ -1779,6 +1794,11 @@ static db::Polygon dpolygon_to_polygon (const db::DPolygon *p, double dbu)
return db::Polygon (*p * (1.0 / dbu), false);
}
static db::Polygon transformed_vcplx_dp (const db::DPolygon *p, const db::VCplxTrans &t)
{
return p->transformed (t, false /*don't compress*/);
}
Class<db::DPolygon> decl_DPolygon ("DPolygon",
constructor ("new|#from_ipoly", &dpolygon_from_ipolygon, gsi::arg ("polygon"),
"@brief Creates a floating-point coordinate polygon from an integer coordinate polygon\n"
@ -1805,6 +1825,16 @@ Class<db::DPolygon> decl_DPolygon ("DPolygon",
"\n"
"This method has been introduced in version 0.24.\n"
) +
method_ext ("transformed", &transformed_vcplx_dp,
"@brief Transforms the polygon with the given complex transformation\n"
"\n"
"@args t\n"
"\n"
"@param t The magnifying transformation to apply\n"
"@return The transformed polygon (in this case an integer coordinate polygon)\n"
"\n"
"This method has been introduced in version 0.25.\n"
) +
polygon_defs<db::DPolygon>::methods (),
"@brief A polygon class\n"
"\n"

View File

@ -446,6 +446,16 @@ Class<db::DText> decl_DText ("DText",
"\n"
"This method has been introduced in version 0.25."
) +
method ("transformed", &db::DText::transformed<db::VCplxTrans>,
"@brief Transforms the text with the given complex transformation\n"
"\n"
"@args t\n"
"\n"
"@param t The magnifying transformation to apply\n"
"@return The transformed text (in this case an integer coordinate text)\n"
"\n"
"This method has been introduced in version 0.25.\n"
) +
text_defs<db::DText>::methods (),
"@brief A text object\n"
"\n"

View File

@ -124,7 +124,11 @@ class DBBox_TestClass < TestBase
t = RBA::DTrans::new( RBA::DTrans::R90, RBA::DPoint::new( 5, 6 ))
assert_equal( b.transformed(t).to_s, "(-17,7;6,23)" )
m = RBA::DCplxTrans::new( t, 1.5 )
assert_equal( b.transformed(m).class.to_s, "RBA::DBox" )
assert_equal( b.transformed(m).to_s, "(-28,7.5;6.5,31.5)" )
m = RBA::VCplxTrans::new( 1000.0 )
assert_equal( b.transformed(m).class.to_s, "RBA::Box" )
assert_equal( b.transformed(m).to_s, "(1000,-1000;17000,22000)" )
end

View File

@ -62,7 +62,10 @@ class DBEdgePair_TestClass < TestBase
assert_equal(ep.normalized.to_s, "(10,20;0,0)/(-10,0;-10,30)")
assert_equal(ep.transformed(RBA::DTrans::new(1)).to_s, "(0,0;-20,10)/(0,-10;-30,-10)")
assert_equal(ep.transformed(RBA::DCplxTrans::new(2.5)).class.to_s, "RBA::DEdgePair")
assert_equal(ep.transformed(RBA::DCplxTrans::new(2.5)).to_s, "(0,0;25,50)/(-25,0;-25,75)")
assert_equal(ep.transformed(RBA::VCplxTrans::new(2.5)).class.to_s, "RBA::EdgePair")
assert_equal(ep.transformed(RBA::VCplxTrans::new(2.5)).to_s, "(0,0;25,50)/(-25,0;-25,75)")
assert_equal(ep.polygon(0).to_s, "(-10,0;-10,30;0,0;10,20)")
assert_equal(ep.polygon(0).class.to_s, "RBA::DPolygon")

View File

@ -96,6 +96,10 @@ class DBEdge_TestClass < TestBase
assert_equal( a.to_s, "(6,2;-2,2)" )
assert_equal( a.transformed(RBA::DCplxTrans::new(2.2)).to_s, "(13.2,4.4;-4.4,4.4)" )
assert_equal( a.transformed(RBA::DCplxTrans::new(2.2)).class.to_s, "RBA::DEdge" )
assert_equal( a.transformed(RBA::VCplxTrans::new(22)).to_s, "(132,44;-44,44)" )
assert_equal( a.transformed(RBA::VCplxTrans::new(22)).class.to_s, "RBA::Edge" )
assert_equal( RBA::DEdge::new( -1, -5, -1, -1 ).crossed_by?( a ), true )
assert_equal( RBA::DEdge::new( -1, -5, -1, -1 ).crossing_point( a ).to_s, "-1,2" )

View File

@ -76,8 +76,13 @@ class DBPath_TestClass < TestBase
assert_equal( b.to_s, "(1,1;3,2;2,5) w=2.5 bx=-0.5 ex=1.5 r=false" )
m = RBA::DCplxTrans::new( RBA::DTrans::new, 1.5 )
assert_equal( a.transformed(m).class.to_s, "RBA::DPath")
assert_equal( a.transformed(m).to_s, "(1.5,1.5;4.5,3;3,7.5) w=3.75 bx=-0.75 ex=2.25 r=false" )
m = RBA::VCplxTrans::new(1000.0)
assert_equal( a.transformed(m).class.to_s, "RBA::Path")
assert_equal( a.transformed(m).to_s, "(1000,1000;3000,2000;2000,5000) w=2500 bx=-500 ex=1500 r=false" )
a.points = [ RBA::DPoint::new( 0, 1 ), RBA::DPoint::new( 1, 1 ), RBA::DPoint::new( 1, 5 ) ]
a.width = 2.0
a.bgn_ext = 1.0

View File

@ -56,8 +56,13 @@ class DBPolygon_TestClass < TestBase
assert_equal( b.to_s, "(6,-10;6,15;21,15;21,-10)" )
m = RBA::DCplxTrans::new( RBA::DTrans::new, 1.5 )
assert_equal( a.transformed(m).class.to_s, "RBA::DPolygon" )
assert_equal( a.transformed(m).to_s, "(9,-15;9,22.5;31.5,22.5;31.5,-15)" )
m = RBA::VCplxTrans::new( 1000.0 )
assert_equal( a.transformed(m).class.to_s, "RBA::Polygon" )
assert_equal( a.transformed(m).to_s, "(6000,-10000;6000,15000;21000,15000;21000,-10000)" )
a.hull = [ RBA::DPoint::new( 0, 1 ), RBA::DPoint::new( 1, 1 ), RBA::DPoint::new( 1, 5 ) ]
assert_equal( a.bbox.to_s, "(0,1;1,5)" )

View File

@ -65,6 +65,7 @@ class DBSimplePolygon_TestClass < TestBase
assert_equal( b.to_s, "(6,-10;6,15;21,15;21,-10)" )
m = RBA::DCplxTrans::new( RBA::DTrans::new, 1.5 )
assert_equal( a.transformed(m).class.to_s, "RBA::DSimplePolygon" )
assert_equal( a.transformed(m).to_s, "(9,-15;9,22.5;31.5,22.5;31.5,-15)" )
assert_equal( a.to_s, "(6,-10;6,15;21,15;21,-10)" )
@ -72,6 +73,10 @@ class DBSimplePolygon_TestClass < TestBase
b.transform(m)
assert_equal( b.to_s, "(9,-15;9,22.5;31.5,22.5;31.5,-15)" )
m = RBA::VCplxTrans::new( 1000.0 )
assert_equal( a.transformed(m).class.to_s, "RBA::SimplePolygon" )
assert_equal( a.transformed(m).to_s, "(6000,-10000;6000,15000;21000,15000;21000,-10000)" )
a.points = [ RBA::DPoint::new( 0, 1 ), RBA::DPoint::new( 1, 1 ), RBA::DPoint::new( 1, 5 ) ]
assert_equal( a.bbox.to_s, "(0,1;1,5)" )

View File

@ -68,8 +68,13 @@ class DBText_TestClass < TestBase
assert_equal( b.to_s, "('hallo',m45 6,7)" )
m = RBA::DCplxTrans::new( RBA::DTrans::new, 1.5 )
assert_equal( a.transformed(m).class.to_s, "RBA::DText" )
assert_equal( a.transformed(m).to_s, "('hallo',m45 9,10.5)" )
m = RBA::VCplxTrans::new( 1000.0 )
assert_equal( a.transformed(m).class.to_s, "RBA::Text" )
assert_equal( a.transformed(m).to_s, "('hallo',m45 6000,7000)" )
end
# Text basics