Thanks for taking the time to discuss this. I really appreciate it. I will be verbose to try to expose problems. Let me know if you see flawed arguments or misconceptions.
wmayer wrote:
Copy constructors are explicitly disallowed in the Geometry class framework. Some classes offer an overloaded constructor where the handle to the actual geometry can be passed
Ok. This was bad terminology. Thanks for pointing it out. Somehow in my head I mixed the intended purpose with the actual syntax. It is not a copy constructor as does not take the same object, but a handle to the OCC object. It is just an overloaded constructor. Any constructor, as per default c++ behaviour will call the default "parent class(es)" constructor(s) and then execute the overloaded constructor. So there will be no problem that the tag is not initialized to be unique per default, the perceived problem is "just" that the tag cannot be set to something we already have.
1. All geometry derivatives implement the clone function as per Geometry class requirement. So all of them can create a clone in the sense of a copy with the same tag.
2. If clone is not used and the overloaded constructor is used, then a newly generated tag is created by default (so not a clone, but a copy).
I want to think that not allowing to assign a tag is intended behaviour. If this is not the case, then I think we would need to write overloaded versions of those constructors and functions taking an additional parameter representing a tag (or Geometry object having the tag to copy). But let's assume it is intended behaviour for a moment. The question evolves to:
do I have the tools to create clones and copies in all the situations which I can face today?
I mean I can have handles of different types, trimmed curves, and still want to clone (copying is not a problem with the current implementation). So I am here with a handle and a Geometry object having the tag I would like to clone.
I would tend to think that developers should be told, via documentation, that if you want a clone, you can not use an overloaded constructor. If you use an overloaded constructor you get a copy. So, how do I clone if I want to?
I would say that the solution is with the second way you just mentioned:
wmayer wrote:or only the default constructor where a copy can be created with setHandle
In this case:
1. If I want to "clone", I can just use the clone function for construction purposes and then assign the handle.
2. If I want to "copy", then I just use "any constructor" to get a random tag and then assign the handle.
Am I wrong?
If I am not wrong, this I think it could be a great answer for the problem in the previous point. We just create setHandle functions in the Geometry derivates where they are missing. The if you want to clone, you use the clone function, then assign the handle.
What do you think?
wmayer wrote:Here it's not possible to assign the tag id (and anyway not what I like) to the copy because it doesn't know where the handle comes from.
I am not sure I am understanding you well. I understand that you are pointing out a potential problem (not being able to assign the tag id) to make me aware (thanks!). I perceive that in principle, if there is not a problem today AND if after thinking there is not a perceived need for it, you would prefer not to allow assigning tag ids. Right?
If this is it, I do not think we have the need of allowing to assign an arbitrary tag today and I can not think with the information I have today of a case where it would be needed. If we ever need that, the best solution I can come with is to overload the "overloaded constructors"/sethandle functions with new versions that take an extra parameter, the tag to be assigned. If you want your arbitrary tag, you use the overloaded version with the tag, if not you can just use the version available as of today.
Some reference of combinations of overloaded constructors and sethandle methods:
setHandle alone:
GeomLineSegment (trimmed curve)
setHandle AND overloaded constructor with same type handle, itself (e.g. Handle_Geom_Ellipse for an Ellipse):
GeomBezierCurve
GeomBSplineCurve
GeomArcOfCircle
GeomEllipse
GeomOffsetCurve (this has an additional overloaded constructor for Handle_Geom_Curve)
GeomTrimmedCurve
GeomBSplineSurface
GeomCylinder
GeomCone
GeomSphere
GeomToroid
GeomPlane
GeomOffsetSurface (this has an additional overloaded constructor for Handle_Geom_Surface)
GeomPlateSurface (this has an additional overloaded constructor for GeomPlate_BuildPlateSurface and another for Handle_Geom_Surface)
GeomTrimmedSurface
GeomSurfaceOfRevolution (this has an additional overloaded constructor for Handle_Geom_Curve)
GeomSurfaceOfExtrusion (this has an additional overloaded constructor for Handle_Geom_Curve)
setHandle with trimmed curve handle AND overloaded constructor with underlaying untrimmed curve handle (e.g. Handle_Geome_Circle for ArcOfCircle):
GeomArcOfEllipse
GeomArcOfHyperbola
GeomArcOfParabola
No setHandle, only overloaded constructors:
GeomPoint (Handle_Geom_CartesianPoint and Base::Vector3d)
GeomCircle
GeomHyperbola
GeomParabola
GeomLine (Handle_Geom_Line and Base::Vector3d)
GeomBezierSurface