43#include <pybind11/pybind11.h>
44#include <pybind11/embed.h>
47#include <PrimitivesGenerator.hh>
51#include <OpenFlipper/BasePlugin/PythonFunctions.hh>
52#include <OpenFlipper/PythonInterpreter/PythonTypeConversions.hh>
54#include <QCoreApplication>
56namespace py = pybind11;
60PYBIND11_EMBEDDED_MODULE(PrimitivesGenerator, m) {
62 QObject* pluginPointer = getPluginPointer(
"PrimitivesGenerator");
65 std::cerr <<
"Error Getting plugin pointer for Plugin-PrimitivesGenerator" << std::endl;
72 std::cerr <<
"Error converting plugin pointer for Plugin-PrimitivesGenerator" << std::endl;
78 py::class_< PrimitivesGeneratorPlugin,std::unique_ptr<PrimitivesGeneratorPlugin, py::nodelete> > generator(m,
"PrimitivesGenerator");
83 generator.def(py::init([plugin]() {
return plugin; }));
86 generator.def(
"addTriangulatedCylinder", &PrimitivesGeneratorPlugin::addTriangulatedCylinder,
87 QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Generates a triangulated cylinder (ObjectId is returned)").toLatin1().data(),
88 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Position (Bottom center vertex position)").toLatin1().data()) =
Vector(0.0,0.0,0.0),
89 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Center axis of cylinder").toLatin1().data()) =
Vector(0.0,0.0,1.0),
90 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Radius").toLatin1().data()),
91 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Height").toLatin1().data()),
92 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Add Top vertex?").toLatin1().data()) =
true,
93 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Add bottom vertex?").toLatin1().data()) =
true );
95 generator.def(
"addSphere", &PrimitivesGeneratorPlugin::addSphere,
96 QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Generates a triangulated sphere with all vertical lines connected to the poles (ObjectId is returned)").toLatin1().data(),
97 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Position (Sphere center)").toLatin1().data()) =
Vector(0.0,0.0,0.0),
98 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Radius").toLatin1().data()) = 1.0);
100 generator.def(
"addSubdivisionSphere", &PrimitivesGeneratorPlugin::addSubdivisionSphere,
101 QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Generates a triangulated sphere by subdivision without poles. (ObjectId is returned)").toLatin1().data(),
102 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Position (Sphere center)").toLatin1().data()) =
Vector(0.0,0.0,0.0),
103 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Radius").toLatin1().data()) = 1.0);
105 generator.def(
"addTetrahedron", &PrimitivesGeneratorPlugin::addTetrahedron,
106 QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Generates a tetrahedron (ObjectId is returned)").toLatin1().data(),
107 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Center position").toLatin1().data()) =
Vector(0.0,0.0,0.0),
108 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Length of each edge").toLatin1().data()) = 1.0);
110 generator.def(
"addPyramid", &PrimitivesGeneratorPlugin::addPyramid,
111 QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Generates a pyramid (ObjectId is returned)").toLatin1().data(),
112 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Center position").toLatin1().data()) =
Vector(0.0,0.0,0.0),
113 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Length of each edge").toLatin1().data()) = 2.0);
115 generator.def(
"addCube", &PrimitivesGeneratorPlugin::addCube,
116 QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Generates a poly mesh of cube (ObjectId is returned)").toLatin1().data(),
117 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Center position").toLatin1().data()) =
Vector(0.0,0.0,0.0),
118 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Length of each edge").toLatin1().data()) = 2.0);
120 generator.def(
"addTriangulatedCube", &PrimitivesGeneratorPlugin::addTriangulatedCube,
121 QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Generates a triangular mesh of cube (ObjectId is returned)").toLatin1().data(),
122 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Center position").toLatin1().data()) =
Vector(0.0,0.0,0.0),
123 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Length of each edge").toLatin1().data()) = 2.0);
125 generator.def(
"addTriangulatedPlaneFlat", &PrimitivesGeneratorPlugin::addTriangulatedPlaneFlat,
126 QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Generates a flat triangular planar mesh in the z plane (ObjectId is returned)").toLatin1().data(),
127 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Corner position").toLatin1().data()) =
Vector(0.0,0.0,0.0),
128 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Size in X direction").toLatin1().data()) = 2.0,
129 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Size in Y direction").toLatin1().data()) = 2.0,
130 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Number of linesegments in x direction").toLatin1().data()) = 10,
131 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Number of linesegments in y direction").toLatin1().data()) = 10);
133 generator.def(
"addTriangulatedPlaneBumpy", &PrimitivesGeneratorPlugin::addTriangulatedPlaneBumpy,
134 QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Generates a bumpy triangular planar mesh in the z plane (ObjectId is returned)").toLatin1().data(),
135 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Corner position").toLatin1().data()) =
Vector(0.0,0.0,0.0),
136 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Size in X direction").toLatin1().data()) = 10.0,
137 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Size in Y direction").toLatin1().data()) = 10.0,
138 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Number of linesegments in x direction").toLatin1().data()) = 200,
139 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Number of linesegments in y direction").toLatin1().data()) = 200);
142 generator.def(
"addTriangulatedPlanesNonManifold", &PrimitivesGeneratorPlugin::addTriangulatedPlanesNonManifold,
143 QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Generates two perpendicular planes in a non manifold config (ObjectId is returned)").toLatin1().data(),
144 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Corner position").toLatin1().data()) =
Vector(0.0,0.0,0.0),
145 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Size in X direction").toLatin1().data()) = 2.0,
146 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Size in Y direction").toLatin1().data()) = 2.0,
147 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Size in Z direction").toLatin1().data()) = 1.0,
148 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Number of linesegments in x direction").toLatin1().data()) = 50,
149 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Number of linesegments in y direction").toLatin1().data()) = 50,
150 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Number of linesegments in y direction").toLatin1().data()) = 50);
152 generator.def(
"addIcosahedron", &PrimitivesGeneratorPlugin::addIcosahedron,
153 QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Generates an Icosahedron (ObjectId is returned)").toLatin1().data(),
154 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Center position").toLatin1().data()) =
Vector(0.0,0.0,0.0),
155 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Length of each edge").toLatin1().data()) = 2.0);
157 generator.def(
"addOctahedron", &PrimitivesGeneratorPlugin::addOctahedron,
158 QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Generates an Octahedron (ObjectId is returned)").toLatin1().data(),
159 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Center position").toLatin1().data()) =
Vector(0.0,0.0,0.0),
160 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Length of each edge").toLatin1().data()) = 2.0);
162 generator.def(
"addDodecahedron", &PrimitivesGeneratorPlugin::addDodecahedron,
163 QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Generates a Dodecahedron (ObjectId is returned)").toLatin1().data(),
164 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Center position").toLatin1().data()) =
Vector(0.0,0.0,0.0),
165 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Length of each edge").toLatin1().data()) = 2.0);
167#ifdef ENABLE_BSPLINECURVE_SUPPORT
168 generator.def(
"addRandomBSplineCurve", &PrimitivesGeneratorPlugin::addRandomBSplineCurve,
169 QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Generates a random B-spline curve (ObjectId is returned)").toLatin1().data(),
170 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Position").toLatin1().data()) =
Vector(0.0,0.0,0.0),
171 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Number of control points").toLatin1().data()) = 5);
175#ifdef ENABLE_BSPLINESURFACE_SUPPORT
176 generator.def(
"addRandomBSplineSurface", &PrimitivesGeneratorPlugin::addRandomBSplineSurface,
177 QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Generates a random B-spline surface (ObjectId is returned)").toLatin1().data(),
178 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Position").toLatin1().data()) =
Vector(0.0,0.0,0.0),
179 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Number of control points").toLatin1().data()) = 5);
182#ifdef ENABLE_POLYHEDRALMESH_SUPPORT
183 generator.def(
"addTetrahedralCube", &PrimitivesGeneratorPlugin::addTetrahedralCube,
184 QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Generates a tetrahedral mesh of a cube (ObjectId is returned)").toLatin1().data(),
185 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Center Position").toLatin1().data()) =
Vector(0.0,0.0,0.0),
186 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Length of each edge").toLatin1().data()) = 2.0);
188 generator.def(
"addTetrahedralCuboid", &PrimitivesGeneratorPlugin::addTetrahedralCuboid,
189 QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Generates a tetrahedral mesh of a cuboid (ObjectId is returned)").toLatin1().data(),
190 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Center Position").toLatin1().data()) =
Vector(0.0,0.0,0.0),
191 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Length of each side").toLatin1().data()) =
Vector(4.0,6.0,12.0),
192 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Number of units in x-axis").toLatin1().data()) = 5,
193 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Number of units in y-axis").toLatin1().data()) = 5,
194 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Number of units in z-axis").toLatin1().data()) = 10);
198#ifdef ENABLE_HEXAHEDRALMESH_SUPPORT
199 generator.def(
"addHexahedralCube", &PrimitivesGeneratorPlugin::addHexahedralCube,
200 QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Generates a hexahedral mesh of a cube (ObjectId is returned)").toLatin1().data(),
201 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Center Position").toLatin1().data()) =
Vector(0.0,0.0,0.0),
202 py::arg(QCoreApplication::translate(
"PythonDocPrimitivesGenerator",
"Length of each edge").toLatin1().data()) = 2.0);
ACG::Vec3d Vector
Standard Type for 3d Vector used for scripting.