From 3a50f84ba4ba59dd77d76763cc340d06917a1da2 Mon Sep 17 00:00:00 2001 From: Markus Lampert Date: Tue, 8 Sep 2020 23:27:19 -0700 Subject: [PATCH] Added Index as attribute of all voronoi objects for easier debugging --- src/Mod/Path/App/VoronoiCellPy.xml | 6 ++++++ src/Mod/Path/App/VoronoiCellPyImp.cpp | 8 ++++++++ src/Mod/Path/App/VoronoiEdgePy.xml | 14 ++++++++++---- src/Mod/Path/App/VoronoiEdgePyImp.cpp | 12 ++++++++++-- src/Mod/Path/App/VoronoiVertexPy.xml | 6 ++++++ src/Mod/Path/App/VoronoiVertexPyImp.cpp | 8 ++++++++ 6 files changed, 48 insertions(+), 6 deletions(-) diff --git a/src/Mod/Path/App/VoronoiCellPy.xml b/src/Mod/Path/App/VoronoiCellPy.xml index 48601d0847..ffc4b57a2b 100644 --- a/src/Mod/Path/App/VoronoiCellPy.xml +++ b/src/Mod/Path/App/VoronoiCellPy.xml @@ -16,6 +16,12 @@ Cell of a Voronoi diagram + + + Internal id of the element. + + + Assigned color of the receiver. diff --git a/src/Mod/Path/App/VoronoiCellPyImp.cpp b/src/Mod/Path/App/VoronoiCellPyImp.cpp index 9a74a18447..95c8328866 100644 --- a/src/Mod/Path/App/VoronoiCellPyImp.cpp +++ b/src/Mod/Path/App/VoronoiCellPyImp.cpp @@ -111,6 +111,14 @@ VoronoiCell* getVoronoiCellFromPy(const VoronoiCellPy *c, PyObject *args = 0) { return self; } +Py::Int VoronoiCellPy::getIndex(void) const { + VoronoiCell *c = getVoronoiCellPtr(); + if (c->isBound()) { + return Py::Int(c->dia->index(c->ptr)); + } + return Py::Int(-1); +} + Py::Long VoronoiCellPy::getColor(void) const { VoronoiCell *c = getVoronoiCellPtr(); if (c->isBound()) { diff --git a/src/Mod/Path/App/VoronoiEdgePy.xml b/src/Mod/Path/App/VoronoiEdgePy.xml index ddefc4586f..daf107b7a2 100644 --- a/src/Mod/Path/App/VoronoiEdgePy.xml +++ b/src/Mod/Path/App/VoronoiEdgePy.xml @@ -16,6 +16,12 @@ Edge of a Voronoi diagram + + + Internal id of the element. + + + Assigned color of the receiver. @@ -46,17 +52,17 @@ - + Rotated CCW next edge whithin voronoi cell - + - + Rotated CCW previous edge whithin voronoi cell - + diff --git a/src/Mod/Path/App/VoronoiEdgePyImp.cpp b/src/Mod/Path/App/VoronoiEdgePyImp.cpp index 0c6fb6c688..7ca2f85251 100644 --- a/src/Mod/Path/App/VoronoiEdgePyImp.cpp +++ b/src/Mod/Path/App/VoronoiEdgePyImp.cpp @@ -130,6 +130,14 @@ VoronoiEdge* getVoronoiEdgeFromPy(const VoronoiEdgePy *e, PyObject *args = 0) { return self; } +Py::Int VoronoiEdgePy::getIndex(void) const { + VoronoiEdge *e = getVoronoiEdgePtr(); + if (e->isBound()) { + return Py::Int(e->dia->index(e->ptr)); + } + return Py::Int(-1); +} + Py::Long VoronoiEdgePy::getColor(void) const { VoronoiEdge *e = getVoronoiEdgePtr(); if (e->isBound()) { @@ -183,13 +191,13 @@ Py::Object VoronoiEdgePy::getPrev(void) const return Py::asObject(new VoronoiEdgePy(new VoronoiEdge(e->dia, e->ptr->prev()))); } -Py::Object VoronoiEdgePy::getRotatedNext(void) const +Py::Object VoronoiEdgePy::getRotNext(void) const { VoronoiEdge *e = getVoronoiEdgeFromPy(this); return Py::asObject(new VoronoiEdgePy(new VoronoiEdge(e->dia, e->ptr->rot_next()))); } -Py::Object VoronoiEdgePy::getRotatedPrev(void) const +Py::Object VoronoiEdgePy::getRotPrev(void) const { VoronoiEdge *e = getVoronoiEdgeFromPy(this); return Py::asObject(new VoronoiEdgePy(new VoronoiEdge(e->dia, e->ptr->rot_prev()))); diff --git a/src/Mod/Path/App/VoronoiVertexPy.xml b/src/Mod/Path/App/VoronoiVertexPy.xml index bffc51c33d..ef5eca069f 100644 --- a/src/Mod/Path/App/VoronoiVertexPy.xml +++ b/src/Mod/Path/App/VoronoiVertexPy.xml @@ -16,6 +16,12 @@ Vertex of a Voronoi diagram + + + Internal id of the element. + + + Assigned color of the receiver. diff --git a/src/Mod/Path/App/VoronoiVertexPyImp.cpp b/src/Mod/Path/App/VoronoiVertexPyImp.cpp index 0a8b7a92ba..beef937908 100644 --- a/src/Mod/Path/App/VoronoiVertexPyImp.cpp +++ b/src/Mod/Path/App/VoronoiVertexPyImp.cpp @@ -113,6 +113,14 @@ VoronoiVertex* getVoronoiVertexFromPy(const VoronoiVertexPy *v, PyObject *args = } +Py::Int VoronoiVertexPy::getIndex(void) const { + VoronoiVertex *v = getVoronoiVertexPtr(); + if (v->isBound()) { + return Py::Int(v->dia->index(v->ptr)); + } + return Py::Int(-1); +} + Py::Long VoronoiVertexPy::getColor(void) const { VoronoiVertex *v = getVoronoiVertexPtr(); if (v->isBound()) {