mirror of https://github.com/KLayout/klayout.git
WIP: Fixed DXF reader
This commit is contained in:
parent
72c933ed47
commit
b6f710a9fe
|
|
@ -122,25 +122,31 @@ extract_ld (const char *s, int &l, int &d, std::string &n)
|
|||
|
||||
std::pair <bool, unsigned int>
|
||||
NamedLayerReader::open_layer (db::Layout &layout, const std::string &n)
|
||||
{
|
||||
return open_layer (layout, n, keep_layer_names (), create_layers ());
|
||||
}
|
||||
|
||||
std::pair <bool, unsigned int>
|
||||
NamedLayerReader::open_layer (db::Layout &layout, const std::string &n, bool keep_layer_name, bool create_layer)
|
||||
{
|
||||
std::map<std::string, std::pair <bool, unsigned int> >::const_iterator lc = m_layer_cache.find (n);
|
||||
if (lc != m_layer_cache.end ()) {
|
||||
return lc->second;
|
||||
} else {
|
||||
std::pair <bool, unsigned int> res = open_layer_uncached (layout, n);
|
||||
std::pair <bool, unsigned int> res = open_layer_uncached (layout, n, keep_layer_name, create_layer);
|
||||
m_layer_cache.insert (std::make_pair (n, res));
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
std::pair <bool, unsigned int>
|
||||
NamedLayerReader::open_layer_uncached (db::Layout &layout, const std::string &n)
|
||||
NamedLayerReader::open_layer_uncached (db::Layout &layout, const std::string &n, bool keep_layer_name, bool create_layer)
|
||||
{
|
||||
int l = -1, d = -1;
|
||||
std::string on;
|
||||
|
||||
std::set<unsigned int> li = m_layer_map.logical (n, layout);
|
||||
if (li.empty () && ! m_keep_layer_names) {
|
||||
if (li.empty () && ! keep_layer_name) {
|
||||
|
||||
if (extract_plain_layer (n.c_str (), l)) {
|
||||
|
||||
|
|
@ -183,7 +189,7 @@ NamedLayerReader::open_layer_uncached (db::Layout &layout, const std::string &n)
|
|||
|
||||
}
|
||||
|
||||
} else if (! m_create_layers) {
|
||||
} else if (! create_layer) {
|
||||
|
||||
return std::pair<bool, unsigned int> (false, 0);
|
||||
|
||||
|
|
@ -212,6 +218,7 @@ NamedLayerReader::open_layer_uncached (db::Layout &layout, const std::string &n)
|
|||
void
|
||||
NamedLayerReader::map_layer (const std::string &name, unsigned int layer)
|
||||
{
|
||||
m_layer_cache [name] = std::make_pair (true, layer);
|
||||
m_layer_map_out.map (name, layer);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -73,6 +73,14 @@ protected:
|
|||
*/
|
||||
void set_layer_map (const LayerMap &lm);
|
||||
|
||||
/**
|
||||
* @brief Gets the input layer map
|
||||
*/
|
||||
const LayerMap &layer_map ()
|
||||
{
|
||||
return m_layer_map;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the layer map
|
||||
*/
|
||||
|
|
@ -105,6 +113,14 @@ protected:
|
|||
*/
|
||||
std::pair <bool, unsigned int> open_layer (db::Layout &layout, const std::string &name);
|
||||
|
||||
/**
|
||||
* @brief Opens a new layer
|
||||
* This method will create or locate a layer for a given name.
|
||||
* The result's first attribute is true, if such a layer could be found
|
||||
* or created. In this case, the second attribute is the layer index.
|
||||
*/
|
||||
std::pair <bool, unsigned int> open_layer (db::Layout &layout, const std::string &name, bool keep_layer_name, bool create_layer);
|
||||
|
||||
/**
|
||||
* @brief Force mapping of a name to a layer index
|
||||
*/
|
||||
|
|
@ -133,7 +149,7 @@ private:
|
|||
std::map<std::string, std::pair <bool, unsigned int> > m_layer_cache;
|
||||
std::map<std::set<unsigned int>, unsigned int> m_multi_mapping_placeholders;
|
||||
|
||||
std::pair <bool, unsigned int> open_layer_uncached (db::Layout &layout, const std::string &name);
|
||||
std::pair <bool, unsigned int> open_layer_uncached (db::Layout &layout, const std::string &name, bool keep_layer_name, bool create_layer);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -364,16 +364,6 @@ DXFReader::warn (const std::string &msg)
|
|||
}
|
||||
}
|
||||
|
||||
std::pair <bool, unsigned int>
|
||||
DXFReader::open_layer (db::Layout &layout, const std::string &n)
|
||||
{
|
||||
if (n == zero_layer_name) {
|
||||
return std::make_pair (true, m_zero_layer);
|
||||
} else {
|
||||
return NamedLayerReader::open_layer (layout, n);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DXFReader::do_read (db::Layout &layout, db::cell_index_type top)
|
||||
{
|
||||
|
|
@ -381,21 +371,24 @@ DXFReader::do_read (db::Layout &layout, db::cell_index_type top)
|
|||
|
||||
// create the zero layer - this is not mapped to GDS but can be specified in the layer mapping as
|
||||
// a layer named "0".
|
||||
std::pair<bool, unsigned int> ll = open_layer (layout, zero_layer_name);
|
||||
if (ll.first) {
|
||||
|
||||
// layer exists
|
||||
m_zero_layer = ll.second;
|
||||
std::pair<bool, unsigned int> li = NamedLayerReader::open_layer (layout, zero_layer_name, true /*keep layer name*/, false /*don't create a new layer*/);
|
||||
if (li.first) {
|
||||
|
||||
// we got one from the layer mapping
|
||||
m_zero_layer = li.second;
|
||||
|
||||
} else {
|
||||
|
||||
// or explicitly create the layer:
|
||||
m_zero_layer = layout.insert_layer (db::LayerProperties (0, 0, zero_layer_name));
|
||||
// or we explicitly create the layer
|
||||
db::LayerProperties lp_zero (0, 0, zero_layer_name);
|
||||
m_zero_layer = layout.insert_layer (lp_zero);
|
||||
map_layer (zero_layer_name, m_zero_layer);
|
||||
|
||||
}
|
||||
|
||||
// Read sections
|
||||
// Read sections
|
||||
|
||||
int g;
|
||||
|
||||
while (true) {
|
||||
|
|
|
|||
|
|
@ -193,7 +193,6 @@ private:
|
|||
|
||||
void do_read (db::Layout &layout, db::cell_index_type top);
|
||||
|
||||
std::pair <bool, unsigned int> open_layer (db::Layout &layout, const std::string &n);
|
||||
db::cell_index_type make_layer_variant (db::Layout &layout, const std::string &cellname, db::cell_index_type template_cell, unsigned int layer, double sx, double sy);
|
||||
void cleanup (db::Layout &layout, db::cell_index_type top);
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ TARGET = dxf_tests
|
|||
include($$PWD/../../../../lib_ut.pri)
|
||||
|
||||
SOURCES = \
|
||||
dbDXFReader.cc \
|
||||
dbDXFReaderTests.cc
|
||||
|
||||
INCLUDEPATH += $$LAY_INC $$TL_INC $$DB_INC $$GSI_INC $$PWD/../db_plugin $$PWD/../../../common
|
||||
DEPENDPATH += $$LAY_INC $$TL_INC $$DB_INC $$GSI_INC $$PWD/../db_plugin $$PWD/../../../common
|
||||
|
|
|
|||
Loading…
Reference in New Issue