diff --git a/src/pex/pex/gsiDeclRExtractor.cc b/src/pex/pex/gsiDeclRExtractor.cc index a0bc54078..f74e8e657 100644 --- a/src/pex/pex/gsiDeclRExtractor.cc +++ b/src/pex/pex/gsiDeclRExtractor.cc @@ -22,7 +22,7 @@ #include "gsiDecl.h" -#include "pexRExtractor.h" +#include "pexSquareCountingRExtractor.h" namespace gsi { diff --git a/src/pex/pex/pex.pro b/src/pex/pex/pex.pro index 80b1b5a8b..251fb9935 100644 --- a/src/pex/pex/pex.pro +++ b/src/pex/pex/pex.pro @@ -10,10 +10,12 @@ SOURCES = \ pexForceLink.cc \ pexRExtractor.cc \ gsiDeclRExtractor.cc \ + pexSquareCountingRExtractor.cc HEADERS = \ pexForceLink.h \ pexRExtractor.h \ + pexSquareCountingRExtractor.h RESOURCES = \ diff --git a/src/pex/pex/pexRExtractor.cc b/src/pex/pex/pexRExtractor.cc index 614e6f009..de4a3585b 100644 --- a/src/pex/pex/pexRExtractor.cc +++ b/src/pex/pex/pexRExtractor.cc @@ -196,36 +196,4 @@ RExtractor::~RExtractor () // .. nothing yet .. } - -SquareCountingRExtractor::SquareCountingRExtractor (double dbu) -{ - m_dbu = dbu; - - m_decomp_param.split_edges = true; - m_decomp_param.with_segments = false; } - -void -SquareCountingRExtractor::extract (const db::Polygon &polygon, const std::vector &vertex_ports, const std::vector &polygon_ports, RNetwork &rnetwork) -{ - db::CplxTrans trans = db::CplxTrans (m_dbu) * db::ICplxTrans (db::Trans (db::Point () - polygon.box ().center ())); - auto inv_trans = trans.inverted (); - - db::plc::Graph plc; - - db::plc::ConvexDecomposition decomp (&plc); - decomp.decompose (polygon, vertex_ports, m_decomp_param, trans); - - std::vector > decomp_polygons; - for (auto p = plc.begin (); p != plc.end (); ++p) { - // @@@decomp_polygons.push_back (db::Polygon ()); - // @@@decomp_polygons.back ().first = inv_trans * p->polygon (); - } - - // @@@ use box_scanner to find interactions between polygon_ports and decomp_polygons - -} - -} - - diff --git a/src/pex/pex/pexRExtractor.h b/src/pex/pex/pexRExtractor.h index 87a2f2565..96c704cbe 100644 --- a/src/pex/pex/pexRExtractor.h +++ b/src/pex/pex/pexRExtractor.h @@ -27,8 +27,6 @@ #include "dbPolygon.h" #include "dbPLC.h" -#include "dbPLCConvexDecomposition.h" // @@@ -#include "dbPLCTriangulation.h" // @@@ #include "tlList.h" #include @@ -168,35 +166,6 @@ public: virtual void extract (const db::Polygon &polygon, const std::vector &vertex_ports, const std::vector &polygon_ports, RNetwork &rnetwork) = 0; }; -// @@@ -class PEX_PUBLIC SquareCountingRExtractor - : public RExtractor -{ -public: - SquareCountingRExtractor (double dbu); - - db::plc::ConvexDecompositionParameters &decomposition_parameters () - { - return m_decomp_param; - } - - void set_dbu (double dbu) - { - m_dbu = dbu; - } - - double dbu () const - { - return m_dbu; - } - - virtual void extract (const db::Polygon &polygon, const std::vector &vertex_ports, const std::vector &polygon_ports, RNetwork &rnetwork); - -private: - db::plc::ConvexDecompositionParameters m_decomp_param; - double m_dbu; -}; - } #endif diff --git a/src/pex/pex/pexSquareCountingRExtractor.cc b/src/pex/pex/pexSquareCountingRExtractor.cc new file mode 100644 index 000000000..76f00b80a --- /dev/null +++ b/src/pex/pex/pexSquareCountingRExtractor.cc @@ -0,0 +1,60 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2025 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 "pexSquareCountingRExtractor.h" + +namespace pex +{ + +SquareCountingRExtractor::SquareCountingRExtractor (double dbu) +{ + m_dbu = dbu; + + m_decomp_param.split_edges = true; + m_decomp_param.with_segments = false; +} + +void +SquareCountingRExtractor::extract (const db::Polygon &polygon, const std::vector &vertex_ports, const std::vector &polygon_ports, RNetwork &rnetwork) +{ + db::CplxTrans trans = db::CplxTrans (m_dbu) * db::ICplxTrans (db::Trans (db::Point () - polygon.box ().center ())); + auto inv_trans = trans.inverted (); + + db::plc::Graph plc; + + db::plc::ConvexDecomposition decomp (&plc); + decomp.decompose (polygon, vertex_ports, m_decomp_param, trans); + + std::vector > decomp_polygons; + for (auto p = plc.begin (); p != plc.end (); ++p) { + // @@@decomp_polygons.push_back (db::Polygon ()); + // @@@decomp_polygons.back ().first = inv_trans * p->polygon (); + } + + // @@@ use box_scanner to find interactions between polygon_ports and decomp_polygons + +} + +} + + diff --git a/src/pex/pex/pexSquareCountingRExtractor.h b/src/pex/pex/pexSquareCountingRExtractor.h new file mode 100644 index 000000000..99881099b --- /dev/null +++ b/src/pex/pex/pexSquareCountingRExtractor.h @@ -0,0 +1,66 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2025 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_pexSquareCountingRExtractor +#define HDR_pexSquareCountingRExtractor + +#include "pexCommon.h" +#include "pexRExtractor.h" + +#include "dbPLCConvexDecomposition.h" + +namespace pex +{ + +// @@@ doc +class PEX_PUBLIC SquareCountingRExtractor + : public RExtractor +{ +public: + SquareCountingRExtractor (double dbu); + + db::plc::ConvexDecompositionParameters &decomposition_parameters () + { + return m_decomp_param; + } + + void set_dbu (double dbu) + { + m_dbu = dbu; + } + + double dbu () const + { + return m_dbu; + } + + virtual void extract (const db::Polygon &polygon, const std::vector &vertex_ports, const std::vector &polygon_ports, RNetwork &rnetwork); + +private: + db::plc::ConvexDecompositionParameters m_decomp_param; + double m_dbu; +}; + +} + +#endif + diff --git a/src/pex/unit_tests/pexSquareCountingRExtractorTests.cc b/src/pex/unit_tests/pexSquareCountingRExtractorTests.cc new file mode 100644 index 000000000..613d630b9 --- /dev/null +++ b/src/pex/unit_tests/pexSquareCountingRExtractorTests.cc @@ -0,0 +1,60 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2025 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 "pexSquareCountingRExtractor.h" +#include "tlUnitTest.h" + +TEST(basic) +{ + db::Point contour[] = { + db::Point (0, 0), + db::Point (0, 100), + db::Point (1000, 100), + db::Point (1000, 1000), + db::Point (1100, 1000), + db::Point (1100, 100), + db::Point (1700, 100), + db::Point (1700, 0) + }; + + db::Polygon poly; + poly.assign_hull (contour + 0, contour + sizeof (contour) / sizeof (contour[0])); + + double dbu = 0.001; + + pex::RNetwork rn; + pex::SquareCountingRExtractor rex (dbu); + + std::vector vertex_ports; + vertex_ports.push_back (db::Point (0, 50)); + vertex_ports.push_back (db::Point (1650, 50)); + + std::vector polygon_ports; + polygon_ports.push_back (db::Polygon (db::Box (1000, 900, 1100, 1000))); + + rex.extract (poly, vertex_ports, polygon_ports, rn); + + EXPECT_EQ (rn.to_string (), + "" + ) +} diff --git a/src/pex/unit_tests/unit_tests.pro b/src/pex/unit_tests/unit_tests.pro index c6ccc1b74..6c380c340 100644 --- a/src/pex/unit_tests/unit_tests.pro +++ b/src/pex/unit_tests/unit_tests.pro @@ -8,6 +8,7 @@ include($$PWD/../../lib_ut.pri) SOURCES = \ pexRExtractorTests.cc \ + pexSquareCountingRExtractorTests.cc INCLUDEPATH += $$TL_INC $$DB_INC $$GSI_INC $$PEX_INC DEPENDPATH += $$TL_INC $$DB_INC $$GSI_INC $$PEX_INC