Skip to content

Commit fdeab5d

Browse files
Merge pull request #2200 from KLayout/issue/issue-2183
Implementing request from issue #2183
2 parents ff49a81 + b990618 commit fdeab5d

File tree

5 files changed

+74
-8
lines changed

5 files changed

+74
-8
lines changed

src/buddies/src/bd/bdWriterOptions.cc

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,23 @@ namespace bd
3030
{
3131

3232
GenericWriterOptions::GenericWriterOptions ()
33-
: m_scale_factor (1.0)
3433
{
35-
db::SaveLayoutOptions save_options;
34+
db::SaveLayoutOptions options;
35+
init_from_options (options);
36+
}
37+
38+
GenericWriterOptions::GenericWriterOptions (const db::SaveLayoutOptions &options)
39+
{
40+
init_from_options (options);
41+
}
42+
43+
void
44+
GenericWriterOptions::init_from_options (const db::SaveLayoutOptions &save_options_nc)
45+
{
46+
// const_cast needed because "get_option_by_name" is not const as it should be
47+
db::SaveLayoutOptions &save_options = const_cast<db::SaveLayoutOptions &> (save_options_nc);
48+
49+
m_scale_factor = 1.0;
3650

3751
m_dbu = save_options.get_option_by_name ("dbu").to_double ();
3852
m_libname = save_options.get_option_by_name ("libname").to_string ();

src/buddies/src/bd/bdWriterOptions.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ class BD_PUBLIC GenericWriterOptions
5353
*/
5454
GenericWriterOptions ();
5555

56+
/**
57+
* @brief Constructor
58+
*
59+
* The "options" object specifies the defaults to be used.
60+
*/
61+
GenericWriterOptions (const db::SaveLayoutOptions &options);
62+
5663
/**
5764
* @brief Adds the generic options to the command line parser object
5865
* The format string gives a hint about the target format. Certain options will be
@@ -142,6 +149,7 @@ class BD_PUBLIC GenericWriterOptions
142149
int m_dxf_polygon_mode;
143150

144151
void set_oasis_substitution_char (const std::string &text);
152+
void init_from_options (const db::SaveLayoutOptions &options);
145153
};
146154

147155
}

src/buddies/src/bd/strmxor.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,9 @@ BD_PUBLIC int strmxor (int argc, char *argv[])
380380
generic_reader_options_a.add_options (cmd);
381381
generic_reader_options_b.add_options (cmd);
382382

383-
bd::GenericWriterOptions writer_options;
383+
db::SaveLayoutOptions def_writer_options;
384+
def_writer_options.set_dont_write_empty_cells (true);
385+
bd::GenericWriterOptions writer_options (def_writer_options);
384386
writer_options.add_options (cmd);
385387

386388
cmd << tl::arg ("input_a", &infile_a, "The first input file (any format, may be gzip compressed)")
@@ -447,7 +449,7 @@ BD_PUBLIC int strmxor (int argc, char *argv[])
447449
cmd.parse (argc, argv);
448450

449451
if (top_a.empty () != top_b.empty ()) {
450-
throw tl::Exception ("Both -ta|--top-a and -tb|--top-b top cells must be given");
452+
throw tl::Exception ("Both -ta|--top-a and -tb|--top-b top cells must be given, not just one of them");
451453
}
452454

453455
if (tolerances.empty ()) {

src/buddies/unit_tests/bdStrmxorTests.cc

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,48 @@ TEST(1A_Deep)
129129

130130
std::string output = this->tmp_file ("tmp.oas");
131131

132+
const char *argv[] = { "x", "--deep", "--drop-empty-cells=false", input_a.c_str (), input_b.c_str (), output.c_str () };
133+
134+
EXPECT_EQ (strmxor (sizeof (argv) / sizeof (argv[0]), (char **) argv), 1);
135+
136+
db::Layout layout;
137+
138+
{
139+
tl::InputStream stream (output);
140+
db::Reader reader (stream);
141+
reader.read (layout);
142+
}
143+
144+
db::compare_layouts (this, layout, au, db::NormalizationMode (db::NoNormalization | db::AsPolygons));
145+
EXPECT_EQ (cap.captured_text (),
146+
"Layer 10/0 is not present in first layout, but in second\n"
147+
"Result summary (layers without differences are not shown):\n"
148+
"\n"
149+
" Layer Output Differences (hierarchical shape count)\n"
150+
" ----------------------------------------------------------------\n"
151+
" 3/0 3/0 3\n"
152+
" 6/0 6/0 314\n"
153+
" 8/1 8/1 1\n"
154+
" 10/0 - (no such layer in first layout)\n"
155+
"\n"
156+
);
157+
}
158+
159+
TEST(1A_DeepNoEmptyCells)
160+
{
161+
tl::CaptureChannel cap;
162+
163+
std::string input_a = tl::testdata ();
164+
input_a += "/bd/strmxor_in1.gds";
165+
166+
std::string input_b = tl::testdata ();
167+
input_b += "/bd/strmxor_in2.gds";
168+
169+
std::string au = tl::testdata ();
170+
au += "/bd/strmxor_au1d2.oas";
171+
172+
std::string output = this->tmp_file ("tmp.oas");
173+
132174
const char *argv[] = { "x", "--deep", input_a.c_str (), input_b.c_str (), output.c_str () };
133175

134176
EXPECT_EQ (strmxor (sizeof (argv) / sizeof (argv[0]), (char **) argv), 1);
@@ -342,7 +384,7 @@ TEST(2_Deep)
342384

343385
std::string output = this->tmp_file ("tmp.oas");
344386

345-
const char *argv[] = { "x", "-u", "--no-summary", "-l", input_a.c_str (), input_b.c_str (), output.c_str () };
387+
const char *argv[] = { "x", "-u", "--no-summary", "--drop-empty-cells=false", "-l", input_a.c_str (), input_b.c_str (), output.c_str () };
346388

347389
EXPECT_EQ (strmxor (sizeof (argv) / sizeof (argv[0]), (char **) argv), 1);
348390

@@ -508,7 +550,7 @@ TEST(3_Deep)
508550
std::string output = this->tmp_file ("tmp.oas");
509551

510552
// NOTE: -p is ignored in deep mode
511-
const char *argv[] = { "x", "-u", "--no-summary", "-p=1.0", "-n=4", input_a.c_str (), input_b.c_str (), output.c_str () };
553+
const char *argv[] = { "x", "-u", "--drop-empty-cells=false", "--no-summary", "-p=1.0", "-n=4", input_a.c_str (), input_b.c_str (), output.c_str () };
512554

513555
EXPECT_EQ (strmxor (sizeof (argv) / sizeof (argv[0]), (char **) argv), 1);
514556

@@ -607,7 +649,7 @@ TEST(4_Deep)
607649

608650
std::string output = this->tmp_file ("tmp.oas");
609651

610-
const char *argv[] = { "x", "-u", "--no-summary", "-p=1.0", "-n=4", "-t=0.0,0.005,0.01,0.02,0.09,0.1", input_a.c_str (), input_b.c_str (), output.c_str () };
652+
const char *argv[] = { "x", "-u", "--drop-empty-cells=false", "--no-summary", "-p=1.0", "-n=4", "-t=0.0,0.005,0.01,0.02,0.09,0.1", input_a.c_str (), input_b.c_str (), output.c_str () };
611653

612654
EXPECT_EQ (strmxor (sizeof (argv) / sizeof (argv[0]), (char **) argv), 1);
613655

@@ -673,7 +715,7 @@ TEST(5_Deep)
673715

674716
std::string output = this->tmp_file ("tmp.oas");
675717

676-
const char *argv[] = { "x", "-u", "--no-summary", "-b=1000", "-t=0.0,0.005,0.01,0.02,0.09,0.1", input_a.c_str (), input_b.c_str (), output.c_str () };
718+
const char *argv[] = { "x", "-u", "--drop-empty-cells=false", "--no-summary", "-b=1000", "-t=0.0,0.005,0.01,0.02,0.09,0.1", input_a.c_str (), input_b.c_str (), output.c_str () };
677719

678720
EXPECT_EQ (strmxor (sizeof (argv) / sizeof (argv[0]), (char **) argv), 1);
679721

testdata/bd/strmxor_au1d2.oas

714 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)