43 #include <pybind11/include/pybind11/pybind11.h> 44 #include <pybind11/include/pybind11/embed.h> 47 #include <PrimitivesGenerator.hh> 51 #include <OpenFlipper/BasePlugin/PythonFunctions.hh> 52 #include <OpenFlipper/PythonInterpreter/PythonTypeConversions.hh> 58 PYBIND11_EMBEDDED_MODULE(PrimitivesGenerator, m) {
60 QObject* pluginPointer = getPluginPointer(
"PrimitivesGenerator");
63 std::cerr <<
"Error Getting plugin pointer for Plugin-PrimitivesGenerator" << std::endl;
70 std::cerr <<
"Error converting plugin pointer for Plugin-PrimitivesGenerator" << std::endl;
76 py::class_< PrimitivesGeneratorPlugin,std::unique_ptr<PrimitivesGeneratorPlugin, py::nodelete> > generator(m,
"PrimitivesGenerator");
81 generator.def(py::init([plugin]() {
return plugin; }));
84 generator.def(
"addTriangulatedCylinder", &PrimitivesGeneratorPlugin::addTriangulatedCylinder,
85 QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Generates a triangulated cylinder (ObjectId is returned)").toLatin1().data(),
86 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Position (Bottom center vertex position)").toLatin1().data()) =
Vector(0.0,0.0,0.0),
87 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Center axis of cylinder").toLatin1().data()) =
Vector(0.0,0.0,1.0),
88 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Radius").toLatin1().data()),
89 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Height").toLatin1().data()),
90 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Add Top vertex?").toLatin1().data()) =
true,
91 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Add bottom vertex?").toLatin1().data()) =
true );
93 generator.def(
"addSphere", &PrimitivesGeneratorPlugin::addSphere,
94 QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Generates a triangulated sphere with all vertical lines connected to the poles (ObjectId is returned)").toLatin1().data(),
95 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Position (Sphere center)").toLatin1().data()) =
Vector(0.0,0.0,0.0),
96 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Radius").toLatin1().data()) = 1.0);
98 generator.def(
"addSubdivisionSphere", &PrimitivesGeneratorPlugin::addSubdivisionSphere,
99 QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Generates a triangulated sphere by subdivision without poles. (ObjectId is returned)").toLatin1().data(),
100 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Position (Sphere center)").toLatin1().data()) =
Vector(0.0,0.0,0.0),
101 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Radius").toLatin1().data()) = 1.0);
103 generator.def(
"addTetrahedron", &PrimitivesGeneratorPlugin::addTetrahedron,
104 QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Generates a tetrahedron (ObjectId is returned)").toLatin1().data(),
105 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Center position").toLatin1().data()) =
Vector(0.0,0.0,0.0),
106 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Length of each edge").toLatin1().data()) = 1.0);
108 generator.def(
"addPyramid", &PrimitivesGeneratorPlugin::addPyramid,
109 QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Generates a pyramid (ObjectId is returned)").toLatin1().data(),
110 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Center position").toLatin1().data()) =
Vector(0.0,0.0,0.0),
111 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Length of each edge").toLatin1().data()) = 2.0);
113 generator.def(
"addCube", &PrimitivesGeneratorPlugin::addCube,
114 QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Generates a poly mesh of cube (ObjectId is returned)").toLatin1().data(),
115 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Center position").toLatin1().data()) =
Vector(0.0,0.0,0.0),
116 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Length of each edge").toLatin1().data()) = 2.0);
118 generator.def(
"addTriangulatedCube", &PrimitivesGeneratorPlugin::addTriangulatedCube,
119 QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Generates a triangular mesh of cube (ObjectId is returned)").toLatin1().data(),
120 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Center position").toLatin1().data()) =
Vector(0.0,0.0,0.0),
121 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Length of each edge").toLatin1().data()) = 2.0);
123 generator.def(
"addIcosahedron", &PrimitivesGeneratorPlugin::addIcosahedron,
124 QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Generates an Icosahedron (ObjectId is returned)").toLatin1().data(),
125 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Center position").toLatin1().data()) =
Vector(0.0,0.0,0.0),
126 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Length of each edge").toLatin1().data()) = 2.0);
128 generator.def(
"addOctahedron", &PrimitivesGeneratorPlugin::addOctahedron,
129 QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Generates an Octahedron (ObjectId is returned)").toLatin1().data(),
130 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Center position").toLatin1().data()) =
Vector(0.0,0.0,0.0),
131 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Length of each edge").toLatin1().data()) = 2.0);
133 generator.def(
"addDodecahedron", &PrimitivesGeneratorPlugin::addDodecahedron,
134 QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Generates a Dodecahedron (ObjectId is returned)").toLatin1().data(),
135 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Center position").toLatin1().data()) =
Vector(0.0,0.0,0.0),
136 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Length of each edge").toLatin1().data()) = 2.0);
138 #ifdef ENABLE_BSPLINECURVE_SUPPORT 139 generator.def(
"addRandomBSplineCurve", &PrimitivesGeneratorPlugin::addRandomBSplineCurve,
140 QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Generates a random B-spline curve (ObjectId is returned)").toLatin1().data(),
141 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Position").toLatin1().data()) =
Vector(0.0,0.0,0.0),
142 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Number of control points").toLatin1().data()) = 5);
146 #ifdef ENABLE_BSPLINESURFACE_SUPPORT 147 generator.def(
"addRandomBSplineSurface", &PrimitivesGeneratorPlugin::addRandomBSplineSurface,
148 QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Generates a random B-spline surface (ObjectId is returned)").toLatin1().data(),
149 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Position").toLatin1().data()) =
Vector(0.0,0.0,0.0),
150 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Number of control points").toLatin1().data()) = 5);
153 #ifdef ENABLE_POLYHEDRALMESH_SUPPORT 154 generator.def(
"addTetrahedralCube", &PrimitivesGeneratorPlugin::addTetrahedralCube,
155 QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Generates a tetrahedral mesh of a cube (ObjectId is returned)").toLatin1().data(),
156 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Center Position").toLatin1().data()) =
Vector(0.0,0.0,0.0),
157 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Length of each edge").toLatin1().data()) = 2.0);
159 generator.def(
"addTetrahedralCuboid", &PrimitivesGeneratorPlugin::addTetrahedralCuboid,
160 QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Generates a tetrahedral mesh of a cuboid (ObjectId is returned)").toLatin1().data(),
161 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Center Position").toLatin1().data()) =
Vector(0.0,0.0,0.0),
162 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Length of each side").toLatin1().data()) =
Vector(4.0,6.0,12.0),
163 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Number of units in x-axis").toLatin1().data()) = 5,
164 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Number of units in y-axis").toLatin1().data()) = 5,
165 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Number of units in z-axis").toLatin1().data()) = 10);
169 #ifdef ENABLE_HEXAHEDRALMESH_SUPPORT 170 generator.def(
"addHexahedralCube", &PrimitivesGeneratorPlugin::addHexahedralCube,
171 QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Generates a hexahedral mesh of a cube (ObjectId is returned)").toLatin1().data(),
172 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Center Position").toLatin1().data()) =
Vector(0.0,0.0,0.0),
173 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Length of each edge").toLatin1().data()) = 2.0);
ACG::Vec3d Vector
Standard Type for 3d Vector used for scripting.