Part: Geometry - implement missing setHandle functions and refactoring

This commit is contained in:
Abdullah Tahiri
2017-03-31 23:59:47 +02:00
committed by wmayer
parent 86932a6f01
commit 3060e28c81
2 changed files with 112 additions and 33 deletions

View File

@@ -236,7 +236,7 @@ GeomPoint::GeomPoint()
GeomPoint::GeomPoint(const Handle_Geom_CartesianPoint& p)
{
this->myPoint = Handle_Geom_CartesianPoint::DownCast(p->Copy());
setHandle(p);
}
GeomPoint::GeomPoint(const Base::Vector3d& p)
@@ -253,6 +253,11 @@ const Handle_Geom_Geometry& GeomPoint::handle() const
return myPoint;
}
void GeomPoint::setHandle(const Handle_Geom_CartesianPoint& p)
{
myPoint = Handle_Geom_CartesianPoint::DownCast(p->Copy());
}
Geometry *GeomPoint::clone(void) const
{
GeomPoint *newPoint = new GeomPoint(myPoint);
@@ -579,7 +584,7 @@ GeomBezierCurve::GeomBezierCurve()
GeomBezierCurve::GeomBezierCurve(const Handle_Geom_BezierCurve& b)
{
this->myCurve = Handle_Geom_BezierCurve::DownCast(b->Copy());
setHandle(b);
}
GeomBezierCurve::~GeomBezierCurve()
@@ -637,7 +642,7 @@ GeomBSplineCurve::GeomBSplineCurve()
GeomBSplineCurve::GeomBSplineCurve(const Handle_Geom_BSplineCurve& b)
{
this->myCurve = Handle_Geom_BSplineCurve::DownCast(b->Copy());
setHandle(b);
}
GeomBSplineCurve::GeomBSplineCurve( const std::vector<Base::Vector3d>& poles, const std::vector<double>& weights,
@@ -1456,7 +1461,7 @@ GeomCircle::GeomCircle()
GeomCircle::GeomCircle(const Handle_Geom_Circle& c)
{
this->myCurve = Handle_Geom_Circle::DownCast(c->Copy());
setHandle(c);
}
GeomCircle::~GeomCircle()
@@ -1468,6 +1473,11 @@ const Handle_Geom_Geometry& GeomCircle::handle() const
return myCurve;
}
void GeomCircle::setHandle(const Handle_Geom_Circle& c)
{
myCurve = Handle_Geom_Circle::DownCast(c->Copy());
}
Geometry *GeomCircle::clone(void) const
{
GeomCircle *newCirc = new GeomCircle(myCurve);
@@ -1621,7 +1631,7 @@ GeomArcOfCircle::GeomArcOfCircle()
GeomArcOfCircle::GeomArcOfCircle(const Handle_Geom_Circle& c)
{
this->myCurve = new Geom_TrimmedCurve(c, c->FirstParameter(),c->LastParameter());
setHandle(c);
}
GeomArcOfCircle::~GeomArcOfCircle()
@@ -1636,6 +1646,12 @@ void GeomArcOfCircle::setHandle(const Handle_Geom_TrimmedCurve& c)
this->myCurve = Handle_Geom_TrimmedCurve::DownCast(c->Copy());
}
void GeomArcOfCircle::setHandle(const Handle_Geom_Circle& c)
{
this->myCurve = new Geom_TrimmedCurve(c, c->FirstParameter(),c->LastParameter());
}
const Handle_Geom_Geometry& GeomArcOfCircle::handle() const
{
return myCurve;
@@ -1842,7 +1858,7 @@ GeomEllipse::GeomEllipse()
GeomEllipse::GeomEllipse(const Handle_Geom_Ellipse& e)
{
this->myCurve = Handle_Geom_Ellipse::DownCast(e->Copy());
setHandle(e);
}
GeomEllipse::~GeomEllipse()
@@ -1854,6 +1870,11 @@ const Handle_Geom_Geometry& GeomEllipse::handle() const
return myCurve;
}
void GeomEllipse::setHandle(const Handle_Geom_Ellipse &e)
{
this->myCurve = Handle_Geom_Ellipse::DownCast(e->Copy());
}
Geometry *GeomEllipse::clone(void) const
{
GeomEllipse *newEllipse = new GeomEllipse(myCurve);
@@ -2073,11 +2094,6 @@ PyObject *GeomEllipse::getPyObject(void)
return new EllipsePy((GeomEllipse*)this->clone());
}
void GeomEllipse::setHandle(const Handle_Geom_Ellipse &e)
{
this->myCurve = Handle_Geom_Ellipse::DownCast(e->Copy());
}
// -------------------------------------------------
TYPESYSTEM_SOURCE(Part::GeomArcOfEllipse,Part::GeomArcOfConic)
@@ -2090,7 +2106,7 @@ GeomArcOfEllipse::GeomArcOfEllipse()
GeomArcOfEllipse::GeomArcOfEllipse(const Handle_Geom_Ellipse& e)
{
this->myCurve = new Geom_TrimmedCurve(e, e->FirstParameter(),e->LastParameter());
setHandle(e);
}
GeomArcOfEllipse::~GeomArcOfEllipse()
@@ -2105,6 +2121,11 @@ void GeomArcOfEllipse::setHandle(const Handle_Geom_TrimmedCurve& c)
this->myCurve = Handle_Geom_TrimmedCurve::DownCast(c->Copy());
}
void GeomArcOfEllipse::setHandle(const Handle_Geom_Ellipse& e)
{
this->myCurve = new Geom_TrimmedCurve(e, e->FirstParameter(),e->LastParameter());
}
const Handle_Geom_Geometry& GeomArcOfEllipse::handle() const
{
return myCurve;
@@ -2363,7 +2384,7 @@ GeomHyperbola::GeomHyperbola()
GeomHyperbola::GeomHyperbola(const Handle_Geom_Hyperbola& h)
{
this->myCurve = Handle_Geom_Hyperbola::DownCast(h->Copy());
setHandle(h);
}
GeomHyperbola::~GeomHyperbola()
@@ -2375,6 +2396,11 @@ const Handle_Geom_Geometry& GeomHyperbola::handle() const
return myCurve;
}
void GeomHyperbola::setHandle(const Handle_Geom_Hyperbola& c)
{
myCurve = Handle_Geom_Hyperbola::DownCast(c->Copy());
}
Geometry *GeomHyperbola::clone(void) const
{
GeomHyperbola *newHyp = new GeomHyperbola(myCurve);
@@ -2519,7 +2545,7 @@ GeomArcOfHyperbola::GeomArcOfHyperbola()
GeomArcOfHyperbola::GeomArcOfHyperbola(const Handle_Geom_Hyperbola& h)
{
this->myCurve = new Geom_TrimmedCurve(h, h->FirstParameter(),h->LastParameter());
setHandle(h);
}
GeomArcOfHyperbola::~GeomArcOfHyperbola()
@@ -2534,6 +2560,11 @@ void GeomArcOfHyperbola::setHandle(const Handle_Geom_TrimmedCurve& c)
this->myCurve = Handle_Geom_TrimmedCurve::DownCast(c->Copy());
}
void GeomArcOfHyperbola::setHandle(const Handle_Geom_Hyperbola& h)
{
this->myCurve = new Geom_TrimmedCurve(h, h->FirstParameter(),h->LastParameter());
}
const Handle_Geom_Geometry& GeomArcOfHyperbola::handle() const
{
return myCurve;
@@ -2783,7 +2814,7 @@ GeomParabola::GeomParabola()
GeomParabola::GeomParabola(const Handle_Geom_Parabola& p)
{
this->myCurve = Handle_Geom_Parabola::DownCast(p->Copy());
setHandle(p);
}
GeomParabola::~GeomParabola()
@@ -2795,6 +2826,11 @@ const Handle_Geom_Geometry& GeomParabola::handle() const
return myCurve;
}
void GeomParabola::setHandle(const Handle_Geom_Parabola& c)
{
myCurve = Handle_Geom_Parabola::DownCast(c->Copy());
}
Geometry *GeomParabola::clone(void) const
{
GeomParabola *newPar = new GeomParabola(myCurve);
@@ -2920,7 +2956,7 @@ GeomArcOfParabola::GeomArcOfParabola()
GeomArcOfParabola::GeomArcOfParabola(const Handle_Geom_Parabola& h)
{
this->myCurve = new Geom_TrimmedCurve(h, h->FirstParameter(),h->LastParameter());
setHandle(h);
}
GeomArcOfParabola::~GeomArcOfParabola()
@@ -2935,6 +2971,11 @@ void GeomArcOfParabola::setHandle(const Handle_Geom_TrimmedCurve& c)
this->myCurve = Handle_Geom_TrimmedCurve::DownCast(c->Copy());
}
void GeomArcOfParabola::setHandle(const Handle_Geom_Parabola& h)
{
this->myCurve = new Geom_TrimmedCurve(h, h->FirstParameter(),h->LastParameter());
}
const Handle_Geom_Geometry& GeomArcOfParabola::handle() const
{
return myCurve;
@@ -3128,7 +3169,7 @@ GeomLine::GeomLine()
GeomLine::GeomLine(const Handle_Geom_Line& l)
{
this->myCurve = Handle_Geom_Line::DownCast(l->Copy());
setHandle(l);
}
GeomLine::GeomLine(const Base::Vector3d& Pos, const Base::Vector3d& Dir)
@@ -3164,6 +3205,12 @@ const Handle_Geom_Geometry& GeomLine::handle() const
return myCurve;
}
void GeomLine::setHandle(const Handle_Geom_Line& l)
{
this->myCurve = Handle_Geom_Line::DownCast(l->Copy());
}
Geometry *GeomLine::clone(void) const
{
GeomLine *newLine = new GeomLine(myCurve);
@@ -3235,6 +3282,11 @@ GeomLineSegment::GeomLineSegment()
this->myCurve = new Geom_TrimmedCurve(c, 0.0,1.0);
}
GeomLineSegment::GeomLineSegment(const Handle_Geom_Line& l)
{
setHandle(l);
}
GeomLineSegment::~GeomLineSegment()
{
}
@@ -3247,6 +3299,11 @@ void GeomLineSegment::setHandle(const Handle_Geom_TrimmedCurve& c)
this->myCurve = Handle_Geom_TrimmedCurve::DownCast(c->Copy());
}
void GeomLineSegment::setHandle(const Handle_Geom_Line& l)
{
this->myCurve = new Geom_TrimmedCurve(l, l->FirstParameter(),l->LastParameter());
}
const Handle_Geom_Geometry& GeomLineSegment::handle() const
{
return myCurve;
@@ -3369,7 +3426,7 @@ GeomOffsetCurve::GeomOffsetCurve(const Handle_Geom_Curve& c, double offset, cons
GeomOffsetCurve::GeomOffsetCurve(const Handle_Geom_OffsetCurve& c)
{
this->myCurve = Handle_Geom_OffsetCurve::DownCast(c->Copy());
setHandle(c);
}
GeomOffsetCurve::~GeomOffsetCurve()
@@ -3414,7 +3471,7 @@ GeomTrimmedCurve::GeomTrimmedCurve()
GeomTrimmedCurve::GeomTrimmedCurve(const Handle_Geom_TrimmedCurve& c)
{
this->myCurve = Handle_Geom_TrimmedCurve::DownCast(c->Copy());
setHandle(c);
}
GeomTrimmedCurve::~GeomTrimmedCurve()
@@ -3514,7 +3571,7 @@ GeomBezierSurface::GeomBezierSurface()
GeomBezierSurface::GeomBezierSurface(const Handle_Geom_BezierSurface& b)
{
this->mySurface = Handle_Geom_BezierSurface::DownCast(b->Copy());
setHandle(b);
}
GeomBezierSurface::~GeomBezierSurface()
@@ -3526,6 +3583,11 @@ const Handle_Geom_Geometry& GeomBezierSurface::handle() const
return mySurface;
}
void GeomBezierSurface::setHandle(const Handle_Geom_BezierSurface& b)
{
this->mySurface = Handle_Geom_BezierSurface::DownCast(b->Copy());
}
Geometry *GeomBezierSurface::clone(void) const
{
GeomBezierSurface *newSurf = new GeomBezierSurface(mySurface);
@@ -3569,7 +3631,7 @@ GeomBSplineSurface::GeomBSplineSurface()
GeomBSplineSurface::GeomBSplineSurface(const Handle_Geom_BSplineSurface& b)
{
this->mySurface = Handle_Geom_BSplineSurface::DownCast(b->Copy());
setHandle(b);
}
GeomBSplineSurface::~GeomBSplineSurface()
@@ -3616,7 +3678,7 @@ GeomCylinder::GeomCylinder()
GeomCylinder::GeomCylinder(const Handle_Geom_CylindricalSurface& c)
{
this->mySurface = Handle_Geom_CylindricalSurface::DownCast(c->Copy());
setHandle(c);
}
GeomCylinder::~GeomCylinder()
@@ -3664,7 +3726,7 @@ GeomCone::GeomCone()
GeomCone::GeomCone(const Handle_Geom_ConicalSurface& c)
{
this->mySurface = Handle_Geom_ConicalSurface::DownCast(c->Copy());
setHandle(c);
}
GeomCone::~GeomCone()
@@ -3712,7 +3774,7 @@ GeomToroid::GeomToroid()
GeomToroid::GeomToroid(const Handle_Geom_ToroidalSurface& t)
{
this->mySurface = Handle_Geom_ToroidalSurface::DownCast(t->Copy());
setHandle(t);
}
GeomToroid::~GeomToroid()
@@ -3760,7 +3822,7 @@ GeomSphere::GeomSphere()
GeomSphere::GeomSphere(const Handle_Geom_SphericalSurface& s)
{
this->mySurface = Handle_Geom_SphericalSurface::DownCast(s->Copy());
setHandle(s);
}
GeomSphere::~GeomSphere()
@@ -3808,7 +3870,7 @@ GeomPlane::GeomPlane()
GeomPlane::GeomPlane(const Handle_Geom_Plane& p)
{
this->mySurface = Handle_Geom_Plane::DownCast(p->Copy());
setHandle(p);
}
GeomPlane::~GeomPlane()
@@ -3859,7 +3921,7 @@ GeomOffsetSurface::GeomOffsetSurface(const Handle_Geom_Surface& s, double offset
GeomOffsetSurface::GeomOffsetSurface(const Handle_Geom_OffsetSurface& s)
{
this->mySurface = Handle_Geom_OffsetSurface::DownCast(s->Copy());
setHandle(s);
}
GeomOffsetSurface::~GeomOffsetSurface()
@@ -3915,7 +3977,7 @@ GeomPlateSurface::GeomPlateSurface(const GeomPlate_BuildPlateSurface& buildPlate
GeomPlateSurface::GeomPlateSurface(const Handle_GeomPlate_Surface& s)
{
this->mySurface = Handle_GeomPlate_Surface::DownCast(s->Copy());
setHandle(s);
}
GeomPlateSurface::~GeomPlateSurface()
@@ -3971,7 +4033,7 @@ GeomTrimmedSurface::GeomTrimmedSurface()
GeomTrimmedSurface::GeomTrimmedSurface(const Handle_Geom_RectangularTrimmedSurface& s)
{
this->mySurface = Handle_Geom_RectangularTrimmedSurface::DownCast(s->Copy());
setHandle(s);
}
GeomTrimmedSurface::~GeomTrimmedSurface()
@@ -4021,7 +4083,7 @@ GeomSurfaceOfRevolution::GeomSurfaceOfRevolution(const Handle_Geom_Curve& c, con
GeomSurfaceOfRevolution::GeomSurfaceOfRevolution(const Handle_Geom_SurfaceOfRevolution& s)
{
this->mySurface = Handle_Geom_SurfaceOfRevolution::DownCast(s->Copy());
setHandle(s);
}
GeomSurfaceOfRevolution::~GeomSurfaceOfRevolution()
@@ -4071,7 +4133,7 @@ GeomSurfaceOfExtrusion::GeomSurfaceOfExtrusion(const Handle_Geom_Curve& c, const
GeomSurfaceOfExtrusion::GeomSurfaceOfExtrusion(const Handle_Geom_SurfaceOfLinearExtrusion& s)
{
this->mySurface = Handle_Geom_SurfaceOfLinearExtrusion::DownCast(s->Copy());
setHandle(s);
}
GeomSurfaceOfExtrusion::~GeomSurfaceOfExtrusion()

View File

@@ -76,9 +76,14 @@ public:
virtual unsigned int getMemSize(void) const;
virtual void Save(Base::Writer &/*writer*/) const;
virtual void Restore(Base::XMLReader &/*reader*/);
/// returns a cloned object
/// 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 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;
/// construction geometry (means no impact on a later built topo)
/// Note: In the Sketcher and only for the specific case of a point, it has a special meaning:
/// a construction point has fixed coordinates for the solver (it has fixed parameters)
bool Construction;
/// returns the tag of the geometry object
boost::uuids::uuid getTag() const;
@@ -113,6 +118,7 @@ public:
virtual PyObject *getPyObject(void);
const Handle_Geom_Geometry& handle() const;
void setHandle(const Handle_Geom_CartesianPoint&);
Base::Vector3d getPoint(void)const;
void setPoint(const Base::Vector3d&);
@@ -369,6 +375,8 @@ public:
virtual GeomBSplineCurve* toNurbs(double first, double last) const;
const Handle_Geom_Geometry& handle() const;
void setHandle(const Handle_Geom_Circle&);
private:
Handle_Geom_Circle myCurve;
@@ -398,6 +406,7 @@ public:
virtual GeomBSplineCurve* toNurbs(double first, double last) const;
void setHandle(const Handle_Geom_TrimmedCurve&);
void setHandle(const Handle_Geom_Circle&);
const Handle_Geom_Geometry& handle() const;
private:
@@ -463,6 +472,7 @@ public:
virtual GeomBSplineCurve* toNurbs(double first, double last) const;
void setHandle(const Handle_Geom_TrimmedCurve&);
void setHandle(const Handle_Geom_Ellipse&);
const Handle_Geom_Geometry& handle() const;
private:
@@ -493,6 +503,7 @@ public:
virtual GeomBSplineCurve* toNurbs(double first, double last) const;
const Handle_Geom_Geometry& handle() const;
void setHandle(const Handle_Geom_Hyperbola&);
private:
Handle_Geom_Hyperbola myCurve;
@@ -526,6 +537,7 @@ public:
virtual GeomBSplineCurve* toNurbs(double first, double last) const;
void setHandle(const Handle_Geom_TrimmedCurve&);
void setHandle(const Handle_Geom_Hyperbola&);
const Handle_Geom_Geometry& handle() const;
private:
@@ -553,6 +565,7 @@ public:
virtual GeomBSplineCurve* toNurbs(double first, double last) const;
const Handle_Geom_Geometry& handle() const;
void setHandle(const Handle_Geom_Parabola&);
private:
Handle_Geom_Parabola myCurve;
@@ -584,6 +597,7 @@ public:
virtual GeomBSplineCurve* toNurbs(double first, double last) const;
void setHandle(const Handle_Geom_TrimmedCurve&);
void setHandle(const Handle_Geom_Parabola&);
const Handle_Geom_Geometry& handle() const;
private:
@@ -612,6 +626,7 @@ public:
virtual PyObject *getPyObject(void);
const Handle_Geom_Geometry& handle() const;
void setHandle(const Handle_Geom_Line&);
private:
Handle_Geom_Line myCurve;
@@ -622,6 +637,7 @@ class PartExport GeomLineSegment : public GeomCurve
TYPESYSTEM_HEADER();
public:
GeomLineSegment();
GeomLineSegment(const Handle_Geom_Line& l);
virtual ~GeomLineSegment();
virtual Geometry *clone(void) const;
@@ -639,6 +655,7 @@ public:
virtual PyObject *getPyObject(void);
void setHandle(const Handle_Geom_TrimmedCurve&);
void setHandle(const Handle_Geom_Line&);
const Handle_Geom_Geometry& handle() const;
private:
@@ -720,7 +737,7 @@ public:
// Base implementer ----------------------------
virtual PyObject *getPyObject(void);
void setHandle(const Handle_Geom_BezierSurface& b);
const Handle_Geom_Geometry& handle() const;
private: