mirror of https://github.com/KLayout/klayout.git
WIP
This commit is contained in:
parent
6db937d9df
commit
dca287b724
|
|
@ -809,6 +809,8 @@ void local_clusters<T>::clear ()
|
||||||
m_clusters.clear ();
|
m_clusters.clear ();
|
||||||
m_bbox = box_type ();
|
m_bbox = box_type ();
|
||||||
m_next_dummy_id = 0;
|
m_next_dummy_id = 0;
|
||||||
|
m_soft_connections.clear ();
|
||||||
|
m_soft_connections_rev.clear ();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
|
|
@ -846,6 +848,9 @@ local_clusters<T>::remove_cluster (typename local_cluster<T>::id_type id)
|
||||||
local_cluster<T> *to_delete = const_cast<local_cluster<T> *> (& m_clusters.objects ().item (id - 1));
|
local_cluster<T> *to_delete = const_cast<local_cluster<T> *> (& m_clusters.objects ().item (id - 1));
|
||||||
to_delete->clear ();
|
to_delete->clear ();
|
||||||
m_needs_update = true;
|
m_needs_update = true;
|
||||||
|
|
||||||
|
// take care of soft connections
|
||||||
|
remove_soft_connection_for (id);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
|
|
@ -866,6 +871,10 @@ local_clusters<T>::join_cluster_with (typename local_cluster<T>::id_type id, typ
|
||||||
// we just clear them.
|
// we just clear them.
|
||||||
with->clear ();
|
with->clear ();
|
||||||
|
|
||||||
|
// take care of soft connections
|
||||||
|
remove_soft_connection_for (id, with_id);
|
||||||
|
remove_soft_connection_for (with_id);
|
||||||
|
|
||||||
m_needs_update = true;
|
m_needs_update = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -883,7 +892,81 @@ template <class T>
|
||||||
void
|
void
|
||||||
local_clusters<T>::make_soft_connection (typename local_cluster<T>::id_type a, typename local_cluster<T>::id_type b)
|
local_clusters<T>::make_soft_connection (typename local_cluster<T>::id_type a, typename local_cluster<T>::id_type b)
|
||||||
{
|
{
|
||||||
// @@@ TODO: implement
|
// NOTE: antiparallel connections are allowed. We will eliminate them later
|
||||||
|
|
||||||
|
m_soft_connections [a].insert (b);
|
||||||
|
m_soft_connections_rev [b].insert (a);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
const std::set<size_t> &
|
||||||
|
local_clusters<T>::downward_soft_connections (typename local_cluster<T>::id_type id) const
|
||||||
|
{
|
||||||
|
static std::set<size_t> empty;
|
||||||
|
|
||||||
|
auto sc = m_soft_connections.find (id);
|
||||||
|
if (sc != m_soft_connections.end ()) {
|
||||||
|
return sc->second;
|
||||||
|
} else {
|
||||||
|
return empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
const std::set<size_t> &
|
||||||
|
local_clusters<T>::upward_soft_connections (typename local_cluster<T>::id_type id) const
|
||||||
|
{
|
||||||
|
static std::set<size_t> empty;
|
||||||
|
|
||||||
|
auto sc = m_soft_connections_rev.find (id);
|
||||||
|
if (sc != m_soft_connections_rev.end ()) {
|
||||||
|
return sc->second;
|
||||||
|
} else {
|
||||||
|
return empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
void
|
||||||
|
local_clusters<T>::remove_soft_connection_for (typename local_cluster<T>::id_type a, typename local_cluster<T>::id_type b)
|
||||||
|
{
|
||||||
|
auto sc = m_soft_connections.find (a);
|
||||||
|
if (sc != m_soft_connections.end ()) {
|
||||||
|
sc->second.erase (b);
|
||||||
|
if (sc->second.empty ()) {
|
||||||
|
m_soft_connections.erase (sc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sc = m_soft_connections_rev.find (b);
|
||||||
|
if (sc != m_soft_connections_rev.end ()) {
|
||||||
|
sc->second.erase (a);
|
||||||
|
if (sc->second.empty ()) {
|
||||||
|
m_soft_connections_rev.erase (sc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
void
|
||||||
|
local_clusters<T>::remove_soft_connection_for (typename local_cluster<T>::id_type id)
|
||||||
|
{
|
||||||
|
auto sc = m_soft_connections.find (id);
|
||||||
|
if (sc != m_soft_connections.end ()) {
|
||||||
|
|
||||||
|
for (auto i = sc->second.begin (); i != sc->second.end (); ++i) {
|
||||||
|
auto sc_rev = m_soft_connections_rev.find (*i);
|
||||||
|
tl_assert (sc_rev != m_soft_connections_rev.end ()) {
|
||||||
|
sc_rev->second.erase (id);
|
||||||
|
if (sc_rev->second.empty ()) {
|
||||||
|
m_soft_connections_rev.erase (*i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_soft_connections.erase (sc);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
|
|
|
||||||
|
|
@ -627,6 +627,16 @@ public:
|
||||||
*/
|
*/
|
||||||
void make_soft_connection (typename local_cluster<T>::id_type a, typename local_cluster<T>::id_type b);
|
void make_soft_connection (typename local_cluster<T>::id_type a, typename local_cluster<T>::id_type b);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the downward soft connections for a given cluster
|
||||||
|
*/
|
||||||
|
const std::set<size_t> &downward_soft_connections (typename local_cluster<T>::id_type id) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the upward soft connections for a given cluster
|
||||||
|
*/
|
||||||
|
const std::set<size_t> &upward_soft_connections (typename local_cluster<T>::id_type id) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Gets the number of clusters
|
* @brief Gets the number of clusters
|
||||||
*/
|
*/
|
||||||
|
|
@ -647,8 +657,12 @@ private:
|
||||||
box_type m_bbox;
|
box_type m_bbox;
|
||||||
tree_type m_clusters;
|
tree_type m_clusters;
|
||||||
size_t m_next_dummy_id;
|
size_t m_next_dummy_id;
|
||||||
|
std::map<size_t, std::set<size_t> > m_soft_connections;
|
||||||
|
std::map<size_t, std::set<size_t> > m_soft_connections_rev;
|
||||||
|
|
||||||
void apply_attr_equivalences (const tl::equivalence_clusters<size_t> &attr_equivalence);
|
void apply_attr_equivalences (const tl::equivalence_clusters<size_t> &attr_equivalence);
|
||||||
|
void remove_soft_connection_for (typename local_cluster<T>::id_type a, typename local_cluster<T>::id_type b);
|
||||||
|
void remove_soft_connection_for (typename local_cluster<T>::id_type id);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue