implement methods of Geometry2dPy
This commit is contained in:
parent
9c720dde7b
commit
8bd22e4d99
|
@ -18,7 +18,6 @@ It describes the common behavior of these objects when:
|
||||||
- applying geometric transformations to objects, and
|
- applying geometric transformations to objects, and
|
||||||
- constructing objects by geometric transformation (including copying).</UserDocu>
|
- constructing objects by geometric transformation (including copying).</UserDocu>
|
||||||
</Documentation>
|
</Documentation>
|
||||||
<!--
|
|
||||||
<Methode Name="mirror">
|
<Methode Name="mirror">
|
||||||
<Documentation>
|
<Documentation>
|
||||||
<UserDocu>Performs the symmetrical transformation of this geometric object</UserDocu>
|
<UserDocu>Performs the symmetrical transformation of this geometric object</UserDocu>
|
||||||
|
@ -26,7 +25,7 @@ It describes the common behavior of these objects when:
|
||||||
</Methode>
|
</Methode>
|
||||||
<Methode Name="rotate">
|
<Methode Name="rotate">
|
||||||
<Documentation>
|
<Documentation>
|
||||||
<UserDocu>Rotates this geometric object at angle Ang (in radians) about axis</UserDocu>
|
<UserDocu>Rotates this geometric object at angle Ang (in radians) around a point</UserDocu>
|
||||||
</Documentation>
|
</Documentation>
|
||||||
</Methode>
|
</Methode>
|
||||||
<Methode Name="scale">
|
<Methode Name="scale">
|
||||||
|
@ -49,6 +48,5 @@ It describes the common behavior of these objects when:
|
||||||
<UserDocu>Create a copy of this geometry</UserDocu>
|
<UserDocu>Create a copy of this geometry</UserDocu>
|
||||||
</Documentation>
|
</Documentation>
|
||||||
</Methode>
|
</Methode>
|
||||||
-->
|
|
||||||
</PythonExport>
|
</PythonExport>
|
||||||
</GenerateModel>
|
</GenerateModel>
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
# include <gp_Dir2d.hxx>
|
# include <gp_Dir2d.hxx>
|
||||||
# include <gp_Pnt2d.hxx>
|
# include <gp_Pnt2d.hxx>
|
||||||
# include <gp_Vec2d.hxx>
|
# include <gp_Vec2d.hxx>
|
||||||
# include <gp_Trsf.hxx>
|
# include <gp_Trsf2d.hxx>
|
||||||
# include <Geom2d_Geometry.hxx>
|
# include <Geom2d_Geometry.hxx>
|
||||||
# include <Geom2d_Curve.hxx>
|
# include <Geom2d_Curve.hxx>
|
||||||
# include <Precision.hxx>
|
# include <Precision.hxx>
|
||||||
|
@ -70,12 +70,12 @@ int Geometry2dPy::PyInit(PyObject* /*args*/, PyObject* /*kwd*/)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#if 0
|
|
||||||
PyObject* Geometry2dPy::mirror(PyObject *args)
|
PyObject* Geometry2dPy::mirror(PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject* o;
|
PyObject* o;
|
||||||
if (PyArg_ParseTuple(args, "O!", Base::Vector2dPy::type_object(),&o)) {
|
if (PyArg_ParseTuple(args, "O!", Base::Vector2dPy::type_object(),&o)) {
|
||||||
Base::Vector2d vec = static_cast<Base::Vector2dPy*>(o)->getValue();
|
Base::Vector2d vec = static_cast<Base::Vector2dPy*>(o)->value();
|
||||||
gp_Pnt2d pnt(vec.x, vec.y);
|
gp_Pnt2d pnt(vec.x, vec.y);
|
||||||
getGeometry2dPtr()->handle()->Mirror(pnt);
|
getGeometry2dPtr()->handle()->Mirror(pnt);
|
||||||
Py_Return;
|
Py_Return;
|
||||||
|
@ -85,8 +85,8 @@ PyObject* Geometry2dPy::mirror(PyObject *args)
|
||||||
PyObject* axis;
|
PyObject* axis;
|
||||||
if (PyArg_ParseTuple(args, "O!O!", Base::Vector2dPy::type_object(),&o,
|
if (PyArg_ParseTuple(args, "O!O!", Base::Vector2dPy::type_object(),&o,
|
||||||
Base::Vector2dPy::type_object(),&axis)) {
|
Base::Vector2dPy::type_object(),&axis)) {
|
||||||
Base::Vector2d pnt = static_cast<Base::Vector2dPy*>(o)->getValue();
|
Base::Vector2d pnt = static_cast<Base::Vector2dPy*>(o)->value();
|
||||||
Base::Vector2d dir = static_cast<Base::Vector2dPy*>(axis)->getValue();
|
Base::Vector2d dir = static_cast<Base::Vector2dPy*>(axis)->value();
|
||||||
gp_Ax2d ax1(gp_Pnt2d(pnt.x,pnt.y), gp_Dir2d(dir.x,dir.y));
|
gp_Ax2d ax1(gp_Pnt2d(pnt.x,pnt.y), gp_Dir2d(dir.x,dir.y));
|
||||||
getGeometry2dPtr()->handle()->Mirror(ax1);
|
getGeometry2dPtr()->handle()->Mirror(ax1);
|
||||||
Py_Return;
|
Py_Return;
|
||||||
|
@ -99,51 +99,49 @@ PyObject* Geometry2dPy::mirror(PyObject *args)
|
||||||
PyObject* Geometry2dPy::rotate(PyObject *args)
|
PyObject* Geometry2dPy::rotate(PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject* o;
|
PyObject* o;
|
||||||
if (!PyArg_ParseTuple(args, "O!", &(Base::PlacementPy::Type),&o))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
Base::Placement* plm = static_cast<Base::PlacementPy*>(o)->getPlacementPtr();
|
|
||||||
Base::Rotation rot(plm->getRotation());
|
|
||||||
Base::Vector3d pnt, dir;
|
|
||||||
double angle;
|
double angle;
|
||||||
|
Base::Vector2d vec;
|
||||||
rot.getValue(dir, angle);
|
if (PyArg_ParseTuple(args, "O!d", Base::Vector2dPy::type_object(), &o, &angle)) {
|
||||||
pnt = plm->getPosition();
|
vec = static_cast<Base::Vector2dPy*>(o)->value();
|
||||||
|
gp_Pnt2d pnt(vec.x, vec.y);
|
||||||
getGeometry2dPtr()->handle()->Rotate(gp_Pnt2d(pnt.x,pnt.y), angle);
|
getGeometry2dPtr()->handle()->Rotate(pnt, angle);
|
||||||
Py_Return;
|
Py_Return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PyErr_SetString(PartExceptionOCCError, "Vector2d and float expected");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
PyObject* Geometry2dPy::scale(PyObject *args)
|
PyObject* Geometry2dPy::scale(PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject* o;
|
PyObject* o;
|
||||||
double scale;
|
double scale;
|
||||||
Base::Vector2d vec;
|
Base::Vector2d vec;
|
||||||
if (PyArg_ParseTuple(args, "O!d", Base::Vector2dPy::type_object(), &o, &scale)) {
|
if (PyArg_ParseTuple(args, "O!d", Base::Vector2dPy::type_object(), &o, &scale)) {
|
||||||
vec = static_cast<Base::Vector2dPy*>(o)->getValue();
|
vec = static_cast<Base::Vector2dPy*>(o)->value();
|
||||||
gp_Pnt2d pnt(vec.x, vec.y);
|
gp_Pnt2d pnt(vec.x, vec.y);
|
||||||
getGeometry2dPtr()->handle()->Scale(pnt, scale);
|
getGeometry2dPtr()->handle()->Scale(pnt, scale);
|
||||||
Py_Return;
|
Py_Return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyErr_SetString(PartExceptionOCCError, "either vector or tuple and float expected");
|
PyErr_SetString(PartExceptionOCCError, "Vector2d and float expected");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject* Geometry2dPy::transform(PyObject *args)
|
PyObject* Geometry2dPy::transform(PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject* o;
|
PyObject* o;
|
||||||
if (!PyArg_ParseTuple(args, "O!", &(Base::MatrixPy::Type),&o))
|
if (!PyArg_ParseTuple(args, "O", &o))
|
||||||
return 0;
|
return 0;
|
||||||
Base::Matrix4D mat = static_cast<Base::MatrixPy*>(o)->value();
|
Py::Sequence list(o);
|
||||||
gp_Trsf trf;
|
double a11 = static_cast<double>(Py::Float(list.getItem(0)));
|
||||||
trf.SetValues(mat[0][0],mat[0][1],mat[0][2],mat[0][3],
|
double a12 = static_cast<double>(Py::Float(list.getItem(1)));
|
||||||
mat[1][0],mat[1][1],mat[1][2],mat[1][3],
|
double a13 = static_cast<double>(Py::Float(list.getItem(2)));
|
||||||
mat[2][0],mat[2][1],mat[2][2],mat[2][3]
|
double a21 = static_cast<double>(Py::Float(list.getItem(3)));
|
||||||
#if OCC_VERSION_HEX < 0x060800
|
double a22 = static_cast<double>(Py::Float(list.getItem(4)));
|
||||||
, 0.00001,0.00001
|
double a23 = static_cast<double>(Py::Float(list.getItem(5)));
|
||||||
#endif
|
gp_Trsf2d trf;
|
||||||
); //precision was removed in OCCT CR0025194
|
trf.SetValues(a11,a12,a13,a21,a22,a23);
|
||||||
getGeometry2dPtr()->handle()->Transform(trf);
|
getGeometry2dPtr()->handle()->Transform(trf);
|
||||||
Py_Return;
|
Py_Return;
|
||||||
}
|
}
|
||||||
|
@ -153,13 +151,13 @@ PyObject* Geometry2dPy::translate(PyObject *args)
|
||||||
PyObject* o;
|
PyObject* o;
|
||||||
Base::Vector2d vec;
|
Base::Vector2d vec;
|
||||||
if (PyArg_ParseTuple(args, "O!", Base::Vector2dPy::type_object(),&o)) {
|
if (PyArg_ParseTuple(args, "O!", Base::Vector2dPy::type_object(),&o)) {
|
||||||
vec = static_cast<Base::Vector2dPy*>(o)->getValue();
|
vec = static_cast<Base::Vector2dPy*>(o)->value();
|
||||||
gp_Vec2d trl(vec.x, vec.y);
|
gp_Vec2d trl(vec.x, vec.y);
|
||||||
getGeometry2dPtr()->handle()->Translate(trl);
|
getGeometry2dPtr()->handle()->Translate(trl);
|
||||||
Py_Return;
|
Py_Return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyErr_SetString(PartExceptionOCCError, "either vector or tuple expected");
|
PyErr_SetString(PartExceptionOCCError, "Vector2d expected");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,7 +187,7 @@ PyObject* Geometry2dPy::copy(PyObject *args)
|
||||||
geompy->_pcTwinPointer = geom->clone();
|
geompy->_pcTwinPointer = geom->clone();
|
||||||
return cpy;
|
return cpy;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
PyObject *Geometry2dPy::getCustomAttributes(const char* /*attr*/) const
|
PyObject *Geometry2dPy::getCustomAttributes(const char* /*attr*/) const
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user