Part: Geometry assignTag function

This commit is contained in:
Abdullah Tahiri
2017-04-09 08:42:22 +02:00
committed by wmayer
parent 19565c3270
commit 52a0ad6e04
2 changed files with 16 additions and 2 deletions

View File

@@ -230,6 +230,14 @@ void Geometry::createNewTag()
tag = gen();
}
void Geometry::assignTag(const Part::Geometry * geo)
{
if(geo->getTypeId() == this->getTypeId())
this->tag = geo->tag;
else
throw Base::TypeError("Geometry tag can not be assigned as geometry types do not match.");
}
// -------------------------------------------------
TYPESYSTEM_SOURCE(Part::GeomPoint,Part::Geometry)

View File

@@ -76,10 +76,14 @@ public:
virtual unsigned int getMemSize(void) const;
virtual void Save(Base::Writer &/*writer*/) const;
virtual void Restore(Base::XMLReader &/*reader*/);
/// returns a copy of this object having a new randomly generated tag. If you also want to copy the tag, you may use clone() instead.
/// For creation of geometry with other handles, with or without the same tag, you may use the constructors and the sethandle functions.
/// The tag of a geometry can be copied to another geometry using the assignTag function.
virtual Geometry *copy(void) const = 0;
/// returns a cloned object. A cloned object has the same tag (see getTag) as the original object.
/// If you want a clone with another handle, it is possible to clone an object and then assign another handle.
/// if you want a copy not having the same tag, you can use copy() instead.
/// If you want a clone with another geometry handle, it is possible to clone an object and then assign another handle or to create an object
/// via constructor and use assignTag to assign the tag of the other geometry.
/// If you do not desire to have the same tag, then a copy can be performed by using a constructor (which will generate another tag)
/// and then, if necessary (e.g. if the constructor did not take a handle as a parameter), set a new handle.
virtual Geometry *clone(void) const = 0;
@@ -91,6 +95,8 @@ public:
boost::uuids::uuid getTag() const;
/// create a new tag for the geometry object
void createNewTag();
/// copies the tag from the geometry passed as a parameter to this object
void assignTag(const Part::Geometry *);
protected:
Geometry();