Part: Geometry refactoring copy/clone

This commit is contained in:
Abdullah Tahiri
2017-04-09 14:23:58 +02:00
committed by wmayer
parent 3f17292a05
commit c3c670e162
2 changed files with 8 additions and 256 deletions

View File

@@ -238,6 +238,13 @@ void Geometry::assignTag(const Part::Geometry * geo)
throw Base::TypeError("Geometry tag can not be assigned as geometry types do not match.");
}
Geometry *Geometry::clone(void) const
{
Geometry* cpy = this->copy();
cpy->tag = this->tag;
return cpy;
}
// -------------------------------------------------
TYPESYSTEM_SOURCE(Part::GeomPoint,Part::Geometry)
@@ -279,14 +286,6 @@ Geometry *GeomPoint::copy(void) const
return newPoint;
}
Geometry *GeomPoint::clone(void) const
{
GeomPoint *newPoint = new GeomPoint(myPoint);
newPoint->Construction = this->Construction;
newPoint->tag = this->tag;
return newPoint;
}
TopoDS_Shape GeomPoint::toShape() const
{
return BRepBuilderAPI_MakeVertex(myPoint->Pnt());
@@ -629,14 +628,6 @@ Geometry *GeomBezierCurve::copy(void) const
return newCurve;
}
Geometry *GeomBezierCurve::clone(void) const
{
GeomBezierCurve *newCurve = new GeomBezierCurve(myCurve);
newCurve->Construction = this->Construction;
newCurve->tag = this->tag;
return newCurve;
}
// Persistence implementer
unsigned int GeomBezierCurve::getMemSize (void) const {assert(0); return 0;/* not implemented yet */}
void GeomBezierCurve::Save (Base::Writer &/*writer*/) const {assert(0); /* not implemented yet */}
@@ -724,14 +715,6 @@ Geometry *GeomBSplineCurve::copy(void) const
return newCurve;
}
Geometry *GeomBSplineCurve::clone(void) const
{
GeomBSplineCurve *newCurve = new GeomBSplineCurve(myCurve);
newCurve->Construction = this->Construction;
newCurve->tag = this->tag;
return newCurve;
}
int GeomBSplineCurve::countPoles() const
{
return myCurve->NbPoles();
@@ -1521,14 +1504,6 @@ Geometry *GeomCircle::copy(void) const
return newCirc;
}
Geometry *GeomCircle::clone(void) const
{
GeomCircle *newCirc = new GeomCircle(myCurve);
newCirc->Construction = this->Construction;
newCirc->tag = this->tag;
return newCirc;
}
GeomBSplineCurve* GeomCircle::toNurbs(double first, double last) const
{
double radius = getRadius();
@@ -1708,15 +1683,6 @@ Geometry *GeomArcOfCircle::copy(void) const
return copy;
}
Geometry *GeomArcOfCircle::clone(void) const
{
GeomArcOfCircle* copy = new GeomArcOfCircle();
copy->setHandle(this->myCurve);
copy->Construction = this->Construction;
copy->tag = this->tag;
return copy;
}
GeomBSplineCurve* GeomArcOfCircle::toNurbs(double first, double last) const
{
Handle_Geom_TrimmedCurve curve = Handle_Geom_TrimmedCurve::DownCast(handle());
@@ -1933,14 +1899,6 @@ Geometry *GeomEllipse::copy(void) const
return newEllipse;
}
Geometry *GeomEllipse::clone(void) const
{
GeomEllipse *newEllipse = new GeomEllipse(myCurve);
newEllipse->Construction = this->Construction;
newEllipse->tag = this->tag;
return newEllipse;
}
GeomBSplineCurve* GeomEllipse::toNurbs(double first, double last) const
{
// for an arc of ellipse use the generic method
@@ -2197,15 +2155,6 @@ Geometry *GeomArcOfEllipse::copy(void) const
return copy;
}
Geometry *GeomArcOfEllipse::clone(void) const
{
GeomArcOfEllipse* copy = new GeomArcOfEllipse();
copy->setHandle(this->myCurve);
copy->Construction = this->Construction;
copy->tag = this->tag;
return copy;
}
GeomBSplineCurve* GeomArcOfEllipse::toNurbs(double first, double last) const
{
Handle_Geom_TrimmedCurve curve = Handle_Geom_TrimmedCurve::DownCast(handle());
@@ -2475,14 +2424,6 @@ Geometry *GeomHyperbola::copy(void) const
return newHyp;
}
Geometry *GeomHyperbola::clone(void) const
{
GeomHyperbola *newHyp = new GeomHyperbola(myCurve);
newHyp->Construction = this->Construction;
newHyp->tag = this->tag;
return newHyp;
}
GeomBSplineCurve* GeomHyperbola::toNurbs(double first, double last) const
{
return GeomCurve::toNurbs(first, last);
@@ -2652,15 +2593,6 @@ Geometry *GeomArcOfHyperbola::copy(void) const
return copy;
}
Geometry *GeomArcOfHyperbola::clone(void) const
{
GeomArcOfHyperbola* copy = new GeomArcOfHyperbola();
copy->setHandle(this->myCurve);
copy->Construction = this->Construction;
copy->tag = this->tag;
return copy;
}
GeomBSplineCurve* GeomArcOfHyperbola::toNurbs(double first, double last) const
{
Handle_Geom_TrimmedCurve curve = Handle_Geom_TrimmedCurve::DownCast(handle());
@@ -2920,14 +2852,6 @@ Geometry *GeomParabola::copy(void) const
return newPar;
}
Geometry *GeomParabola::clone(void) const
{
GeomParabola *newPar = new GeomParabola(myCurve);
newPar->Construction = this->Construction;
newPar->tag = this->tag;
return newPar;
}
GeomBSplineCurve* GeomParabola::toNurbs(double first, double last) const
{
// the default implementation suffices because a non-rational B-spline with
@@ -3078,15 +3002,6 @@ Geometry *GeomArcOfParabola::copy(void) const
return copy;
}
Geometry *GeomArcOfParabola::clone(void) const
{
GeomArcOfParabola* copy = new GeomArcOfParabola();
copy->setHandle(this->myCurve);
copy->Construction = this->Construction;
copy->tag = this->tag;
return copy;
}
GeomBSplineCurve* GeomArcOfParabola::toNurbs(double first, double last) const
{
Handle_Geom_TrimmedCurve curve = Handle_Geom_TrimmedCurve::DownCast(handle());
@@ -3315,14 +3230,6 @@ Geometry *GeomLine::copy(void) const
return newLine;
}
Geometry *GeomLine::clone(void) const
{
GeomLine *newLine = new GeomLine(myCurve);
newLine->Construction = this->Construction;
newLine->tag = this->tag;
return newLine;
}
// Persistence implementer
unsigned int GeomLine::getMemSize (void) const
{
@@ -3421,15 +3328,6 @@ Geometry *GeomLineSegment::copy(void)const
return tempCurve;
}
Geometry *GeomLineSegment::clone(void)const
{
GeomLineSegment *tempCurve = new GeomLineSegment();
tempCurve->myCurve = Handle_Geom_TrimmedCurve::DownCast(myCurve->Copy());
tempCurve->Construction = this->Construction;
tempCurve->tag = this->tag;
return tempCurve;
}
Base::Vector3d GeomLineSegment::getStartPoint() const
{
Handle_Geom_TrimmedCurve this_curve = Handle_Geom_TrimmedCurve::DownCast(handle());
@@ -3552,14 +3450,6 @@ Geometry *GeomOffsetCurve::copy(void) const
return newCurve;
}
Geometry *GeomOffsetCurve::clone(void) const
{
GeomOffsetCurve *newCurve = new GeomOffsetCurve(myCurve);
newCurve->Construction = this->Construction;
newCurve->tag = this->tag;
return newCurve;
}
void GeomOffsetCurve::setHandle(const Handle_Geom_OffsetCurve& c)
{
this->myCurve = Handle_Geom_OffsetCurve::DownCast(c->Copy());
@@ -3614,14 +3504,6 @@ Geometry *GeomTrimmedCurve::copy(void) const
return newCurve;
}
Geometry *GeomTrimmedCurve::clone(void) const
{
GeomTrimmedCurve *newCurve = new GeomTrimmedCurve(myCurve);
newCurve->Construction = this->Construction;
newCurve->tag = this->tag;
return newCurve;
}
// Persistence implementer
unsigned int GeomTrimmedCurve::getMemSize (void) const {assert(0); return 0;/* not implemented yet */}
void GeomTrimmedCurve::Save (Base::Writer &/*writer*/) const {assert(0); /* not implemented yet */}
@@ -3721,14 +3603,6 @@ Geometry *GeomBezierSurface::copy(void) const
return newSurf;
}
Geometry *GeomBezierSurface::clone(void) const
{
GeomBezierSurface *newSurf = new GeomBezierSurface(mySurface);
newSurf->Construction = this->Construction;
newSurf->tag = this->tag;
return newSurf;
}
// Persistence implementer
unsigned int GeomBezierSurface::getMemSize (void) const {assert(0); return 0;/* not implemented yet */}
void GeomBezierSurface::Save (Base::Writer &/*writer*/) const {assert(0); /* not implemented yet */}
@@ -3788,14 +3662,6 @@ Geometry *GeomBSplineSurface::copy(void) const
return newSurf;
}
Geometry *GeomBSplineSurface::clone(void) const
{
GeomBSplineSurface *newSurf = new GeomBSplineSurface(mySurface);
newSurf->Construction = this->Construction;
newSurf->tag = this->tag;
return newSurf;
}
// Persistence implementer
unsigned int GeomBSplineSurface::getMemSize (void) const {assert(0); return 0;/* not implemented yet */}
void GeomBSplineSurface::Save (Base::Writer &/*writer*/) const {assert(0); /* not implemented yet */}
@@ -3843,15 +3709,6 @@ Geometry *GeomCylinder::copy(void) const
return tempCurve;
}
Geometry *GeomCylinder::clone(void) const
{
GeomCylinder *tempCurve = new GeomCylinder();
tempCurve->mySurface = Handle_Geom_CylindricalSurface::DownCast(mySurface->Copy());
tempCurve->Construction = this->Construction;
tempCurve->tag = this->tag;
return tempCurve;
}
// Persistence implementer
unsigned int GeomCylinder::getMemSize (void) const {assert(0); return 0;/* not implemented yet */}
void GeomCylinder::Save (Base::Writer &/*writer*/) const {assert(0); /* not implemented yet */}
@@ -3899,15 +3756,6 @@ Geometry *GeomCone::copy(void) const
return tempCurve;
}
Geometry *GeomCone::clone(void) const
{
GeomCone *tempCurve = new GeomCone();
tempCurve->mySurface = Handle_Geom_ConicalSurface::DownCast(mySurface->Copy());
tempCurve->Construction = this->Construction;
tempCurve->tag = this->tag;
return tempCurve;
}
// Persistence implementer
unsigned int GeomCone::getMemSize (void) const {assert(0); return 0;/* not implemented yet */}
void GeomCone::Save (Base::Writer &/*writer*/) const {assert(0); /* not implemented yet */}
@@ -3955,15 +3803,6 @@ Geometry *GeomToroid::copy(void) const
return tempCurve;
}
Geometry *GeomToroid::clone(void) const
{
GeomToroid *tempCurve = new GeomToroid();
tempCurve->mySurface = Handle_Geom_ToroidalSurface::DownCast(mySurface->Copy());
tempCurve->Construction = this->Construction;
tempCurve->tag = this->tag;
return tempCurve;
}
// Persistence implementer
unsigned int GeomToroid::getMemSize (void) const {assert(0); return 0;/* not implemented yet */}
void GeomToroid::Save (Base::Writer &/*writer*/) const {assert(0); /* not implemented yet */}
@@ -4011,15 +3850,6 @@ Geometry *GeomSphere::copy(void) const
return tempCurve;
}
Geometry *GeomSphere::clone(void) const
{
GeomSphere *tempCurve = new GeomSphere();
tempCurve->mySurface = Handle_Geom_SphericalSurface::DownCast(mySurface->Copy());
tempCurve->Construction = this->Construction;
tempCurve->tag = this->tag;
return tempCurve;
}
// Persistence implementer
unsigned int GeomSphere::getMemSize (void) const {assert(0); return 0;/* not implemented yet */}
void GeomSphere::Save (Base::Writer &/*writer*/) const {assert(0); /* not implemented yet */}
@@ -4067,15 +3897,6 @@ Geometry *GeomPlane::copy(void) const
return tempCurve;
}
Geometry *GeomPlane::clone(void) const
{
GeomPlane *tempCurve = new GeomPlane();
tempCurve->mySurface = Handle_Geom_Plane::DownCast(mySurface->Copy());
tempCurve->Construction = this->Construction;
tempCurve->tag = this->tag;
return tempCurve;
}
// Persistence implementer
unsigned int GeomPlane::getMemSize (void) const {assert(0); return 0;/* not implemented yet */}
void GeomPlane::Save (Base::Writer &/*writer*/) const {assert(0); /* not implemented yet */}
@@ -4125,14 +3946,6 @@ Geometry *GeomOffsetSurface::copy(void) const
return newSurf;
}
Geometry *GeomOffsetSurface::clone(void) const
{
GeomOffsetSurface *newSurf = new GeomOffsetSurface(mySurface);
newSurf->Construction = this->Construction;
newSurf->tag = this->tag;
return newSurf;
}
// Persistence implementer
unsigned int GeomOffsetSurface::getMemSize (void) const {assert(0); return 0;/* not implemented yet */}
void GeomOffsetSurface::Save (Base::Writer &/*writer*/) const {assert(0); /* not implemented yet */}
@@ -4188,14 +4001,6 @@ Geometry *GeomPlateSurface::copy(void) const
return newSurf;
}
Geometry *GeomPlateSurface::clone(void) const
{
GeomPlateSurface *newSurf = new GeomPlateSurface(mySurface);
newSurf->Construction = this->Construction;
newSurf->tag = this->tag;
return newSurf;
}
// Persistence implementer
unsigned int GeomPlateSurface::getMemSize (void) const
{
@@ -4251,14 +4056,6 @@ Geometry *GeomTrimmedSurface::copy(void) const
return newSurf;
}
Geometry *GeomTrimmedSurface::clone(void) const
{
GeomTrimmedSurface *newSurf = new GeomTrimmedSurface(mySurface);
newSurf->Construction = this->Construction;
newSurf->tag = this->tag;
return newSurf;
}
// Persistence implementer
unsigned int GeomTrimmedSurface::getMemSize (void) const {assert(0); return 0;/* not implemented yet */}
void GeomTrimmedSurface::Save (Base::Writer &/*writer*/) const {assert(0); /* not implemented yet */}
@@ -4308,14 +4105,6 @@ Geometry *GeomSurfaceOfRevolution::copy(void) const
return newSurf;
}
Geometry *GeomSurfaceOfRevolution::clone(void) const
{
GeomSurfaceOfRevolution *newSurf = new GeomSurfaceOfRevolution(mySurface);
newSurf->Construction = this->Construction;
newSurf->tag = this->tag;
return newSurf;
}
// Persistence implementer
unsigned int GeomSurfaceOfRevolution::getMemSize (void) const {assert(0); return 0;/* not implemented yet */}
void GeomSurfaceOfRevolution::Save (Base::Writer &/*writer*/) const {assert(0); /* not implemented yet */}
@@ -4365,14 +4154,6 @@ Geometry *GeomSurfaceOfExtrusion::copy(void) const
return newSurf;
}
Geometry *GeomSurfaceOfExtrusion::clone(void) const
{
GeomSurfaceOfExtrusion *newSurf = new GeomSurfaceOfExtrusion(mySurface);
newSurf->Construction = this->Construction;
newSurf->tag = this->tag;
return newSurf;
}
// Persistence implementer
unsigned int GeomSurfaceOfExtrusion::getMemSize (void) const {assert(0); return 0;/* not implemented yet */}
void GeomSurfaceOfExtrusion::Save (Base::Writer &/*writer*/) const {assert(0); /* not implemented yet */}