Skip to content

Commit

Permalink
add Python wrappers for Geom2d classes
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Nov 22, 2016
1 parent 14594dd commit 9bdad96
Show file tree
Hide file tree
Showing 38 changed files with 7,766 additions and 693 deletions.
16 changes: 16 additions & 0 deletions src/Base/GeometryPyCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,22 @@ Vector2dPy::Vector2dPy(Py::PythonClassInstance *self, Py::Tuple &args, Py::Dict
{
}

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;
}

Vector2dPy::~Vector2dPy()
{
}
Expand Down
2 changes: 2 additions & 0 deletions src/Base/GeometryPyCXX.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ 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);
Expand Down
117 changes: 78 additions & 39 deletions src/Mod/Part/App/AppPart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,44 +57,60 @@
#include "CustomFeature.h"
#include "Geometry.h"
#include "Geometry2d.h"
#include "TopoShapePy.h"
#include "TopoShapeVertexPy.h"
#include "TopoShapeFacePy.h"
#include "TopoShapeWirePy.h"
#include "TopoShapeEdgePy.h"
#include "TopoShapeSolidPy.h"
#include "TopoShapeCompoundPy.h"
#include "TopoShapeCompSolidPy.h"
#include "TopoShapeShellPy.h"
#include "LinePy.h"
#include "PointPy.h"
#include "CirclePy.h"
#include "EllipsePy.h"
#include "ArcPy.h"
#include "ArcOfCirclePy.h"
#include "ArcOfEllipsePy.h"
#include "ArcOfParabolaPy.h"
#include "ArcOfHyperbolaPy.h"
#include "BezierCurvePy.h"
#include "BSplineCurvePy.h"
#include "HyperbolaPy.h"
#include "OffsetCurvePy.h"
#include "ParabolaPy.h"
#include "BezierSurfacePy.h"
#include "BSplineSurfacePy.h"
#include "ConePy.h"
#include "CylinderPy.h"
#include "OffsetSurfacePy.h"
#include "PlateSurfacePy.h"
#include "PlanePy.h"
#include "RectangularTrimmedSurfacePy.h"
#include "SpherePy.h"
#include "SurfaceOfExtrusionPy.h"
#include "SurfaceOfRevolutionPy.h"
#include "ToroidPy.h"
#include "BRepOffsetAPI_MakePipeShellPy.h"
#include "PartFeaturePy.h"
#include "AttachEnginePy.h"
#include "Mod/Part/App/TopoShapePy.h"
#include "Mod/Part/App/TopoShapeVertexPy.h"
#include "Mod/Part/App/TopoShapeFacePy.h"
#include "Mod/Part/App/TopoShapeWirePy.h"
#include "Mod/Part/App/TopoShapeEdgePy.h"
#include "Mod/Part/App/TopoShapeSolidPy.h"
#include "Mod/Part/App/TopoShapeCompoundPy.h"
#include "Mod/Part/App/TopoShapeCompSolidPy.h"
#include "Mod/Part/App/TopoShapeShellPy.h"
#include "Mod/Part/App/LinePy.h"
#include "Mod/Part/App/PointPy.h"
#include "Mod/Part/App/CirclePy.h"
#include "Mod/Part/App/EllipsePy.h"
#include "Mod/Part/App/ArcPy.h"
#include "Mod/Part/App/ArcOfCirclePy.h"
#include "Mod/Part/App/ArcOfEllipsePy.h"
#include "Mod/Part/App/ArcOfParabolaPy.h"
#include "Mod/Part/App/ArcOfHyperbolaPy.h"
#include "Mod/Part/App/BezierCurvePy.h"
#include "Mod/Part/App/BSplineCurvePy.h"
#include "Mod/Part/App/HyperbolaPy.h"
#include "Mod/Part/App/OffsetCurvePy.h"
#include "Mod/Part/App/ParabolaPy.h"
#include "Mod/Part/App/BezierSurfacePy.h"
#include "Mod/Part/App/BSplineSurfacePy.h"
#include "Mod/Part/App/ConePy.h"
#include "Mod/Part/App/CylinderPy.h"
#include "Mod/Part/App/OffsetSurfacePy.h"
#include "Mod/Part/App/PlateSurfacePy.h"
#include "Mod/Part/App/PlanePy.h"
#include "Mod/Part/App/RectangularTrimmedSurfacePy.h"
#include "Mod/Part/App/SpherePy.h"
#include "Mod/Part/App/SurfaceOfExtrusionPy.h"
#include "Mod/Part/App/SurfaceOfRevolutionPy.h"
#include "Mod/Part/App/ToroidPy.h"
#include "Mod/Part/App/BRepOffsetAPI_MakePipeShellPy.h"
#include "Mod/Part/App/PartFeaturePy.h"
#include "Mod/Part/App/AttachEnginePy.h"
#include <Mod/Part/App/Geom2d/ArcOfCircle2dPy.h>
#include <Mod/Part/App/Geom2d/ArcOfConic2dPy.h>
#include <Mod/Part/App/Geom2d/ArcOfEllipse2dPy.h>
#include <Mod/Part/App/Geom2d/ArcOfHyperbola2dPy.h>
#include <Mod/Part/App/Geom2d/ArcOfParabola2dPy.h>
#include <Mod/Part/App/Geom2d/BezierCurve2dPy.h>
#include <Mod/Part/App/Geom2d/BSplineCurve2dPy.h>
#include <Mod/Part/App/Geom2d/Circle2dPy.h>
#include <Mod/Part/App/Geom2d/Conic2dPy.h>
#include <Mod/Part/App/Geom2d/Ellipse2dPy.h>
#include <Mod/Part/App/Geom2d/Geometry2dPy.h>
#include <Mod/Part/App/Geom2d/Hyperbola2dPy.h>
#include <Mod/Part/App/Geom2d/Curve2dPy.h>
#include <Mod/Part/App/Geom2d/Line2dSegmentPy.h>
#include <Mod/Part/App/Geom2d/OffsetCurve2dPy.h>
#include <Mod/Part/App/Geom2d/Parabola2dPy.h>
#include "PropertyGeometryList.h"
#include "DatumFeature.h"
#include "Attacher.h"
Expand Down Expand Up @@ -227,7 +243,28 @@ PyMODINIT_FUNC initPart()
PyModule_AddObject(partModule, "BRepOffsetAPI", brepModule);
Base::Interpreter().addType(&Part::BRepOffsetAPI_MakePipeShellPy::Type,brepModule,"MakePipeShell");

