55#ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_SIMPLE_POLYGON_2D_H
56#define LASS_GUARDIAN_OF_INCLUSION_PRIM_SIMPLE_POLYGON_2D_H
77 typedef SimplePolygon2D<T, NoDegenerate> TSelf;
78 typedef DegeneratePolicy TDegeneratePolicy;
80 typedef Point2D<T> TPoint;
82 typedef typename TPoint::TVector TVector;
85 typedef typename TPoint::TValue TValue;
86 typedef typename TPoint::TParam TParam;
87 typedef typename TPoint::TReference TReference;
88 typedef typename TPoint::TConstReference TConstReference;
89 typedef typename TPoint::TNumTraits TNumTraits;
91 enum { dimension = TPoint::dimension };
93 template <
typename U>
struct Rebind
95 typedef SimplePolygon2D<U, NoDegenerate> Type;
99 template <
typename InputIterator>
100 SimplePolygon2D(InputIterator iFirstVertex, InputIterator iLastVertex);
101 SimplePolygon2D(std::initializer_list<TPoint> init);
105 const TPoint&
at(
int iIndexOfVertex)
const;
106 TPoint&
at(
int iIndexOfVertex);
107 const TLineSegment
edge(
int iIndexOfTailVertex)
const;
108 const TVector
vector(
int iIndexOfTailVertex)
const;
110 void add(
const TPoint& iVertex);
111 void insert(
int iIndexOfVertex,
const TPoint& iVertex);
129 Side classify(
const TPoint& iP)
const;
138 bool isInRange(
size_t iIndexOfVertex)
const;
140 typedef std::vector<TPoint> TVertices;
145template <
typename T,
typename DP,
typename PP>
148template <
typename T,
typename DP,
typename PP>
151template <
typename T,
typename DP1,
typename DP2>
155template <
typename T,
class DP>
158template <
typename T,
class DP>
161template <
typename T,
class DP>
168template <
typename T,
class DP>
172template <
typename T,
class DP>
176template <
typename T,
class DP>
186#define LASS_PRIM_HAVE_PY_EXPORT_TRAITS_SIMPLE_POLYGON_2D
187#ifdef LASS_GUARDIAN_OF_INCLUSION_UTIL_PYOBJECT_PLUS_H
191#ifdef LASS_GUARDIAN_OF_INCLUSION_PRIM_AABB_2D_H
195#ifdef LASS_GUARDIAN_OF_INCLUSION_PRIM_RAY_2D_H
Output stream for writing a selection of geometric primitives to matlab M files.
Output stream for writing a selection of geometric primitives to XML files.
convex or concave polygon in 2D (not selfintersecting, no holes)
const TPointH vertexCentroid() const
return the barycenter of all vertices.
bool isSimple() const
return true if polygon is simple, false if not.
void flip()
flip orientation of polygon.
size_t size() const
return number of vertices
void erase(int iIndexOfVertex)
remove the vertex at(iIndex)
bool isValid() const
a simple polygon is valid if it is not degenerate.
const TValue perimeter() const
return sum of the lengths of all edges
const TPoint & at(int iIndexOfVertex) const
return vertex of polygon by its index, but wrap around the bounds.
const TValue area() const
return area of the polygons surface.
const TPointH surfaceCentroid() const
return the centroid of the filled polygon.
bool isReflex(int iIndexOfVertex) const
return true if inner angle of vertex is reflex (is > 180 degrees).
bool isEmpty() const
return true if polygon has no vertices
Orientation orientation() const
return orientation of polygon.
bool isConvex() const
return true if polygon is convex, false if not.
TPoint & at(int iIndexOfVertex)
return vertex of polygon by its index, but wrap around the bounds.
TPoint & operator[](size_t iIndexOfVertex)
return vertex of polygon by its index, not wrapped, no bounds check.
void insert(int iIndexOfVertex, const TPoint &iVertex)
insert a vertex at iIndex (so it will sit before the current at(iIndex)).
void add(const TPoint &iVertex)
add a point at the "end" of the vertex list.
const TLineSegment edge(int iIndexOfTailVertex) const
return the edge of the polygon between vertices at(iIndex) and at(iIndex + 1).
const TVector vector(int iIndexOfTailVertex) const
return the vector between vertices at(iIndex) and at(iIndex + 1)\
const TValue signedArea() const
return signed polygon area.
const TPoint & operator[](size_t iIndexOfVertex) const
return vertex of polygon by its index, not wrapped, no bounds check.
void fixDegenerate()
fixes degenerate polygons as far as possible.
bool contains(const TPoint &iP) const
return true when a point is inside or on a polygon.
set of geometrical primitives
Side
Different sides of a surface.
bool set_union(const SimplePolygon2D< T, DP > &iPolygonA, const SimplePolygon2D< T, DP > &iPolygonB, std::vector< SimplePolygon2D< T, DP > > &oPolygonsC)
C = A U B.
bool set_intersect(const SimplePolygon2D< T, DP > &iPolygonA, const SimplePolygon2D< T, DP > &iPolygonB, std::vector< SimplePolygon2D< T, DP > > &oPolygonsC)
C = (A U B) \ (A \ B) \ (B \ A)
bool set_difference(const SimplePolygon2D< T, DP > &iPolygonA, const SimplePolygon2D< T, DP > &iPolygonB, std::vector< SimplePolygon2D< T, DP > > &oPolygonsC)
C = A \ B.
Orientation
enumeration of clockwise versus counterclockwise
Library for Assembled Shared Sources.
This is the default policy.