add method to create new tag id

This commit is contained in:
wmayer
2017-04-08 13:31:28 +02:00
parent e13b810954
commit 3663cfbd0e
2 changed files with 18 additions and 11 deletions

View File

@@ -183,17 +183,7 @@ TYPESYSTEM_SOURCE_ABSTRACT(Part::Geometry,Base::Persistence)
Geometry::Geometry()
: Construction(false)
{
// Initialize a random number generator, to avoid Valgrind false positives.
static boost::mt19937 ran;
static bool seeded = false;
if (!seeded) {
ran.seed(static_cast<unsigned int>(std::time(0)));
seeded = true;
}
static boost::uuids::basic_random_generator<boost::mt19937> gen(&ran);
tag = gen();
createNewTag();
}
Geometry::~Geometry()
@@ -225,6 +215,21 @@ boost::uuids::uuid Geometry::getTag() const
return tag;
}
void Geometry::createNewTag()
{
// Initialize a random number generator, to avoid Valgrind false positives.
static boost::mt19937 ran;
static bool seeded = false;
if (!seeded) {
ran.seed(static_cast<unsigned int>(std::time(0)));
seeded = true;
}
static boost::uuids::basic_random_generator<boost::mt19937> gen(&ran);
tag = gen();
}
// -------------------------------------------------
TYPESYSTEM_SOURCE(Part::GeomPoint,Part::Geometry)

View File

@@ -87,6 +87,8 @@ public:
bool Construction;
/// returns the tag of the geometry object
boost::uuids::uuid getTag() const;
/// create a new tag for the geometry object
void createNewTag();
protected:
Geometry();