mirror of https://github.com/KLayout/klayout.git
Heavy refactoring of buddy sources
* To reduce the redundancy * To enable testing of the bd library including the apps The apps are entirely configured through their names. Their .pro files are identical and the app implementation is inside the bd lib (partially generic too). Hence the apps can be tested by bd library unit tests.
This commit is contained in:
parent
681c255e50
commit
b296cdd915
|
|
@ -12,12 +12,22 @@ SOURCES = \
|
|||
bdInit.cc \
|
||||
bdReaderOptions.cc \
|
||||
bdWriterOptions.cc \
|
||||
bdConverterMain.cc \
|
||||
strm2cif.cc \
|
||||
strm2gds.cc \
|
||||
strm2oas.cc \
|
||||
strmclip.cc \
|
||||
strm2dxf.cc \
|
||||
strm2gdstxt.cc \
|
||||
strm2txt.cc \
|
||||
strmcmp.cc \
|
||||
|
||||
HEADERS = \
|
||||
bdCommon.h \
|
||||
bdInit.h \
|
||||
bdReaderOptions.h \
|
||||
bdWriterOptions.h \
|
||||
bdConverterMain.h \
|
||||
|
||||
RESOURCES = \
|
||||
|
||||
|
|
|
|||
|
|
@ -20,29 +20,32 @@
|
|||
|
||||
*/
|
||||
|
||||
#include "bdInit.h"
|
||||
#include "bdWriterOptions.h"
|
||||
#include "bdReaderOptions.h"
|
||||
#include "bdConverterMain.h"
|
||||
#include "dbLayout.h"
|
||||
#include "dbReader.h"
|
||||
#include "dbCIFWriter.h"
|
||||
#include "tlCommandLineParser.h"
|
||||
|
||||
BD_MAIN_FUNC
|
||||
namespace bd
|
||||
{
|
||||
|
||||
int converter_main (int argc, char *argv[], const std::string &format)
|
||||
{
|
||||
bd::GenericWriterOptions generic_writer_options;
|
||||
bd::GenericReaderOptions generic_reader_options;
|
||||
std::string infile, outfile;
|
||||
|
||||
tl::CommandLineOptions cmd;
|
||||
generic_writer_options.add_options_for_cif (cmd);
|
||||
generic_writer_options.add_options (cmd, format);
|
||||
generic_reader_options.add_options (cmd);
|
||||
|
||||
cmd << tl::arg ("input", &infile, "The input file (any format, may be gzip compressed)")
|
||||
<< tl::arg ("output", &outfile, "The output file")
|
||||
cmd << tl::arg ("input", &infile, "The input file (any format, may be gzip compressed)")
|
||||
<< tl::arg ("output", &outfile, tl::sprintf ("The output file (%s format)", format))
|
||||
;
|
||||
|
||||
cmd.brief ("This program will convert the given file to a CIF file");
|
||||
cmd.brief (tl::sprintf ("This program will convert the given file to a %s file", format));
|
||||
|
||||
cmd.parse (argc, argv);
|
||||
|
||||
|
|
@ -60,13 +63,14 @@ BD_MAIN_FUNC
|
|||
{
|
||||
db::SaveLayoutOptions save_options;
|
||||
generic_writer_options.configure (save_options, layout);
|
||||
save_options.set_format (format);
|
||||
|
||||
tl::OutputStream stream (outfile);
|
||||
db::CIFWriter writer;
|
||||
writer.write (layout, stream, save_options);
|
||||
db::Writer writer (save_options);
|
||||
writer.write (layout, stream);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
BD_MAIN
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
|
||||
/*
|
||||
|
||||
KLayout Layout Viewer
|
||||
Copyright (C) 2006-2017 Matthias Koefferlein
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
*/
|
||||
|
||||
#ifndef HDR_bdConverterMain
|
||||
#define HDR_bdConverterMain
|
||||
|
||||
#include "bdCommon.h"
|
||||
#include <string>
|
||||
|
||||
namespace bd
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief A common main() implementation for the "to" converters
|
||||
*/
|
||||
BD_PUBLIC int converter_main (int argc, char *argv[], const std::string &format);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -47,4 +47,23 @@ void init ()
|
|||
tl::CommandLineOptions::set_license (license);
|
||||
}
|
||||
|
||||
int _main_impl (int (*delegate) (int, char *[]), int argc, char *argv[])
|
||||
{
|
||||
try {
|
||||
init ();
|
||||
return (*delegate) (argc, argv);
|
||||
} catch (tl::CancelException & /*ex*/) {
|
||||
return 1;
|
||||
} catch (std::exception &ex) {
|
||||
tl::error << ex.what ();
|
||||
return 1;
|
||||
} catch (tl::Exception &ex) {
|
||||
tl::error << ex.msg ();
|
||||
return 1;
|
||||
} catch (...) {
|
||||
tl::error << "unspecific error";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@
|
|||
#define HDR_bdInit
|
||||
|
||||
#include "bdCommon.h"
|
||||
#include "tlLog.h" // because of BD_MAIN
|
||||
|
||||
namespace bd
|
||||
{
|
||||
|
|
@ -36,42 +35,9 @@ namespace bd
|
|||
void BD_PUBLIC init ();
|
||||
|
||||
/**
|
||||
* @brief Provides a main () implementation
|
||||
*
|
||||
* Use this macro like this:
|
||||
*
|
||||
* @code
|
||||
* #include "bdInit.h"
|
||||
*
|
||||
* BD_MAIN_FUNC
|
||||
* {
|
||||
* .. your code. Use argc and argv for the arguments.
|
||||
* }
|
||||
*
|
||||
* BD_MAIN
|
||||
* @brief The main function implementation
|
||||
*/
|
||||
|
||||
#define BD_MAIN \
|
||||
int main (int argc, char *argv []) \
|
||||
{ \
|
||||
try { \
|
||||
bd::init (); \
|
||||
return main_func (argc, argv); \
|
||||
} catch (tl::CancelException & /*ex*/) { \
|
||||
return 1; \
|
||||
} catch (std::exception &ex) { \
|
||||
tl::error << ex.what (); \
|
||||
return 1; \
|
||||
} catch (tl::Exception &ex) { \
|
||||
tl::error << ex.msg (); \
|
||||
return 1; \
|
||||
} catch (...) { \
|
||||
tl::error << "unspecific error"; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define BD_MAIN_FUNC \
|
||||
int main_func (int argc, char *argv [])
|
||||
int BD_PUBLIC _main_impl (int (*delegate) (int, char *[]), int argc, char *argv[]);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ GenericWriterOptions::add_options (tl::CommandLineOptions &cmd, const std::strin
|
|||
"* 0: create POLYLINE\n"
|
||||
"* 1: create LWPOLYLINE\n"
|
||||
"* 2: decompose into SOLID\n"
|
||||
"* 3: create HATCH\n"
|
||||
"* 3: create HATCH"
|
||||
)
|
||||
;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,39 @@
|
|||
|
||||
/*
|
||||
|
||||
KLayout Layout Viewer
|
||||
Copyright (C) 2006-2017 Matthias Koefferlein
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
*/
|
||||
|
||||
#include "bdInit.h"
|
||||
|
||||
BD_PUBLIC int BD_TARGET (int argc, char *argv []);
|
||||
|
||||
/**
|
||||
* @brief Provides a main () implementation
|
||||
*
|
||||
* NOTE:
|
||||
* This file is not part of the bd sources, but the template for the
|
||||
* main() function of the various applications. It's configured through the
|
||||
* BD_TARGET macro which is set to the application name in the app's .pro
|
||||
* files.
|
||||
*/
|
||||
int main (int argc, char *argv [])
|
||||
{
|
||||
return bd::_main_impl (&BD_TARGET, argc, argv);
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
|
||||
/*
|
||||
|
||||
KLayout Layout Viewer
|
||||
Copyright (C) 2006-2017 Matthias Koefferlein
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
*/
|
||||
|
||||
#include "bdConverterMain.h"
|
||||
#include "dbCIFWriter.h"
|
||||
|
||||
BD_PUBLIC int strm2cif (int argc, char *argv[])
|
||||
{
|
||||
return bd::converter_main (argc, argv, db::CIFWriterOptions ().format_name ());
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
|
||||
/*
|
||||
|
||||
KLayout Layout Viewer
|
||||
Copyright (C) 2006-2017 Matthias Koefferlein
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
*/
|
||||
|
||||
#include "bdConverterMain.h"
|
||||
#include "dbDXFWriter.h"
|
||||
|
||||
BD_PUBLIC int strm2dxf (int argc, char *argv[])
|
||||
{
|
||||
return bd::converter_main (argc, argv, db::DXFWriterOptions ().format_name ());
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
|
||||
/*
|
||||
|
||||
KLayout Layout Viewer
|
||||
Copyright (C) 2006-2017 Matthias Koefferlein
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
*/
|
||||
|
||||
#include "bdConverterMain.h"
|
||||
#include "dbGDS2Writer.h"
|
||||
|
||||
BD_PUBLIC int strm2gds (int argc, char *argv[])
|
||||
{
|
||||
return bd::converter_main (argc, argv, db::GDS2WriterOptions ().format_name ());
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
|
||||
/*
|
||||
|
||||
KLayout Layout Viewer
|
||||
Copyright (C) 2006-2017 Matthias Koefferlein
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
*/
|
||||
|
||||
#include "bdConverterMain.h"
|
||||
#include "dbGDS2Writer.h"
|
||||
|
||||
BD_PUBLIC int strm2gdstxt (int argc, char *argv[])
|
||||
{
|
||||
return bd::converter_main (argc, argv, db::GDS2WriterOptions ().format_name () + "Text");
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
|
||||
/*
|
||||
|
||||
KLayout Layout Viewer
|
||||
Copyright (C) 2006-2017 Matthias Koefferlein
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
*/
|
||||
|
||||
#include "bdConverterMain.h"
|
||||
#include "dbOASISWriter.h"
|
||||
|
||||
BD_PUBLIC int strm2oas (int argc, char *argv[])
|
||||
{
|
||||
return bd::converter_main (argc, argv, db::OASISWriterOptions ().format_name ());
|
||||
}
|
||||
|
|
@ -20,14 +20,13 @@
|
|||
|
||||
*/
|
||||
|
||||
#include "bdInit.h"
|
||||
#include "bdReaderOptions.h"
|
||||
#include "dbLayout.h"
|
||||
#include "dbReader.h"
|
||||
#include "dbTextWriter.h"
|
||||
#include "tlCommandLineParser.h"
|
||||
|
||||
BD_MAIN_FUNC
|
||||
BD_PUBLIC int strm2txt (int argc, char *argv[])
|
||||
{
|
||||
bd::GenericReaderOptions generic_reader_options;
|
||||
std::string infile, outfile;
|
||||
|
|
@ -35,8 +34,8 @@ BD_MAIN_FUNC
|
|||
tl::CommandLineOptions cmd;
|
||||
generic_reader_options.add_options (cmd);
|
||||
|
||||
cmd << tl::arg ("input", &infile, "The input file (any format, may be gzip compressed)")
|
||||
<< tl::arg ("output", &outfile, "The output file")
|
||||
cmd << tl::arg ("input", &infile, "The input file (any format, may be gzip compressed)")
|
||||
<< tl::arg ("output", &outfile, "The output file (proprietary text format)")
|
||||
;
|
||||
|
||||
cmd.brief ("This program will convert the given file to a proprietary text format file");
|
||||
|
|
@ -62,5 +61,3 @@ BD_MAIN_FUNC
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
BD_MAIN
|
||||
|
|
@ -20,7 +20,6 @@
|
|||
|
||||
*/
|
||||
|
||||
#include "bdInit.h"
|
||||
#include "bdReaderOptions.h"
|
||||
#include "bdWriterOptions.h"
|
||||
#include "dbClip.h"
|
||||
|
|
@ -165,12 +164,10 @@ void clip (const ClipData &data)
|
|||
writer.write (target_layout, stream);
|
||||
}
|
||||
|
||||
BD_MAIN_FUNC
|
||||
BD_PUBLIC int strmclip (int argc, char *argv[])
|
||||
{
|
||||
ClipData data;
|
||||
|
||||
bd::init ();
|
||||
|
||||
tl::CommandLineOptions cmd;
|
||||
data.reader_options.add_options (cmd);
|
||||
data.writer_options.add_options (cmd);
|
||||
|
|
@ -182,7 +179,7 @@ BD_MAIN_FUNC
|
|||
<< tl::arg ("output", &data.file_out, "The output file",
|
||||
"The output format is determined from the suffix of the file. If the suffix indicates "
|
||||
"gzip compression, the file will be compressed on output. Examples for recognized suffixes are "
|
||||
"\".oas\", \".gds.gz\", \".dxf\" or \"gds2\"."
|
||||
"\".oas\", \".gds.gz\", \".dxf\" or \".gds2\"."
|
||||
)
|
||||
<< tl::arg ("-l|--clip-layer=spec", &data, &ClipData::set_clip_layer, "Specifies a layer to take the clip regions from",
|
||||
"If this option is given, the clip rectangles are taken from the given layer."
|
||||
|
|
@ -196,7 +193,7 @@ BD_MAIN_FUNC
|
|||
"If given, this name will be used as the top cell name in the output file. "
|
||||
"By default the output's top cell will be \"CLIPPED_\" plus the input's top cell name."
|
||||
)
|
||||
<< tl::arg ("*-r|--clip-box=l,b,r,t", &data, &ClipData::add_box, "Specifies a clip box",
|
||||
<< tl::arg ("*-r|--rect=\"l,b,r,t\"", &data, &ClipData::add_box, "Specifies a clip box",
|
||||
"This option specifies the box to clip in micrometer units. The box is given "
|
||||
"by left, bottom, right and top coordinates. This option can be used multiple times "
|
||||
"to produce a clip covering more than one rectangle."
|
||||
|
|
@ -211,5 +208,3 @@ BD_MAIN_FUNC
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
BD_MAIN
|
||||
|
|
@ -20,17 +20,14 @@
|
|||
|
||||
*/
|
||||
|
||||
#include "bdInit.h"
|
||||
#include "bdReaderOptions.h"
|
||||
#include "dbLayout.h"
|
||||
#include "dbLayoutDiff.h"
|
||||
#include "dbReader.h"
|
||||
#include "tlCommandLineParser.h"
|
||||
|
||||
BD_MAIN_FUNC
|
||||
BD_PUBLIC int strmcmp (int argc, char *argv[])
|
||||
{
|
||||
bd::init ();
|
||||
|
||||
bd::GenericReaderOptions generic_reader_options_a;
|
||||
generic_reader_options_a.set_prefix ("a");
|
||||
generic_reader_options_a.set_long_prefix ("a-");
|
||||
|
|
@ -222,5 +219,3 @@ BD_MAIN_FUNC
|
|||
|
||||
return result ? 0 : 1;
|
||||
}
|
||||
|
||||
BD_MAIN
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
|
||||
include($$PWD/../klayout.pri)
|
||||
|
||||
TEMPLATE = app
|
||||
|
||||
PRO_BASENAME = $$basename(_PRO_FILE_)
|
||||
TARGET = $$replace(PRO_BASENAME, ".pro", "")
|
||||
DESTDIR = $$OUT_PWD/../..
|
||||
|
||||
# Since the main function is entirely unspecific, we can put it into a common
|
||||
# place - it's not part of the bd sources.
|
||||
SOURCES = $$PWD/bd/main.cc
|
||||
|
||||
INCLUDEPATH += ../bd
|
||||
DEPENDPATH += ../bd
|
||||
LIBS += -L$$DESTDIR -lklayout_bd
|
||||
|
||||
DEFINES += BD_TARGET=$$TARGET
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
|
||||
#include "dbLayout.h"
|
||||
#include "dbReader.h"
|
||||
#include "dbCIFWriter.h"
|
||||
|
||||
int
|
||||
main (int argc, char *argv [])
|
||||
{
|
||||
if (argc != 3) {
|
||||
printf ("Syntax: strm2cif <infile> <outfile>\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::string infile (argv[1]);
|
||||
std::string outfile (argv[2]);
|
||||
|
||||
try {
|
||||
|
||||
db::Manager m;
|
||||
db::Layout layout (&m);
|
||||
db::LayerMap map;
|
||||
|
||||
{
|
||||
tl::InputStream stream (infile);
|
||||
db::Reader reader (stream);
|
||||
map = reader.read (layout);
|
||||
}
|
||||
|
||||
{
|
||||
tl::OutputStream stream (outfile);
|
||||
db::CIFWriter writer;
|
||||
writer.write (layout, stream, db::SaveLayoutOptions ());
|
||||
}
|
||||
|
||||
} catch (std::exception &ex) {
|
||||
fprintf (stderr, "*** ERROR: %s\n", ex.what ());
|
||||
return 1;
|
||||
} catch (tl::Exception &ex) {
|
||||
fprintf (stderr, "*** ERROR: %s\n", ex.msg ().c_str ());
|
||||
return 1;
|
||||
} catch (...) {
|
||||
fprintf (stderr, "*** ERROR: unspecific error\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,13 +1,2 @@
|
|||
|
||||
include($$PWD/../../klayout.pri)
|
||||
|
||||
TEMPLATE = app
|
||||
|
||||
TARGET = strm2cif
|
||||
DESTDIR = $$OUT_PWD/../..
|
||||
|
||||
SOURCES = strm2cif.cc
|
||||
|
||||
INCLUDEPATH += ../bd ../../tl ../../db ../../gsi
|
||||
DEPENDPATH += ../bd ../../tl ../../db ../../gsi
|
||||
LIBS += -L$$DESTDIR -lklayout_bd -lklayout_tl -lklayout_db -lklayout_gsi
|
||||
include($$PWD/../buddy_app.pri)
|
||||
|
|
|
|||
|
|
@ -1,49 +0,0 @@
|
|||
|
||||
#include "dbLayout.h"
|
||||
#include "dbReader.h"
|
||||
#include "dbDXFWriter.h"
|
||||
|
||||
int
|
||||
main (int argc, char *argv [])
|
||||
{
|
||||
if (argc != 3) {
|
||||
printf ("Syntax: strm2dxf <infile> <outfile>\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::string infile (argv[1]);
|
||||
std::string outfile (argv[2]);
|
||||
|
||||
try {
|
||||
|
||||
db::Manager m;
|
||||
db::Layout layout (&m);
|
||||
db::LayerMap map;
|
||||
|
||||
{
|
||||
tl::InputStream stream (infile);
|
||||
db::Reader reader (stream);
|
||||
map = reader.read (layout);
|
||||
}
|
||||
|
||||
{
|
||||
tl::OutputStream stream (outfile);
|
||||
db::DXFWriter writer;
|
||||
writer.write (layout, stream, db::SaveLayoutOptions ());
|
||||
}
|
||||
|
||||
} catch (std::exception &ex) {
|
||||
fprintf (stderr, "*** ERROR: %s\n", ex.what ());
|
||||
return 1;
|
||||
} catch (tl::Exception &ex) {
|
||||
fprintf (stderr, "*** ERROR: %s\n", ex.msg ().c_str ());
|
||||
return 1;
|
||||
} catch (...) {
|
||||
fprintf (stderr, "*** ERROR: unspecific error\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
|
||||
/*
|
||||
|
||||
KLayout Layout Viewer
|
||||
Copyright (C) 2006-2017 Matthias Koefferlein
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
*/
|
||||
|
||||
#include "bdInit.h"
|
||||
#include "bdWriterOptions.h"
|
||||
#include "bdReaderOptions.h"
|
||||
#include "dbLayout.h"
|
||||
#include "dbReader.h"
|
||||
#include "dbDXFWriter.h"
|
||||
#include "tlCommandLineParser.h"
|
||||
|
||||
BD_MAIN_FUNC
|
||||
{
|
||||
bd::GenericWriterOptions generic_writer_options;
|
||||
bd::GenericReaderOptions generic_reader_options;
|
||||
std::string infile, outfile;
|
||||
|
||||
tl::CommandLineOptions cmd;
|
||||
generic_writer_options.add_options_for_dxf (cmd);
|
||||
generic_reader_options.add_options (cmd);
|
||||
|
||||
cmd << tl::arg ("input", &infile, "The input file (any format, may be gzip compressed)")
|
||||
<< tl::arg ("output", &outfile, "The output file")
|
||||
;
|
||||
|
||||
cmd.brief ("This program will convert the given file to a DXF file");
|
||||
|
||||
cmd.parse (argc, argv);
|
||||
|
||||
db::Layout layout;
|
||||
|
||||
{
|
||||
db::LoadLayoutOptions load_options;
|
||||
generic_reader_options.configure (load_options);
|
||||
|
||||
tl::InputStream stream (infile);
|
||||
db::Reader reader (stream);
|
||||
reader.read (layout, load_options);
|
||||
}
|
||||
|
||||
{
|
||||
db::SaveLayoutOptions save_options;
|
||||
generic_writer_options.configure (save_options, layout);
|
||||
|
||||
tl::OutputStream stream (outfile);
|
||||
db::DXFWriter writer;
|
||||
writer.write (layout, stream, save_options);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
BD_MAIN
|
||||
|
|
@ -1,13 +1,2 @@
|
|||
|
||||
include($$PWD/../../klayout.pri)
|
||||
|
||||
TEMPLATE = app
|
||||
|
||||
TARGET = strm2dxf
|
||||
DESTDIR = $$OUT_PWD/../..
|
||||
|
||||
SOURCES = strm2dxf.cc
|
||||
|
||||
INCLUDEPATH += ../bd ../../tl ../../db ../../gsi
|
||||
DEPENDPATH += ../bd ../../tl ../../db ../../gsi
|
||||
LIBS += -L$$DESTDIR -lklayout_bd -lklayout_tl -lklayout_db -lklayout_gsi
|
||||
include($$PWD/../buddy_app.pri)
|
||||
|
|
|
|||
|
|
@ -1,49 +0,0 @@
|
|||
|
||||
#include "dbLayout.h"
|
||||
#include "dbReader.h"
|
||||
#include "dbGDS2Writer.h"
|
||||
|
||||
int
|
||||
main (int argc, char *argv [])
|
||||
{
|
||||
if (argc != 3) {
|
||||
printf ("Syntax: strm2gds <infile> <outfile>\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::string infile (argv[1]);
|
||||
std::string outfile (argv[2]);
|
||||
|
||||
try {
|
||||
|
||||
db::Manager m;
|
||||
db::Layout layout (&m);
|
||||
db::LayerMap map;
|
||||
|
||||
{
|
||||
tl::InputStream stream (infile);
|
||||
db::Reader reader (stream);
|
||||
map = reader.read (layout);
|
||||
}
|
||||
|
||||
{
|
||||
tl::OutputStream stream (outfile);
|
||||
db::GDS2Writer writer;
|
||||
writer.write (layout, stream, db::SaveLayoutOptions ());
|
||||
}
|
||||
|
||||
} catch (std::exception &ex) {
|
||||
fprintf (stderr, "*** ERROR: %s\n", ex.what ());
|
||||
return 1;
|
||||
} catch (tl::Exception &ex) {
|
||||
fprintf (stderr, "*** ERROR: %s\n", ex.msg ().c_str ());
|
||||
return 1;
|
||||
} catch (...) {
|
||||
fprintf (stderr, "*** ERROR: unspecific error\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
|
||||
/*
|
||||
|
||||
KLayout Layout Viewer
|
||||
Copyright (C) 2006-2017 Matthias Koefferlein
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
*/
|
||||
|
||||
#include "bdInit.h"
|
||||
#include "bdWriterOptions.h"
|
||||
#include "bdReaderOptions.h"
|
||||
#include "dbLayout.h"
|
||||
#include "dbReader.h"
|
||||
#include "dbGDS2Writer.h"
|
||||
#include "tlCommandLineParser.h"
|
||||
|
||||
BD_MAIN_FUNC
|
||||
{
|
||||
bd::GenericWriterOptions generic_writer_options;
|
||||
bd::GenericReaderOptions generic_reader_options;
|
||||
std::string infile, outfile;
|
||||
|
||||
tl::CommandLineOptions cmd;
|
||||
generic_writer_options.add_options_for_gds2 (cmd);
|
||||
generic_reader_options.add_options (cmd);
|
||||
|
||||
cmd << tl::arg ("input", &infile, "The input file (any format, may be gzip compressed)")
|
||||
<< tl::arg ("output", &outfile, "The output file")
|
||||
;
|
||||
|
||||
cmd.brief ("This program will convert the given file to a GDS2 file");
|
||||
|
||||
cmd.parse (argc, argv);
|
||||
|
||||
db::Layout layout;
|
||||
|
||||
{
|
||||
db::LoadLayoutOptions load_options;
|
||||
generic_reader_options.configure (load_options);
|
||||
|
||||
tl::InputStream stream (infile);
|
||||
db::Reader reader (stream);
|
||||
reader.read (layout, load_options);
|
||||
}
|
||||
|
||||
{
|
||||
db::SaveLayoutOptions save_options;
|
||||
generic_writer_options.configure (save_options, layout);
|
||||
|
||||
tl::OutputStream stream (outfile);
|
||||
db::GDS2Writer writer;
|
||||
writer.write (layout, stream, save_options);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
BD_MAIN
|
||||
|
|
@ -1,13 +1,2 @@
|
|||
|
||||
include($$PWD/../../klayout.pri)
|
||||
|
||||
TEMPLATE = app
|
||||
|
||||
TARGET = strm2gds
|
||||
DESTDIR = $$OUT_PWD/../..
|
||||
|
||||
SOURCES = strm2gds.cc
|
||||
|
||||
INCLUDEPATH += ../bd ../../tl ../../db ../../gsi
|
||||
DEPENDPATH += ../bd ../../tl ../../db ../../gsi
|
||||
LIBS += -L$$DESTDIR -lklayout_bd -lklayout_tl -lklayout_db -lklayout_gsi
|
||||
include($$PWD/../buddy_app.pri)
|
||||
|
|
|
|||
|
|
@ -1,49 +0,0 @@
|
|||
|
||||
#include "dbLayout.h"
|
||||
#include "dbReader.h"
|
||||
#include "contrib/gds2_txt/dbGDS2TextWriter.h"
|
||||
|
||||
int
|
||||
main (int argc, char *argv [])
|
||||
{
|
||||
if (argc != 3) {
|
||||
printf ("Syntax: strm2gdstxt <infile> <outfile>\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::string infile (argv[1]);
|
||||
std::string outfile (argv[2]);
|
||||
|
||||
try {
|
||||
|
||||
db::Manager m;
|
||||
db::Layout layout (&m);
|
||||
db::LayerMap map;
|
||||
|
||||
{
|
||||
tl::InputStream stream (infile);
|
||||
db::Reader reader (stream);
|
||||
map = reader.read (layout);
|
||||
}
|
||||
|
||||
{
|
||||
tl::OutputStream stream (outfile);
|
||||
db::GDS2WriterText writer;
|
||||
writer.write (layout, stream, db::SaveLayoutOptions ());
|
||||
}
|
||||
|
||||
} catch (std::exception &ex) {
|
||||
fprintf (stderr, "*** ERROR: %s\n", ex.what ());
|
||||
return 1;
|
||||
} catch (tl::Exception &ex) {
|
||||
fprintf (stderr, "*** ERROR: %s\n", ex.msg ().c_str ());
|
||||
return 1;
|
||||
} catch (...) {
|
||||
fprintf (stderr, "*** ERROR: unspecific error\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
|
||||
/*
|
||||
|
||||
KLayout Layout Viewer
|
||||
Copyright (C) 2006-2017 Matthias Koefferlein
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
*/
|
||||
|
||||
#include "bdInit.h"
|
||||
#include "bdWriterOptions.h"
|
||||
#include "bdReaderOptions.h"
|
||||
#include "dbLayout.h"
|
||||
#include "dbReader.h"
|
||||
#include "contrib/dbGDS2TextWriter.h"
|
||||
#include "tlCommandLineParser.h"
|
||||
|
||||
BD_MAIN_FUNC
|
||||
{
|
||||
bd::GenericWriterOptions generic_writer_options;
|
||||
bd::GenericReaderOptions generic_reader_options;
|
||||
std::string infile, outfile;
|
||||
|
||||
tl::CommandLineOptions cmd;
|
||||
generic_reader_options.add_options (cmd);
|
||||
generic_writer_options.add_options_for_gds2 (cmd);
|
||||
|
||||
cmd << tl::arg ("input", &infile, "The input file (any format, may be gzip compressed)")
|
||||
<< tl::arg ("output", &outfile, "The output file")
|
||||
;
|
||||
|
||||
cmd.brief ("This program will convert the given file to a GDS2Text file");
|
||||
|
||||
cmd.parse (argc, argv);
|
||||
|
||||
db::Layout layout;
|
||||
|
||||
{
|
||||
db::LoadLayoutOptions load_options;
|
||||
generic_reader_options.configure (load_options);
|
||||
|
||||
tl::InputStream stream (infile);
|
||||
db::Reader reader (stream);
|
||||
reader.read (layout, load_options);
|
||||
}
|
||||
|
||||
{
|
||||
db::SaveLayoutOptions save_options;
|
||||
generic_writer_options.configure (save_options, layout);
|
||||
|
||||
tl::OutputStream stream (outfile);
|
||||
db::GDS2WriterText writer;
|
||||
writer.write (layout, stream, save_options);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
BD_MAIN
|
||||
|
|
@ -1,13 +1,2 @@
|
|||
|
||||
include($$PWD/../../klayout.pri)
|
||||
|
||||
TEMPLATE = app
|
||||
|
||||
TARGET = strm2gdstxt
|
||||
DESTDIR = $$OUT_PWD/../..
|
||||
|
||||
SOURCES = strm2gdstxt.cc
|
||||
|
||||
INCLUDEPATH += ../bd ../../tl ../../db ../../gsi
|
||||
DEPENDPATH += ../bd ../../tl ../../db ../../gsi
|
||||
LIBS += -L$$DESTDIR -lklayout_bd -lklayout_tl -lklayout_db -lklayout_gsi
|
||||
include($$PWD/../buddy_app.pri)
|
||||
|
|
|
|||
|
|
@ -1,108 +0,0 @@
|
|||
|
||||
#include "dbLayout.h"
|
||||
#include "dbReader.h"
|
||||
#include "dbOASISWriter.h"
|
||||
#include "tlTimer.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
void
|
||||
syntax ()
|
||||
{
|
||||
printf ("Syntax: strm2oas [-o <optimization-level>] [-c] <infile> <outfile>\n");
|
||||
printf ("\n");
|
||||
printf (" -o n Specify optimization level (0..10, default is 2)\n");
|
||||
printf (" -c Use CBLOCK compression\n");
|
||||
printf (" -s Use strict mode\n");
|
||||
printf (" -r Recompression (ignore existing arrays)\n");
|
||||
printf (" -v Verbose - print timing information\n");
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv [])
|
||||
{
|
||||
std::string infile, outfile;
|
||||
bool verbose = false;
|
||||
|
||||
try {
|
||||
|
||||
db::OASISWriterOptions writer_options;
|
||||
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
std::string o (argv[i]);
|
||||
if (o == "-o") {
|
||||
if (i < argc - 1) {
|
||||
++i;
|
||||
tl::from_string (argv[i], writer_options.compression_level);
|
||||
}
|
||||
} else if (o == "-v") {
|
||||
verbose = true;
|
||||
} else if (o == "-c") {
|
||||
writer_options.write_cblocks = true;
|
||||
} else if (o == "-s") {
|
||||
writer_options.strict_mode = true;
|
||||
} else if (o == "-r") {
|
||||
writer_options.recompress = true;
|
||||
} else if (o == "-h" || o == "-help" || o == "--help") {
|
||||
syntax ();
|
||||
return 0;
|
||||
} else if (argv[i][0] == '-') {
|
||||
throw tl::Exception ("Unknown option: %s - use '-h' for help", (const char *) argv[i]);
|
||||
} else if (infile.empty ()) {
|
||||
infile = argv[i];
|
||||
} else if (outfile.empty ()) {
|
||||
outfile = argv[i];
|
||||
} else {
|
||||
throw tl::Exception ("Superfluous argument: %s - use '-h' for help", (const char *) argv[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (infile.empty ()) {
|
||||
throw tl::Exception ("Input file not given");
|
||||
}
|
||||
if (outfile.empty ()) {
|
||||
throw tl::Exception ("Output file not given");
|
||||
}
|
||||
|
||||
db::Manager m;
|
||||
db::Layout layout (false, &m);
|
||||
db::LayerMap map;
|
||||
|
||||
{
|
||||
std::auto_ptr<tl::SelfTimer> timer;
|
||||
if (verbose) {
|
||||
timer.reset (new tl::SelfTimer ("Reading input layout"));
|
||||
}
|
||||
tl::InputStream stream (infile);
|
||||
db::Reader reader (stream);
|
||||
map = reader.read (layout);
|
||||
}
|
||||
|
||||
{
|
||||
db::SaveLayoutOptions options;
|
||||
options.set_specific_options (writer_options);
|
||||
|
||||
std::auto_ptr<tl::SelfTimer> timer;
|
||||
if (verbose) {
|
||||
timer.reset (new tl::SelfTimer ("Writing OAS"));
|
||||
}
|
||||
tl::OutputStream stream (outfile);
|
||||
db::OASISWriter writer;
|
||||
writer.write (layout, stream, options);
|
||||
}
|
||||
|
||||
} catch (std::exception &ex) {
|
||||
fprintf (stderr, "*** ERROR: %s\n", ex.what ());
|
||||
return 1;
|
||||
} catch (tl::Exception &ex) {
|
||||
fprintf (stderr, "*** ERROR: %s\n", ex.msg ().c_str ());
|
||||
return 1;
|
||||
} catch (...) {
|
||||
fprintf (stderr, "*** ERROR: unspecific error\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
|
||||
/*
|
||||
|
||||
KLayout Layout Viewer
|
||||
Copyright (C) 2006-2017 Matthias Koefferlein
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
*/
|
||||
|
||||
#include "bdInit.h"
|
||||
#include "bdWriterOptions.h"
|
||||
#include "bdReaderOptions.h"
|
||||
#include "dbLayout.h"
|
||||
#include "dbReader.h"
|
||||
#include "dbOASISWriter.h"
|
||||
#include "tlCommandLineParser.h"
|
||||
|
||||
BD_MAIN_FUNC
|
||||
{
|
||||
bd::GenericWriterOptions generic_writer_options;
|
||||
bd::GenericReaderOptions generic_reader_options;
|
||||
std::string infile, outfile;
|
||||
|
||||
tl::CommandLineOptions cmd;
|
||||
generic_reader_options.add_options (cmd);
|
||||
generic_writer_options.add_options_for_oasis (cmd);
|
||||
|
||||
cmd << tl::arg ("input", &infile, "The input file (any format, may be gzip compressed)")
|
||||
<< tl::arg ("output", &outfile, "The output file")
|
||||
;
|
||||
|
||||
cmd.brief ("This program will convert the given file to an OASIS file");
|
||||
|
||||
cmd.parse (argc, argv);
|
||||
|
||||
db::Layout layout;
|
||||
|
||||
{
|
||||
db::LoadLayoutOptions load_options;
|
||||
generic_reader_options.configure (load_options);
|
||||
|
||||
tl::InputStream stream (infile);
|
||||
db::Reader reader (stream);
|
||||
reader.read (layout, load_options);
|
||||
}
|
||||
|
||||
{
|
||||
db::SaveLayoutOptions save_options;
|
||||
generic_writer_options.configure (save_options, layout);
|
||||
|
||||
tl::OutputStream stream (outfile);
|
||||
db::OASISWriter writer;
|
||||
writer.write (layout, stream, save_options);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
BD_MAIN
|
||||
|
|
@ -1,13 +1,2 @@
|
|||
|
||||
include($$PWD/../../klayout.pri)
|
||||
|
||||
TEMPLATE = app
|
||||
|
||||
TARGET = strm2oas
|
||||
DESTDIR = $$OUT_PWD/../..
|
||||
|
||||
SOURCES = strm2oas.cc
|
||||
|
||||
INCLUDEPATH += ../bd ../../tl ../../db ../../gsi
|
||||
DEPENDPATH += ../bd ../../tl ../../db ../../gsi
|
||||
LIBS += -L$$DESTDIR -lklayout_bd -lklayout_tl -lklayout_db -lklayout_gsi
|
||||
include($$PWD/../buddy_app.pri)
|
||||
|
|
|
|||
|
|
@ -1,50 +0,0 @@
|
|||
|
||||
#include "dbLayout.h"
|
||||
#include "dbReader.h"
|
||||
#include "dbTextWriter.h"
|
||||
|
||||
int
|
||||
main (int argc, char *argv [])
|
||||
{
|
||||
if (argc != 3) {
|
||||
printf ("Syntax: strm2txt <infile> <outfile>\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::string infile (argv[1]);
|
||||
std::string outfile (argv[2]);
|
||||
|
||||
try {
|
||||
|
||||
db::Manager m;
|
||||
db::Layout layout (&m);
|
||||
db::LayerMap map;
|
||||
|
||||
{
|
||||
tl::InputStream stream (infile);
|
||||
db::Reader reader (stream);
|
||||
reader.set_warnings_as_errors (true);
|
||||
map = reader.read (layout);
|
||||
}
|
||||
|
||||
{
|
||||
tl::OutputStream stream (outfile);
|
||||
db::TextWriter writer (stream);
|
||||
writer.write (layout);
|
||||
}
|
||||
|
||||
} catch (std::exception &ex) {
|
||||
fprintf (stderr, "*** ERROR: %s\n", ex.what ());
|
||||
return 1;
|
||||
} catch (tl::Exception &ex) {
|
||||
fprintf (stderr, "*** ERROR: %s\n", ex.msg ().c_str ());
|
||||
return 1;
|
||||
} catch (...) {
|
||||
fprintf (stderr, "*** ERROR: unspecific error\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,13 +1,2 @@
|
|||
|
||||
include($$PWD/../../klayout.pri)
|
||||
|
||||
TEMPLATE = app
|
||||
|
||||
TARGET = strm2txt
|
||||
DESTDIR = $$OUT_PWD/../..
|
||||
|
||||
SOURCES = strm2txt.cc
|
||||
|
||||
INCLUDEPATH += ../bd ../../tl ../../db ../../gsi
|
||||
DEPENDPATH += ../bd ../../tl ../../db ../../gsi
|
||||
LIBS += -L$$DESTDIR -lklayout_bd -lklayout_tl -lklayout_db -lklayout_gsi
|
||||
include($$PWD/../buddy_app.pri)
|
||||
|
|
|
|||
|
|
@ -1,235 +0,0 @@
|
|||
|
||||
|
||||
#include "dbClip.h"
|
||||
#include "dbLayout.h"
|
||||
#include "dbGDS2Writer.h"
|
||||
#include "dbOASISWriter.h"
|
||||
#include "dbReader.h"
|
||||
#include "layParsedLayerSource.h"
|
||||
#include "tlLog.h"
|
||||
|
||||
|
||||
struct ClipData
|
||||
{
|
||||
ClipData ()
|
||||
: file_in (), file_out (), clip_layer (),
|
||||
oasis (false), gzip (false)
|
||||
{ }
|
||||
|
||||
std::string file_in;
|
||||
std::string file_out;
|
||||
lay::ParsedLayerSource clip_layer;
|
||||
bool oasis;
|
||||
bool gzip;
|
||||
std::vector <db::DBox> clip_boxes;
|
||||
std::string result;
|
||||
std::string top;
|
||||
};
|
||||
|
||||
|
||||
void clip (const ClipData &data)
|
||||
{
|
||||
db::Manager m;
|
||||
db::Layout layout (&m);
|
||||
db::Layout target_layout (&m);
|
||||
|
||||
{
|
||||
tl::InputStream stream (data.file_in);
|
||||
db::Reader reader (stream);
|
||||
reader.read (layout);
|
||||
}
|
||||
|
||||
// create the layers in the target layout as well
|
||||
for (unsigned int i = 0; i < layout.layers (); ++i) {
|
||||
if (layout.is_valid_layer (i)) {
|
||||
target_layout.insert_layer (i, layout.get_properties (i));
|
||||
}
|
||||
}
|
||||
|
||||
// copy the properties repository in order to have the same ID mapping
|
||||
target_layout.properties_repository () = layout.properties_repository ();
|
||||
target_layout.dbu (layout.dbu ());
|
||||
|
||||
// look for the clip layer
|
||||
int clip_layer_index = -1;
|
||||
for (unsigned int i = 0; i < layout.layers (); ++i) {
|
||||
if (layout.is_valid_layer (i) && data.clip_layer.match (layout.get_properties (i))) {
|
||||
clip_layer_index = int (i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
tl::log << "Clip layer index is " << clip_layer_index;
|
||||
|
||||
// get top cells
|
||||
std::vector <db::cell_index_type> top_cells;
|
||||
if (data.top.empty ()) {
|
||||
top_cells.assign (layout.begin_top_down (), layout.end_top_cells ());
|
||||
} else {
|
||||
std::pair<bool, db::cell_index_type> tc = layout.cell_by_name (data.top.c_str ());
|
||||
if (! tc.first) {
|
||||
throw tl::Exception ("Cell %s is not a valid cell in the input layout", data.top);
|
||||
}
|
||||
top_cells.push_back (tc.second);
|
||||
}
|
||||
|
||||
// go through the top cells
|
||||
for (std::vector <db::cell_index_type>::const_iterator tc = top_cells.begin (); tc != top_cells.end (); ++tc) {
|
||||
|
||||
std::vector <db::Box> clip_boxes;
|
||||
|
||||
// add the explicit boxes first
|
||||
for (std::vector <db::DBox>::const_iterator b = data.clip_boxes.begin (); b != data.clip_boxes.end (); ++b) {
|
||||
clip_boxes.push_back (db::Box::from_double (*b * (1.0 / layout.dbu ())));
|
||||
}
|
||||
|
||||
// fetch the boxes of the clip shapes
|
||||
if (clip_layer_index >= 0) {
|
||||
collect_clip_boxes (layout, *tc, clip_layer_index, clip_boxes);
|
||||
}
|
||||
|
||||
// sort our duplicate boxes
|
||||
std::sort (clip_boxes.begin (), clip_boxes.end ());
|
||||
clip_boxes.erase (std::unique (clip_boxes.begin (), clip_boxes.end ()), clip_boxes.end ());
|
||||
|
||||
tl::log << "Clip boxes are:";
|
||||
for (std::vector <db::Box>::const_iterator cbx = clip_boxes.begin (); cbx != clip_boxes.end (); ++cbx) {
|
||||
tl::log << " " << cbx->to_string ();
|
||||
}
|
||||
|
||||
std::vector<db::cell_index_type> new_cells = db::clip_layout (layout, target_layout, *tc, clip_boxes);
|
||||
|
||||
// create "very top" cells to put the result cells into
|
||||
std::string result_top;
|
||||
if (! data.result.empty ()) {
|
||||
result_top = data.result;
|
||||
} else {
|
||||
result_top = std::string ("CLIPPED_") + layout.cell_name (*tc);
|
||||
}
|
||||
db::cell_index_type clip_top = target_layout.add_cell (result_top.c_str ());
|
||||
db::Cell &clip_top_cell = target_layout.cell (clip_top);
|
||||
|
||||
for (std::vector <db::cell_index_type>::const_iterator cc = new_cells.begin (); cc != new_cells.end (); ++cc) {
|
||||
clip_top_cell.insert (db::CellInstArray (db::CellInst (*cc), db::Trans ()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// write the layout
|
||||
tl::OutputStreamBase *out_file = 0;
|
||||
try {
|
||||
|
||||
tl::OutputStream stream (data.file_out, data.gzip ? tl::OutputStream::OM_Zlib : tl::OutputStream::OM_Plain);
|
||||
|
||||
if (data.oasis) {
|
||||
db::OASISWriter writer;
|
||||
writer.write (target_layout, stream, db::SaveLayoutOptions ());
|
||||
} else {
|
||||
db::GDS2Writer writer;
|
||||
writer.write (target_layout, stream, db::SaveLayoutOptions ());
|
||||
}
|
||||
|
||||
delete out_file;
|
||||
|
||||
} catch (...) {
|
||||
if (out_file) {
|
||||
delete out_file;
|
||||
}
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
void print_syntax ()
|
||||
{
|
||||
printf ("Syntax: strmclip [<options>] <infile> <outfile>\n");
|
||||
printf ("\n");
|
||||
printf ("Options are:\n");
|
||||
printf (" -l 'l/d' take clip regions from layer l, datatype d\n");
|
||||
printf (" -o produce oasis output\n");
|
||||
printf (" -g produce gds output\n");
|
||||
printf (" -z gzip output\n");
|
||||
printf (" -t 'cell' use this cell from input (default: determine top cell automatically)\n");
|
||||
printf (" -x 'name' use this cell as top cell in output\n");
|
||||
printf (" -r 'l,b,r,t' explicitly specify a clip retangle (can be present multiple times)\n");
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv [])
|
||||
{
|
||||
try {
|
||||
|
||||
ClipData data;
|
||||
|
||||
for (int n = 1; n < argc; ++n) {
|
||||
|
||||
if (std::string (argv [n]) == "-h") {
|
||||
print_syntax ();
|
||||
return 0;
|
||||
} else if (std::string (argv [n]) == "-o") {
|
||||
data.oasis = true;
|
||||
} else if (std::string (argv [n]) == "-g") {
|
||||
data.oasis = false;
|
||||
} else if (std::string (argv [n]) == "-z") {
|
||||
data.gzip = true;
|
||||
} else if (std::string (argv [n]) == "-x") {
|
||||
if (n < argc + 1) {
|
||||
++n;
|
||||
data.result = argv [n];
|
||||
}
|
||||
} else if (std::string (argv [n]) == "-t") {
|
||||
if (n < argc + 1) {
|
||||
++n;
|
||||
data.top = argv [n];
|
||||
}
|
||||
} else if (std::string (argv [n]) == "-r") {
|
||||
if (n < argc + 1) {
|
||||
++n;
|
||||
tl::Extractor ex (argv [n]);
|
||||
double l = 0.0, b = 0.0, r = 0.0, t = 0.0;
|
||||
ex.read (l); ex.expect (",");
|
||||
ex.read (b); ex.expect (",");
|
||||
ex.read (r); ex.expect (",");
|
||||
ex.read (t); ex.expect_end ();
|
||||
data.clip_boxes.push_back (db::DBox (l, b, r, t));
|
||||
}
|
||||
} else if (std::string (argv [n]) == "-l") {
|
||||
if (n < argc + 1) {
|
||||
++n;
|
||||
data.clip_layer = lay::ParsedLayerSource (argv [n]);
|
||||
}
|
||||
} else if (argv [n][0] == '-') {
|
||||
print_syntax ();
|
||||
throw tl::Exception ("Unknown option: " + std::string (argv [n]));
|
||||
} else if (data.file_in.empty ()) {
|
||||
data.file_in = argv [n];
|
||||
} else if (data.file_out.empty ()) {
|
||||
data.file_out = argv [n];
|
||||
} else {
|
||||
print_syntax ();
|
||||
throw tl::Exception ("Superfluous command element: " + std::string (argv [n]));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (data.file_in.empty () || data.file_out.empty ()) {
|
||||
print_syntax ();
|
||||
throw tl::Exception ("Input or output file name missing");
|
||||
}
|
||||
|
||||
clip (data);
|
||||
|
||||
} catch (std::exception &ex) {
|
||||
tl::error << ex.what ();
|
||||
return 1;
|
||||
} catch (tl::Exception &ex) {
|
||||
tl::error << ex.msg ();
|
||||
return 1;
|
||||
} catch (...) {
|
||||
tl::error << "unspecific error";
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,13 +1,2 @@
|
|||
|
||||
include($$PWD/../../klayout.pri)
|
||||
|
||||
TEMPLATE = app
|
||||
|
||||
TARGET = strmclip
|
||||
DESTDIR = $$OUT_PWD/../..
|
||||
|
||||
SOURCES = strmclip.cc
|
||||
|
||||
INCLUDEPATH += ../bd ../../tl ../../db ../../gsi
|
||||
DEPENDPATH += ../bd ../../tl ../../db ../../gsi
|
||||
LIBS += -L$$DESTDIR -lklayout_bd -lklayout_tl -lklayout_db -lklayout_gsi
|
||||
include($$PWD/../buddy_app.pri)
|
||||
|
|
|
|||
|
|
@ -1,54 +0,0 @@
|
|||
|
||||
|
||||
#include "dbLayout.h"
|
||||
#include "dbLayoutDiff.h"
|
||||
#include "dbReader.h"
|
||||
|
||||
int
|
||||
main (int argc, char *argv [])
|
||||
{
|
||||
if (argc != 3) {
|
||||
printf ("Syntax: strmcmp <infile-a> <infile-b>\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::string infile_a (argv[1]);
|
||||
std::string infile_b (argv[2]);
|
||||
|
||||
try {
|
||||
|
||||
db::Manager m;
|
||||
db::Layout layout_a (false, &m);
|
||||
db::Layout layout_b (false, &m);
|
||||
|
||||
{
|
||||
tl::InputStream stream (infile_a);
|
||||
db::Reader reader (stream);
|
||||
reader.read (layout_a);
|
||||
}
|
||||
|
||||
{
|
||||
tl::InputStream stream (infile_b);
|
||||
db::Reader reader (stream);
|
||||
reader.read (layout_b);
|
||||
}
|
||||
|
||||
if (! db::compare_layouts (layout_a, layout_b, db::layout_diff::f_boxes_as_polygons | db::layout_diff::f_no_text_orientation | db::layout_diff::f_verbose)) {
|
||||
throw tl::Exception ("layouts differ");
|
||||
}
|
||||
|
||||
} catch (std::exception &ex) {
|
||||
tl::error << ex.what ();
|
||||
return 1;
|
||||
} catch (tl::Exception &ex) {
|
||||
tl::error << ex.msg ();
|
||||
return 1;
|
||||
} catch (...) {
|
||||
tl::error << "unspecific error";
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,13 +1,2 @@
|
|||
|
||||
include($$PWD/../../klayout.pri)
|
||||
|
||||
TEMPLATE = app
|
||||
|
||||
TARGET = strmcmp
|
||||
DESTDIR = $$OUT_PWD/../..
|
||||
|
||||
SOURCES = strmcmp.cc
|
||||
|
||||
INCLUDEPATH += ../bd ../../tl ../../db ../../gsi
|
||||
DEPENDPATH += ../bd ../../tl ../../db ../../gsi
|
||||
LIBS += -L$$DESTDIR -lklayout_bd -lklayout_tl -lklayout_db -lklayout_gsi
|
||||
include($$PWD/../buddy_app.pri)
|
||||
|
|
|
|||
|
|
@ -1,215 +0,0 @@
|
|||
|
||||
|
||||
#include "dbLayout.h"
|
||||
#include "dbReader.h"
|
||||
#include "dbWriter.h"
|
||||
#include "dbEdgeProcessor.h"
|
||||
#include "tlString.h"
|
||||
|
||||
void
|
||||
syntax ()
|
||||
{
|
||||
printf ("Syntax: strmxor [-u <undersize>] [-topa <topcell-a>] [-topb <topcell-b>] [-oasis|-oas] [-gds2|-gds] <infile-a> <infile-b> [<outfile>]\n");
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv [])
|
||||
{
|
||||
std::string topcell_a;
|
||||
std::string topcell_b;
|
||||
std::string infile_a;
|
||||
std::string infile_b;
|
||||
std::string outfile;
|
||||
double undersize = 0.0;
|
||||
bool format_set = false;
|
||||
std::string format;
|
||||
|
||||
int ret = 0;
|
||||
|
||||
try {
|
||||
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
std::string o (argv[i]);
|
||||
if (o == "-u") {
|
||||
if (i < argc - 1) {
|
||||
++i;
|
||||
tl::from_string (argv[i], undersize);
|
||||
}
|
||||
} else if (o == "-topa") {
|
||||
if (i < argc - 1) {
|
||||
++i;
|
||||
topcell_a = argv[i];
|
||||
}
|
||||
} else if (o == "-topb") {
|
||||
if (i < argc - 1) {
|
||||
++i;
|
||||
topcell_b = argv[i];
|
||||
}
|
||||
} else if (o == "-oasis" || o == "-oas") {
|
||||
format_set = true;
|
||||
format = "OASIS";
|
||||
} else if (o == "-gds2" || o == "-gds") {
|
||||
format_set = true;
|
||||
format = "GDS2";
|
||||
} else if (o == "-h" || o == "-help" || o == "--help") {
|
||||
syntax ();
|
||||
return 0;
|
||||
} else if (argv[i][0] == '-') {
|
||||
throw tl::Exception("Unknown option: %s - use '-h' for help", (const char *) argv[i]);
|
||||
} else if (infile_a.empty ()) {
|
||||
infile_a = argv[i];
|
||||
} else if (infile_b.empty ()) {
|
||||
infile_b = argv[i];
|
||||
} else if (outfile.empty ()) {
|
||||
outfile = argv[i];
|
||||
} else {
|
||||
throw tl::Exception("Superfluous argument: %s - use '-h' for help", (const char *) argv[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (infile_a.empty () || infile_b.empty ()) {
|
||||
throw tl::Exception("Both input files must be specified");
|
||||
}
|
||||
|
||||
db::Manager m;
|
||||
db::Layout layout_a (&m);
|
||||
db::Layout layout_b (&m);
|
||||
|
||||
{
|
||||
tl::InputStream stream (infile_a);
|
||||
db::Reader reader (stream);
|
||||
reader.read (layout_a);
|
||||
}
|
||||
|
||||
{
|
||||
tl::InputStream stream (infile_b);
|
||||
db::Reader reader (stream);
|
||||
reader.read (layout_b);
|
||||
}
|
||||
|
||||
db::cell_index_type top_a;
|
||||
if (topcell_a.empty ()) {
|
||||
db::Layout::top_down_iterator t = layout_a.begin_top_down ();
|
||||
if (t == layout_a.end_top_cells ()) {
|
||||
throw tl::Exception ("Layout A (%s) does not have a top cell", infile_a);
|
||||
}
|
||||
top_a = *t++;
|
||||
if (t != layout_a.end_top_cells ()) {
|
||||
throw tl::Exception ("Layout A (%s) has multiple top cells", infile_a);
|
||||
}
|
||||
} else {
|
||||
std::pair<bool, db::cell_index_type> cn = layout_a.cell_by_name (topcell_a.c_str ());
|
||||
if (! cn.first) {
|
||||
throw tl::Exception ("Layout A (%s) does not have a topcell called '%s'", infile_a, topcell_a);
|
||||
}
|
||||
top_a = cn.second;
|
||||
}
|
||||
|
||||
db::cell_index_type top_b;
|
||||
if (topcell_b.empty ()) {
|
||||
db::Layout::top_down_iterator t = layout_b.begin_top_down ();
|
||||
if (t == layout_b.end_top_cells ()) {
|
||||
throw tl::Exception ("Layout B (%s) does not have a top cell", infile_b);
|
||||
}
|
||||
top_b = *t++;
|
||||
if (t != layout_b.end_top_cells ()) {
|
||||
throw tl::Exception ("Layout B (%s) has multiple top cells", infile_b);
|
||||
}
|
||||
} else {
|
||||
std::pair<bool, db::cell_index_type> cn = layout_b.cell_by_name (topcell_b.c_str ());
|
||||
if (! cn.first) {
|
||||
throw tl::Exception ("Layout B (%s) does not have a topcell called '%s'", infile_b, topcell_b);
|
||||
}
|
||||
top_b = cn.second;
|
||||
}
|
||||
|
||||
if (fabs (layout_a.dbu () - layout_b.dbu ()) > 1e-6) {
|
||||
throw tl::Exception("Input file database units differ (A:%g vs. B:%g)", layout_a.dbu (), layout_b.dbu ());
|
||||
}
|
||||
|
||||
std::map<db::LayerProperties, std::pair<int, int> > all_layers;
|
||||
for (unsigned int i = 0; i < layout_a.layers (); ++i) {
|
||||
if (layout_a.is_valid_layer (i)) {
|
||||
all_layers.insert (std::make_pair(layout_a.get_properties (i), std::make_pair(-1, -1))).first->second.first = int (i);
|
||||
}
|
||||
}
|
||||
for (unsigned int i = 0; i < layout_b.layers (); ++i) {
|
||||
if (layout_b.is_valid_layer (i)) {
|
||||
all_layers.insert (std::make_pair(layout_b.get_properties (i), std::make_pair(-1, -1))).first->second.second = int (i);
|
||||
}
|
||||
}
|
||||
|
||||
db::Layout output;
|
||||
output.dbu (layout_a.dbu ());
|
||||
db::cell_index_type top_id = output.add_cell (layout_a.cell_name (top_a));
|
||||
|
||||
db::Coord us = db::coord_traits<db::Coord>::rounded (undersize / layout_a.dbu ());
|
||||
|
||||
db::ShapeProcessor sp;
|
||||
|
||||
size_t ndiff = 0;
|
||||
|
||||
for (std::map<db::LayerProperties, std::pair<int, int> >::const_iterator l = all_layers.begin (); l != all_layers.end (); ++l) {
|
||||
|
||||
int layer_id = output.insert_layer (l->first);
|
||||
|
||||
if (l->second.first >= 0 && l->second.second >= 0) {
|
||||
|
||||
sp.boolean (layout_a, layout_a.cell (top_a), l->second.first, layout_b, layout_b.cell (top_b), l->second.second,
|
||||
output.cell (top_id).shapes (layer_id), db::BooleanOp::Xor, true /*recursive*/);
|
||||
|
||||
sp.size (output, output.cell (top_id), layer_id, output.cell (top_id).shapes (layer_id), -us, (unsigned int) 2, true /*recursive*/);
|
||||
|
||||
} else if (l->second.first >= 0) {
|
||||
|
||||
sp.size (layout_a, layout_a.cell (top_a), l->second.first, output.cell (top_id).shapes (layer_id), -us, (unsigned int) 2, true /*recursive*/);
|
||||
|
||||
} else if (l->second.second >= 0) {
|
||||
|
||||
sp.size (layout_b, layout_b.cell (top_b), l->second.second, output.cell (top_id).shapes (layer_id), -us, (unsigned int) 2, true /*recursive*/);
|
||||
|
||||
}
|
||||
|
||||
size_t n = output.cell (top_id).shapes (layer_id).size ();
|
||||
// if (n > 0) {
|
||||
ndiff += n;
|
||||
tl::info << " " << l->first.to_string () << ": " << n;
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
if (ndiff > 0) {
|
||||
tl::info << "----------------------------------------------------";
|
||||
tl::info << " Total differences: " << ndiff;
|
||||
ret = 1;
|
||||
}
|
||||
|
||||
if (! outfile.empty ()) {
|
||||
|
||||
db::SaveLayoutOptions options;
|
||||
options.set_format_from_filename (outfile);
|
||||
if (format_set) {
|
||||
options.set_format (format);
|
||||
}
|
||||
|
||||
db::Writer writer (options);
|
||||
tl::OutputStream file (outfile, tl::OutputStream::OM_Auto);
|
||||
writer.write (output, file);
|
||||
|
||||
}
|
||||
|
||||
} catch (std::exception &ex) {
|
||||
tl::error << ex.what ();
|
||||
return 1;
|
||||
} catch (tl::Exception &ex) {
|
||||
tl::error << ex.msg ();
|
||||
return 1;
|
||||
} catch (...) {
|
||||
tl::error << "unspecific error";
|
||||
return 1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -66,16 +66,16 @@ ArgBase::ParsedOption::ParsedOption (const std::string &option)
|
|||
optional = true;
|
||||
ex.read_word (long_option, "_-");
|
||||
if (ex.test ("=")) {
|
||||
ex.read_word (name);
|
||||
ex.read_word_or_quoted (name);
|
||||
}
|
||||
} else if (ex.test ("-")) {
|
||||
optional = true;
|
||||
ex.read_word (short_option, "");
|
||||
if (ex.test ("=")) {
|
||||
ex.read_word (name);
|
||||
ex.read_word_or_quoted (name);
|
||||
}
|
||||
} else {
|
||||
ex.read_word (name);
|
||||
ex.read_word_or_quoted (name);
|
||||
}
|
||||
ex.test("|");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue