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

@@ -73,7 +73,7 @@
#include <Mod/Part/App/TopoShapeFacePy.h>
namespace Part {
extern const Py::Object makeGeometryCurvePy(const Handle_Geom_Curve& c);
extern const Py::Object makeGeometryCurvePy(const Handle(Geom_Curve)& c);
}
using namespace Part;
@@ -102,12 +102,12 @@ PyObject* Curve2dPy::reverse(PyObject * args)
{
if (PyArg_ParseTuple(args, "")) {
try {
Handle_Geom2d_Curve curve = Handle_Geom2d_Curve::DownCast(getGeom2dCurvePtr()->handle());
Handle(Geom2d_Curve) curve = Handle(Geom2d_Curve)::DownCast(getGeom2dCurvePtr()->handle());
curve->Reverse();
Py_Return;
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
@@ -187,14 +187,14 @@ PyObject* Curve2dPy::toShape(PyObject *args)
{
if (PyArg_ParseTuple(args, "")) {
try {
Handle_Geom2d_Curve curv = Handle_Geom2d_Curve::DownCast(getGeometry2dPtr()->handle());
Handle(Geom2d_Curve) curv = Handle(Geom2d_Curve)::DownCast(getGeometry2dPtr()->handle());
BRepBuilderAPI_MakeEdge2d mkBuilder(curv);
TopoDS_Shape edge = mkBuilder.Shape();
return Py::new_reference_to(shape2pyshape(edge));
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
@@ -204,14 +204,14 @@ PyObject* Curve2dPy::toShape(PyObject *args)
double u1, u2;
if (PyArg_ParseTuple(args, "dd", &u1, &u2)) {
try {
Handle_Geom2d_Curve curv = Handle_Geom2d_Curve::DownCast(getGeometry2dPtr()->handle());
Handle(Geom2d_Curve) curv = Handle(Geom2d_Curve)::DownCast(getGeometry2dPtr()->handle());
BRepBuilderAPI_MakeEdge2d mkBuilder(curv, u1, u2);
TopoDS_Shape edge = mkBuilder.Shape();
return Py::new_reference_to(shape2pyshape(edge));
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
@@ -221,9 +221,9 @@ PyObject* Curve2dPy::toShape(PyObject *args)
PyObject* p;
if (PyArg_ParseTuple(args, "O!", &(Part::GeometrySurfacePy::Type), &p)) {
try {
Handle_Geom_Surface surf = Handle_Geom_Surface::DownCast(
Handle(Geom_Surface) surf = Handle(Geom_Surface)::DownCast(
static_cast<GeometrySurfacePy*>(p)->getGeomSurfacePtr()->handle());
Handle_Geom2d_Curve curv = Handle_Geom2d_Curve::DownCast(getGeometry2dPtr()->handle());
Handle(Geom2d_Curve) curv = Handle(Geom2d_Curve)::DownCast(getGeometry2dPtr()->handle());
BRepBuilderAPI_MakeEdge mkBuilder(curv, surf);
TopoDS_Edge edge = mkBuilder.Edge();
@@ -232,7 +232,7 @@ PyObject* Curve2dPy::toShape(PyObject *args)
return Py::new_reference_to(shape2pyshape(edge));
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
@@ -241,9 +241,9 @@ PyObject* Curve2dPy::toShape(PyObject *args)
PyErr_Clear();
if (PyArg_ParseTuple(args, "O!dd", &(Part::GeometrySurfacePy::Type), &p, &u1, &u2)) {
try {
Handle_Geom_Surface surf = Handle_Geom_Surface::DownCast(
Handle(Geom_Surface) surf = Handle(Geom_Surface)::DownCast(
static_cast<GeometrySurfacePy*>(p)->getGeomSurfacePtr()->handle());
Handle_Geom2d_Curve curv = Handle_Geom2d_Curve::DownCast(getGeometry2dPtr()->handle());
Handle(Geom2d_Curve) curv = Handle(Geom2d_Curve)::DownCast(getGeometry2dPtr()->handle());
BRepBuilderAPI_MakeEdge mkBuilder(curv, surf, u1, u2);
TopoDS_Edge edge = mkBuilder.Edge();
@@ -252,7 +252,7 @@ PyObject* Curve2dPy::toShape(PyObject *args)
return Py::new_reference_to(shape2pyshape(edge));
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
@@ -262,7 +262,7 @@ PyObject* Curve2dPy::toShape(PyObject *args)
if (PyArg_ParseTuple(args, "O!", &(Part::TopoShapeFacePy::Type), &p)) {
try {
const TopoDS_Face& face = TopoDS::Face(static_cast<TopoShapeFacePy*>(p)->getTopoShapePtr()->getShape());
Handle_Geom2d_Curve curv = Handle_Geom2d_Curve::DownCast(getGeometry2dPtr()->handle());
Handle(Geom2d_Curve) curv = Handle(Geom2d_Curve)::DownCast(getGeometry2dPtr()->handle());
BRepAdaptor_Surface adapt(face);
BRepBuilderAPI_MakeEdge mkBuilder(curv, adapt.Surface().Surface());
@@ -272,7 +272,7 @@ PyObject* Curve2dPy::toShape(PyObject *args)
return Py::new_reference_to(shape2pyshape(edge));
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
@@ -282,7 +282,7 @@ PyObject* Curve2dPy::toShape(PyObject *args)
if (PyArg_ParseTuple(args, "O!dd", &(Part::TopoShapeFacePy::Type), &p, &u1, &u2)) {
try {
const TopoDS_Face& face = TopoDS::Face(static_cast<TopoShapeFacePy*>(p)->getTopoShapePtr()->getShape());
Handle_Geom2d_Curve curv = Handle_Geom2d_Curve::DownCast(getGeometry2dPtr()->handle());
Handle(Geom2d_Curve) curv = Handle(Geom2d_Curve)::DownCast(getGeometry2dPtr()->handle());
BRepAdaptor_Surface adapt(face);
BRepBuilderAPI_MakeEdge mkBuilder(curv, adapt.Surface().Surface(), u1, u2);
@@ -292,7 +292,7 @@ PyObject* Curve2dPy::toShape(PyObject *args)
return Py::new_reference_to(shape2pyshape(edge));
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
@@ -305,8 +305,8 @@ PyObject* Curve2dPy::toShape(PyObject *args)
PyObject* Curve2dPy::discretize(PyObject *args, PyObject *kwds)
{
try {
Handle_Geom2d_Geometry g = getGeometry2dPtr()->handle();
Handle_Geom2d_Curve c = Handle_Geom2d_Curve::DownCast(g);
Handle(Geom2d_Geometry) g = getGeometry2dPtr()->handle();
Handle(Geom2d_Curve) c = Handle(Geom2d_Curve)::DownCast(g);
if (c.IsNull()) {
PyErr_SetString(PartExceptionOCCError, "Geometry is not a curve");
return 0;
@@ -501,8 +501,8 @@ PyObject* Curve2dPy::discretize(PyObject *args, PyObject *kwds)
PyObject* Curve2dPy::length(PyObject *args)
{
Handle_Geom2d_Geometry g = getGeometry2dPtr()->handle();
Handle_Geom2d_Curve c = Handle_Geom2d_Curve::DownCast(g);
Handle(Geom2d_Geometry) g = getGeometry2dPtr()->handle();
Handle(Geom2d_Curve) c = Handle(Geom2d_Curve)::DownCast(g);
try {
if (!c.IsNull()) {
double u=c->FirstParameter();
@@ -516,7 +516,7 @@ PyObject* Curve2dPy::length(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;
}
@@ -527,8 +527,8 @@ PyObject* Curve2dPy::length(PyObject *args)
PyObject* Curve2dPy::parameterAtDistance(PyObject *args)
{
Handle_Geom2d_Geometry g = getGeometry2dPtr()->handle();
Handle_Geom2d_Curve c = Handle_Geom2d_Curve::DownCast(g);
Handle(Geom2d_Geometry) g = getGeometry2dPtr()->handle();
Handle(Geom2d_Curve) c = Handle(Geom2d_Curve)::DownCast(g);
try {
if (!c.IsNull()) {
double abscissa;
@@ -542,7 +542,7 @@ PyObject* Curve2dPy::parameterAtDistance(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;
}
@@ -553,8 +553,8 @@ PyObject* Curve2dPy::parameterAtDistance(PyObject *args)
PyObject* Curve2dPy::value(PyObject *args)
{
Handle_Geom2d_Geometry g = getGeometry2dPtr()->handle();
Handle_Geom2d_Curve c = Handle_Geom2d_Curve::DownCast(g);
Handle(Geom2d_Geometry) g = getGeometry2dPtr()->handle();
Handle(Geom2d_Curve) c = Handle(Geom2d_Curve)::DownCast(g);
try {
if (!c.IsNull()) {
double u;
@@ -571,7 +571,7 @@ PyObject* Curve2dPy::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;
}
@@ -582,8 +582,8 @@ PyObject* Curve2dPy::value(PyObject *args)
PyObject* Curve2dPy::tangent(PyObject *args)
{
Handle_Geom2d_Geometry g = getGeometry2dPtr()->handle();
Handle_Geom2d_Curve c = Handle_Geom2d_Curve::DownCast(g);
Handle(Geom2d_Geometry) g = getGeometry2dPtr()->handle();
Handle(Geom2d_Curve) c = Handle(Geom2d_Curve)::DownCast(g);
try {
if (!c.IsNull()) {
double u;
@@ -604,7 +604,7 @@ PyObject* Curve2dPy::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;
}
@@ -615,8 +615,8 @@ PyObject* Curve2dPy::tangent(PyObject *args)
PyObject* Curve2dPy::normal(PyObject *args)
{
Handle_Geom2d_Geometry g = getGeometry2dPtr()->handle();
Handle_Geom2d_Curve c = Handle_Geom2d_Curve::DownCast(g);
Handle(Geom2d_Geometry) g = getGeometry2dPtr()->handle();
Handle(Geom2d_Curve) c = Handle(Geom2d_Curve)::DownCast(g);
try {
if (!c.IsNull()) {
double u;
@@ -635,7 +635,7 @@ PyObject* Curve2dPy::normal(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;
}
@@ -646,8 +646,8 @@ PyObject* Curve2dPy::normal(PyObject *args)
PyObject* Curve2dPy::curvature(PyObject *args)
{
Handle_Geom2d_Geometry g = getGeometry2dPtr()->handle();
Handle_Geom2d_Curve c = Handle_Geom2d_Curve::DownCast(g);
Handle(Geom2d_Geometry) g = getGeometry2dPtr()->handle();
Handle(Geom2d_Curve) c = Handle(Geom2d_Curve)::DownCast(g);
try {
if (!c.IsNull()) {
double u;
@@ -659,7 +659,7 @@ PyObject* Curve2dPy::curvature(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;
}
@@ -670,8 +670,8 @@ PyObject* Curve2dPy::curvature(PyObject *args)
PyObject* Curve2dPy::centerOfCurvature(PyObject *args)
{
Handle_Geom2d_Geometry g = getGeometry2dPtr()->handle();
Handle_Geom2d_Curve c = Handle_Geom2d_Curve::DownCast(g);
Handle(Geom2d_Geometry) g = getGeometry2dPtr()->handle();
Handle(Geom2d_Curve) c = Handle(Geom2d_Curve)::DownCast(g);
try {
if (!c.IsNull()) {
double u;
@@ -690,7 +690,7 @@ PyObject* Curve2dPy::centerOfCurvature(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;
}
@@ -701,8 +701,8 @@ PyObject* Curve2dPy::centerOfCurvature(PyObject *args)
PyObject* Curve2dPy::parameter(PyObject *args)
{
Handle_Geom2d_Geometry g = getGeometry2dPtr()->handle();
Handle_Geom2d_Curve c = Handle_Geom2d_Curve::DownCast(g);
Handle(Geom2d_Geometry) g = getGeometry2dPtr()->handle();
Handle(Geom2d_Curve) c = Handle(Geom2d_Curve)::DownCast(g);
try {
if (!c.IsNull()) {
PyObject *p;
@@ -716,7 +716,7 @@ PyObject* Curve2dPy::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;
}
@@ -727,8 +727,8 @@ PyObject* Curve2dPy::parameter(PyObject *args)
PyObject* Curve2dPy::toBSpline(PyObject * args)
{
Handle_Geom2d_Geometry g = getGeometry2dPtr()->handle();
Handle_Geom2d_Curve c = Handle_Geom2d_Curve::DownCast(g);
Handle(Geom2d_Geometry) g = getGeometry2dPtr()->handle();
Handle(Geom2d_Curve) c = Handle(Geom2d_Curve)::DownCast(g);
try {
if (!c.IsNull()) {
double u,v;
@@ -737,14 +737,14 @@ PyObject* Curve2dPy::toBSpline(PyObject * args)
if (!PyArg_ParseTuple(args, "|dd", &u,&v))
return 0;
ShapeConstruct_Curve scc;
Handle_Geom2d_BSplineCurve spline = scc.ConvertToBSpline(c, u, v, Precision::Confusion());
Handle(Geom2d_BSplineCurve) spline = scc.ConvertToBSpline(c, u, v, Precision::Confusion());
if (spline.IsNull())
Standard_NullValue::Raise("Conversion to B-Spline failed");
return new BSplineCurve2dPy(new Geom2dBSplineCurve(spline));
}
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
Handle(Standard_Failure) e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
@@ -781,7 +781,7 @@ PyObject* Curve2dPy::approximateBSpline(PyObject *args)
absShape = GeomAbs_C2;
try {
Handle_Geom2d_Curve self = Handle_Geom2d_Curve::DownCast(getGeometry2dPtr()->handle());
Handle(Geom2d_Curve) self = Handle(Geom2d_Curve)::DownCast(getGeometry2dPtr()->handle());
Geom2dConvert_ApproxCurve approx(self, tolerance, absShape, maxSegment, maxDegree);
if (approx.IsDone()) {
return new BSplineCurve2dPy(new Geom2dBSplineCurve(approx.Curve()));
@@ -798,7 +798,7 @@ PyObject* Curve2dPy::approximateBSpline(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;
}
@@ -806,7 +806,7 @@ PyObject* Curve2dPy::approximateBSpline(PyObject *args)
Py::String Curve2dPy::getContinuity(void) const
{
GeomAbs_Shape c = Handle_Geom2d_Curve::DownCast
GeomAbs_Shape c = Handle(Geom2d_Curve)::DownCast
(getGeometry2dPtr()->handle())->Continuity();
std::string str;
switch (c) {
@@ -840,25 +840,25 @@ Py::String Curve2dPy::getContinuity(void) const
Py::Boolean Curve2dPy::getClosed(void) const
{
return Py::Boolean(Handle_Geom2d_Curve::DownCast
return Py::Boolean(Handle(Geom2d_Curve)::DownCast
(getGeometry2dPtr()->handle())->IsClosed() ? true : false);
}
Py::Boolean Curve2dPy::getPeriodic(void) const
{
return Py::Boolean(Handle_Geom2d_Curve::DownCast
return Py::Boolean(Handle(Geom2d_Curve)::DownCast
(getGeometry2dPtr()->handle())->IsPeriodic() ? true : false);
}
Py::Float Curve2dPy::getFirstParameter(void) const
{
return Py::Float(Handle_Geom2d_Curve::DownCast
return Py::Float(Handle(Geom2d_Curve)::DownCast
(getGeometry2dPtr()->handle())->FirstParameter());
}
Py::Float Curve2dPy::getLastParameter(void) const
{
return Py::Float(Handle_Geom2d_Curve::DownCast
return Py::Float(Handle(Geom2d_Curve)::DownCast
(getGeometry2dPtr()->handle())->LastParameter());
}
@@ -874,14 +874,14 @@ int Curve2dPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
PyObject* Curve2dPy::intersectCC(PyObject *args)
{
Handle_Geom2d_Curve curve1 = Handle_Geom2d_Curve::DownCast(getGeometry2dPtr()->handle());
Handle(Geom2d_Curve) curve1 = Handle(Geom2d_Curve)::DownCast(getGeometry2dPtr()->handle());
try {
if (!curve1.IsNull()) {
PyObject *p;
double prec = Precision::Confusion();
if (!PyArg_ParseTuple(args, "O!|d", &(Part::Curve2dPy::Type), &p, &prec))
return 0;
Handle_Geom2d_Curve curve2 = Handle_Geom2d_Curve::DownCast(static_cast<Geometry2dPy*>(p)->getGeometry2dPtr()->handle());
Handle(Geom2d_Curve) curve2 = Handle(Geom2d_Curve)::DownCast(static_cast<Geometry2dPy*>(p)->getGeometry2dPtr()->handle());
Geom2dAPI_ExtremaCurveCurve intersector(curve1, curve2,
curve1->FirstParameter(),
curve1->LastParameter(),
@@ -911,7 +911,7 @@ PyObject* Curve2dPy::intersectCC(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;
}