+ Allow to get/set x/y axes of circle
This commit is contained in:
parent
1dcbf6a06d
commit
80f166bbf7
|
@ -48,5 +48,17 @@ Part.Circle(Point1,Point2,Point3)
|
||||||
</Documentation>
|
</Documentation>
|
||||||
<Parameter Name="Axis" Type="Object"/>
|
<Parameter Name="Axis" Type="Object"/>
|
||||||
</Attribute>
|
</Attribute>
|
||||||
|
<Attribute Name="XAxis" ReadOnly="false">
|
||||||
|
<Documentation>
|
||||||
|
<UserDocu>The X axis direction of the circle</UserDocu>
|
||||||
|
</Documentation>
|
||||||
|
<Parameter Name="XAxis" Type="Object"/>
|
||||||
|
</Attribute>
|
||||||
|
<Attribute Name="YAxis" ReadOnly="false">
|
||||||
|
<Documentation>
|
||||||
|
<UserDocu>The Y axis direction of the circle</UserDocu>
|
||||||
|
</Documentation>
|
||||||
|
<Parameter Name="YAxis" Type="Object"/>
|
||||||
|
</Attribute>
|
||||||
</PythonExport>
|
</PythonExport>
|
||||||
</GenerateModel>
|
</GenerateModel>
|
||||||
|
|
|
@ -233,6 +233,78 @@ void CirclePy::setAxis(Py::Object arg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Py::Object CirclePy::getXAxis(void) const
|
||||||
|
{
|
||||||
|
Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(getGeomCirclePtr()->handle());
|
||||||
|
gp_Ax1 axis = circle->XAxis();
|
||||||
|
gp_Dir dir = axis.Direction();
|
||||||
|
return Py::Vector(Base::Vector3d(dir.X(), dir.Y(), dir.Z()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CirclePy::setXAxis(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_Circle circle = Handle_Geom_Circle::DownCast(getGeomCirclePtr()->handle());
|
||||||
|
try {
|
||||||
|
gp_Ax2 pos;
|
||||||
|
pos = circle->Position();
|
||||||
|
pos.SetXDirection(gp_Dir(val.x, val.y, val.z));
|
||||||
|
circle->SetPosition(pos);
|
||||||
|
}
|
||||||
|
catch (Standard_Failure) {
|
||||||
|
throw Py::Exception("cannot set X axis");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Py::Object CirclePy::getYAxis(void) const
|
||||||
|
{
|
||||||
|
Handle_Geom_Circle circle = Handle_Geom_Circle::DownCast(getGeomCirclePtr()->handle());
|
||||||
|
gp_Ax1 axis = circle->YAxis();
|
||||||
|
gp_Dir dir = axis.Direction();
|
||||||
|
return Py::Vector(Base::Vector3d(dir.X(), dir.Y(), dir.Z()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CirclePy::setYAxis(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_Circle circle = Handle_Geom_Circle::DownCast(getGeomCirclePtr()->handle());
|
||||||
|
try {
|
||||||
|
gp_Ax2 pos;
|
||||||
|
pos = circle->Position();
|
||||||
|
pos.SetYDirection(gp_Dir(val.x, val.y, val.z));
|
||||||
|
circle->SetPosition(pos);
|
||||||
|
}
|
||||||
|
catch (Standard_Failure) {
|
||||||
|
throw Py::Exception("cannot set Y axis");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
PyObject *CirclePy::getCustomAttributes(const char* attr) const
|
PyObject *CirclePy::getCustomAttributes(const char* attr) const
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user