Use OCCT Handle macro for Handle_ classes

This is the result of running OCCT's upgrade script provided
with OCCT 7.0. See
https://www.opencascade.com/content/freecad-occt710-and-windows-rtti-data-missing#comment-form
and
https://www.forum.freecadweb.org/viewtopic.php?f=4&t=21405&start=120#p169019
for why this is necessary for OCCT >= 7.1
This commit is contained in:
Peter Lama
2017-04-17 20:33:29 -04:00
committed by wmayer
parent 4564e4f4a4
commit fa4bebf2e0
141 changed files with 2198 additions and 2208 deletions

View File

@@ -62,46 +62,46 @@
#include <Mod/Part/App/TopoShapeFacePy.h>
namespace Part {
const Py::Object makeGeometryCurvePy(const Handle_Geom_Curve& c)
const Py::Object makeGeometryCurvePy(const Handle(Geom_Curve)& c)
{
if (c->IsKind(STANDARD_TYPE(Geom_Circle))) {
Handle_Geom_Circle circ = Handle_Geom_Circle::DownCast(c);
Handle(Geom_Circle) circ = Handle(Geom_Circle)::DownCast(c);
return Py::asObject(new CirclePy(new GeomCircle(circ)));
}
else if (c->IsKind(STANDARD_TYPE(Geom_Ellipse))) {
Handle_Geom_Ellipse ell = Handle_Geom_Ellipse::DownCast(c);
Handle(Geom_Ellipse) ell = Handle(Geom_Ellipse)::DownCast(c);
return Py::asObject(new EllipsePy(new GeomEllipse(ell)));
}
else if (c->IsKind(STANDARD_TYPE(Geom_Hyperbola))) {
Handle_Geom_Hyperbola hyp = Handle_Geom_Hyperbola::DownCast(c);
Handle(Geom_Hyperbola) hyp = Handle(Geom_Hyperbola)::DownCast(c);
return Py::asObject(new HyperbolaPy(new GeomHyperbola(hyp)));
}
else if (c->IsKind(STANDARD_TYPE(Geom_Line))) {
Handle_Geom_Line lin = Handle_Geom_Line::DownCast(c);
Handle(Geom_Line) lin = Handle(Geom_Line)::DownCast(c);
return Py::asObject(new GeometryCurvePy(new GeomLine(lin)));
}
else if (c->IsKind(STANDARD_TYPE(Geom_OffsetCurve))) {
Handle_Geom_OffsetCurve oc = Handle_Geom_OffsetCurve::DownCast(c);
Handle(Geom_OffsetCurve) oc = Handle(Geom_OffsetCurve)::DownCast(c);
return Py::asObject(new OffsetCurvePy(new GeomOffsetCurve(oc)));
}
else if (c->IsKind(STANDARD_TYPE(Geom_Parabola))) {
Handle_Geom_Parabola par = Handle_Geom_Parabola::DownCast(c);
Handle(Geom_Parabola) par = Handle(Geom_Parabola)::DownCast(c);
return Py::asObject(new ParabolaPy(new GeomParabola(par)));
}
else if (c->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) {
Handle_Geom_TrimmedCurve trc = Handle_Geom_TrimmedCurve::DownCast(c);
Handle(Geom_TrimmedCurve) trc = Handle(Geom_TrimmedCurve)::DownCast(c);
return Py::asObject(new GeometryCurvePy(new GeomTrimmedCurve(trc)));
}
/*else if (c->IsKind(STANDARD_TYPE(Geom_BoundedCurve))) {
Handle_Geom_BoundedCurve bc = Handle_Geom_BoundedCurve::DownCast(c);
Handle(Geom_BoundedCurve) bc = Handle(Geom_BoundedCurve)::DownCast(c);
return Py::asObject(new GeometryCurvePy(new GeomBoundedCurve(bc)));
}*/
else if (c->IsKind(STANDARD_TYPE(Geom_BezierCurve))) {
Handle_Geom_BezierCurve bezier = Handle_Geom_BezierCurve::DownCast(c);
Handle(Geom_BezierCurve) bezier = Handle(Geom_BezierCurve)::DownCast(c);
return Py::asObject(new BezierCurvePy(new GeomBezierCurve(bezier)));
}
else if (c->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) {
Handle_Geom_BSplineCurve bspline = Handle_Geom_BSplineCurve::DownCast(c);
Handle(Geom_BSplineCurve) bspline = Handle(Geom_BSplineCurve)::DownCast(c);
return Py::asObject(new BSplineCurvePy(new GeomBSplineCurve(bspline)));
}
@@ -138,8 +138,8 @@ int GeometrySurfacePy::PyInit(PyObject* /*args*/, PyObject* /*kwd*/)
PyObject* GeometrySurfacePy::toShape(PyObject *args)
{
Handle_Geom_Geometry g = getGeometryPtr()->handle();
Handle_Geom_Surface s = Handle_Geom_Surface::DownCast(g);
Handle(Geom_Geometry) g = getGeometryPtr()->handle();
Handle(Geom_Surface) s = Handle(Geom_Surface)::DownCast(g);
try {
if (!s.IsNull()) {
double u1,u2,v1,v2;
@@ -156,7 +156,7 @@ PyObject* GeometrySurfacePy::toShape(PyObject *args)
}
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
@@ -167,8 +167,8 @@ PyObject* GeometrySurfacePy::toShape(PyObject *args)
PyObject* GeometrySurfacePy::value(PyObject *args)
{
Handle_Geom_Geometry g = getGeometryPtr()->handle();
Handle_Geom_Surface s = Handle_Geom_Surface::DownCast(g);
Handle(Geom_Geometry) g = getGeometryPtr()->handle();
Handle(Geom_Surface) s = Handle(Geom_Surface)::DownCast(g);
try {
if (!s.IsNull()) {
double u,v;
@@ -179,7 +179,7 @@ PyObject* GeometrySurfacePy::value(PyObject *args)
}
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
@@ -190,8 +190,8 @@ PyObject* GeometrySurfacePy::value(PyObject *args)
PyObject* GeometrySurfacePy::tangent(PyObject *args)
{
Handle_Geom_Geometry g = getGeometryPtr()->handle();
Handle_Geom_Surface s = Handle_Geom_Surface::DownCast(g);
Handle(Geom_Geometry) g = getGeometryPtr()->handle();
Handle(Geom_Surface) s = Handle(Geom_Surface)::DownCast(g);
try {
if (!s.IsNull()) {
double u,v;
@@ -213,7 +213,7 @@ PyObject* GeometrySurfacePy::tangent(PyObject *args)
}
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
@@ -224,7 +224,7 @@ PyObject* GeometrySurfacePy::tangent(PyObject *args)
PyObject* GeometrySurfacePy::parameter(PyObject *args)
{
Handle_Geom_Surface surf = Handle_Geom_Surface
Handle(Geom_Surface) surf = Handle(Geom_Surface)
::DownCast(getGeometryPtr()->handle());
try {
if (!surf.IsNull()) {
@@ -243,7 +243,7 @@ PyObject* GeometrySurfacePy::parameter(PyObject *args)
}
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
@@ -257,7 +257,7 @@ PyObject* GeometrySurfacePy::bounds(PyObject * args)
if (!PyArg_ParseTuple(args, ""))
return 0;
Handle_Geom_Surface surf = Handle_Geom_Surface
Handle(Geom_Surface) surf = Handle(Geom_Surface)
::DownCast(getGeometryPtr()->handle());
Py::Tuple bound(4);
Standard_Real u1,u2,v1,v2;
@@ -276,18 +276,18 @@ PyObject* GeometrySurfacePy::uIso(PyObject * args)
return 0;
try {
Handle_Geom_Surface surf = Handle_Geom_Surface::DownCast
Handle(Geom_Surface) surf = Handle(Geom_Surface)::DownCast
(getGeometryPtr()->handle());
Handle_Geom_Curve c = surf->UIso(v);
Handle(Geom_Curve) c = surf->UIso(v);
if (c.IsNull()) {
PyErr_SetString(PyExc_RuntimeError, "failed to create u iso curve");
return 0;
}
if (c->IsKind(STANDARD_TYPE(Geom_Line))) {
Handle_Geom_Line aLine = Handle_Geom_Line::DownCast(c);
Handle(Geom_Line) aLine = Handle(Geom_Line)::DownCast(c);
GeomLine* line = new GeomLine();
Handle_Geom_Line this_curv = Handle_Geom_Line::DownCast
Handle(Geom_Line) this_curv = Handle(Geom_Line)::DownCast
(line->handle());
this_curv->SetLin(aLine->Lin());
return new LinePy(line);
@@ -297,7 +297,7 @@ PyObject* GeometrySurfacePy::uIso(PyObject * args)
}
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
@@ -310,18 +310,18 @@ PyObject* GeometrySurfacePy::vIso(PyObject * args)
return 0;
try {
Handle_Geom_Surface surf = Handle_Geom_Surface::DownCast
Handle(Geom_Surface) surf = Handle(Geom_Surface)::DownCast
(getGeometryPtr()->handle());
Handle_Geom_Curve c = surf->VIso(v);
Handle(Geom_Curve) c = surf->VIso(v);
if (c.IsNull()) {
PyErr_SetString(PyExc_RuntimeError, "failed to create v iso curve");
return 0;
}
if (c->IsKind(STANDARD_TYPE(Geom_Line))) {
Handle_Geom_Line aLine = Handle_Geom_Line::DownCast(c);
Handle(Geom_Line) aLine = Handle(Geom_Line)::DownCast(c);
GeomLine* line = new GeomLine();
Handle_Geom_Line this_curv = Handle_Geom_Line::DownCast
Handle(Geom_Line) this_curv = Handle(Geom_Line)::DownCast
(line->handle());
this_curv->SetLin(aLine->Lin());
return new LinePy(line);
@@ -331,7 +331,7 @@ PyObject* GeometrySurfacePy::vIso(PyObject * args)
}
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
@@ -342,7 +342,7 @@ PyObject* GeometrySurfacePy::isUPeriodic(PyObject * args)
if (!PyArg_ParseTuple(args, ""))
return 0;
Handle_Geom_Surface surf = Handle_Geom_Surface::DownCast
Handle(Geom_Surface) surf = Handle(Geom_Surface)::DownCast
(getGeometryPtr()->handle());
Standard_Boolean val = surf->IsUPeriodic();
return PyBool_FromLong(val ? 1 : 0);
@@ -353,7 +353,7 @@ PyObject* GeometrySurfacePy::isVPeriodic(PyObject * args)
if (!PyArg_ParseTuple(args, ""))
return 0;
Handle_Geom_Surface surf = Handle_Geom_Surface::DownCast
Handle(Geom_Surface) surf = Handle(Geom_Surface)::DownCast
(getGeometryPtr()->handle());
Standard_Boolean val = surf->IsVPeriodic();
return PyBool_FromLong(val ? 1 : 0);
@@ -364,7 +364,7 @@ PyObject* GeometrySurfacePy::isUClosed(PyObject * args)
if (!PyArg_ParseTuple(args, ""))
return 0;
Handle_Geom_Surface surf = Handle_Geom_Surface::DownCast
Handle(Geom_Surface) surf = Handle(Geom_Surface)::DownCast
(getGeometryPtr()->handle());
Standard_Boolean val = surf->IsUClosed();
return PyBool_FromLong(val ? 1 : 0);
@@ -375,7 +375,7 @@ PyObject* GeometrySurfacePy::isVClosed(PyObject * args)
if (!PyArg_ParseTuple(args, ""))
return 0;
Handle_Geom_Surface surf = Handle_Geom_Surface::DownCast
Handle(Geom_Surface) surf = Handle(Geom_Surface)::DownCast
(getGeometryPtr()->handle());
Standard_Boolean val = surf->IsVClosed();
return PyBool_FromLong(val ? 1 : 0);
@@ -387,13 +387,13 @@ PyObject* GeometrySurfacePy::UPeriod(PyObject * args)
return 0;
try {
Handle_Geom_Surface surf = Handle_Geom_Surface::DownCast
Handle(Geom_Surface) surf = Handle(Geom_Surface)::DownCast
(getGeometryPtr()->handle());
Standard_Real val = surf->UPeriod();
return PyFloat_FromDouble(val);
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
@@ -405,13 +405,13 @@ PyObject* GeometrySurfacePy::VPeriod(PyObject * args)
return 0;
try {
Handle_Geom_Surface surf = Handle_Geom_Surface::DownCast
Handle(Geom_Surface) surf = Handle(Geom_Surface)::DownCast
(getGeometryPtr()->handle());
Standard_Real val = surf->VPeriod();
return PyFloat_FromDouble(val);
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
@@ -419,7 +419,7 @@ PyObject* GeometrySurfacePy::VPeriod(PyObject * args)
Py::String GeometrySurfacePy::getContinuity(void) const
{
GeomAbs_Shape c = Handle_Geom_Surface::DownCast
GeomAbs_Shape c = Handle(Geom_Surface)::DownCast
(getGeometryPtr()->handle())->Continuity();
std::string str;
switch (c) {
@@ -494,7 +494,7 @@ PyObject* GeometrySurfacePy::toBSpline(PyObject * args)
absV = GeomAbs_G2;
try {
Handle_Geom_Surface surf = Handle_Geom_Surface::DownCast
Handle(Geom_Surface) surf = Handle(Geom_Surface)::DownCast
(getGeometryPtr()->handle());
GeomConvert_ApproxSurface cvt(surf, tol3d, absU, absV, maxDegU, maxDegV, maxSegm, prec);
if (cvt.IsDone() && cvt.HasResult()) {
@@ -505,7 +505,7 @@ PyObject* GeometrySurfacePy::toBSpline(PyObject * args)
}
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
}
@@ -526,14 +526,14 @@ int GeometrySurfacePy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj
PyObject* GeometrySurfacePy::intersectSS(PyObject *args)
{
Handle_Geom_Surface surf1 = Handle_Geom_Surface::DownCast(getGeometryPtr()->handle());
Handle(Geom_Surface) surf1 = Handle(Geom_Surface)::DownCast(getGeometryPtr()->handle());
try {
if (!surf1.IsNull()) {
PyObject *p;
double prec = Precision::Confusion();
if (!PyArg_ParseTuple(args, "O!|d", &(Part::GeometrySurfacePy::Type), &p, &prec))
return 0;
Handle_Geom_Surface surf2 = Handle_Geom_Surface::DownCast(static_cast<GeometryPy*>(p)->getGeometryPtr()->handle());
Handle(Geom_Surface) surf2 = Handle(Geom_Surface)::DownCast(static_cast<GeometryPy*>(p)->getGeometryPtr()->handle());
GeomAPI_IntSS intersector(surf1, surf2, prec);
if (!intersector.IsDone()) {
PyErr_SetString(PyExc_Exception, "Intersection of surfaces failed");
@@ -542,7 +542,7 @@ PyObject* GeometrySurfacePy::intersectSS(PyObject *args)
Py::List result;
for (int i = 1; i <= intersector.NbLines(); i++) {
Handle_Geom_Curve line = intersector.Line(i);
Handle(Geom_Curve) line = intersector.Line(i);
result.append(makeGeometryCurvePy(line));
}
@@ -550,7 +550,7 @@ PyObject* GeometrySurfacePy::intersectSS(PyObject *args)
}
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PyExc_Exception, e->GetMessageString());
return 0;
}
@@ -563,7 +563,7 @@ PyObject* GeometrySurfacePy::intersectSS(PyObject *args)
PyObject* GeometrySurfacePy::intersect(PyObject *args)
{
Handle_Geom_Surface surf = Handle_Geom_Surface::DownCast(getGeometryPtr()->handle());
Handle(Geom_Surface) surf = Handle(Geom_Surface)::DownCast(getGeometryPtr()->handle());
try {
if (!surf.IsNull()) {
PyObject *p;
@@ -587,7 +587,7 @@ PyObject* GeometrySurfacePy::intersect(PyObject *args)
}
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PyExc_Exception, e->GetMessageString());
return 0;
}