try{
// Geom2d package
PyObject* geom2dModule = Py_InitModule3("Geom2d", 0, "Geom2d");
Py_INCREF(geom2dModule);
PyModule_AddObject(partModule, "Geom2d", geom2dModule);
Base::Interpreter().addType(&Part::Geometry2dPy::Type,geom2dModule,"Geometry2d");
Base::Interpreter().addType(&Part::Curve2dPy::Type,geom2dModule,"Curve2d");
Base::Interpreter().addType(&Part::Conic2dPy::Type,geom2dModule,"Conic2d");
Base::Interpreter().addType(&Part::Circle2dPy::Type,geom2dModule,"Circle2d");
Base::Interpreter().addType(&Part::Ellipse2dPy::Type,geom2dModule,"Ellipse2d");
Base::Interpreter().addType(&Part::Hyperbola2dPy::Type,geom2dModule,"Hyperbola2d");
Base::Interpreter().addType(&Part::Parabola2dPy::Type,geom2dModule,"Parabola2d");
Base::Interpreter().addType(&Part::ArcOfConic2dPy::Type,geom2dModule,"ArcOfConic2d");
Base::Interpreter().addType(&Part::ArcOfCircle2dPy::Type,geom2dModule,"ArcOfCircle2d");
Base::Interpreter().addType(&Part::ArcOfEllipse2dPy::Type,geom2dModule,"ArcOfEllipse2d");
Base::Interpreter().addType(&Part::ArcOfHyperbola2dPy::Type,geom2dModule,"ArcOfHyperbola2d");
Base::Interpreter().addType(&Part::ArcOfParabola2dPy::Type,geom2dModule,"ArcOfParabola2d");
Base::Interpreter().addType(&Part::BezierCurve2dPy::Type,geom2dModule,"BezierCurve2d");
Base::Interpreter().addType(&Part::BSplineCurve2dPy::Type,geom2dModule,"BSplineCurve2d");
Base::Interpreter().addType(&Part::Line2dSegmentPy::Type,geom2dModule,"Line2dSegment");
Base::Interpreter().addType(&Part::OffsetCurve2dPy::Type,geom2dModule,"OffsetCurve2d");

try {
//import all submodules of BOPTools, to make them easy to browse in Py console.
//It's done in this weird manner instead of bt.caMemberFunction("importAll"),
//because the latter crashed when importAll failed with exception.
Expand Down Expand Up @@ -355,6 +392,8 @@ PyMODINIT_FUNC initPart()
Part::Geom2dCurve ::init();
Part::Geom2dBezierCurve ::init();
Part::Geom2dBSplineCurve ::init();
Part::Geom2dConic ::init();
Part::Geom2dArcOfConic ::init();
Part::Geom2dCircle ::init();
Part::Geom2dArcOfCircle ::init();
Part::Geom2dEllipse ::init();
Expand Down
55 changes: 55 additions & 0 deletions src/Mod/Part/App/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ include_directories(
${CMAKE_BINARY_DIR}/src
${CMAKE_SOURCE_DIR}/src
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${Boost_INCLUDE_DIRS}
${OCC_INCLUDE_DIR}
${PYTHON_INCLUDE_DIRS}
Expand Down Expand Up @@ -82,6 +83,22 @@ 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)

SET(Features_SRCS
FeaturePartBoolean.cpp
Expand Down Expand Up @@ -249,10 +266,48 @@ SET(Python_SRCS
)
SOURCE_GROUP("Python" FILES ${Python_SRCS})

# Geom2d wrappers
SET(Geom2dPy_SRCS
Geom2d/ArcOfCircle2dPy.xml
Geom2d/ArcOfCircle2dPyImp.cpp
Geom2d/ArcOfConic2dPy.xml
Geom2d/ArcOfConic2dPyImp.cpp
Geom2d/ArcOfEllipse2dPy.xml
Geom2d/ArcOfEllipse2dPyImp.cpp
Geom2d/ArcOfHyperbola2dPy.xml
Geom2d/ArcOfHyperbola2dPyImp.cpp
Geom2d/ArcOfParabola2dPy.xml
Geom2d/ArcOfParabola2dPyImp.cpp
Geom2d/BezierCurve2dPy.xml
Geom2d/BezierCurve2dPyImp.cpp
Geom2d/BSplineCurve2dPy.xml
Geom2d/BSplineCurve2dPyImp.cpp
Geom2d/Circle2dPy.xml
Geom2d/Circle2dPyImp.cpp
Geom2d/Conic2dPy.xml
Geom2d/Conic2dPyImp.cpp
Geom2d/Ellipse2dPy.xml
Geom2d/Ellipse2dPyImp.cpp
Geom2d/Geometry2dPy.xml
Geom2d/Geometry2dPyImp.cpp
Geom2d/Curve2dPy.xml
Geom2d/Curve2dPyImp.cpp
Geom2d/Hyperbola2dPy.xml
Geom2d/Hyperbola2dPyImp.cpp
Geom2d/Line2dSegmentPy.xml
Geom2d/Line2dSegmentPyImp.cpp
Geom2d/OffsetCurve2dPy.xml
Geom2d/OffsetCurve2dPyImp.cpp
Geom2d/Parabola2dPy.xml
Geom2d/Parabola2dPyImp.cpp
)
SOURCE_GROUP("Geom2d" FILES ${Geom2dPy_SRCS})

SET(Part_SRCS
${Features_SRCS}
${Properties_SRCS}
${Python_SRCS}
${Geom2dPy_SRCS}
Attacher.cpp
Attacher.h
AppPart.cpp
Expand Down
44 changes: 44 additions & 0 deletions src/Mod/Part/App/Geom2d/ArcOfCircle2dPy.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
<PythonExport
Father="ArcOfConic2dPy"
Name="ArcOfCircle2dPy"
Twin="Geom2dArcOfCircle"
TwinPointer="Geom2dArcOfCircle"
Include="Mod/Part/App/Geometry2d.h"
Namespace="Part"
FatherInclude="Mod/Part/App/Geom2d/ArcOfConic2dPy.h"
FatherNamespace="Part"
Constructor="true">
<Documentation>
<Author Licence="LGPL" Name="Werner Mayer" EMail="wmayer[at]users.sourceforge.net" />
<UserDocu>Describes a portion of a circle</UserDocu>
</Documentation>
<!--
<Attribute Name="Radius" ReadOnly="false">
<Documentation>
<UserDocu>The radius of the circle.</UserDocu>
</Documentation>
<Parameter Name="Radius" Type="Float"/>
</Attribute>
<Attribute Name="Center" ReadOnly="false">
<Documentation>
<UserDocu>Center of the circle.</UserDocu>
</Documentation>
<Parameter Name="Center" Type="Object"/>
</Attribute>
<Attribute Name="Axis" ReadOnly="false">
<Documentation>
<UserDocu>The axis direction of the circle</UserDocu>
</Documentation>
<Parameter Name="Axis" Type="Object"/>
</Attribute>
<Attribute Name="Circle" ReadOnly="true">
<Documentation>
<UserDocu>The internal circle representation</UserDocu>
</Documentation>
<Parameter Name="Circle" Type="Object"/>
</Attribute>
-->
</PythonExport>
</GenerateModel>
Loading

0 comments on commit 9bdad96

Please sign in to comment.