Refactoring: separated sources for db::Region

This commit is contained in:
Matthias Koefferlein 2018-11-07 22:17:51 +01:00
parent 885a440089
commit 8107e1bb51
15 changed files with 3310 additions and 5721 deletions

View File

@ -119,7 +119,12 @@ SOURCES = \
gsiDeclDbVector.cc \
gsiDeclDbLayoutDiff.cc \
gsiDeclDbGlyphs.cc \
dbConverters.cc
dbConverters.cc \
dbAsIfFlatRegion.cc \
dbEmptyRegion.cc \
dbFlatRegion.cc \
dbOriginalLayerRegion.cc \
dbRegionDelegate.cc
HEADERS = \
dbArray.h \
@ -208,7 +213,12 @@ HEADERS = \
dbForceLink.h \
dbPlugin.h \
dbInit.h \
dbConverters.h
dbConverters.h \
dbAsIfFlatRegion.h \
dbEmptyRegion.h \
dbFlatRegion.h \
dbOriginalLayerRegion.h \
dbRegionDelegate.h
!equals(HAVE_QT, "0") {

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,226 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2018 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_dbAsIfFlatRegion
#define HDR_dbAsIfFlatRegion
#include "dbCommon.h"
#include "dbRegionDelegate.h"
namespace db {
/**
* @brief Provides default flat implementations
*/
class DB_PUBLIC AsIfFlatRegion
: public RegionDelegate
{
public:
AsIfFlatRegion ();
virtual ~AsIfFlatRegion ();
virtual bool is_box () const;
virtual size_t size () const;
virtual area_type area (const db::Box &box) const;
virtual perimeter_type perimeter (const db::Box &box) const;
virtual Box bbox () const;
virtual std::string to_string (size_t nmax) const;
EdgePairs width_check (db::Coord d, bool whole_edges, metrics_type metrics, double ignore_angle, distance_type min_projection, distance_type max_projection) const
{
return run_single_polygon_check (db::WidthRelation, d, whole_edges, metrics, ignore_angle, min_projection, max_projection);
}
EdgePairs space_check (db::Coord d, bool whole_edges, metrics_type metrics, double ignore_angle, distance_type min_projection, distance_type max_projection) const
{
return run_check (db::SpaceRelation, false, 0, d, whole_edges, metrics, ignore_angle, min_projection, max_projection);
}
EdgePairs isolated_check (db::Coord d, bool whole_edges, metrics_type metrics, double ignore_angle, distance_type min_projection, distance_type max_projection) const
{
return run_check (db::SpaceRelation, true, 0, d, whole_edges, metrics, ignore_angle, min_projection, max_projection);
}
EdgePairs notch_check (db::Coord d, bool whole_edges, metrics_type metrics, double ignore_angle, distance_type min_projection, distance_type max_projection) const
{
return run_single_polygon_check (db::SpaceRelation, d, whole_edges, metrics, ignore_angle, min_projection, max_projection);
}
EdgePairs enclosing_check (const Region &other, db::Coord d, bool whole_edges, metrics_type metrics, double ignore_angle, distance_type min_projection, distance_type max_projection) const
{
return run_check (db::OverlapRelation, true, &other, d, whole_edges, metrics, ignore_angle, min_projection, max_projection);
}
EdgePairs overlap_check (const Region &other, db::Coord d, bool whole_edges, metrics_type metrics, double ignore_angle, distance_type min_projection, distance_type max_projection) const
{
return run_check (db::WidthRelation, true, &other, d, whole_edges, metrics, ignore_angle, min_projection, max_projection);
}
EdgePairs separation_check (const Region &other, db::Coord d, bool whole_edges, metrics_type metrics, double ignore_angle, distance_type min_projection, distance_type max_projection) const
{
return run_check (db::SpaceRelation, true, &other, d, whole_edges, metrics, ignore_angle, min_projection, max_projection);
}
EdgePairs inside_check (const Region &other, db::Coord d, bool whole_edges, metrics_type metrics, double ignore_angle, distance_type min_projection, distance_type max_projection) const
{
return run_check (db::InsideRelation, true, &other, d, whole_edges, metrics, ignore_angle, min_projection, max_projection);
}
virtual EdgePairs grid_check (db::Coord gx, db::Coord gy) const;
virtual EdgePairs angle_check (double min, double max, bool inverse) const;
virtual RegionDelegate *snapped_in_place (db::Coord gx, db::Coord gy)
{
return snapped (gx, gy);
}
virtual RegionDelegate *snapped (db::Coord gx, db::Coord gy);
virtual Edges edges (const EdgeFilterBase *) const;
virtual RegionDelegate *filter_in_place (const PolygonFilterBase &filter)
{
return filtered (filter);
}
virtual RegionDelegate *filtered (const PolygonFilterBase &filter) const;
virtual RegionDelegate *merged_in_place ()
{
return merged ();
}
virtual RegionDelegate *merged_in_place (bool min_coherence, unsigned int min_wc)
{
return merged (min_coherence, min_wc);
}
virtual RegionDelegate *merged () const
{
return merged (min_coherence (), 0);
}
virtual RegionDelegate *merged (bool min_coherence, unsigned int min_wc) const;
virtual RegionDelegate *strange_polygon_check () const;
virtual RegionDelegate *sized (coord_type d, unsigned int mode) const;
virtual RegionDelegate *sized (coord_type dx, coord_type dy, unsigned int mode) const;
virtual RegionDelegate *and_with (const Region &other) const;
virtual RegionDelegate *not_with (const Region &other) const;
virtual RegionDelegate *xor_with (const Region &other) const;
virtual RegionDelegate *or_with (const Region &other) const;
virtual RegionDelegate *add_in_place (const Region &other)
{
return add (other);
}
virtual RegionDelegate *add (const Region &other) const;
virtual RegionDelegate *selected_outside (const Region &other) const
{
return selected_interacting_generic (other, 1, false, false);
}
virtual RegionDelegate *selected_not_outside (const Region &other) const
{
return selected_interacting_generic (other, 1, false, true);
}
virtual RegionDelegate *selected_inside (const Region &other) const
{
return selected_interacting_generic (other, -1, true, false);
}
virtual RegionDelegate *selected_not_inside (const Region &other) const
{
return selected_interacting_generic (other, -1, true, true);
}
virtual RegionDelegate *selected_interacting (const Region &other) const
{
return selected_interacting_generic (other, 0, true, false);
}
virtual RegionDelegate *selected_not_interacting (const Region &other) const
{
return selected_interacting_generic (other, 0, true, true);
}
virtual RegionDelegate *selected_interacting (const Edges &other) const
{
return selected_interacting_generic (other, false);
}
virtual RegionDelegate *selected_not_interacting (const Edges &other) const
{
return selected_interacting_generic (other, true);
}
virtual RegionDelegate *selected_overlapping (const Region &other) const
{
return selected_interacting_generic (other, 0, false, false);
}
virtual RegionDelegate *selected_not_overlapping (const Region &other) const
{
return selected_interacting_generic (other, 0, false, true);
}
virtual RegionDelegate *holes () const;
virtual RegionDelegate *hulls () const;
virtual RegionDelegate *in (const Region &other, bool invert) const;
virtual RegionDelegate *rounded_corners (double rinner, double router, unsigned int n) const;
virtual RegionDelegate *smoothed (coord_type d) const;
virtual bool equals (const Region &other) const;
virtual bool less (const Region &other) const;
protected:
void update_bbox (const db::Box &box);
void invalidate_bbox ();
private:
AsIfFlatRegion &operator= (const AsIfFlatRegion &other);
mutable bool m_bbox_valid;
mutable db::Box m_bbox;
virtual db::Box compute_bbox () const;
static RegionDelegate *region_from_box (const db::Box &b);
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;
RegionDelegate *selected_interacting_generic (const Region &other, int mode, bool touching, bool inverse) const;
RegionDelegate *selected_interacting_generic (const Edges &other, bool inverse) const;
};
}
#endif

View File

@ -28,6 +28,7 @@
#include "dbBoxConvert.h"
#include "dbBoxScanner.h"
#include "dbPolygonTools.h"
#include "dbShapeProcessor.h"
#include "tlIntervalMap.h"
#include "tlVariant.h"

View File

@ -0,0 +1,98 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2018 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 "dbEmptyRegion.h"
#include "dbRegion.h"
namespace db
{
// -------------------------------------------------------------------------------------------------------------
// EmptyRegion implementation
EmptyRegion::EmptyRegion ()
{
// .. nothing yet ..
}
EmptyRegion::~EmptyRegion ()
{
// .. nothing yet ..
}
EmptyRegion::EmptyRegion (const EmptyRegion &other)
: RegionDelegate (other)
{
// .. nothing yet ..
}
RegionDelegate *
EmptyRegion::clone () const
{
return new EmptyRegion (*this);
}
RegionDelegate *
EmptyRegion::add_in_place (const Region &other)
{
return add (other);
}
RegionDelegate *
EmptyRegion::add (const Region &other) const
{
return other.delegate ()->clone ();
}
RegionDelegate *
EmptyRegion::xor_with (const Region &other) const
{
return or_with (other);
}
RegionDelegate *
EmptyRegion::or_with (const Region &other) const
{
if (other.empty ()) {
return new EmptyRegion ();
} else if (! other.strict_handling ()) {
return other.delegate ()->clone ();
} else {
return other.delegate ()->merged ();
}
}
bool
EmptyRegion::equals (const Region &other) const
{
return other.empty ();
}
bool
EmptyRegion::less (const Region &other) const
{
return other.empty () ? false : true;
}
}

130
src/db/db/dbEmptyRegion.h Normal file
View File

@ -0,0 +1,130 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2018 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_dbEmptyRegion
#define HDR_dbEmptyRegion
#include "dbCommon.h"
#include "dbRegionDelegate.h"
namespace db {
/**
* @brief An empty Region
*/
class DB_PUBLIC EmptyRegion
: public RegionDelegate
{
public:
EmptyRegion ();
virtual ~EmptyRegion ();
EmptyRegion (const EmptyRegion &other);
RegionDelegate *clone () const;
virtual RegionIteratorDelegate *begin () const { return 0; }
virtual RegionIteratorDelegate *begin_merged () const { return 0; }
virtual std::pair<db::RecursiveShapeIterator, db::ICplxTrans> begin_iter () const { return std::make_pair (db::RecursiveShapeIterator (), db::ICplxTrans ()); }
virtual std::pair<db::RecursiveShapeIterator, db::ICplxTrans> begin_merged_iter () const { return std::make_pair (db::RecursiveShapeIterator (), db::ICplxTrans ()); }
virtual bool empty () const { return true; }
virtual size_t size () const { return 0; }
virtual std::string to_string (size_t) const { return std::string (); }
virtual bool is_box () const { return false; }
virtual bool is_merged () const { return true; }
virtual area_type area (const db::Box &) const { return 0; }
virtual perimeter_type perimeter (const db::Box &) const { return 0; }
virtual Box bbox () const { return Box (); }
virtual EdgePairs width_check (db::Coord, bool, metrics_type, double, distance_type, distance_type) const { return EdgePairs (); }
virtual EdgePairs space_check (db::Coord, bool, metrics_type, double, distance_type, distance_type) const { return EdgePairs (); }
virtual EdgePairs isolated_check (db::Coord, bool, metrics_type, double, distance_type, distance_type) const { return EdgePairs (); }
virtual EdgePairs notch_check (db::Coord, bool, metrics_type, double, distance_type, distance_type) const { return EdgePairs (); }
virtual EdgePairs enclosing_check (const Region &, db::Coord, bool, metrics_type, double, distance_type, distance_type) const { return EdgePairs (); }
virtual EdgePairs overlap_check (const Region &, db::Coord, bool, metrics_type, double, distance_type, distance_type) const { return EdgePairs (); }
virtual EdgePairs separation_check (const Region &, db::Coord, bool , metrics_type, double, distance_type, distance_type) const { return EdgePairs (); }
virtual EdgePairs inside_check (const Region &, db::Coord, bool, metrics_type, double, distance_type, distance_type) const { return EdgePairs (); }
virtual EdgePairs grid_check (db::Coord, db::Coord) const { return EdgePairs (); }
virtual EdgePairs angle_check (double, double, bool) const { return EdgePairs (); }
virtual RegionDelegate *snapped_in_place (db::Coord, db::Coord) { return this; }
virtual RegionDelegate *snapped (db::Coord, db::Coord) { return new EmptyRegion (); }
virtual RegionDelegate *strange_polygon_check () const { return new EmptyRegion (); }
virtual Edges edges (const EdgeFilterBase *) const { return db::Edges (); }
virtual RegionDelegate *filter_in_place (const PolygonFilterBase &) { return this; }
virtual RegionDelegate *filtered (const PolygonFilterBase &) const { return new EmptyRegion (); }
virtual RegionDelegate *merged_in_place () { return this; }
virtual RegionDelegate *merged_in_place (bool, unsigned int) { return this; }
virtual RegionDelegate *merged () const { return new EmptyRegion (); }
virtual RegionDelegate *merged (bool, unsigned int) const { return new EmptyRegion (); }
virtual RegionDelegate *sized (coord_type, unsigned int) const { return new EmptyRegion (); }
virtual RegionDelegate *sized (coord_type, coord_type, unsigned int) const { return new EmptyRegion (); }
virtual RegionDelegate *and_with (const Region &) const { return new EmptyRegion (); }
virtual RegionDelegate *not_with (const Region &) const { return new EmptyRegion (); }
virtual RegionDelegate *xor_with (const Region &other) const;
virtual RegionDelegate *or_with (const Region &other) const;
virtual RegionDelegate *add_in_place (const Region &other);
virtual RegionDelegate *add (const Region &other) const;
virtual RegionDelegate *selected_outside (const Region &) const { return new EmptyRegion (); }
virtual RegionDelegate *selected_not_outside (const Region &) const { return new EmptyRegion (); }
virtual RegionDelegate *selected_inside (const Region &) const { return new EmptyRegion (); }
virtual RegionDelegate *selected_not_inside (const Region &) const { return new EmptyRegion (); }
virtual RegionDelegate *selected_interacting (const Region &) const { return new EmptyRegion (); }
virtual RegionDelegate *selected_not_interacting (const Region &) const { return new EmptyRegion (); }
virtual RegionDelegate *selected_interacting (const Edges &) const { return new EmptyRegion (); }
virtual RegionDelegate *selected_not_interacting (const Edges &) const { return new EmptyRegion (); }
virtual RegionDelegate *selected_overlapping (const Region &) const { return new EmptyRegion (); }
virtual RegionDelegate *selected_not_overlapping (const Region &) const { return new EmptyRegion (); }
virtual RegionDelegate *holes () const { return new EmptyRegion (); }
virtual RegionDelegate *hulls () const { return new EmptyRegion (); }
virtual RegionDelegate *in (const Region &, bool) const { return new EmptyRegion (); }
virtual RegionDelegate *rounded_corners (double, double, unsigned int) const { return new EmptyRegion (); }
virtual RegionDelegate *smoothed (coord_type) const { return new EmptyRegion (); }
virtual bool has_valid_polygons () const { return true; }
virtual bool has_valid_merged_polygons () const { return true; }
virtual const db::Polygon *nth (size_t) const { tl_assert (false); }
virtual const db::RecursiveShapeIterator *iter () const { return 0; }
virtual bool equals (const Region &other) const;
virtual bool less (const Region &other) const;
private:
EmptyRegion &operator= (const EmptyRegion &other);
};
} // namespace db
#endif

432
src/db/db/dbFlatRegion.cc Normal file
View File

@ -0,0 +1,432 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2018 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 "dbFlatRegion.h"
#include "dbEmptyRegion.h"
#include "dbRegion.h"
#include "dbShapeProcessor.h"
namespace db
{
// -------------------------------------------------------------------------------------------------------------
// FlatRegion implementation
FlatRegion::FlatRegion ()
: AsIfFlatRegion (), m_polygons (false), m_merged_polygons (false)
{
init ();
}
FlatRegion::~FlatRegion ()
{
// .. nothing yet ..
}
FlatRegion::FlatRegion (const FlatRegion &other)
: AsIfFlatRegion (other), m_polygons (false), m_merged_polygons (false)
{
init ();
m_is_merged = other.m_is_merged;
m_polygons = other.m_polygons;
m_merged_polygons = other.m_merged_polygons;
m_merged_polygons_valid = other.m_merged_polygons_valid;
}
FlatRegion::FlatRegion (const db::Shapes &polygons, bool is_merged)
: AsIfFlatRegion (), m_polygons (polygons), m_merged_polygons (false)
{
init ();
m_is_merged = is_merged;
}
FlatRegion::FlatRegion (bool is_merged)
: AsIfFlatRegion (), m_polygons (false), m_merged_polygons (false)
{
init ();
m_is_merged = is_merged;
}
void FlatRegion::set_is_merged (bool m)
{
m_is_merged = m;
}
void FlatRegion::invalidate_cache ()
{
invalidate_bbox ();
m_merged_polygons.clear ();
m_merged_polygons_valid = false;
}
void FlatRegion::init ()
{
m_is_merged = true;
m_merged_polygons_valid = false;
}
void FlatRegion::merged_semantics_changed ()
{
m_merged_polygons.clear ();
m_merged_polygons_valid = false;
}
void FlatRegion::reserve (size_t n)
{
m_polygons.reserve (db::Polygon::tag (), n);
}
void
FlatRegion::ensure_merged_polygons_valid () const
{
if (! m_merged_polygons_valid) {
m_merged_polygons.clear ();
db::EdgeProcessor ep (report_progress (), progress_desc ());
// count edges and reserve memory
size_t n = 0;
for (RegionIterator p (begin ()); ! p.at_end (); ++p) {
n += p->vertices ();
}
ep.reserve (n);
// insert the polygons into the processor
n = 0;
for (RegionIterator p (begin ()); ! p.at_end (); ++p, ++n) {
ep.insert (*p, n);
}
// and run the merge step
db::MergeOp op (0);
db::ShapeGenerator pc (m_merged_polygons);
db::PolygonGenerator pg (pc, false /*don't resolve holes*/, min_coherence ());
ep.process (pg, op);
m_merged_polygons_valid = true;
}
}
RegionIteratorDelegate *FlatRegion::begin () const
{
return new FlatRegionIterator (m_polygons.get_layer<db::Polygon, db::unstable_layer_tag> ().begin (), m_polygons.get_layer<db::Polygon, db::unstable_layer_tag> ().end ());
}
RegionIteratorDelegate *FlatRegion::begin_merged () const
{
if (! merged_semantics () || m_is_merged) {
return begin ();
} else {
ensure_merged_polygons_valid ();
return new FlatRegionIterator (m_merged_polygons.get_layer<db::Polygon, db::unstable_layer_tag> ().begin (), m_merged_polygons.get_layer<db::Polygon, db::unstable_layer_tag> ().end ());
}
}
std::pair<db::RecursiveShapeIterator, db::ICplxTrans> FlatRegion::begin_iter () const
{
return std::make_pair (db::RecursiveShapeIterator (m_polygons), db::ICplxTrans ());
}
std::pair<db::RecursiveShapeIterator, db::ICplxTrans> FlatRegion::begin_merged_iter () const
{
if (! merged_semantics () || m_is_merged) {
return begin_iter ();
} else {
ensure_merged_polygons_valid ();
return std::make_pair (db::RecursiveShapeIterator (m_merged_polygons), db::ICplxTrans ());
}
}
bool FlatRegion::empty () const
{
return m_polygons.empty ();
}
size_t FlatRegion::size () const
{
return m_polygons.size ();
}
bool FlatRegion::is_merged () const
{
return m_is_merged;
}
Box FlatRegion::compute_bbox () const
{
m_polygons.update_bbox ();
return m_polygons.bbox ();
}
RegionDelegate *FlatRegion::filter_in_place (const PolygonFilterBase &filter)
{
polygon_iterator_type pw = m_polygons.get_layer<db::Polygon, db::unstable_layer_tag> ().begin ();
for (RegionIterator p (begin_merged ()); ! p.at_end (); ++p) {
if (filter.selected (*p)) {
if (pw == m_polygons.get_layer<db::Polygon, db::unstable_layer_tag> ().end ()) {
m_polygons.get_layer<db::Polygon, db::unstable_layer_tag> ().insert (*p);
pw = m_polygons.get_layer<db::Polygon, db::unstable_layer_tag> ().end ();
} else {
m_polygons.get_layer<db::Polygon, db::unstable_layer_tag> ().replace (pw++, *p);
}
}
}
m_polygons.get_layer<db::Polygon, db::unstable_layer_tag> ().erase (pw, m_polygons.get_layer<db::Polygon, db::unstable_layer_tag> ().end ());
m_merged_polygons.clear ();
m_is_merged = merged_semantics ();
return this;
}
RegionDelegate *FlatRegion::merged_in_place ()
{
if (! m_is_merged) {
if (m_merged_polygons_valid) {
m_polygons.swap (m_merged_polygons);
m_merged_polygons.clear ();
m_is_merged = true;
return this;
} else {
return merged_in_place (min_coherence (), 0);
}
} else {
return this;
}
}
RegionDelegate *FlatRegion::merged_in_place (bool min_coherence, unsigned int min_wc)
{
if (empty ()) {
// ignore empty
return new EmptyRegion ();
} else if (is_box ()) {
// take box only if min_wc == 0, otherwise clear
if (min_wc > 0) {
return new EmptyRegion ();
}
} else {
invalidate_cache ();
db::EdgeProcessor ep (report_progress (), progress_desc ());
// count edges and reserve memory
size_t n = 0;
for (RegionIterator p (begin ()); ! p.at_end (); ++p) {
n += p->vertices ();
}
ep.reserve (n);
// insert the polygons into the processor
n = 0;
for (RegionIterator p (begin ()); ! p.at_end (); ++p, ++n) {
ep.insert (*p, n);
}
// and run the merge step
db::MergeOp op (min_wc);
db::ShapeGenerator pc (m_polygons, true /*clear*/);
db::PolygonGenerator pg (pc, false /*don't resolve holes*/, min_coherence);
ep.process (pg, op);
m_is_merged = true;
}
return this;
}
RegionDelegate *FlatRegion::merged () const
{
if (! m_is_merged) {
if (m_merged_polygons_valid) {
return new FlatRegion (m_merged_polygons, true);
} else {
return AsIfFlatRegion::merged (min_coherence (), 0);
}
} else {
return clone ();
}
}
RegionDelegate *FlatRegion::add (const Region &other) const
{
std::auto_ptr<FlatRegion> new_region (new FlatRegion (*this));
new_region->invalidate_cache ();
new_region->set_is_merged (false);
FlatRegion *other_flat = dynamic_cast<FlatRegion *> (other.delegate ());
if (other_flat) {
new_region->raw_polygons ().insert (other_flat->raw_polygons ().get_layer<db::Polygon, db::unstable_layer_tag> ().begin (), other_flat->raw_polygons ().get_layer<db::Polygon, db::unstable_layer_tag> ().end ());
} else {
size_t n = new_region->raw_polygons ().size ();
for (RegionIterator p (other.begin ()); ! p.at_end (); ++p) {
++n;
}
new_region->raw_polygons ().reserve (db::Polygon::tag (), n);
for (RegionIterator p (other.begin ()); ! p.at_end (); ++p) {
new_region->raw_polygons ().insert (*p);
}
}
return new_region.release ();
}
RegionDelegate *FlatRegion::add_in_place (const Region &other)
{
invalidate_cache ();
m_is_merged = false;
FlatRegion *other_flat = dynamic_cast<FlatRegion *> (other.delegate ());
if (other_flat) {
m_polygons.insert (other_flat->raw_polygons ().get_layer<db::Polygon, db::unstable_layer_tag> ().begin (), other_flat->raw_polygons ().get_layer<db::Polygon, db::unstable_layer_tag> ().end ());
} else {
size_t n = m_polygons.size ();
for (RegionIterator p (other.begin ()); ! p.at_end (); ++p) {
++n;
}
m_polygons.reserve (db::Polygon::tag (), n);
for (RegionIterator p (other.begin ()); ! p.at_end (); ++p) {
m_polygons.insert (*p);
}
}
return this;
}
const db::Polygon *FlatRegion::nth (size_t n) const
{
return n < m_polygons.size () ? &m_polygons.get_layer<db::Polygon, db::unstable_layer_tag> ().begin () [n] : 0;
}
bool FlatRegion::has_valid_polygons () const
{
return true;
}
bool FlatRegion::has_valid_merged_polygons () const
{
return true;
}
const db::RecursiveShapeIterator *FlatRegion::iter () const
{
return 0;
}
void
FlatRegion::insert (const db::Box &box)
{
if (! box.empty () && box.width () > 0 && box.height () > 0) {
if (empty ()) {
m_polygons.insert (db::Polygon (box));
m_is_merged = true;
update_bbox (box);
} else {
m_polygons.insert (db::Polygon (box));
m_is_merged = false;
invalidate_cache ();
}
}
}
void
FlatRegion::insert (const db::Path &path)
{
if (path.points () > 0) {
m_polygons.insert (path.polygon ());
m_is_merged = false;
invalidate_cache ();
}
}
void
FlatRegion::insert (const db::Polygon &polygon)
{
if (polygon.holes () > 0 || polygon.vertices () > 0) {
m_polygons.insert (polygon);
m_is_merged = false;
invalidate_cache ();
}
}
void
FlatRegion::insert (const db::SimplePolygon &polygon)
{
if (polygon.vertices () > 0) {
db::Polygon poly;
poly.assign_hull (polygon.begin_hull (), polygon.end_hull ());
m_polygons.insert (poly);
m_is_merged = false;
invalidate_cache ();
}
}
void
FlatRegion::insert (const db::Shape &shape)
{
if (shape.is_polygon () || shape.is_path () || shape.is_box ()) {
db::Polygon poly;
shape.polygon (poly);
m_polygons.insert (poly);
m_is_merged = false;
invalidate_cache ();
}
}
}

197
src/db/db/dbFlatRegion.h Normal file
View File

@ -0,0 +1,197 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2018 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_dbFlatRegion
#define HDR_dbFlatRegion
#include "dbCommon.h"
#include "dbAsIfFlatRegion.h"
#include "dbShapes.h"
#include "dbShapes2.h"
namespace db {
/**
* @brief An iterator delegate for the flat region
*/
class DB_PUBLIC FlatRegionIterator
: public RegionIteratorDelegate
{
public:
typedef db::layer<db::Polygon, db::unstable_layer_tag> polygon_layer_type;
typedef polygon_layer_type::iterator iterator_type;
FlatRegionIterator (iterator_type from, iterator_type to)
: m_from (from), m_to (to)
{
// .. nothing yet ..
}
virtual bool at_end () const
{
return m_from == m_to;
}
virtual void increment ()
{
++m_from;
}
virtual const value_type *get () const
{
return m_from.operator-> ();
}
virtual RegionIteratorDelegate *clone () const
{
return new FlatRegionIterator (*this);
}
private:
friend class Region;
iterator_type m_from, m_to;
};
/**
* @brief A flat, polygon-set delegate
*/
class DB_PUBLIC FlatRegion
: public AsIfFlatRegion
{
public:
typedef db::layer<db::Polygon, db::unstable_layer_tag> polygon_layer_type;
typedef polygon_layer_type::iterator polygon_iterator_type;
FlatRegion ();
FlatRegion (const db::Shapes &polygons, bool is_merged);
FlatRegion (bool is_merged);
FlatRegion (const FlatRegion &other);
virtual ~FlatRegion ();
RegionDelegate *clone () const
{
return new FlatRegion (*this);
}
void reserve (size_t);
virtual RegionIteratorDelegate *begin () const;
virtual RegionIteratorDelegate *begin_merged () const;
virtual std::pair<db::RecursiveShapeIterator, db::ICplxTrans> begin_iter () const;
virtual std::pair<db::RecursiveShapeIterator, db::ICplxTrans> begin_merged_iter () const;
virtual bool empty () const;
virtual size_t size () const;
virtual bool is_merged () const;
virtual RegionDelegate *merged_in_place ();
virtual RegionDelegate *merged_in_place (bool min_coherence, unsigned int min_wc);
virtual RegionDelegate *merged () const;
virtual RegionDelegate *filter_in_place (const PolygonFilterBase &filter);
virtual RegionDelegate *add_in_place (const Region &other);
virtual RegionDelegate *add (const Region &other) const;
virtual const db::Polygon *nth (size_t n) const;
virtual bool has_valid_polygons () const;
virtual bool has_valid_merged_polygons () const;
virtual const db::RecursiveShapeIterator *iter () const;
void insert (const db::Box &box);
void insert (const db::Path &path);
void insert (const db::SimplePolygon &polygon);
void insert (const db::Polygon &polygon);
void insert (const db::Shape &shape);
template <class T>
void insert (const db::Shape &shape, const T &trans)
{
if (shape.is_polygon () || shape.is_path () || shape.is_box ()) {
db::Polygon poly;
shape.polygon (poly);
poly.transform (trans);
insert (poly);
}
}
template <class Iter>
void insert (const Iter &b, const Iter &e)
{
reserve (size () + (e - b));
for (Iter i = b; i != e; ++i) {
insert (*i);
}
}
template <class Iter>
void insert_seq (const Iter &seq)
{
for (Iter i = seq; ! i.at_end (); ++i) {
insert (*i);
}
}
template <class Trans>
void transform (const Trans &trans)
{
if (! trans.is_unity ()) {
for (polygon_iterator_type p = m_polygons.get_layer<db::Polygon, db::unstable_layer_tag> ().begin (); p != m_polygons.get_layer<db::Polygon, db::unstable_layer_tag> ().end (); ++p) {
m_polygons.get_layer<db::Polygon, db::unstable_layer_tag> ().replace (p, p->transformed (trans));
}
invalidate_cache ();
}
}
protected:
virtual void merged_semantics_changed ();
virtual Box compute_bbox () const;
void invalidate_cache ();
void set_is_merged (bool m);
private:
friend class AsIfFlatRegion;
db::Shapes &raw_polygons () { return m_polygons; }
FlatRegion &operator= (const FlatRegion &other);
bool m_is_merged;
mutable db::Shapes m_polygons;
mutable db::Shapes m_merged_polygons;
mutable bool m_merged_polygons_valid;
void init ();
void ensure_merged_polygons_valid () const;
};
}
#endif

View File

@ -0,0 +1,274 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2018 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 "dbOriginalLayerRegion.h"
#include "dbFlatRegion.h"
#include "dbRegion.h"
#include "dbShapeProcessor.h"
namespace db
{
// -------------------------------------------------------------------------------------------------------------
// OriginalLayerRegion implementation
namespace
{
class OriginalLayerRegionIterator
: public RegionIteratorDelegate
{
public:
OriginalLayerRegionIterator (const db::RecursiveShapeIterator &iter, const db::ICplxTrans &trans)
: m_rec_iter (iter), m_iter_trans (trans)
{
set ();
}
virtual bool at_end () const
{
return m_rec_iter.at_end ();
}
virtual void increment ()
{
inc ();
set ();
}
virtual const value_type *get () const
{
return &m_polygon;
}
virtual RegionIteratorDelegate *clone () const
{
return new OriginalLayerRegionIterator (*this);
}
private:
friend class Region;
db::RecursiveShapeIterator m_rec_iter;
db::ICplxTrans m_iter_trans;
db::Polygon m_polygon;
void set ()
{
while (! m_rec_iter.at_end () && ! (m_rec_iter.shape ().is_polygon () || m_rec_iter.shape ().is_path () || m_rec_iter.shape ().is_box ())) {
++m_rec_iter;
}
if (! m_rec_iter.at_end ()) {
m_rec_iter.shape ().polygon (m_polygon);
m_polygon.transform (m_iter_trans * m_rec_iter.trans (), false);
}
}
void inc ()
{
if (! m_rec_iter.at_end ()) {
++m_rec_iter;
}
}
};
}
OriginalLayerRegion::OriginalLayerRegion ()
: AsIfFlatRegion (), m_merged_polygons (false)
{
init ();
}
OriginalLayerRegion::OriginalLayerRegion (const OriginalLayerRegion &other)
: AsIfFlatRegion (other),
m_is_merged (other.m_is_merged),
m_merged_polygons (other.m_merged_polygons),
m_merged_polygons_valid (other.m_merged_polygons_valid),
m_iter (other.m_iter),
m_iter_trans (other.m_iter_trans)
{
// .. nothing yet ..
}
OriginalLayerRegion::OriginalLayerRegion (const RecursiveShapeIterator &si, bool is_merged)
: AsIfFlatRegion (), m_merged_polygons (false), m_iter (si)
{
init ();
m_is_merged = is_merged;
}
OriginalLayerRegion::OriginalLayerRegion (const RecursiveShapeIterator &si, const db::ICplxTrans &trans, bool merged_semantics, bool is_merged)
: AsIfFlatRegion (), m_merged_polygons (false), m_iter (si), m_iter_trans (trans)
{
init ();
m_is_merged = is_merged;
set_merged_semantics (merged_semantics);
}
OriginalLayerRegion::~OriginalLayerRegion ()
{
// .. nothing yet ..
}
RegionDelegate *
OriginalLayerRegion::clone () const
{
return new OriginalLayerRegion (*this);
}
RegionIteratorDelegate *
OriginalLayerRegion::begin () const
{
return new OriginalLayerRegionIterator (m_iter, m_iter_trans);
}
RegionIteratorDelegate *
OriginalLayerRegion::begin_merged () const
{
if (! merged_semantics () || m_is_merged) {
return begin ();
} else {
ensure_merged_polygons_valid ();
return new FlatRegionIterator (m_merged_polygons.get_layer<db::Polygon, db::unstable_layer_tag> ().begin (), m_merged_polygons.get_layer<db::Polygon, db::unstable_layer_tag> ().end ());
}
}
std::pair<db::RecursiveShapeIterator, db::ICplxTrans>
OriginalLayerRegion::begin_iter () const
{
return std::make_pair (m_iter, m_iter_trans);
}
std::pair<db::RecursiveShapeIterator, db::ICplxTrans>
OriginalLayerRegion::begin_merged_iter () const
{
if (! merged_semantics () || m_is_merged) {
return begin_iter ();
} else {
ensure_merged_polygons_valid ();
return std::make_pair (db::RecursiveShapeIterator (m_merged_polygons), db::ICplxTrans ());
}
}
bool
OriginalLayerRegion::empty () const
{
return m_iter.at_end ();
}
bool
OriginalLayerRegion::is_merged () const
{
return m_is_merged;
}
const db::Polygon *
OriginalLayerRegion::nth (size_t) const
{
tl_assert (false);
}
bool
OriginalLayerRegion::has_valid_polygons () const
{
return false;
}
bool
OriginalLayerRegion::has_valid_merged_polygons () const
{
return merged_semantics () && ! m_is_merged;
}
const db::RecursiveShapeIterator *
OriginalLayerRegion::iter () const
{
return &m_iter;
}
bool
OriginalLayerRegion::equals (const Region &other) const
{
const OriginalLayerRegion *other_delegate = dynamic_cast<const OriginalLayerRegion *> (other.delegate ());
if (other_delegate && other_delegate->m_iter == m_iter && other_delegate->m_iter_trans == m_iter_trans) {
return true;
} else {
return AsIfFlatRegion::equals (other);
}
}
bool
OriginalLayerRegion::less (const Region &other) const
{
const OriginalLayerRegion *other_delegate = dynamic_cast<const OriginalLayerRegion *> (other.delegate ());
if (other_delegate && other_delegate->m_iter == m_iter && other_delegate->m_iter_trans == m_iter_trans) {
return false;
} else {
return AsIfFlatRegion::less (other);
}
}
void
OriginalLayerRegion::init ()
{
m_is_merged = true;
m_merged_polygons_valid = false;
}
void
OriginalLayerRegion::ensure_merged_polygons_valid () const
{
if (! m_merged_polygons_valid) {
m_merged_polygons.clear ();
db::EdgeProcessor ep (report_progress (), progress_desc ());
// count edges and reserve memory
size_t n = 0;
for (RegionIterator p (begin ()); ! p.at_end (); ++p) {
n += p->vertices ();
}
ep.reserve (n);
// insert the polygons into the processor
n = 0;
for (RegionIterator p (begin ()); ! p.at_end (); ++p, ++n) {
ep.insert (*p, n);
}
// and run the merge step
db::MergeOp op (0);
db::ShapeGenerator pc (m_merged_polygons);
db::PolygonGenerator pg (pc, false /*don't resolve holes*/, min_coherence ());
ep.process (pg, op);
m_merged_polygons_valid = true;
}
}
}

View File

@ -0,0 +1,83 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2018 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_dbOriginalLayerRegion
#define HDR_dbOriginalLayerRegion
#include "dbCommon.h"
#include "dbAsIfFlatRegion.h"
namespace db {
/**
* @brief An original layerregion based on a RecursiveShapeIterator
*/
class DB_PUBLIC OriginalLayerRegion
: public AsIfFlatRegion
{
public:
OriginalLayerRegion ();
OriginalLayerRegion (const OriginalLayerRegion &other);
OriginalLayerRegion (const RecursiveShapeIterator &si, bool is_merged = false);
OriginalLayerRegion (const RecursiveShapeIterator &si, const db::ICplxTrans &trans, bool merged_semantics, bool is_merged = false);
virtual ~OriginalLayerRegion ();
RegionDelegate *clone () const;
virtual RegionIteratorDelegate *begin () const;
virtual RegionIteratorDelegate *begin_merged () const;
virtual std::pair<db::RecursiveShapeIterator, db::ICplxTrans> begin_iter () const;
virtual std::pair<db::RecursiveShapeIterator, db::ICplxTrans> begin_merged_iter () const;
virtual bool empty () const;
virtual bool is_merged () const;
virtual const db::Polygon *nth (size_t n) const;
virtual bool has_valid_polygons () const;
virtual bool has_valid_merged_polygons () const;
virtual const db::RecursiveShapeIterator *iter () const;
virtual bool equals (const Region &other) const;
virtual bool less (const Region &other) const;
private:
OriginalLayerRegion &operator= (const OriginalLayerRegion &other);
bool m_is_merged;
mutable db::Shapes m_merged_polygons;
mutable bool m_merged_polygons_valid;
mutable db::RecursiveShapeIterator m_iter;
db::ICplxTrans m_iter_trans;
void init ();
void ensure_merged_polygons_valid () const;
};
}
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,91 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2018 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 "dbRegionDelegate.h"
namespace db
{
// -------------------------------------------------------------------------------------------------------------
RegionDelegate::RegionDelegate ()
{
m_report_progress = false;
m_merged_semantics = true;
m_strict_handling = false;
m_merge_min_coherence = false;
}
RegionDelegate::RegionDelegate (const RegionDelegate &other)
{
operator= (other);
}
RegionDelegate &
RegionDelegate::operator= (const RegionDelegate &other)
{
if (this != &other) {
m_report_progress = other.m_report_progress;
m_merged_semantics = other.m_merged_semantics;
m_strict_handling = other.m_strict_handling;
m_merge_min_coherence = other.m_merge_min_coherence;
}
return *this;
}
RegionDelegate::~RegionDelegate ()
{
// .. nothing yet ..
}
void RegionDelegate::enable_progress (const std::string &progress_desc)
{
m_report_progress = true;
m_progress_desc = progress_desc;
}
void RegionDelegate::disable_progress ()
{
m_report_progress = false;
}
void RegionDelegate::set_min_coherence (bool f)
{
m_merge_min_coherence = f;
}
void RegionDelegate::set_merged_semantics (bool f)
{
if (f != m_merged_semantics) {
m_merged_semantics = f;
merged_semantics_changed ();
}
}
void RegionDelegate::set_strict_handling (bool f)
{
m_strict_handling = f;
}
}

View File

@ -0,0 +1,206 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2018 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_dbRegionDelegate
#define HDR_dbRegionDelegate
#include "dbCommon.h"
#include "dbPolygon.h"
#include "dbEdges.h"
#include "dbEdgePairs.h"
#include "dbEdgePairRelations.h"
#include <list>
namespace db {
class RecursiveShapeIterator;
class EdgeFilterBase;
class PolygonFilterBase;
/**
* @brief The region iterator delegate
*/
class DB_PUBLIC RegionIteratorDelegate
{
public:
RegionIteratorDelegate () { }
virtual ~RegionIteratorDelegate () { }
typedef db::Polygon value_type;
virtual bool at_end () const = 0;
virtual void increment () = 0;
virtual const value_type *get () const = 0;
virtual RegionIteratorDelegate *clone () const = 0;
};
/**
* @brief The delegate for the actual region implementation
*/
class DB_PUBLIC RegionDelegate
{
public:
typedef db::Coord coord_type;
typedef db::coord_traits<db::Coord> coord_traits;
typedef db::Polygon polygon_type;
typedef db::Vector vector_type;
typedef db::Point point_type;
typedef db::Box box_type;
typedef coord_traits::distance_type distance_type;
typedef coord_traits::perimeter_type perimeter_type;
typedef coord_traits::area_type area_type;
RegionDelegate ();
virtual ~RegionDelegate ();
RegionDelegate (const RegionDelegate &other);
RegionDelegate &operator= (const RegionDelegate &other);
virtual RegionDelegate *clone () const = 0;
void enable_progress (const std::string &progress_desc);
void disable_progress ();
void set_min_coherence (bool f);
bool min_coherence () const
{
return m_merge_min_coherence;
}
void set_merged_semantics (bool f);
bool merged_semantics () const
{
return m_merged_semantics;
}
void set_strict_handling (bool f);
bool strict_handling () const
{
return m_strict_handling;
}
virtual std::string to_string (size_t nmax) const = 0;
virtual RegionIteratorDelegate *begin () const = 0;
virtual RegionIteratorDelegate *begin_merged () const = 0;
virtual std::pair<db::RecursiveShapeIterator, db::ICplxTrans> begin_iter () const = 0;
virtual std::pair<db::RecursiveShapeIterator, db::ICplxTrans> begin_merged_iter () const = 0;
virtual bool empty () const = 0;
virtual bool is_box () const = 0;
virtual bool is_merged () const = 0;
virtual size_t size () const = 0;
virtual area_type area (const db::Box &box) const = 0;
virtual perimeter_type perimeter (const db::Box &box) const = 0;
virtual Box bbox () const = 0;
virtual EdgePairs width_check (db::Coord d, bool whole_edges, metrics_type metrics, double ignore_angle, distance_type min_projection, distance_type max_projection) const = 0;
virtual EdgePairs space_check (db::Coord d, bool whole_edges, metrics_type metrics, double ignore_angle, distance_type min_projection, distance_type max_projection) const = 0;
virtual EdgePairs isolated_check (db::Coord d, bool whole_edges, metrics_type metrics, double ignore_angle, distance_type min_projection, distance_type max_projection) const = 0;
virtual EdgePairs notch_check (db::Coord d, bool whole_edges, metrics_type metrics, double ignore_angle, distance_type min_projection, distance_type max_projection) const = 0;
virtual EdgePairs enclosing_check (const Region &other, db::Coord d, bool whole_edges, metrics_type metrics, double ignore_angle, distance_type min_projection, distance_type max_projection) const = 0;
virtual EdgePairs overlap_check (const Region &other, db::Coord d, bool whole_edges, metrics_type metrics, double ignore_angle, distance_type min_projection, distance_type max_projection) const = 0;
virtual EdgePairs separation_check (const Region &other, db::Coord d, bool whole_edges, metrics_type metrics, double ignore_angle, distance_type min_projection, distance_type max_projection) const = 0;
virtual EdgePairs inside_check (const Region &other, db::Coord d, bool whole_edges, metrics_type metrics, double ignore_angle, distance_type min_projection, distance_type max_projection) const = 0;
virtual EdgePairs grid_check (db::Coord gx, db::Coord gy) const = 0;
virtual EdgePairs angle_check (double min, double max, bool inverse) const = 0;
virtual RegionDelegate *snapped_in_place (db::Coord gx, db::Coord gy) = 0;
virtual RegionDelegate *snapped (db::Coord gx, db::Coord gy) = 0;
virtual Edges edges (const EdgeFilterBase *filter) const = 0;
virtual RegionDelegate *filter_in_place (const PolygonFilterBase &filter) = 0;
virtual RegionDelegate *filtered (const PolygonFilterBase &filter) const = 0;
virtual RegionDelegate *merged_in_place () = 0;
virtual RegionDelegate *merged_in_place (bool min_coherence, unsigned int min_wc) = 0;
virtual RegionDelegate *merged () const = 0;
virtual RegionDelegate *merged (bool min_coherence, unsigned int min_wc) const = 0;
virtual RegionDelegate *strange_polygon_check () const = 0;
virtual RegionDelegate *sized (coord_type d, unsigned int mode) const = 0;
virtual RegionDelegate *sized (coord_type dx, coord_type dy, unsigned int mode) const = 0;
virtual RegionDelegate *and_with (const Region &other) const = 0;
virtual RegionDelegate *not_with (const Region &other) const = 0;
virtual RegionDelegate *xor_with (const Region &other) const = 0;
virtual RegionDelegate *or_with (const Region &other) const = 0;
virtual RegionDelegate *add_in_place (const Region &other) = 0;
virtual RegionDelegate *add (const Region &other) const = 0;
virtual RegionDelegate *selected_outside (const Region &other) const = 0;
virtual RegionDelegate *selected_not_outside (const Region &other) const = 0;
virtual RegionDelegate *selected_inside (const Region &other) const = 0;
virtual RegionDelegate *selected_not_inside (const Region &other) const = 0;
virtual RegionDelegate *selected_interacting (const Region &other) const = 0;
virtual RegionDelegate *selected_not_interacting (const Region &other) const = 0;
virtual RegionDelegate *selected_interacting (const Edges &other) const = 0;
virtual RegionDelegate *selected_not_interacting (const Edges &other) const = 0;
virtual RegionDelegate *selected_overlapping (const Region &other) const = 0;
virtual RegionDelegate *selected_not_overlapping (const Region &other) const = 0;
virtual RegionDelegate *holes () const = 0;
virtual RegionDelegate *hulls () const = 0;
virtual RegionDelegate *in (const Region &other, bool invert) const = 0;
virtual RegionDelegate *rounded_corners (double rinner, double router, unsigned int n) const = 0;
virtual RegionDelegate *smoothed (coord_type d) const = 0;
virtual const db::Polygon *nth (size_t n) const = 0;
virtual bool has_valid_polygons () const = 0;
virtual bool has_valid_merged_polygons () const = 0;
virtual const db::RecursiveShapeIterator *iter () const = 0;
virtual bool equals (const Region &other) const = 0;
virtual bool less (const Region &other) const = 0;
protected:
const std::string &progress_desc () const
{
return m_progress_desc;
}
bool report_progress () const
{
return m_report_progress;
}
virtual void merged_semantics_changed () { }
private:
bool m_merged_semantics;
bool m_strict_handling;
bool m_merge_min_coherence;
bool m_report_progress;
std::string m_progress_desc;
};
}
#endif

View File

@ -29,6 +29,7 @@
#include "gsiDecl.h"
#include "dbWriter.h"
#include "dbSaveLayoutOptions.h"
#include "dbShapeProcessor.h"
#include <cstdlib>
#include <QMutex>