From 7ea1bb0cb76e98853bb55b55fe8e096d2a82d21c Mon Sep 17 00:00:00 2001 From: Markus Lampert Date: Sun, 4 Oct 2020 22:44:45 -0700 Subject: [PATCH] Dealing with 32bit compile error of Voronoi interface. --- src/Mod/Path/App/Voronoi.h | 8 +++++++- src/Mod/Path/App/VoronoiCellPyImp.cpp | 6 ++++-- src/Mod/Path/App/VoronoiEdgePyImp.cpp | 3 ++- src/Mod/Path/App/VoronoiVertexPyImp.cpp | 3 ++- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/Mod/Path/App/Voronoi.h b/src/Mod/Path/App/Voronoi.h index 0634ef3c91..7be3cac3d7 100644 --- a/src/Mod/Path/App/Voronoi.h +++ b/src/Mod/Path/App/Voronoi.h @@ -34,6 +34,12 @@ #include #include +#if (SIZE_MAX == UINT_MAX) +# define PATH_VORONOI_COLOR_MASK 0x07FFFFFFul +#else +# define PATH_VORONOI_COLOR_MASK 0x07FFFFFFFFFFFFFFul +#endif + namespace Path { class PathExport Voronoi @@ -48,7 +54,7 @@ namespace Path typedef std::size_t color_type; static const int InvalidIndex = INT_MAX; - static const color_type ColorMask = 0x07FFFFFFFFFFFFFFul; // top 5 bits reserved internally + static const color_type ColorMask = PATH_VORONOI_COLOR_MASK; // types typedef double coordinate_type; diff --git a/src/Mod/Path/App/VoronoiCellPyImp.cpp b/src/Mod/Path/App/VoronoiCellPyImp.cpp index 8e780f2d57..ce0e8a1b0a 100644 --- a/src/Mod/Path/App/VoronoiCellPyImp.cpp +++ b/src/Mod/Path/App/VoronoiCellPyImp.cpp @@ -122,7 +122,8 @@ Py::Long VoronoiCellPy::getIndex(void) const { Py::Long VoronoiCellPy::getColor(void) const { VoronoiCell *c = getVoronoiCellPtr(); if (c->isBound()) { - return Py::Long(c->ptr->color() & Voronoi::ColorMask); + Voronoi::color_type color = c->ptr->color() & Voronoi::ColorMask; + return Py::Long(color); } return Py::Long(0); } @@ -134,7 +135,8 @@ void VoronoiCellPy::setColor(Py::Long color) { Py::Long VoronoiCellPy::getSourceIndex(void) const { VoronoiCell *c = getVoronoiCellFromPy(this); - return Py::Long(c->ptr->source_index()); + long index = c->ptr->source_index(); + return Py::Long(index); } Py::Int VoronoiCellPy::getSourceCategory(void) const diff --git a/src/Mod/Path/App/VoronoiEdgePyImp.cpp b/src/Mod/Path/App/VoronoiEdgePyImp.cpp index 6043754b60..4177302f24 100644 --- a/src/Mod/Path/App/VoronoiEdgePyImp.cpp +++ b/src/Mod/Path/App/VoronoiEdgePyImp.cpp @@ -141,7 +141,8 @@ Py::Long VoronoiEdgePy::getIndex(void) const { Py::Long VoronoiEdgePy::getColor(void) const { VoronoiEdge *e = getVoronoiEdgePtr(); if (e->isBound()) { - return Py::Long(e->ptr->color() & Voronoi::ColorMask); + Voronoi::color_type color = e->ptr->color() & Voronoi::ColorMask; + return Py::Long(color); } return Py::Long(0); } diff --git a/src/Mod/Path/App/VoronoiVertexPyImp.cpp b/src/Mod/Path/App/VoronoiVertexPyImp.cpp index 837c2efea4..86a1dd9b5d 100644 --- a/src/Mod/Path/App/VoronoiVertexPyImp.cpp +++ b/src/Mod/Path/App/VoronoiVertexPyImp.cpp @@ -124,7 +124,8 @@ Py::Long VoronoiVertexPy::getIndex(void) const { Py::Long VoronoiVertexPy::getColor(void) const { VoronoiVertex *v = getVoronoiVertexPtr(); if (v->isBound()) { - return Py::Long(v->ptr->color() & Voronoi::ColorMask); + Voronoi::color_type color = v->ptr->color() & Voronoi::ColorMask; + return Py::Long(color); } return Py::Long(0); }