ROOM » Utilities » C++ Classes » GdsImporter
GdsImporter Class
Reads a GDSII layout file into an in-memory Database. Moreā¦
| Header: | #include "gds_importer.h" |
|---|---|
| CMake: | target_link_libraries(mytarget PRIVATE ROOM::room_utils) |
Public Types
| struct Options | Library name and default DBU scale for import. |
Public Functions
| GdsImporter() | Default constructor with default Options. |
| explicit GdsImporter(const Options & options) | Constructs with custom import settings. |
| Database importFile(const std::string & gdsPath) const | Parses a GDSII file and returns a database. |
| const std::vector<std::string> & warnings() const | Non-fatal messages from the last import. |
| const std::vector<std::string> & errors() const | Fatal error messages from the last import. |
Detailed Description
Creates cells with ViewType::Layout, maps GDS layers to Lib::layers(), and attaches GDS user properties to shapes and instances. See also the gds_to_room walkthrough.
Member Type Documentation
struct Options
| Member | Default | Description |
|---|---|---|
std::string libName | "gds_import" | Name of the output Lib. |
double defaultDbuPerMicron | 1000.0 | DBU per micron when the GDS file has no UNITS record. |
Member Function Documentation
GdsImporter()
Default constructor. Creates an importer with default Options (libName = "gds_import", defaultDbuPerMicron = 1000.0).
explicit GdsImporter(const Options & options)
Constructs an importer with custom import settings.
| Parameter | Description |
|---|---|
options | Library name and default DBU resolution used when the GDS file has no UNITS record. |
Database importFile(const std::string & gdsPath) const
Parses a GDSII file and builds an in-memory database. Clears previous warning and error messages before parsing.
| Parameter | Description |
|---|---|
gdsPath | Path to the input GDS or GDSII file to read. |
Returns: A populated Database on success, or an empty database if parsing failed. Inspect errors() for failure details.
const std::vector<std::string> & warnings() const
Returns non-fatal messages from the most recent importFile() call.
Returns: Const reference to warning strings (for example unsupported records or recoverable issues).
const std::vector<std::string> & errors() const
Returns fatal error messages from the most recent importFile() call.
Returns: Const reference to error strings. Non-empty usually means import failed.
Supported GDS records
| Record | Result |
|---|---|
| STRNAME | Cell |
| BOUNDARY, BOX | Shape::Polygon |
| PATH | Shape::Path |
| TEXT | Shape::Text |
| SREF | Instance |
| UNITS | dbuPerMicron |
Private Variables
Private members are implementation details.
Options m_options | Import settings. |
mutable std::vector<std::string> m_warnings | Warnings from last importFile(). |
mutable std::vector<std::string> m_errors | Errors from last importFile(). |
Example
room::GdsImporter::Options opts;
opts.libName = "demo_lib";
opts.defaultDbuPerMicron = 1000.0;
room::GdsImporter importer(opts);
room::Database db = importer.importFile("layout.gds");
for (const auto & w : importer.warnings())
std::cerr << "warn: " << w << "\n";
for (const auto & e : importer.errors())
std::cerr << "err: " << e << "\n";
db.saveToFile("layout.room");
See also the gds_to_room walkthrough.