fix build problems on Linux/OSX

This commit is contained in:
wmayer 2016-11-22 16:16:48 +01:00
parent 9bdad96a69
commit 03ab1a4a4d
4 changed files with 38 additions and 32 deletions

View File

@ -23,6 +23,7 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <sstream>
#endif
#include "GeometryPyCXX.h"
@ -92,20 +93,11 @@ namespace Base {
Vector2dPy::Vector2dPy(Py::PythonClassInstance *self, Py::Tuple &args, Py::Dict &kwds)
: Py::PythonClass<Vector2dPy>::PythonClass(self, args, kwds)
{
}
double x=0,y=0;
if (!PyArg_ParseTuple(args.ptr(), "|dd", &x, &y)) {
throw Py::Exception();
}
Vector2dPy::Vector2dPy()
: Py::PythonClass<Vector2dPy>::PythonClass
(reinterpret_cast<Py::PythonClassInstance *>
(Vector2dPy::type_object()), Py::Tuple(), Py::Dict())
{
}
Vector2dPy::Vector2dPy(double x, double y)
: Py::PythonClass<Vector2dPy>::PythonClass
(reinterpret_cast<Py::PythonClassInstance *>
(Vector2dPy::type_object()), Py::Tuple(), Py::Dict())
{
v.x = x;
v.y = y;
}
@ -120,10 +112,23 @@ void Vector2dPy::init_type(void)
behaviors().doc( "Vector2d class" );
behaviors().supportGetattro();
behaviors().supportSetattro();
behaviors().supportRepr();
// Call to make the type ready for use
behaviors().readyType();
}
Py::Object Vector2dPy::repr()
{
Py::Float x(v.x);
Py::Float y(v.y);
std::stringstream str;
str << "Vector2 (";
str << (std::string)x.repr() << ", "<< (std::string)y.repr();
str << ")";
return Py::String(str.str());
}
Py::Object Vector2dPy::getattro(const Py::String &name_)
{
std::string name( name_.as_std_string( "utf-8" ) );

View File

@ -51,14 +51,13 @@ class BaseExport Vector2dPy : public Py::PythonClass<Vector2dPy>
{
public:
Vector2dPy(Py::PythonClassInstance *self, Py::Tuple &args, Py::Dict &kwds);
Vector2dPy();
Vector2dPy(double, double);
virtual ~Vector2dPy();
static void init_type(void);
Py::Object getattro(const Py::String &name_);
int setattro(const Py::String &name_, const Py::Object &value);
inline const Vector2d& getValue() const {
virtual Py::Object repr();
inline const Vector2d& value() const {
return v;
}
inline void setValue(const Vector2d& n) {

View File

@ -83,22 +83,8 @@ generate_from_xml(TopoShapeSolidPy)
generate_from_xml(TopoShapeVertexPy)
generate_from_xml(TopoShapeWirePy)
generate_from_xml(BRepOffsetAPI_MakePipeShellPy)
generate_from_xml(Geom2d/ArcOfCircle2dPy)
generate_from_xml(Geom2d/ArcOfConic2dPy)
generate_from_xml(Geom2d/ArcOfEllipse2dPy)
generate_from_xml(Geom2d/ArcOfHyperbola2dPy)
generate_from_xml(Geom2d/ArcOfParabola2dPy)
generate_from_xml(Geom2d/BezierCurve2dPy)
generate_from_xml(Geom2d/BSplineCurve2dPy)
generate_from_xml(Geom2d/Circle2dPy)
generate_from_xml(Geom2d/Conic2dPy)
generate_from_xml(Geom2d/Ellipse2dPy)
generate_from_xml(Geom2d/Geometry2dPy)
generate_from_xml(Geom2d/Hyperbola2dPy)
generate_from_xml(Geom2d/Curve2dPy)
generate_from_xml(Geom2d/Line2dSegmentPy)
generate_from_xml(Geom2d/OffsetCurve2dPy)
generate_from_xml(Geom2d/Parabola2dPy)
add_subdirectory(Geom2d)
SET(Features_SRCS
FeaturePartBoolean.cpp

View File

@ -0,0 +1,16 @@
generate_from_xml(ArcOfCircle2dPy)
generate_from_xml(ArcOfConic2dPy)
generate_from_xml(ArcOfEllipse2dPy)
generate_from_xml(ArcOfHyperbola2dPy)
generate_from_xml(ArcOfParabola2dPy)
generate_from_xml(BezierCurve2dPy)
generate_from_xml(BSplineCurve2dPy)
generate_from_xml(Circle2dPy)
generate_from_xml(Conic2dPy)
generate_from_xml(Ellipse2dPy)
generate_from_xml(Geometry2dPy)
generate_from_xml(Hyperbola2dPy)
generate_from_xml(Curve2dPy)
generate_from_xml(Line2dSegmentPy)
generate_from_xml(OffsetCurve2dPy)
generate_from_xml(Parabola2dPy)