add class GeomArcOfConic to reduce code duplication
This commit is contained in:
@@ -30,10 +30,10 @@
|
||||
# include <Geom_TrimmedCurve.hxx>
|
||||
#endif
|
||||
|
||||
#include "Mod/Part/App/Geometry.h"
|
||||
#include "ArcOfEllipsePy.h"
|
||||
#include "ArcOfEllipsePy.cpp"
|
||||
#include "EllipsePy.h"
|
||||
#include "Geometry.h"
|
||||
#include <Mod/Part/App/ArcOfEllipsePy.h>
|
||||
#include <Mod/Part/App/ArcOfEllipsePy.cpp>
|
||||
#include <Mod/Part/App/EllipsePy.h>
|
||||
#include "OCCError.h"
|
||||
|
||||
#include <Base/GeometryPyCXX.h>
|
||||
@@ -141,79 +141,6 @@ void ArcOfEllipsePy::setMinorRadius(Py::Float arg)
|
||||
getGeomArcOfEllipsePtr()->setMinorRadius((double)arg);
|
||||
}
|
||||
|
||||
Py::Float ArcOfEllipsePy::getAngleXU(void) const
|
||||
{
|
||||
return Py::Float(getGeomArcOfEllipsePtr()->getAngleXU());
|
||||
}
|
||||
|
||||
void ArcOfEllipsePy::setAngleXU(Py::Float arg)
|
||||
{
|
||||
getGeomArcOfEllipsePtr()->setAngleXU((double)arg);
|
||||
}
|
||||
|
||||
Py::Object ArcOfEllipsePy::getCenter(void) const
|
||||
{
|
||||
return Py::Vector(getGeomArcOfEllipsePtr()->getCenter());
|
||||
}
|
||||
|
||||
void ArcOfEllipsePy::setCenter(Py::Object arg)
|
||||
{
|
||||
PyObject* p = arg.ptr();
|
||||
if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) {
|
||||
Base::Vector3d loc = static_cast<Base::VectorPy*>(p)->value();
|
||||
getGeomArcOfEllipsePtr()->setCenter(loc);
|
||||
}
|
||||
else if (PyObject_TypeCheck(p, &PyTuple_Type)) {
|
||||
Base::Vector3d loc = Base::getVectorFromTuple<double>(p);
|
||||
getGeomArcOfEllipsePtr()->setCenter(loc);
|
||||
}
|
||||
else {
|
||||
std::string error = std::string("type must be 'Vector', not ");
|
||||
error += p->ob_type->tp_name;
|
||||
throw Py::TypeError(error);
|
||||
}
|
||||
}
|
||||
|
||||
Py::Object ArcOfEllipsePy::getAxis(void) const
|
||||
{
|
||||
Handle_Geom_TrimmedCurve trim = Handle_Geom_TrimmedCurve::DownCast
|
||||
(getGeomArcOfEllipsePtr()->handle());
|
||||
Handle_Geom_Ellipse ellipse = Handle_Geom_Ellipse::DownCast(trim->BasisCurve());
|
||||
gp_Ax1 axis = ellipse->Axis();
|
||||
gp_Dir dir = axis.Direction();
|
||||
return Py::Vector(Base::Vector3d(dir.X(), dir.Y(), dir.Z()));
|
||||
}
|
||||
|
||||
void ArcOfEllipsePy::setAxis(Py::Object arg)
|
||||
{
|
||||
PyObject* p = arg.ptr();
|
||||
Base::Vector3d val;
|
||||
if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) {
|
||||
val = static_cast<Base::VectorPy*>(p)->value();
|
||||
}
|
||||
else if (PyTuple_Check(p)) {
|
||||
val = Base::getVectorFromTuple<double>(p);
|
||||
}
|
||||
else {
|
||||
std::string error = std::string("type must be 'Vector', not ");
|
||||
error += p->ob_type->tp_name;
|
||||
throw Py::TypeError(error);
|
||||
}
|
||||
|
||||
Handle_Geom_TrimmedCurve trim = Handle_Geom_TrimmedCurve::DownCast
|
||||
(getGeomArcOfEllipsePtr()->handle());
|
||||
Handle_Geom_Ellipse ellipse = Handle_Geom_Ellipse::DownCast(trim->BasisCurve());
|
||||
try {
|
||||
gp_Ax1 axis;
|
||||
axis.SetLocation(ellipse->Location());
|
||||
axis.SetDirection(gp_Dir(val.x, val.y, val.z));
|
||||
ellipse->SetAxis(axis);
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
throw Py::Exception("cannot set axis");
|
||||
}
|
||||
}
|
||||
|
||||
Py::Object ArcOfEllipsePy::getEllipse(void) const
|
||||
{
|
||||
Handle_Geom_TrimmedCurve trim = Handle_Geom_TrimmedCurve::DownCast
|
||||
|
||||
Reference in New Issue
Block a user