1 #ifndef SIMPT_EDITOR_VORONOI_TESSELATION_H_INCLUDED
2 #define SIMPT_EDITOR_VORONOI_TESSELATION_H_INCLUDED
22 #include <QGraphicsPolygonItem>
28 #include <boost/polygon/point_data.hpp>
29 #include <boost/polygon/voronoi.hpp>
35 class QGraphicsSceneMouseEvent;
74 void UpdateTesselation();
84 : edge(QLineF()), clippedP1(
false), nextBoundaryP1(QPointF()), clippedP2(
false), nextBoundaryP2(QPointF())
87 ClippedEdge(QLineF e,
bool c1, QPointF nBP1,
bool c2, QPointF nBP2)
88 : edge(e), clippedP1(c1), nextBoundaryP1(nBP1), clippedP2(c2), nextBoundaryP2(nBP2)
93 QPointF nextBoundaryP1;
95 QPointF nextBoundaryP2;
98 void AddEdge(
const boost::polygon::voronoi_diagram<double>::edge_type *edge, QPolygonF &polygon, std::map<
const boost::polygon::voronoi_diagram<double>::edge_type*, ClippedEdge> &clippingCache);
99 ClippedEdge GetClippedEdge(
const boost::polygon::voronoi_diagram<double>::edge_type *edge, std::map<
const boost::polygon::voronoi_diagram<double>::edge_type*, ClippedEdge> &clippingCache);
100 ClippedEdge ClipEdge(
const boost::polygon::voronoi_diagram<double>::edge_type *edge);
103 static boost::polygon::point_data<long> ToVoronoiPoint(
const QPointF &point);
104 static QPointF FromVoronoiPoint(
const boost::polygon::voronoi_diagram<double>::vertex_type &point);
107 std::vector<QPointF> m_points;
108 std::list<QPolygonF> m_cell_polygons;
109 std::list<QGraphicsLineItem*> m_lines;
112 static const QRectF g_point_rect;
113 static const QBrush g_point_brush;
114 static const double g_points_precision;
119 #endif // end-of-include-guard
Namespace for SimPT tissue editor package.
virtual ~VoronoiTesselation()
Destructor.
see the online Qt documentation
see the online Qt documentation
virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
Reimplementation of QGraphicsItem::mouseDoubleClickEvent to add a point to the tesselation.
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event)
Reimplementation of QGraphicsItem::mousePressEvent to remove a point from the tesselation.
std::list< QPolygonF > GetCellPolygons()
Returns the polygons of cell of the Voronoi tesselation.
VoronoiTesselation(const QPolygonF &boundaryPolygon, QGraphicsItem *parent=nullptr)
Constructor.
see the online Qt documentation
Graphics item for Voronoi tesselation of a polygon.