mirror of https://github.com/KLayout/klayout.git
WIP: introducing points as valid objects into database - implementation. Includes: edge pair perimeter and area.
This commit is contained in:
parent
cca20773a7
commit
4d04cf4fe3
|
|
@ -56,7 +56,7 @@ class ArrayRepository;
|
|||
* coordinates box).
|
||||
*/
|
||||
|
||||
template <class C, class R = C>
|
||||
template <class C, class R>
|
||||
struct DB_PUBLIC_TEMPLATE box
|
||||
{
|
||||
typedef C coord_type;
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ public:
|
|||
typedef db::coord_traits<C> coord_traits;
|
||||
typedef typename coord_traits::distance_type distance_type;
|
||||
typedef typename coord_traits::area_type area_type;
|
||||
typedef typename coord_traits::perimeter_type perimeter_type;
|
||||
typedef db::object_tag< edge_pair<C> > tag;
|
||||
|
||||
/**
|
||||
|
|
@ -379,6 +380,30 @@ public:
|
|||
return box_type (m_first.p1 (), m_first.p2 ()) + box_type (m_second.p1 (), m_second.p2 ());
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the perimeter of the edge pair
|
||||
*
|
||||
* The perimeter is defined by then sum of the lengths of the edges ("active perimeter")
|
||||
*/
|
||||
perimeter_type perimeter () const
|
||||
{
|
||||
return m_first.length () + m_second.length ();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the area of the edge pair
|
||||
*
|
||||
* This is the area covered between the edges.
|
||||
*/
|
||||
area_type area () const
|
||||
{
|
||||
vector_type v12 = m_first.p2 () - m_first.p1 ();
|
||||
vector_type v13 = m_second.p1 () - m_first.p1 ();
|
||||
vector_type v14 = m_second.p2 () - m_first.p1 ();
|
||||
area_type a = (db::vprod (v12, v13) + db::vprod (v13, v14)) / 2;
|
||||
return a < 0 ? -a : a;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test if the edges are orthogonal (vertical or horizontal)
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
#include "dbCommon.h"
|
||||
|
||||
#include "dbTypes.h"
|
||||
#include "dbObjectTag.h"
|
||||
#include "tlString.h"
|
||||
#include "tlTypeTraits.h"
|
||||
#include "tlVector.h"
|
||||
|
|
@ -37,6 +38,9 @@
|
|||
namespace db {
|
||||
|
||||
template <class C> class vector;
|
||||
template <class C, class R = C> struct box;
|
||||
template <class C> class generic_repository;
|
||||
class ArrayRepository;
|
||||
|
||||
/**
|
||||
* @brief A point class
|
||||
|
|
@ -51,6 +55,9 @@ public:
|
|||
typedef db::vector<C> vector_type;
|
||||
typedef typename coord_traits::distance_type distance_type;
|
||||
typedef typename coord_traits::area_type area_type;
|
||||
typedef db::object_tag< point<C> > tag;
|
||||
typedef db::box<C> box_type;
|
||||
typedef db::point<C> point_type;
|
||||
|
||||
/**
|
||||
* @brief Default constructor
|
||||
|
|
@ -321,6 +328,24 @@ public:
|
|||
*/
|
||||
bool less (const point<C> &p) const;
|
||||
|
||||
/**
|
||||
* @brief The (dummy) translation operator
|
||||
*/
|
||||
void translate (const point<C> &d, db::generic_repository<C> &, db::ArrayRepository &)
|
||||
{
|
||||
*this = d;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief The (dummy) translation operator
|
||||
*/
|
||||
template <class T>
|
||||
void translate (const point<C> &d, const T &t, db::generic_repository<C> &, db::ArrayRepository &)
|
||||
{
|
||||
*this = d;
|
||||
transform (t);
|
||||
}
|
||||
|
||||
private:
|
||||
C m_x, m_y;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -95,6 +95,8 @@ db::properties_id_type Shape::prop_id () const
|
|||
return (**((pedge_iter_type *) m_generic.iter)).properties_id ();
|
||||
case EdgePair:
|
||||
return (**((pedge_pair_iter_type *) m_generic.iter)).properties_id ();
|
||||
case Point:
|
||||
return (**((ppoint_iter_type *) m_generic.iter)).properties_id ();
|
||||
case Path:
|
||||
return (**((ppath_iter_type *) m_generic.iter)).properties_id ();
|
||||
case PathRef:
|
||||
|
|
@ -144,6 +146,8 @@ db::properties_id_type Shape::prop_id () const
|
|||
return m_generic.pedge->properties_id ();
|
||||
case EdgePair:
|
||||
return m_generic.pedge_pair->properties_id ();
|
||||
case Point:
|
||||
return m_generic.ppoint->properties_id ();
|
||||
case Path:
|
||||
return m_generic.ppath->properties_id ();
|
||||
case PathRef:
|
||||
|
|
@ -564,6 +568,9 @@ Shape::box_type Shape::box () const
|
|||
return m_trans * basic_ptr (box_array_type::tag ())->object ();
|
||||
} else if (m_type == ShortBoxArrayMember) {
|
||||
return m_trans * basic_ptr (short_box_array_type::tag ())->object ();
|
||||
} else if (m_type == Point) {
|
||||
point_type pt = point ();
|
||||
return m_trans * box_type (pt, pt);
|
||||
} else {
|
||||
raise_no_box ();
|
||||
}
|
||||
|
|
@ -614,6 +621,12 @@ Shape::perimeter_type Shape::perimeter () const
|
|||
const short_box_array_type *arr = basic_ptr (short_box_array_type::tag ());
|
||||
return arr->size () * arr->object ().perimeter ();
|
||||
}
|
||||
case Point:
|
||||
return 0;
|
||||
case Edge:
|
||||
return edge ().length ();
|
||||
case EdgePair:
|
||||
return edge_pair ().perimeter ();
|
||||
case Box:
|
||||
case ShortBox:
|
||||
case BoxArrayMember:
|
||||
|
|
@ -629,6 +642,9 @@ size_t Shape::array_size () const
|
|||
switch (m_type) {
|
||||
case Null:
|
||||
return 0;
|
||||
case Point:
|
||||
case Edge:
|
||||
case EdgePair:
|
||||
case Polygon:
|
||||
case PolygonRef:
|
||||
case PolygonPtrArrayMember:
|
||||
|
|
@ -681,6 +697,11 @@ Shape::area_type Shape::area () const
|
|||
switch (m_type) {
|
||||
case Null:
|
||||
return area_type ();
|
||||
case Point:
|
||||
case Edge:
|
||||
return 0;
|
||||
case EdgePair:
|
||||
return edge_pair ().area ();
|
||||
case Polygon:
|
||||
return polygon ().area ();
|
||||
case PolygonRef:
|
||||
|
|
@ -761,6 +782,8 @@ Shape::box_type Shape::bbox () const
|
|||
return box_type (edge ().p1 (), edge ().p2 ());
|
||||
case EdgePair:
|
||||
return edge_pair ().bbox ();
|
||||
case Point:
|
||||
return box_type (point (), point ());
|
||||
case Path:
|
||||
return path ().box ();
|
||||
case PathRef:
|
||||
|
|
@ -835,6 +858,9 @@ Shape::to_string () const
|
|||
case EdgePair:
|
||||
r = "edge_pair " + edge_pair ().to_string ();
|
||||
break;
|
||||
case Point:
|
||||
r = "point " + point ().to_string ();
|
||||
break;
|
||||
case Path:
|
||||
case PathRef:
|
||||
case PathPtrArrayMember:
|
||||
|
|
|
|||
|
|
@ -645,6 +645,7 @@ public:
|
|||
typedef tl::reuse_vector<db::array<path_ptr_type, disp_type> >::const_iterator path_ptr_array_iter_type;
|
||||
typedef tl::reuse_vector<db::edge<coord_type> >::const_iterator edge_iter_type;
|
||||
typedef tl::reuse_vector<db::edge_pair<coord_type> >::const_iterator edge_pair_iter_type;
|
||||
typedef tl::reuse_vector<db::point<coord_type> >::const_iterator point_iter_type;
|
||||
typedef tl::reuse_vector<db::text<coord_type> >::const_iterator text_iter_type;
|
||||
typedef tl::reuse_vector<db::text_ref<text_type, disp_type> >::const_iterator text_ref_iter_type;
|
||||
typedef tl::reuse_vector<db::text_ref<text_type, unit_trans_type> >::const_iterator text_ptr_iter_type;
|
||||
|
|
@ -669,6 +670,7 @@ public:
|
|||
typedef tl::reuse_vector<db::object_with_properties<db::array<path_ptr_type, disp_type> > >::const_iterator ppath_ptr_array_iter_type;
|
||||
typedef tl::reuse_vector<db::object_with_properties<db::edge<coord_type> > >::const_iterator pedge_iter_type;
|
||||
typedef tl::reuse_vector<db::object_with_properties<db::edge_pair<coord_type> > >::const_iterator pedge_pair_iter_type;
|
||||
typedef tl::reuse_vector<db::object_with_properties<db::point<coord_type> > >::const_iterator ppoint_iter_type;
|
||||
typedef tl::reuse_vector<db::object_with_properties<db::text<coord_type> > >::const_iterator ptext_iter_type;
|
||||
typedef tl::reuse_vector<db::object_with_properties<db::text_ref<text_type, disp_type> > >::const_iterator ptext_ref_iter_type;
|
||||
typedef tl::reuse_vector<db::object_with_properties<db::text_ref<text_type, unit_trans_type> > >::const_iterator ptext_ptr_iter_type;
|
||||
|
|
@ -709,6 +711,7 @@ public:
|
|||
TextRef,
|
||||
TextPtrArray,
|
||||
TextPtrArrayMember,
|
||||
Point,
|
||||
UserObject
|
||||
};
|
||||
|
||||
|
|
@ -1029,6 +1032,14 @@ public:
|
|||
m_type = EdgePair;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Construct a shape proxy as a reference to a point
|
||||
*/
|
||||
void init (point_type::tag)
|
||||
{
|
||||
m_type = Point;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Construct a shape proxy as a reference to a box
|
||||
*/
|
||||
|
|
@ -1373,6 +1384,22 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return the actual object that this shape reference is pointing to
|
||||
*
|
||||
* This is a generalization of the polygon (), etc. methods using a tag to identify the
|
||||
* target object.
|
||||
*/
|
||||
const point_type *basic_ptr (point_type::tag) const
|
||||
{
|
||||
tl_assert (m_type == Point);
|
||||
if (m_stable) {
|
||||
return m_with_props ? &**(((ppoint_iter_type *) m_generic.iter)) : &**(((ppoint_iter_type *) m_generic.iter));
|
||||
} else {
|
||||
return m_with_props ? m_generic.ppoint : m_generic.point;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return the actual object that this shape reference is pointing to
|
||||
*
|
||||
|
|
@ -1682,6 +1709,23 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return the actual object that this shape reference is pointing to for objects with properties
|
||||
*
|
||||
* This is a generalization of the polygon (), etc. methods using a tag to identify the
|
||||
* target object.
|
||||
*/
|
||||
const db::object_with_properties<point_type> *basic_ptr (db::object_with_properties<point_type>::tag) const
|
||||
{
|
||||
tl_assert (m_type == Point);
|
||||
tl_assert (m_with_props);
|
||||
if (m_stable) {
|
||||
return &**(((ppoint_iter_type *) m_generic.iter));
|
||||
} else {
|
||||
return m_generic.ppoint;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return the actual object that this shape reference is pointing to for objects with properties
|
||||
*
|
||||
|
|
@ -1917,6 +1961,15 @@ public:
|
|||
return *(((edge_pair_iter_type *) m_generic.iter));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return the iterator (in stable reference mode) by tag
|
||||
*/
|
||||
point_iter_type basic_iter (point_type::tag) const
|
||||
{
|
||||
tl_assert (m_type == Point && ! m_with_props);
|
||||
return *(((point_iter_type *) m_generic.iter));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return the iterator (in stable reference mode) by tag
|
||||
*/
|
||||
|
|
@ -2088,6 +2141,15 @@ public:
|
|||
return *(((pedge_pair_iter_type *) m_generic.iter));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return the iterator (in stable reference mode) by tag for objects with properties
|
||||
*/
|
||||
ppoint_iter_type basic_iter (db::object_with_properties<point_type>::tag) const
|
||||
{
|
||||
tl_assert (m_type == Point && m_with_props);
|
||||
return *(((ppoint_iter_type *) m_generic.iter));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return the iterator (in stable reference mode) by tag for objects with properties
|
||||
*/
|
||||
|
|
@ -2395,6 +2457,49 @@ public:
|
|||
return edge_pair (p);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return a reference to the point if one is referenced
|
||||
*/
|
||||
const point_type &point () const
|
||||
{
|
||||
tl_assert (m_type == Point);
|
||||
return *basic_ptr (point_type::tag ());
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test if the shape proxy points to a point
|
||||
*/
|
||||
bool is_point () const
|
||||
{
|
||||
return (m_type == Point);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Instantiate the edge object
|
||||
*
|
||||
* If a edge is referenced, this object is instantiated
|
||||
* by this method.
|
||||
* Returns true, if the conversion was successful.
|
||||
*/
|
||||
bool point (point_type &p) const
|
||||
{
|
||||
if (is_point ()) {
|
||||
p = point ();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Alias for polymorphic expansion
|
||||
* Returns true, if the conversion was successful.
|
||||
*/
|
||||
bool instantiate (point_type &p) const
|
||||
{
|
||||
return point (p);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return a reference to the text if one is referenced
|
||||
*/
|
||||
|
|
@ -2675,6 +2780,7 @@ public:
|
|||
const text_ptr_array_type *text_aref;
|
||||
const edge_type *edge;
|
||||
const edge_pair_type *edge_pair;
|
||||
const point_type *point;
|
||||
const path_type *path;
|
||||
const path_ref_type *path_ref;
|
||||
const path_ptr_array_type *path_aref;
|
||||
|
|
@ -2695,6 +2801,7 @@ public:
|
|||
const db::object_with_properties<text_ptr_array_type> *ptext_aref;
|
||||
const db::object_with_properties<edge_type> *pedge;
|
||||
const db::object_with_properties<edge_pair_type> *pedge_pair;
|
||||
const db::object_with_properties<point_type> *ppoint;
|
||||
const db::object_with_properties<path_type> *ppath;
|
||||
const db::object_with_properties<path_ref_type> *ppath_ref;
|
||||
const db::object_with_properties<path_ptr_array_type> *ppath_aref;
|
||||
|
|
|
|||
|
|
@ -641,6 +641,9 @@ ShapeIterator::advance_generic (int mode)
|
|||
case EdgePair:
|
||||
if (advance_shape<edge_pair_type, StableTag, RegionTag> (mode)) return;
|
||||
break;
|
||||
case Point:
|
||||
if (advance_shape<point_type, StableTag, RegionTag> (mode)) return;
|
||||
break;
|
||||
case Path:
|
||||
if (advance_shape<path_type, StableTag, RegionTag> (mode)) return;
|
||||
break;
|
||||
|
|
@ -767,6 +770,8 @@ ShapeIterator::quad_box_generic () const
|
|||
return (quad_box_by_shape<edge_type, StableTag> (region_tag));
|
||||
case EdgePair:
|
||||
return (quad_box_by_shape<edge_pair_type, StableTag> (region_tag));
|
||||
case Point:
|
||||
return (quad_box_by_shape<point_type, StableTag> (region_tag));
|
||||
case Path:
|
||||
return (quad_box_by_shape<path_type, StableTag> (region_tag));
|
||||
case PathRef:
|
||||
|
|
|
|||
|
|
@ -375,6 +375,8 @@ Shapes::do_insert (const Shapes::shape_type &shape, const Shapes::unit_trans_typ
|
|||
return (insert_by_tag (shape_type::edge_type::tag (), shape, pm));
|
||||
case shape_type::EdgePair:
|
||||
return (insert_by_tag (shape_type::edge_pair_type::tag (), shape, pm));
|
||||
case shape_type::Point:
|
||||
return (insert_by_tag (shape_type::point_type::tag (), shape, pm));
|
||||
case shape_type::Path:
|
||||
return (insert_by_tag (shape_type::path_type::tag (), shape, pm));
|
||||
case shape_type::PathRef:
|
||||
|
|
@ -531,6 +533,16 @@ Shapes::do_insert (const Shapes::shape_type &shape, const Trans &t, tl::func_del
|
|||
return insert (db::object_with_properties<shape_type::edge_type> (p, pm (shape.prop_id ())));
|
||||
}
|
||||
}
|
||||
case shape_type::Point:
|
||||
{
|
||||
shape_type::point_type p (shape.point ());
|
||||
p = t.trans (p);
|
||||
if (! shape.has_prop_id ()) {
|
||||
return insert (p);
|
||||
} else {
|
||||
return insert (db::object_with_properties<shape_type::point_type> (p, pm (shape.prop_id ())));
|
||||
}
|
||||
}
|
||||
case shape_type::EdgePair:
|
||||
{
|
||||
shape_type::edge_pair_type p (shape.edge_pair ());
|
||||
|
|
@ -658,6 +670,8 @@ Shapes::find (const Shapes::shape_type &shape) const
|
|||
return find_shape_by_tag (shape_type::edge_type::tag (), shape);
|
||||
case shape_type::EdgePair:
|
||||
return find_shape_by_tag (shape_type::edge_pair_type::tag (), shape);
|
||||
case shape_type::Point:
|
||||
return find_shape_by_tag (shape_type::point_type::tag (), shape);
|
||||
case shape_type::Path:
|
||||
return find_shape_by_tag (shape_type::path_type::tag (), shape);
|
||||
case shape_type::PathRef:
|
||||
|
|
@ -727,6 +741,9 @@ Shapes::replace_prop_id (const Shapes::shape_type &ref, db::properties_id_type p
|
|||
case shape_type::EdgePair:
|
||||
replace_prop_id (ref.basic_ptr (object_with_properties<shape_type::edge_pair_type>::tag ()), prop_id);
|
||||
break;
|
||||
case shape_type::Point:
|
||||
replace_prop_id (ref.basic_ptr (object_with_properties<shape_type::point_type>::tag ()), prop_id);
|
||||
break;
|
||||
case shape_type::Path:
|
||||
replace_prop_id (ref.basic_ptr (object_with_properties<shape_type::path_type>::tag ()), prop_id);
|
||||
break;
|
||||
|
|
@ -789,6 +806,8 @@ Shapes::replace_prop_id (const Shapes::shape_type &ref, db::properties_id_type p
|
|||
return replace_prop_id_iter (shape_type::simple_polygon_ptr_array_type::tag (), ref.basic_iter (shape_type::simple_polygon_ptr_array_type::tag ()), prop_id);
|
||||
case shape_type::Edge:
|
||||
return replace_prop_id_iter (shape_type::edge_type::tag (), ref.basic_iter (shape_type::edge_type::tag ()), prop_id);
|
||||
case shape_type::Point:
|
||||
return replace_prop_id_iter (shape_type::point_type::tag (), ref.basic_iter (shape_type::point_type::tag ()), prop_id);
|
||||
case shape_type::EdgePair:
|
||||
return replace_prop_id_iter (shape_type::edge_pair_type::tag (), ref.basic_iter (shape_type::edge_pair_type::tag ()), prop_id);
|
||||
case shape_type::Path:
|
||||
|
|
@ -874,6 +893,12 @@ Shapes::transform (const Shapes::shape_type &ref, const Trans &t)
|
|||
p.transform (t);
|
||||
return replace_member_with_props (shape_type::edge_pair_type::tag (), ref, p);
|
||||
}
|
||||
case shape_type::Point:
|
||||
{
|
||||
shape_type::point_type p (ref.point ());
|
||||
p = t.trans (p);
|
||||
return replace_member_with_props (shape_type::point_type::tag (), ref, p);
|
||||
}
|
||||
case shape_type::Path:
|
||||
{
|
||||
shape_type::path_type p (ref.path ());
|
||||
|
|
@ -962,6 +987,8 @@ Shapes::replace (const Shapes::shape_type &ref, const Sh &sh)
|
|||
return replace_member_with_props (shape_type::edge_type::tag (), ref, sh);
|
||||
case shape_type::EdgePair:
|
||||
return replace_member_with_props (shape_type::edge_pair_type::tag (), ref, sh);
|
||||
case shape_type::Point:
|
||||
return replace_member_with_props (shape_type::point_type::tag (), ref, sh);
|
||||
case shape_type::Path:
|
||||
return replace_member_with_props (shape_type::path_type::tag (), ref, sh);
|
||||
case shape_type::PathRef:
|
||||
|
|
@ -1347,6 +1374,7 @@ template DB_PUBLIC Shape Shapes::replace<>(const Shape &, const SimplePolygon &)
|
|||
template DB_PUBLIC Shape Shapes::replace<>(const Shape &, const Text &);
|
||||
template DB_PUBLIC Shape Shapes::replace<>(const Shape &, const Edge &);
|
||||
template DB_PUBLIC Shape Shapes::replace<>(const Shape &, const EdgePair &);
|
||||
template DB_PUBLIC Shape Shapes::replace<>(const Shape &, const Point &);
|
||||
|
||||
template DB_PUBLIC Shape Shapes::transform<> (const Shape &, const ICplxTrans &);
|
||||
template DB_PUBLIC Shape Shapes::transform<> (const Shape &, const Trans &);
|
||||
|
|
@ -1376,6 +1404,8 @@ template class DB_PUBLIC layer_op<db::Shape::edge_type, db::stable_layer_tag>;
|
|||
template class DB_PUBLIC layer_op<db::object_with_properties<db::Shape::edge_type>, db::stable_layer_tag>;
|
||||
template class DB_PUBLIC layer_op<db::Shape::edge_pair_type, db::stable_layer_tag>;
|
||||
template class DB_PUBLIC layer_op<db::object_with_properties<db::Shape::edge_pair_type>, db::stable_layer_tag>;
|
||||
template class DB_PUBLIC layer_op<db::Shape::point_type, db::stable_layer_tag>;
|
||||
template class DB_PUBLIC layer_op<db::object_with_properties<db::Shape::point_type>, db::stable_layer_tag>;
|
||||
template class DB_PUBLIC layer_op<db::Shape::text_type, db::stable_layer_tag>;
|
||||
template class DB_PUBLIC layer_op<db::object_with_properties<db::Shape::text_type>, db::stable_layer_tag>;
|
||||
template class DB_PUBLIC layer_op<db::Shape::text_ref_type, db::stable_layer_tag>;
|
||||
|
|
|
|||
|
|
@ -138,8 +138,9 @@ public:
|
|||
Text = 15,
|
||||
TextRef = 16,
|
||||
TextPtrArray = 17,
|
||||
UserObject = 18,
|
||||
Null = 19 // must be last!
|
||||
Point = 18,
|
||||
UserObject = 19,
|
||||
Null = 20 // must be last!
|
||||
};
|
||||
|
||||
enum flags_type
|
||||
|
|
@ -154,6 +155,7 @@ public:
|
|||
| (1 << SimplePolygonPtrArray),
|
||||
Edges = (1 << Edge),
|
||||
EdgePairs = (1 << EdgePair),
|
||||
Points = (1 << Point),
|
||||
Paths = (1 << Path)
|
||||
| (1 << PathRef)
|
||||
| (1 << PathPtrArray),
|
||||
|
|
@ -392,6 +394,7 @@ private:
|
|||
char sz17 [sizeof (per_shape_iter_size <text_ref_type>)];
|
||||
char sz18 [sizeof (per_shape_iter_size <text_ptr_array_type>)];
|
||||
char sz19 [sizeof (per_shape_iter_size <user_object_type>)];
|
||||
char sz20 [sizeof (per_shape_iter_size <point_type>)];
|
||||
};
|
||||
|
||||
// this union is simply there to determine the maximum size required for all
|
||||
|
|
|
|||
|
|
@ -679,6 +679,12 @@ inline unsigned int iterator_type_mask (ShapeIterator::edge_pair_type::tag)
|
|||
return 1 << ShapeIterator::EdgePair;
|
||||
}
|
||||
|
||||
/// @brief Internal: ShapeIterator masks per shape type
|
||||
inline unsigned int iterator_type_mask (ShapeIterator::point_type::tag)
|
||||
{
|
||||
return 1 << ShapeIterator::Point;
|
||||
}
|
||||
|
||||
/// @brief Internal: ShapeIterator masks per shape type
|
||||
inline unsigned int iterator_type_mask (ShapeIterator::path_type::tag)
|
||||
{
|
||||
|
|
@ -917,6 +923,8 @@ template class layer_class<db::Shape::path_ptr_array_type, db::stable_layer_tag>
|
|||
template class layer_class<db::object_with_properties<db::Shape::path_ptr_array_type>, db::stable_layer_tag>;
|
||||
template class layer_class<db::Shape::edge_type, db::stable_layer_tag>;
|
||||
template class layer_class<db::object_with_properties<db::Shape::edge_type>, db::stable_layer_tag>;
|
||||
template class layer_class<db::Shape::point_type, db::stable_layer_tag>;
|
||||
template class layer_class<db::object_with_properties<db::Shape::point_type>, db::stable_layer_tag>;
|
||||
template class layer_class<db::Shape::edge_pair_type, db::stable_layer_tag>;
|
||||
template class layer_class<db::object_with_properties<db::Shape::edge_pair_type>, db::stable_layer_tag>;
|
||||
template class layer_class<db::Shape::text_type, db::stable_layer_tag>;
|
||||
|
|
|
|||
|
|
@ -134,6 +134,8 @@ template DB_PUBLIC layer<db::Shape::edge_type, db::stable_layer_tag> &Shapes::ge
|
|||
template DB_PUBLIC layer<db::object_with_properties<db::Shape::edge_type>, db::stable_layer_tag> &Shapes::get_layer<db::object_with_properties<db::Shape::edge_type>, db::stable_layer_tag> ();
|
||||
template DB_PUBLIC layer<db::Shape::edge_pair_type, db::stable_layer_tag> &Shapes::get_layer<db::Shape::edge_pair_type, db::stable_layer_tag> ();
|
||||
template DB_PUBLIC layer<db::object_with_properties<db::Shape::edge_pair_type>, db::stable_layer_tag> &Shapes::get_layer<db::object_with_properties<db::Shape::edge_pair_type>, db::stable_layer_tag> ();
|
||||
template DB_PUBLIC layer<db::Shape::point_type, db::stable_layer_tag> &Shapes::get_layer<db::Shape::point_type, db::stable_layer_tag> ();
|
||||
template DB_PUBLIC layer<db::object_with_properties<db::Shape::point_type>, db::stable_layer_tag> &Shapes::get_layer<db::object_with_properties<db::Shape::point_type>, db::stable_layer_tag> ();
|
||||
template DB_PUBLIC layer<db::Shape::text_type, db::stable_layer_tag> &Shapes::get_layer<db::Shape::text_type, db::stable_layer_tag> ();
|
||||
template DB_PUBLIC layer<db::object_with_properties<db::Shape::text_type>, db::stable_layer_tag> &Shapes::get_layer<db::object_with_properties<db::Shape::text_type>, db::stable_layer_tag> ();
|
||||
template DB_PUBLIC layer<db::Shape::text_ref_type, db::stable_layer_tag> &Shapes::get_layer<db::Shape::text_ref_type, db::stable_layer_tag> ();
|
||||
|
|
@ -211,6 +213,8 @@ template DB_PUBLIC const layer<db::Shape::edge_type, db::stable_layer_tag> &Shap
|
|||
template DB_PUBLIC const layer<db::object_with_properties<db::Shape::edge_type>, db::stable_layer_tag> &Shapes::get_layer<db::object_with_properties<db::Shape::edge_type>, db::stable_layer_tag> () const;
|
||||
template DB_PUBLIC const layer<db::Shape::edge_pair_type, db::stable_layer_tag> &Shapes::get_layer<db::Shape::edge_pair_type, db::stable_layer_tag> () const;
|
||||
template DB_PUBLIC const layer<db::object_with_properties<db::Shape::edge_pair_type>, db::stable_layer_tag> &Shapes::get_layer<db::object_with_properties<db::Shape::edge_pair_type>, db::stable_layer_tag> () const;
|
||||
template DB_PUBLIC const layer<db::Shape::point_type, db::stable_layer_tag> &Shapes::get_layer<db::Shape::point_type, db::stable_layer_tag> () const;
|
||||
template DB_PUBLIC const layer<db::object_with_properties<db::Shape::point_type>, db::stable_layer_tag> &Shapes::get_layer<db::object_with_properties<db::Shape::point_type>, db::stable_layer_tag> () const;
|
||||
template DB_PUBLIC const layer<db::Shape::text_type, db::stable_layer_tag> &Shapes::get_layer<db::Shape::text_type, db::stable_layer_tag> () const;
|
||||
template DB_PUBLIC const layer<db::object_with_properties<db::Shape::text_type>, db::stable_layer_tag> &Shapes::get_layer<db::object_with_properties<db::Shape::text_type>, db::stable_layer_tag> () const;
|
||||
template DB_PUBLIC const layer<db::Shape::text_ref_type, db::stable_layer_tag> &Shapes::get_layer<db::Shape::text_ref_type, db::stable_layer_tag> () const;
|
||||
|
|
@ -315,6 +319,8 @@ Shapes::is_valid (const Shapes::shape_type &shape) const
|
|||
return is_valid_shape_by_tag (shape_type::edge_type::tag (), shape);
|
||||
case shape_type::EdgePair:
|
||||
return is_valid_shape_by_tag (shape_type::edge_pair_type::tag (), shape);
|
||||
case shape_type::Point:
|
||||
return is_valid_shape_by_tag (shape_type::point_type::tag (), shape);
|
||||
case shape_type::Path:
|
||||
return is_valid_shape_by_tag (shape_type::path_type::tag (), shape);
|
||||
case shape_type::PathRef:
|
||||
|
|
@ -478,6 +484,9 @@ Shapes::erase_shape (const Shapes::shape_type &shape)
|
|||
case shape_type::EdgePair:
|
||||
erase_shape_by_tag (shape_type::edge_pair_type::tag (), shape);
|
||||
break;
|
||||
case shape_type::Point:
|
||||
erase_shape_by_tag (shape_type::point_type::tag (), shape);
|
||||
break;
|
||||
case shape_type::Path:
|
||||
erase_shape_by_tag (shape_type::path_type::tag (), shape);
|
||||
break;
|
||||
|
|
@ -570,6 +579,9 @@ Shapes::erase_shapes (const std::vector<Shapes::shape_type> &shapes)
|
|||
case shape_type::Edge:
|
||||
erase_shapes_by_tag (shape_type::edge_type::tag (), s, snext);
|
||||
break;
|
||||
case shape_type::Point:
|
||||
erase_shapes_by_tag (shape_type::point_type::tag (), s, snext);
|
||||
break;
|
||||
case shape_type::EdgePair:
|
||||
erase_shapes_by_tag (shape_type::edge_pair_type::tag (), s, snext);
|
||||
break;
|
||||
|
|
@ -625,5 +637,4 @@ Shapes::erase_shapes (const std::vector<Shapes::shape_type> &shapes)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -169,6 +169,18 @@ struct edge_pair_defs
|
|||
method ("bbox", &C::bbox,
|
||||
"@brief Gets the bounding box of the edge pair\n"
|
||||
) +
|
||||
method ("perimeter", &C::perimeter,
|
||||
"@brief Gets the perimeter of the edge pair\n"
|
||||
"\n"
|
||||
"The perimeter is defined as the sum of the lengths of both edges ('active perimeter').\n"
|
||||
"\n"
|
||||
"This attribute has been introduced in version 0.28."
|
||||
) +
|
||||
method ("area", &C::area,
|
||||
"@brief Gets the area between the edges of the edge pair\n"
|
||||
"\n"
|
||||
"This attribute has been introduced in version 0.28."
|
||||
) +
|
||||
method ("<", &C::less, gsi::arg ("box"),
|
||||
"@brief Less operator\n"
|
||||
"Returns true, if this edge pair is 'less' with respect to first and second edge\n"
|
||||
|
|
|
|||
|
|
@ -709,6 +709,26 @@ static tl::Variant get_dedge_pair (const db::Shape *s)
|
|||
}
|
||||
}
|
||||
|
||||
static tl::Variant get_point (const db::Shape *s)
|
||||
{
|
||||
db::Shape::point_type p;
|
||||
if (s->point (p)) {
|
||||
return tl::Variant (p);
|
||||
} else {
|
||||
return tl::Variant ();
|
||||
}
|
||||
}
|
||||
|
||||
static tl::Variant get_dpoint (const db::Shape *s)
|
||||
{
|
||||
db::Shape::point_type p;
|
||||
if (s->point (p)) {
|
||||
return tl::Variant (db::CplxTrans (shape_dbu (s)) * p);
|
||||
} else {
|
||||
return tl::Variant ();
|
||||
}
|
||||
}
|
||||
|
||||
static tl::Variant get_text (const db::Shape *s)
|
||||
{
|
||||
db::Shape::text_type p;
|
||||
|
|
@ -1108,6 +1128,7 @@ static int t_simplePolygonPtrArray () { return db::Shape::SimplePolygonPtr
|
|||
static int t_simplePolygonPtrArrayMember () { return db::Shape::SimplePolygonPtrArrayMember; }
|
||||
static int t_edge () { return db::Shape::Edge; }
|
||||
static int t_edge_pair () { return db::Shape::EdgePair; }
|
||||
static int t_point () { return db::Shape::Point; }
|
||||
static int t_path () { return db::Shape::Path; }
|
||||
static int t_pathRef () { return db::Shape::PathRef; }
|
||||
static int t_pathPtrArray () { return db::Shape::PathPtrArray; }
|
||||
|
|
@ -1250,6 +1271,22 @@ Class<db::Shape> decl_Shape ("db", "Shape",
|
|||
"\n"
|
||||
"This method has been introduced in version 0.25."
|
||||
) +
|
||||
gsi::method_ext ("point=", &set_shape<db::Point>, gsi::arg("point"),
|
||||
"@brief Replaces the shape by the given point\n"
|
||||
"This method replaces the shape by the given point. This method can only be called "
|
||||
"for editable layouts. It does not change the user properties of the shape.\n"
|
||||
"Calling this method will invalidate any iterators. It should not be called inside a "
|
||||
"loop iterating over shapes.\n"
|
||||
"\n"
|
||||
"This method has been introduced in version 0.28."
|
||||
) +
|
||||
gsi::method_ext ("point=|dpoint=", &set_dshape<db::DPoint>, gsi::arg("point"),
|
||||
"@brief Replaces the shape by the given point (in micrometer units)\n"
|
||||
"This method replaces the shape by the given point, like \\point= with a \\Point argument does. "
|
||||
"This version translates the point from micrometer units to database units internally.\n"
|
||||
"\n"
|
||||
"This method has been introduced in version 0.28."
|
||||
) +
|
||||
gsi::method_ext ("edge_pair=", &set_shape<db::EdgePair>, gsi::arg("edge_pair"),
|
||||
"@brief Replaces the shape by the given edge pair\n"
|
||||
"This method replaces the shape by the given edge pair. This method can only be called "
|
||||
|
|
@ -1760,6 +1797,23 @@ Class<db::Shape> decl_Shape ("db", "Shape",
|
|||
"\n"
|
||||
"This method has been added in version 0.26.\n"
|
||||
) +
|
||||
gsi::method ("is_point?", &db::Shape::is_point,
|
||||
"@brief Returns true, if the object is an point\n"
|
||||
"\n"
|
||||
"This method has been introduced in version 0.28.\n"
|
||||
) +
|
||||
gsi::method_ext ("point", &get_point,
|
||||
"@brief Returns the point object\n"
|
||||
"\n"
|
||||
"This method has been introduced in version 0.28.\n"
|
||||
) +
|
||||
gsi::method_ext ("dpoint", &get_dpoint,
|
||||
"@brief Returns the point object as a \\DPoint object in micrometer units\n"
|
||||
"See \\point for a description of this method. This method returns the point after translation to "
|
||||
"micrometer units.\n"
|
||||
"\n"
|
||||
"This method has been introduced in version 0.28.\n"
|
||||
) +
|
||||
gsi::method ("is_text?", &db::Shape::is_text,
|
||||
"@brief Returns true, if the object is a text\n"
|
||||
) +
|
||||
|
|
@ -2057,6 +2111,7 @@ Class<db::Shape> decl_Shape ("db", "Shape",
|
|||
gsi::method ("TSimplePolygonPtrArrayMember|#t_simple_polygon_ptr_array_member", &t_simplePolygonPtrArrayMember) +
|
||||
gsi::method ("TEdge|#t_edge", &t_edge) +
|
||||
gsi::method ("TEdgePair|#t_edge_pair", &t_edge_pair) +
|
||||
gsi::method ("TPoint|#t_point", &t_point) +
|
||||
gsi::method ("TPath|#t_path", &t_path) +
|
||||
gsi::method ("TPathRef|#t_path_ref", &t_pathRef) +
|
||||
gsi::method ("TPathPtrArray|#t_path_ptr_array", &t_pathPtrArray) +
|
||||
|
|
|
|||
|
|
@ -454,6 +454,7 @@ static unsigned int s_regions () { return db::ShapeIterator::Regions
|
|||
static unsigned int s_boxes () { return db::ShapeIterator::Boxes; }
|
||||
static unsigned int s_edges () { return db::ShapeIterator::Edges; }
|
||||
static unsigned int s_edge_pairs () { return db::ShapeIterator::EdgePairs; }
|
||||
static unsigned int s_points () { return db::ShapeIterator::Points; }
|
||||
static unsigned int s_paths () { return db::ShapeIterator::Paths; }
|
||||
static unsigned int s_texts () { return db::ShapeIterator::Texts; }
|
||||
static unsigned int s_user_objects () { return db::ShapeIterator::UserObjects; }
|
||||
|
|
@ -875,6 +876,25 @@ Class<db::Shapes> decl_Shapes ("db", "Shapes",
|
|||
"\n"
|
||||
"This variant has been introduced in version 0.26.\n"
|
||||
) +
|
||||
gsi::method_ext ("replace", &replace<db::Point>, gsi::arg ("shape"), gsi::arg ("point"),
|
||||
"@brief Replaces the given shape with an point object\n"
|
||||
"\n"
|
||||
"This method replaces the given shape with the "
|
||||
"object specified. It does not change the property Id. To change the property Id, "
|
||||
"use the \\replace_prop_id method. To replace a shape and discard the property Id, erase the "
|
||||
"shape and insert a new shape."
|
||||
"\n"
|
||||
"This variant has been introduced in version 0.28."
|
||||
) +
|
||||
gsi::method_ext ("replace", &dreplace<db::DPoint>, gsi::arg ("shape"), gsi::arg ("point"),
|
||||
"@brief Replaces the given shape with an point given in micrometer units\n"
|
||||
"@return A reference to the new shape (a \\Shape object)\n"
|
||||
"\n"
|
||||
"This method behaves like the \\replace version with an \\Point argument, except that it will "
|
||||
"internally translate the point from micrometer to database units.\n"
|
||||
"\n"
|
||||
"This variant has been introduced in version 0.28."
|
||||
) +
|
||||
gsi::method_ext ("replace", &replace<db::Text>, gsi::arg ("shape"), gsi::arg ("text"),
|
||||
"@brief Replaces the given shape with a text object\n"
|
||||
"@return A reference to the new shape (a \\Shape object)\n"
|
||||
|
|
@ -989,6 +1009,19 @@ Class<db::Shapes> decl_Shapes ("db", "Shapes",
|
|||
"\n"
|
||||
"This variant has been introduced in version 0.26."
|
||||
) +
|
||||
gsi::method_ext ("insert|#insert_point", &insert<db::Point>, gsi::arg ("point"),
|
||||
"@brief Inserts an point into the shapes list\n"
|
||||
"\n"
|
||||
"This variant has been introduced in version 0.28.\n"
|
||||
) +
|
||||
gsi::method_ext ("insert", &dinsert<db::DPoint>, gsi::arg ("point"),
|
||||
"@brief Inserts a micrometer-unit point into the shapes list\n"
|
||||
"@return A reference to the new shape (a \\Shape object)\n"
|
||||
"This method behaves like the \\insert version with a \\Point argument, except that it will "
|
||||
"internally translate the point from micrometer to database units.\n"
|
||||
"\n"
|
||||
"This variant has been introduced in version 0.28.\n"
|
||||
) +
|
||||
gsi::method_ext ("insert|#insert_text", &insert<db::Text>, gsi::arg ("text"),
|
||||
"@brief Inserts a text into the shapes list\n"
|
||||
"@return A reference to the new shape (a \\Shape object)\n"
|
||||
|
|
@ -1285,6 +1318,11 @@ Class<db::Shapes> decl_Shapes ("db", "Shapes",
|
|||
gsi::method ("SEdgePairs|#s_edge_pairs", &s_edge_pairs,
|
||||
"@brief Indicates that edge pairs shall be retrieved"
|
||||
) +
|
||||
gsi::method ("SPoints|#s_points", &s_points,
|
||||
"@brief Indicates that points shall be retrieved"
|
||||
"\n"
|
||||
"This constant has been added in version 0.28."
|
||||
) +
|
||||
gsi::method ("SPaths|#s_paths", &s_paths,
|
||||
"@brief Indicates that paths shall be retrieved"
|
||||
) +
|
||||
|
|
|
|||
Loading…
Reference in New Issue