diff --git a/src/Mod/Part/App/Geometry.cpp b/src/Mod/Part/App/Geometry.cpp index 4ce511f416..ed4604b29f 100644 --- a/src/Mod/Part/App/Geometry.cpp +++ b/src/Mod/Part/App/Geometry.cpp @@ -372,13 +372,20 @@ void Geometry::assignTag(const Part::Geometry * geo) throw Base::TypeError("Geometry tag can not be assigned as geometry types do not match."); } +void Geometry::copyNonTag(const Part::Geometry * src) +{ + this->Construction = src->Construction; + + for(auto & ext: src->extensions) + this->extensions.push_back(ext->copy()); +} + Geometry *Geometry::clone(void) const { Geometry* cpy = this->copy(); cpy->tag = this->tag; - for(auto & ext: extensions) - cpy->extensions.push_back(ext->copy()); + // class copy is responsible for copying extensions return cpy; } @@ -472,7 +479,7 @@ void GeomPoint::setHandle(const Handle(Geom_CartesianPoint)& p) Geometry *GeomPoint::copy(void) const { GeomPoint *newPoint = new GeomPoint(myPoint); - newPoint->Construction = this->Construction; + newPoint->copyNonTag(this); return newPoint; } @@ -929,7 +936,7 @@ const Handle(Geom_Geometry)& GeomBezierCurve::handle() const Geometry *GeomBezierCurve::copy(void) const { GeomBezierCurve *newCurve = new GeomBezierCurve(myCurve); - newCurve->Construction = this->Construction; + newCurve->copyNonTag(this); return newCurve; } @@ -1118,7 +1125,7 @@ Geometry *GeomBSplineCurve::copy(void) const { try { GeomBSplineCurve *newCurve = new GeomBSplineCurve(myCurve); - newCurve->Construction = this->Construction; + newCurve->copyNonTag(this); return newCurve; } catch (Standard_Failure& e) { @@ -1746,7 +1753,7 @@ const Handle(Geom_Geometry)& GeomTrimmedCurve::handle() const Geometry *GeomTrimmedCurve::copy(void) const { GeomTrimmedCurve *newCurve = new GeomTrimmedCurve(myCurve); - newCurve->Construction = this->Construction; + newCurve->copyNonTag(this); return newCurve; } @@ -2033,7 +2040,7 @@ void GeomCircle::setHandle(const Handle(Geom_Circle)& c) Geometry *GeomCircle::copy(void) const { GeomCircle *newCirc = new GeomCircle(myCurve); - newCirc->Construction = this->Construction; + newCirc->copyNonTag(this); return newCirc; } @@ -2225,7 +2232,7 @@ Geometry *GeomArcOfCircle::copy(void) const { GeomArcOfCircle* copy = new GeomArcOfCircle(); copy->setHandle(this->myCurve); - copy->Construction = this->Construction; + copy->copyNonTag(this); return copy; } @@ -2454,7 +2461,7 @@ void GeomEllipse::setHandle(const Handle(Geom_Ellipse) &e) Geometry *GeomEllipse::copy(void) const { GeomEllipse *newEllipse = new GeomEllipse(myCurve); - newEllipse->Construction = this->Construction; + newEllipse->copyNonTag(this); return newEllipse; } @@ -2710,7 +2717,7 @@ Geometry *GeomArcOfEllipse::copy(void) const { GeomArcOfEllipse* copy = new GeomArcOfEllipse(); copy->setHandle(this->myCurve); - copy->Construction = this->Construction; + copy->copyNonTag(this); return copy; } @@ -2979,7 +2986,7 @@ void GeomHyperbola::setHandle(const Handle(Geom_Hyperbola)& c) Geometry *GeomHyperbola::copy(void) const { GeomHyperbola *newHyp = new GeomHyperbola(myCurve); - newHyp->Construction = this->Construction; + newHyp->copyNonTag(this); return newHyp; } @@ -3148,7 +3155,7 @@ Geometry *GeomArcOfHyperbola::copy(void) const { GeomArcOfHyperbola* copy = new GeomArcOfHyperbola(); copy->setHandle(this->myCurve); - copy->Construction = this->Construction; + copy->copyNonTag(this); return copy; } @@ -3407,7 +3414,7 @@ void GeomParabola::setHandle(const Handle(Geom_Parabola)& c) Geometry *GeomParabola::copy(void) const { GeomParabola *newPar = new GeomParabola(myCurve); - newPar->Construction = this->Construction; + newPar->copyNonTag(this); return newPar; } @@ -3557,7 +3564,7 @@ Geometry *GeomArcOfParabola::copy(void) const { GeomArcOfParabola* copy = new GeomArcOfParabola(); copy->setHandle(this->myCurve); - copy->Construction = this->Construction; + copy->copyNonTag(this); return copy; } @@ -3785,7 +3792,7 @@ void GeomLine::setHandle(const Handle(Geom_Line)& l) Geometry *GeomLine::copy(void) const { GeomLine *newLine = new GeomLine(myCurve); - newLine->Construction = this->Construction; + newLine->copyNonTag(this); return newLine; } @@ -3883,7 +3890,7 @@ Geometry *GeomLineSegment::copy(void)const { GeomLineSegment *tempCurve = new GeomLineSegment(); tempCurve->myCurve = Handle(Geom_TrimmedCurve)::DownCast(myCurve->Copy()); - tempCurve->Construction = this->Construction; + tempCurve->copyNonTag(this); return tempCurve; } @@ -4029,7 +4036,7 @@ GeomOffsetCurve::~GeomOffsetCurve() Geometry *GeomOffsetCurve::copy(void) const { GeomOffsetCurve *newCurve = new GeomOffsetCurve(myCurve); - newCurve->Construction = this->Construction; + newCurve->copyNonTag(this); return newCurve; } @@ -4201,7 +4208,7 @@ void GeomBezierSurface::setHandle(const Handle(Geom_BezierSurface)& b) Geometry *GeomBezierSurface::copy(void) const { GeomBezierSurface *newSurf = new GeomBezierSurface(mySurface); - newSurf->Construction = this->Construction; + newSurf->copyNonTag(this); return newSurf; } @@ -4260,7 +4267,7 @@ const Handle(Geom_Geometry)& GeomBSplineSurface::handle() const Geometry *GeomBSplineSurface::copy(void) const { GeomBSplineSurface *newSurf = new GeomBSplineSurface(mySurface); - newSurf->Construction = this->Construction; + newSurf->copyNonTag(this); return newSurf; } @@ -4307,7 +4314,7 @@ Geometry *GeomCylinder::copy(void) const { GeomCylinder *tempCurve = new GeomCylinder(); tempCurve->mySurface = Handle(Geom_CylindricalSurface)::DownCast(mySurface->Copy()); - tempCurve->Construction = this->Construction; + tempCurve->copyNonTag(this); return tempCurve; } @@ -4354,7 +4361,7 @@ Geometry *GeomCone::copy(void) const { GeomCone *tempCurve = new GeomCone(); tempCurve->mySurface = Handle(Geom_ConicalSurface)::DownCast(mySurface->Copy()); - tempCurve->Construction = this->Construction; + tempCurve->copyNonTag(this); return tempCurve; } @@ -4401,7 +4408,7 @@ Geometry *GeomToroid::copy(void) const { GeomToroid *tempCurve = new GeomToroid(); tempCurve->mySurface = Handle(Geom_ToroidalSurface)::DownCast(mySurface->Copy()); - tempCurve->Construction = this->Construction; + tempCurve->copyNonTag(this); return tempCurve; } @@ -4448,7 +4455,7 @@ Geometry *GeomSphere::copy(void) const { GeomSphere *tempCurve = new GeomSphere(); tempCurve->mySurface = Handle(Geom_SphericalSurface)::DownCast(mySurface->Copy()); - tempCurve->Construction = this->Construction; + tempCurve->copyNonTag(this); return tempCurve; } @@ -4495,7 +4502,7 @@ Geometry *GeomPlane::copy(void) const { GeomPlane *tempCurve = new GeomPlane(); tempCurve->mySurface = Handle(Geom_Plane)::DownCast(mySurface->Copy()); - tempCurve->Construction = this->Construction; + tempCurve->copyNonTag(this); return tempCurve; } @@ -4544,7 +4551,7 @@ const Handle(Geom_Geometry)& GeomOffsetSurface::handle() const Geometry *GeomOffsetSurface::copy(void) const { GeomOffsetSurface *newSurf = new GeomOffsetSurface(mySurface); - newSurf->Construction = this->Construction; + newSurf->copyNonTag(this); return newSurf; } @@ -4599,7 +4606,7 @@ const Handle(Geom_Geometry)& GeomPlateSurface::handle() const Geometry *GeomPlateSurface::copy(void) const { GeomPlateSurface *newSurf = new GeomPlateSurface(mySurface); - newSurf->Construction = this->Construction; + newSurf->copyNonTag(this); return newSurf; } @@ -4654,7 +4661,7 @@ const Handle(Geom_Geometry)& GeomTrimmedSurface::handle() const Geometry *GeomTrimmedSurface::copy(void) const { GeomTrimmedSurface *newSurf = new GeomTrimmedSurface(mySurface); - newSurf->Construction = this->Construction; + newSurf->copyNonTag(this); return newSurf; } @@ -4703,7 +4710,7 @@ const Handle(Geom_Geometry)& GeomSurfaceOfRevolution::handle() const Geometry *GeomSurfaceOfRevolution::copy(void) const { GeomSurfaceOfRevolution *newSurf = new GeomSurfaceOfRevolution(mySurface); - newSurf->Construction = this->Construction; + newSurf->copyNonTag(this); return newSurf; } @@ -4752,7 +4759,7 @@ const Handle(Geom_Geometry)& GeomSurfaceOfExtrusion::handle() const Geometry *GeomSurfaceOfExtrusion::copy(void) const { GeomSurfaceOfExtrusion *newSurf = new GeomSurfaceOfExtrusion(mySurface); - newSurf->Construction = this->Construction; + newSurf->copyNonTag(this); return newSurf; } diff --git a/src/Mod/Part/App/Geometry.h b/src/Mod/Part/App/Geometry.h index 611784c018..9ed35a73a2 100644 --- a/src/Mod/Part/App/Geometry.h +++ b/src/Mod/Part/App/Geometry.h @@ -124,6 +124,8 @@ protected: /// copies the tag from the geometry passed as a parameter to this object void assignTag(const Part::Geometry *); + void copyNonTag(const Part::Geometry *); + protected: Geometry();