mirror of https://github.com/KLayout/klayout.git
WIP
This commit is contained in:
parent
ebc96d8de4
commit
c532a3a7e6
|
|
@ -150,7 +150,7 @@ AsIfFlatEdges::selected_interacting_generic (const Region &other, EdgeInteractio
|
|||
|
||||
std::vector<generic_shape_iterator<db::Polygon> > others;
|
||||
// NOTE: with counting the other region needs to be merged
|
||||
others.push_back (counting ? other.begin_merged () : other.begin ());
|
||||
others.push_back (counting || mode == EdgesInside ? other.begin_merged () : other.begin ());
|
||||
|
||||
proc.run_flat (edges, others, std::vector<bool> (), &op, oph.results ());
|
||||
|
||||
|
|
@ -162,7 +162,6 @@ AsIfFlatEdges::selected_interacting_generic (const Edges &other, EdgeInteraction
|
|||
{
|
||||
min_count = std::max (size_t (1), min_count);
|
||||
|
||||
// @@@
|
||||
// shortcuts
|
||||
if (max_count < min_count || other.empty () || empty ()) {
|
||||
return ((mode == EdgesOutside) == inverse) ? new EmptyEdges () : clone ();
|
||||
|
|
@ -182,7 +181,7 @@ AsIfFlatEdges::selected_interacting_generic (const Edges &other, EdgeInteraction
|
|||
|
||||
std::vector<generic_shape_iterator<db::Edge> > others;
|
||||
// NOTE: with counting the other edge collection needs to be merged
|
||||
others.push_back (counting ? other.begin_merged () : other.begin ());
|
||||
others.push_back (counting || mode == EdgesInside ? other.begin_merged () : other.begin ());
|
||||
|
||||
proc.run_flat (edges, others, std::vector<bool> (), &op, oph.results ());
|
||||
|
||||
|
|
@ -194,7 +193,6 @@ AsIfFlatEdges::selected_interacting_pair_generic (const Region &other, EdgeInter
|
|||
{
|
||||
min_count = std::max (size_t (1), min_count);
|
||||
|
||||
// @@@
|
||||
// shortcuts
|
||||
if (max_count < min_count || other.empty () || empty ()) {
|
||||
if (mode != EdgesOutside) {
|
||||
|
|
@ -218,7 +216,7 @@ AsIfFlatEdges::selected_interacting_pair_generic (const Region &other, EdgeInter
|
|||
|
||||
std::vector<generic_shape_iterator<db::Polygon> > others;
|
||||
// NOTE: with counting the other region needs to be merged
|
||||
others.push_back (counting ? other.begin_merged () : other.begin ());
|
||||
others.push_back (counting || mode == EdgesInside ? other.begin_merged () : other.begin ());
|
||||
|
||||
proc.run_flat (edges, others, std::vector<bool> (), &op, oph.results ());
|
||||
|
||||
|
|
@ -230,7 +228,6 @@ AsIfFlatEdges::selected_interacting_pair_generic (const Edges &other, EdgeIntera
|
|||
{
|
||||
min_count = std::max (size_t (1), min_count);
|
||||
|
||||
// @@@
|
||||
// shortcuts
|
||||
if (max_count < min_count || other.empty () || empty ()) {
|
||||
if (mode != EdgesOutside) {
|
||||
|
|
@ -254,7 +251,7 @@ AsIfFlatEdges::selected_interacting_pair_generic (const Edges &other, EdgeIntera
|
|||
|
||||
std::vector<generic_shape_iterator<db::Edge> > others;
|
||||
// NOTE: with counting the other edge collection needs to be merged
|
||||
others.push_back (counting ? other.begin_merged () : other.begin ());
|
||||
others.push_back (counting || mode == EdgesInside ? other.begin_merged () : other.begin ());
|
||||
|
||||
proc.run_flat (edges, others, std::vector<bool> (), &op, oph.results ());
|
||||
|
||||
|
|
|
|||
|
|
@ -1357,7 +1357,8 @@ RegionDelegate *DeepEdges::extended (coord_type ext_b, coord_type ext_e, coord_t
|
|||
EdgesDelegate *
|
||||
DeepEdges::selected_interacting_generic (const Region &other, EdgeInteractionMode mode, bool inverse, size_t min_count, size_t max_count) const
|
||||
{
|
||||
// @@@
|
||||
min_count = std::max (size_t (1), min_count);
|
||||
|
||||
std::unique_ptr<db::DeepRegion> dr_holder;
|
||||
const db::DeepRegion *other_deep = dynamic_cast<const db::DeepRegion *> (other.delegate ());
|
||||
if (! other_deep) {
|
||||
|
|
@ -1384,7 +1385,8 @@ DeepEdges::selected_interacting_generic (const Region &other, EdgeInteractionMod
|
|||
std::pair<EdgesDelegate *, EdgesDelegate *>
|
||||
DeepEdges::selected_interacting_pair_generic (const Region &other, EdgeInteractionMode mode, size_t min_count, size_t max_count) const
|
||||
{
|
||||
// @@@
|
||||
min_count = std::max (size_t (1), min_count);
|
||||
|
||||
std::unique_ptr<db::DeepRegion> dr_holder;
|
||||
const db::DeepRegion *other_deep = dynamic_cast<const db::DeepRegion *> (other.delegate ());
|
||||
if (! other_deep) {
|
||||
|
|
@ -1417,7 +1419,8 @@ DeepEdges::selected_interacting_pair_generic (const Region &other, EdgeInteracti
|
|||
EdgesDelegate *
|
||||
DeepEdges::selected_interacting_generic (const Edges &other, EdgeInteractionMode mode, bool inverse, size_t min_count, size_t max_count) const
|
||||
{
|
||||
// @@@
|
||||
min_count = std::max (size_t (1), min_count);
|
||||
|
||||
std::unique_ptr<db::DeepEdges> dr_holder;
|
||||
const db::DeepEdges *other_deep = dynamic_cast<const db::DeepEdges *> (other.delegate ());
|
||||
if (! other_deep) {
|
||||
|
|
@ -1444,7 +1447,8 @@ DeepEdges::selected_interacting_generic (const Edges &other, EdgeInteractionMode
|
|||
std::pair<EdgesDelegate *, EdgesDelegate *>
|
||||
DeepEdges::selected_interacting_pair_generic (const Edges &other, EdgeInteractionMode mode, size_t min_count, size_t max_count) const
|
||||
{
|
||||
// @@@
|
||||
min_count = std::max (size_t (1), min_count);
|
||||
|
||||
std::unique_ptr<db::DeepEdges> dr_holder;
|
||||
const db::DeepEdges *other_deep = dynamic_cast<const db::DeepEdges *> (other.delegate ());
|
||||
if (! other_deep) {
|
||||
|
|
|
|||
|
|
@ -344,6 +344,7 @@ public:
|
|||
{
|
||||
// NOTE: "counting" does not really make much sense in Outside mode ...
|
||||
m_counting = !(min_count == 1 && max_count == std::numeric_limits<size_t>::max ());
|
||||
tl_assert (!m_counting || mode != EdgesOutside);
|
||||
}
|
||||
|
||||
void finish (const db::Edge *o, size_t p)
|
||||
|
|
@ -450,6 +451,7 @@ public:
|
|||
{
|
||||
// NOTE: "counting" does not really make much sense in Outside mode ...
|
||||
m_counting = !(min_count == 1 && max_count == std::numeric_limits<size_t>::max ());
|
||||
tl_assert (!m_counting || mode != EdgesOutside);
|
||||
}
|
||||
|
||||
void finish (const OutputType *o)
|
||||
|
|
|
|||
|
|
@ -83,5 +83,25 @@ TEST(1)
|
|||
EXPECT_EQ (db::edge_is_outside (db::Edge (db::Point (0, 11), db::Point (10, 11)), db::Polygon (db::Box (0, 0, 10, 10))), true);
|
||||
EXPECT_EQ (db::edge_is_outside (db::Edge (db::Point (0, 5), db::Point (10, 5)), db::Polygon (db::Box (0, 0, 10, 10))), false);
|
||||
EXPECT_EQ (db::edge_is_outside (db::Edge (db::Point (-5, 5), db::Point (15, 5)), db::Polygon (db::Box (0, 0, 10, 10))), false);
|
||||
EXPECT_EQ (db::edge_is_outside (db::Edge (db::Point (-10, 5), db::Point (0, 5)), db::Polygon (db::Box (0, 0, 10, 10))), true);
|
||||
EXPECT_EQ (db::edge_is_outside (db::Edge (db::Point (-10, 0), db::Point (10, 0)), db::Polygon (db::Box (0, 0, 10, 10))), true);
|
||||
|
||||
db::Point pts[] = {
|
||||
db::Point (0, 0),
|
||||
db::Point (0, 10),
|
||||
db::Point (20, 10),
|
||||
db::Point (20, -10),
|
||||
db::Point (10, -10),
|
||||
db::Point (10, 0)
|
||||
};
|
||||
|
||||
db::Polygon poly;
|
||||
poly.assign_hull (pts + 0, pts + sizeof(pts) / sizeof(pts[0]));
|
||||
|
||||
EXPECT_EQ (db::edge_is_outside (db::Edge (db::Point (-10, 10), db::Point (20, 10)), poly), true);
|
||||
EXPECT_EQ (db::edge_is_outside (db::Edge (db::Point (-10, -10), db::Point (20, -10)), poly), true);
|
||||
EXPECT_EQ (db::edge_is_outside (db::Edge (db::Point (-10, 0), db::Point (11, 0)), poly), false);
|
||||
EXPECT_EQ (db::edge_is_outside (db::Edge (db::Point (-10, 0), db::Point (10, 0)), poly), true);
|
||||
EXPECT_EQ (db::edge_is_outside (db::Edge (db::Point (-10, 0), db::Point (9, 0)), poly), true);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue