mirror of
https://github.com/KLayout/klayout.git
synced 2026-08-22 05:57:41 +02:00
Some refactoring (removed code copies)
This commit is contained in:
@@ -76,8 +76,7 @@ private:
|
|||||||
db::RecursiveShapeIterator m_iter;
|
db::RecursiveShapeIterator m_iter;
|
||||||
mutable value_type m_edge_pair;
|
mutable value_type m_edge_pair;
|
||||||
|
|
||||||
void set () const
|
void set () const {
|
||||||
{
|
|
||||||
if (! m_iter.at_end ()) {
|
if (! m_iter.at_end ()) {
|
||||||
m_iter.shape ().edge_pair (m_edge_pair);
|
m_iter.shape ().edge_pair (m_edge_pair);
|
||||||
m_edge_pair.transform (m_iter.trans ());
|
m_edge_pair.transform (m_iter.trans ());
|
||||||
@@ -191,39 +190,6 @@ const db::RecursiveShapeIterator *DeepEdgePairs::iter () const
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
DeepEdgePairs::add_from (const DeepLayer &dl)
|
|
||||||
{
|
|
||||||
if (&dl.layout () == &deep_layer ().layout ()) {
|
|
||||||
|
|
||||||
// intra-layout merge
|
|
||||||
|
|
||||||
deep_layer ().layout ().copy_layer (dl.layer (), deep_layer ().layer ());
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
// inter-layout merge
|
|
||||||
|
|
||||||
db::cell_index_type into_cell = deep_layer ().initial_cell ().cell_index ();
|
|
||||||
db::Layout *into_layout = &deep_layer ().layout ();
|
|
||||||
db::cell_index_type source_cell = dl.initial_cell ().cell_index ();
|
|
||||||
const db::Layout *source_layout = &dl.layout ();
|
|
||||||
|
|
||||||
db::CellMapping cm;
|
|
||||||
cm.create_from_geometry_full (*into_layout, into_cell, *source_layout, source_cell);
|
|
||||||
|
|
||||||
// Actually copy the shapes
|
|
||||||
|
|
||||||
std::map<unsigned int, unsigned int> lm;
|
|
||||||
lm.insert (std::make_pair (dl.layer (), deep_layer ().layer ()));
|
|
||||||
|
|
||||||
std::vector <db::cell_index_type> source_cells;
|
|
||||||
source_cells.push_back (source_cell);
|
|
||||||
db::copy_shapes (*into_layout, *source_layout, db::ICplxTrans (), source_cells, cm.table (), lm);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
EdgePairsDelegate *
|
EdgePairsDelegate *
|
||||||
DeepEdgePairs::add_in_place (const EdgePairs &other)
|
DeepEdgePairs::add_in_place (const EdgePairs &other)
|
||||||
{
|
{
|
||||||
@@ -234,7 +200,7 @@ DeepEdgePairs::add_in_place (const EdgePairs &other)
|
|||||||
const DeepEdgePairs *other_deep = dynamic_cast <const DeepEdgePairs *> (other.delegate ());
|
const DeepEdgePairs *other_deep = dynamic_cast <const DeepEdgePairs *> (other.delegate ());
|
||||||
if (other_deep) {
|
if (other_deep) {
|
||||||
|
|
||||||
add_from (other_deep->deep_layer ());
|
deep_layer ().add_from (other_deep->deep_layer ());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,6 @@ private:
|
|||||||
DeepLayer m_deep_layer;
|
DeepLayer m_deep_layer;
|
||||||
|
|
||||||
void init ();
|
void init ();
|
||||||
void add_from (const DeepLayer &dl);
|
|
||||||
EdgesDelegate *generic_edges (bool first, bool second) const;
|
EdgesDelegate *generic_edges (bool first, bool second) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -526,39 +526,6 @@ EdgesDelegate *DeepEdges::or_with (const Edges &other) const
|
|||||||
return AsIfFlatEdges::or_with (other);
|
return AsIfFlatEdges::or_with (other);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
DeepEdges::add_from (const DeepLayer &dl)
|
|
||||||
{
|
|
||||||
if (&dl.layout () == &deep_layer ().layout ()) {
|
|
||||||
|
|
||||||
// intra-layout merge
|
|
||||||
|
|
||||||
deep_layer ().layout ().copy_layer (dl.layer (), deep_layer ().layer ());
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
// inter-layout merge
|
|
||||||
|
|
||||||
db::cell_index_type into_cell = deep_layer ().initial_cell ().cell_index ();
|
|
||||||
db::Layout *into_layout = &deep_layer ().layout ();
|
|
||||||
db::cell_index_type source_cell = dl.initial_cell ().cell_index ();
|
|
||||||
const db::Layout *source_layout = &dl.layout ();
|
|
||||||
|
|
||||||
db::CellMapping cm;
|
|
||||||
cm.create_from_geometry_full (*into_layout, into_cell, *source_layout, source_cell);
|
|
||||||
|
|
||||||
// Actually copy the shapes
|
|
||||||
|
|
||||||
std::map<unsigned int, unsigned int> lm;
|
|
||||||
lm.insert (std::make_pair (dl.layer (), deep_layer ().layer ()));
|
|
||||||
|
|
||||||
std::vector <db::cell_index_type> source_cells;
|
|
||||||
source_cells.push_back (source_cell);
|
|
||||||
db::copy_shapes (*into_layout, *source_layout, db::ICplxTrans (), source_cells, cm.table (), lm);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
EdgesDelegate *
|
EdgesDelegate *
|
||||||
DeepEdges::add_in_place (const Edges &other)
|
DeepEdges::add_in_place (const Edges &other)
|
||||||
{
|
{
|
||||||
@@ -569,7 +536,7 @@ DeepEdges::add_in_place (const Edges &other)
|
|||||||
const DeepEdges *other_deep = dynamic_cast <const DeepEdges *> (other.delegate ());
|
const DeepEdges *other_deep = dynamic_cast <const DeepEdges *> (other.delegate ());
|
||||||
if (other_deep) {
|
if (other_deep) {
|
||||||
|
|
||||||
add_from (other_deep->deep_layer ());
|
deep_layer ().add_from (other_deep->deep_layer ());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|||||||
@@ -165,7 +165,6 @@ private:
|
|||||||
|
|
||||||
void init ();
|
void init ();
|
||||||
void ensure_merged_edges_valid () const;
|
void ensure_merged_edges_valid () const;
|
||||||
void add_from (const DeepLayer &dl);
|
|
||||||
EdgePairs run_check (db::edge_relation_type rel, const Edges *other, db::Coord d, bool whole_edges, metrics_type metrics, double ignore_angle, distance_type min_projection, distance_type max_projection) const;
|
EdgePairs run_check (db::edge_relation_type rel, const Edges *other, db::Coord d, bool whole_edges, metrics_type metrics, double ignore_angle, distance_type min_projection, distance_type max_projection) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -500,42 +500,8 @@ DeepRegion::xor_with (const Region &other) const
|
|||||||
DeepLayer n1 (and_or_not_with (other_deep, false));
|
DeepLayer n1 (and_or_not_with (other_deep, false));
|
||||||
DeepLayer n2 (other_deep->and_or_not_with (this, false));
|
DeepLayer n2 (other_deep->and_or_not_with (this, false));
|
||||||
|
|
||||||
std::auto_ptr<DeepRegion> r (new DeepRegion (n1));
|
n1.add_from (n2);
|
||||||
r->add_from (n2);
|
return new DeepRegion (n1);
|
||||||
return r.release ();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
DeepRegion::add_from (const DeepLayer &dl)
|
|
||||||
{
|
|
||||||
if (&dl.layout () == &deep_layer ().layout ()) {
|
|
||||||
|
|
||||||
// intra-layout merge
|
|
||||||
|
|
||||||
deep_layer ().layout ().copy_layer (dl.layer (), deep_layer ().layer ());
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
// inter-layout merge
|
|
||||||
|
|
||||||
db::cell_index_type into_cell = deep_layer ().initial_cell ().cell_index ();
|
|
||||||
db::Layout *into_layout = &deep_layer ().layout ();
|
|
||||||
db::cell_index_type source_cell = dl.initial_cell ().cell_index ();
|
|
||||||
const db::Layout *source_layout = &dl.layout ();
|
|
||||||
|
|
||||||
db::CellMapping cm;
|
|
||||||
cm.create_from_geometry_full (*into_layout, into_cell, *source_layout, source_cell);
|
|
||||||
|
|
||||||
// Actually copy the shapes
|
|
||||||
|
|
||||||
std::map<unsigned int, unsigned int> lm;
|
|
||||||
lm.insert (std::make_pair (dl.layer (), deep_layer ().layer ()));
|
|
||||||
|
|
||||||
std::vector <db::cell_index_type> source_cells;
|
|
||||||
source_cells.push_back (source_cell);
|
|
||||||
db::copy_shapes (*into_layout, *source_layout, db::ICplxTrans (), source_cells, cm.table (), lm);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -550,7 +516,7 @@ DeepRegion::add_in_place (const Region &other)
|
|||||||
const DeepRegion *other_deep = dynamic_cast <const DeepRegion *> (other.delegate ());
|
const DeepRegion *other_deep = dynamic_cast <const DeepRegion *> (other.delegate ());
|
||||||
if (other_deep) {
|
if (other_deep) {
|
||||||
|
|
||||||
add_from (other_deep->deep_layer ());
|
deep_layer ().add_from (other_deep->deep_layer ());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|||||||
@@ -237,7 +237,6 @@ private:
|
|||||||
void init ();
|
void init ();
|
||||||
void ensure_merged_polygons_valid () const;
|
void ensure_merged_polygons_valid () const;
|
||||||
DeepLayer and_or_not_with(const DeepRegion *other, bool and_op) const;
|
DeepLayer and_or_not_with(const DeepRegion *other, bool and_op) const;
|
||||||
void add_from (const DeepLayer &dl);
|
|
||||||
EdgePairs run_check (db::edge_relation_type rel, bool different_polygons, const Region *other, db::Coord d, bool whole_edges, metrics_type metrics, double ignore_angle, distance_type min_projection, distance_type max_projection) const;
|
EdgePairs run_check (db::edge_relation_type rel, bool different_polygons, const Region *other, db::Coord d, bool whole_edges, metrics_type metrics, double ignore_angle, distance_type min_projection, distance_type max_projection) const;
|
||||||
EdgePairs run_single_polygon_check (db::edge_relation_type rel, db::Coord d, bool whole_edges, metrics_type metrics, double ignore_angle, distance_type min_projection, distance_type max_projection) const;
|
EdgePairs run_single_polygon_check (db::edge_relation_type rel, db::Coord d, bool whole_edges, metrics_type metrics, double ignore_angle, distance_type min_projection, distance_type max_projection) const;
|
||||||
RegionDelegate *selected_interacting_generic (const Region &other, int mode, bool touching, bool inverse) const;
|
RegionDelegate *selected_interacting_generic (const Region &other, int mode, bool touching, bool inverse) const;
|
||||||
|
|||||||
@@ -106,6 +106,39 @@ DeepLayer::copy () const
|
|||||||
return new_layer;
|
return new_layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
DeepLayer::add_from (const DeepLayer &dl)
|
||||||
|
{
|
||||||
|
if (&dl.layout () == &layout ()) {
|
||||||
|
|
||||||
|
// intra-layout merge
|
||||||
|
|
||||||
|
layout ().copy_layer (dl.layer (), layer ());
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
// inter-layout merge
|
||||||
|
|
||||||
|
db::cell_index_type into_cell = initial_cell ().cell_index ();
|
||||||
|
db::Layout *into_layout = &layout ();
|
||||||
|
db::cell_index_type source_cell = dl.initial_cell ().cell_index ();
|
||||||
|
const db::Layout *source_layout = &dl.layout ();
|
||||||
|
|
||||||
|
db::CellMapping cm;
|
||||||
|
cm.create_from_geometry_full (*into_layout, into_cell, *source_layout, source_cell);
|
||||||
|
|
||||||
|
// Actually copy the shapes
|
||||||
|
|
||||||
|
std::map<unsigned int, unsigned int> lm;
|
||||||
|
lm.insert (std::make_pair (dl.layer (), layer ()));
|
||||||
|
|
||||||
|
std::vector <db::cell_index_type> source_cells;
|
||||||
|
source_cells.push_back (source_cell);
|
||||||
|
db::copy_shapes (*into_layout, *source_layout, db::ICplxTrans (), source_cells, cm.table (), lm);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DeepLayer::insert_into (db::Layout *into_layout, db::cell_index_type into_cell, unsigned int into_layer) const
|
DeepLayer::insert_into (db::Layout *into_layout, db::cell_index_type into_cell, unsigned int into_layer) const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -153,6 +153,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
DeepLayer copy () const;
|
DeepLayer copy () const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Adds shapes from another deep layer to this one
|
||||||
|
*/
|
||||||
|
void add_from (const DeepLayer &dl);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Separates cell variants (see DeepShapeStore::separate_variants)
|
* @brief Separates cell variants (see DeepShapeStore::separate_variants)
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user