Skip to content

Commit 2470e2a

Browse files
committed
Add documentation
1 parent f852b73 commit 2470e2a

File tree

2 files changed

+60
-12
lines changed

2 files changed

+60
-12
lines changed

bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_DrawTool.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ void moduleAddDrawTool(py::module &m)
9595
dt.def("drawPoints", [](DrawTool *self, py::array_t<double> points, float size, sofa::type::RGBAColor& color)
9696
{
9797
self->drawPoints(getPoints(points), size, color);
98-
});
98+
}, sofapython3::doc::drawtool::drawPoints);
9999
dt.def("drawPoints", [](DrawTool *self, BaseData* dpositions, float size, sofa::type::RGBAColor& color){
100100
auto positions = dynamic_cast<Data<sofa::type::vector<sofa::type::Vec3>>*>(dpositions);
101101
if(!positions)
@@ -107,7 +107,7 @@ void moduleAddDrawTool(py::module &m)
107107
/// Draw lines
108108
dt.def("drawLines", [](DrawTool *self, const py::array_t<double>& positions, const float size, sofa::type::RGBAColor& color){
109109
self->drawLines(getPoints(positions), size, color);
110-
});
110+
}, sofapython3::doc::drawtool::drawLines);
111111
dt.def("drawLines", [](DrawTool *self, BaseData* dpositions, const float size, sofa::type::RGBAColor& color){
112112
auto positions = dynamic_cast<Data<sofa::type::vector<sofa::type::Vec3>>*>(dpositions);
113113
if(!positions)
@@ -127,7 +127,7 @@ void moduleAddDrawTool(py::module &m)
127127
// Draw mesh
128128
dt.def("drawTriangles", [](DrawTool *self, py::array_t<double>& positions, sofa::type::RGBAColor& color){
129129
self->drawTriangles(getPoints(positions), color);
130-
});
130+
}, sofapython3::doc::drawtool::drawTriangles);
131131
dt.def("drawTriangles", [](DrawTool *self, BaseData* dpositions, BaseData* dtriangles, sofa::type::RGBAColor& color){
132132
auto positions = dynamic_cast<Data<sofa::type::vector<sofa::type::Vec3d>>*>(dpositions);
133133
if(!positions)
@@ -156,7 +156,7 @@ void moduleAddDrawTool(py::module &m)
156156
// Draw mesh
157157
dt.def("drawQuads", [](DrawTool *self, py::array_t<double>& positions, sofa::type::RGBAColor& color){
158158
self->drawQuads(getPoints(positions), color);
159-
});
159+
}, sofapython3::doc::drawtool::drawQuads);
160160
dt.def("drawQuads", [](DrawTool *self, BaseData* dpositions, BaseData* dquads, sofa::type::RGBAColor& color){
161161
auto positions = dynamic_cast<Data<sofa::type::vector<sofa::type::Vec3d>>*>(dpositions);
162162
if(!positions)
@@ -187,7 +187,7 @@ void moduleAddDrawTool(py::module &m)
187187
// Draw spheres
188188
dt.def("drawSpheres", [](DrawTool *self, const py::array_t<double>& positions, const std::vector<float>& radius, sofa::type::RGBAColor& color){
189189
self->drawSpheres(getPoints(positions), radius, color);
190-
});
190+
}, sofapython3::doc::drawtool::drawSpheres);
191191
dt.def("drawSpheres", [](DrawTool *self, BaseData* dpositions, const float radius, sofa::type::RGBAColor& color){
192192
auto positions = dynamic_cast<Data<sofa::type::vector<sofa::type::Vec3>>*>(dpositions);
193193
if(!positions)
@@ -196,11 +196,11 @@ void moduleAddDrawTool(py::module &m)
196196
});
197197

198198
// Draw boundingBox
199-
dt.def("boundingBox", [](DrawTool *self, const std::array<double,4>& min, const std::array<double, 4>& max, double width){
199+
dt.def("drawBoundingBox", [](DrawTool *self, const std::array<double,4>& min, const std::array<double, 4>& max, double width){
200200
sofa::type::Vec3d cmin { min[0], min[1], min[2] };
201201
sofa::type::Vec3d cmax { max[0], max[1], max[2] };
202202
self->drawBoundingBox( cmin, cmax, width);
203-
});
203+
}, sofapython3::doc::drawtool::drawBoundingBox);
204204

205205
// Draw frames
206206
dt.def("drawFrames", [](DrawTool* self,
@@ -214,7 +214,7 @@ void moduleAddDrawTool(py::module &m)
214214
{
215215
self->drawFrame(cpoints[i], corientations[i], csize);
216216
}
217-
});
217+
}, sofapython3::doc::drawtool::drawFrames);
218218
dt.def("drawFrames", [](DrawTool* self, BaseData* dpositions, std::array<double, 3>& size ){
219219
using sofa::defaulttype::Rigid3Types;
220220
using Coord = sofa::defaulttype::Rigid3Types::Coord;
@@ -241,15 +241,13 @@ void moduleAddDrawTool(py::module &m)
241241
const sofa::type::RGBAColor& color)
242242
{
243243
self->draw3DText(point, size, color, text.c_str());
244-
});
244+
}, sofapython3::doc::drawtool::drawText);
245245

246246
// Draw overlay text
247247
dt.def("drawOverlayText", [](DrawTool* self, const std::array<double,2>& point,
248248
int fontSize, char* text, sofa::type::RGBAColor& color){
249249
self->writeOverlayText(point[0],point[1], fontSize, color, text);
250-
});
251-
252-
250+
}, sofapython3::doc::drawtool::drawOverlayText);
253251

254252
}
255253

bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_DrawTool_doc.h

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,54 @@ static auto baseDrawToolClass =
2727
It provides higher-level drawing functions like drawing lines, points, spheres, arrows, etc., without
2828
needing to write raw OpenGL each time.)";
2929

30+
static auto drawPoints =
31+
R"(Draws 3D points.
32+
points: NumPy array of shape (N, 3) or BaseData of type vector<Vec3>
33+
size: Point size (float)
34+
color: RGBAColor object)";
35+
36+
static auto drawLines =
37+
R"(Draws connected line segments between given 3D points.)";
38+
39+
40+
static auto drawTriangles =
41+
R"(Draws a triangle mesh from a flat array of 3-point group.
42+
points: NumPy array of shape (N, 3) or BaseData of type vector<Vec3>
43+
color: RGBAColor object)";
44+
45+
static auto drawQuads =
46+
R"(Draws quad mesh from a flat array of 4-point groups.
47+
points: NumPy array of shape (N, 3) or BaseData of type vector<Vec4>
48+
color: RGBAColor object)";
49+
50+
static auto drawSpheres =
51+
R"(Draws spheres from a set of points.
52+
points: NumPy array of shape (N, 3) or BaseData of type vector<Vec4>
53+
color: RGBAColor object)";
54+
55+
static auto drawBoundingBox =
56+
R"(Draws a bounding box from its min and max point
57+
min: an array of 3 values
58+
max: an array of 3 values)";
59+
60+
static auto drawFrames =
61+
R"(Draws 3d frames from position and orientation
62+
position: an array of size N,3
63+
orientaiton: an array of size N,4)";
64+
65+
static auto drawText =
66+
R"(Draws text in 3D
67+
position: an array of size 3
68+
size: dimmension of the text,
69+
text: content to show on screen
70+
color: RGBAColor)";
71+
72+
static auto drawOverlayText =
73+
R"(Draws text in 2D
74+
position: an array of size 2
75+
size: the font size,
76+
text: content to show on screen
77+
color: RGBAColor)";
78+
79+
3080
}

0 commit comments

Comments
 (0)