Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New python interface with documentation #34

Merged
merged 22 commits into from
Oct 21, 2021
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
c70ef5d
Working on including documentation in the python library. Also refres…
MatteoRagni Oct 18, 2021
3032833
Completed base curve wrapping
MatteoRagni Oct 19, 2021
de542c3
:snake: Working on biarc wrapper
MatteoRagni Oct 19, 2021
dbacf64
:snake: A more python copy concept for Biarc
MatteoRagni Oct 19, 2021
acbdd9f
Merge branch 'bugfix/biarc_list_memory' into develop
MatteoRagni Oct 19, 2021
bd0bad3
:snake: revision of BiarcList wrapper (and Biarc)
MatteoRagni Oct 19, 2021
c01e629
:snake: G2lib has a __version__ attribute
MatteoRagni Oct 19, 2021
cccd831
:snake: refreshed wrapper for Circle Arc
MatteoRagni Oct 19, 2021
a62e41a
Merge remote-tracking branch 'upstream/develop' into develop
MatteoRagni Oct 20, 2021
72c33a7
:snake: minor fixes in biarc docs
MatteoRagni Oct 20, 2021
b139a0a
:snake: full remake of the LineSegment and PolyLine interfaces
MatteoRagni Oct 20, 2021
b9b1deb
:snake: full remake for Triangle2d wrapper
MatteoRagni Oct 20, 2021
f549d8b
:snake: full remake of the interface for Clothoids and ClothoidsList
MatteoRagni Oct 20, 2021
a2f4814
:snake: const correctness in trinagle2d
MatteoRagni Oct 20, 2021
7f78f5f
:snake: minor fix in clothoids
MatteoRagni Oct 20, 2021
b6dc95b
:snake: Reimporting some stuff from antemotion repository
MatteoRagni Oct 20, 2021
1a89bc6
:snake: Fixes an error in const requirements for ClothoidList::load
MatteoRagni Oct 20, 2021
e0b427d
Fixes a segmentation fault on ClothoidList::length for empty list
MatteoRagni Oct 20, 2021
2c72ff2
:snake: Several improvements to interface and vectorial version of me…
MatteoRagni Oct 21, 2021
c490850
git submodules now are CI complaint
MatteoRagni Oct 21, 2021
f3d9ca3
Fix to minor cmake stuff, that raise an error on some platform
MatteoRagni Oct 21, 2021
1223e24
:snake: Fixes segmentation fault on getXY for clothoidList and Biarc
MatteoRagni Oct 21, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
🐍 Working on biarc wrapper
 - removed functions wrapped now in base curve
 - added documentation to all methods of biarc
 - getC0 becomes c0
 - getC1 becomes c1
  • Loading branch information
MatteoRagni committed Oct 19, 2021
commit de542c31f94c7a8abccdcf6d27946893926c0ff4
220 changes: 157 additions & 63 deletions src_py/src/python-Biarc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,54 +21,163 @@
namespace G2lib {
namespace python {
void wrap_Biarc(py::module & m) {
py::class_<Biarc, BaseCurve>(m, "Biarc")
.def(py::init())
.def(py::init<Biarc const &>())
.def(py::init<real_type, real_type, real_type, real_type, real_type, real_type>())
.def(py::init<BaseCurve const &>())
.def("copy", &Biarc::copy)
.def("build", &Biarc::build)
.def("build_3P", &Biarc::build_3P)
.def("getC0", &Biarc::C0)
.def("getC1", &Biarc::C1)
.def("xMiddle", &Biarc::xMiddle)
.def("yMiddle", &Biarc::yMiddle)
.def("thetaMiddle", &Biarc::thetaMiddle)
.def("kappa0", &Biarc::kappa0)
.def("kappa1", &Biarc::kappa1)
.def("length0", &Biarc::length0)
.def("length1", &Biarc::length1)
.def("delta_theta", &Biarc::delta_theta)
.def("bbTriangles", [](Biarc * self, real_type max_angle = Utils::m_pi/18,
real_type max_size = 1e100, int_type icurve = 0) {
std::vector<Triangle2D> tvec;
self->bbTriangles(tvec, max_angle, max_size, icurve);
return tvec;
}, py::arg("max_angle") = Utils::m_pi/18, py::arg("max_size") = 1e100, py::arg("icurve") = 0)
.def("bbTriangles_ISO", [](Biarc * self, real_type offs, real_type max_angle = Utils::m_pi/18,
real_type max_size = 1e100, int_type icurve = 0) {
std::vector<Triangle2D> tvec;
self->bbTriangles_ISO(offs, tvec, max_angle, max_size, icurve);
return tvec;
}, py::arg("offs"), py::arg("max_angle") = Utils::m_pi/18, py::arg("max_size") = 1e100, py::arg("icurve") = 0)
.def("bbTriangles_SAE", [](Biarc * self, real_type offs, real_type max_angle = Utils::m_pi/18,
real_type max_size = 1e100, int_type icurve = 0) {
std::vector<Triangle2D> tvec;
self->bbTriangles_SAE(offs, tvec, max_angle, max_size, icurve);
return tvec;
}, py::arg("offs"), py::arg("max_angle") = Utils::m_pi/18, py::arg("max_size") = 1e100, py::arg("icurve") = 0)
.def("collision", &Biarc::collision)
.def("collision_ISO", &Biarc::collision_ISO)
.def("intersect", [](Biarc * self, Biarc const & B, bool swap_s_vals) {
IntersectList ilist;
self->intersect(B, ilist, swap_s_vals);
return ilist;
})
.def("intersect_ISO", [](Biarc * self, real_type offs, Biarc const & B, real_type Coffs, bool swap_s_vals) {
IntersectList ilist;
self->intersect_ISO(offs, B, Coffs, ilist, swap_s_vals);
return ilist;
});
py::class_<Biarc, BaseCurve>(m, "Biarc",
R"S(
Compute biarc fitting by Hermite data

There are several possible constructors for this class:

* Empty constructor
* Copy contructor
* Constructor from data
* Explicit constructor from another base curve (unused)

For the copy constructor

:param Biarc curve: curve for copy

For the data constructor:

:param float x0: **x** coordinate of the origin
:param float y0: **y** coordinate of the origin
:param float theta0: tangent in the origin
:param float x1: **x** coordinate of the destination
:param float y1: **y** coordinate of the destination
:param float theta1: tangent in the destination
)S")

.def(py::init())
.def(py::init<Biarc const &>(), py::arg("curve"))
.def(py::init<real_type, real_type, real_type, real_type, real_type, real_type>(),
py::arg("x0"), py::arg("y0"), py::arg("theta0"),
py::arg("x1"), py::arg("y1"), py::arg("theta1"))
.def(py::init<BaseCurve const &>(), py::arg("curve"))

.def("copy", &Biarc::copy, py::arg("curve"),
R"S(
Copy onto this object another biarc parameters

:param Biarc curve: another biarc
:return: nothing, works in place
:rtype: NoneType
)S")

.def("build", &Biarc::build,
py::arg("x0"), py::arg("y0"), py::arg("theta0"),
py::arg("x1"), py::arg("y1"), py::arg("theta1"),
R"S(
Construct a biarc passing from the points
:math:`(x_0,y_0)` to the point :math:`(x_1,y_1)`
with initial angle :math:`\theta_0` and final angle :math:`\theta_1`

:param float x0: **x** coordinate of the origin
:param float y0: **y** coordinate of the origin
:param float theta0: tangent in the origin
:param float x1: **x** coordinate of the destination
:param float y1: **y** coordinate of the destination
:param float theta1: tangent in the destination
:return: false if biarc cannot be computed
:rtype: bool
)S")

.def("c0", &Biarc::C0,
R"S(
Returns the first circle arc of the biarc

:return: circle arc of the biarc
:rtype: CircleArc
)S")

.def("c1", &Biarc::C1,
R"S(
Returns the second circle arc of the biarc

:return: circle arc of the biarc
:rtype: CircleArc
)S")

.def("build_3P", &Biarc::build_3P,
py::arg("x0"), py::arg("y0"), py::arg("x1"), py::arg("y1"), py::arg("x2"), py::arg("y2"),
R"S(
Construct a biarc by 3 point at "minimum energy"

* Planar point set fairing and fitting by arc splines
* Xunnian Yang and Guozhao Wang
* Computer-Aided Design, vol 33, 2001

:param float x0: **x** coordinate of initial point
:param float y0: **y** coordinate of initial point
:param float x1: **x** coordinate of central point
:param float y1: **y** coordinate of central point
:param float x2: **x** coordinate of final point
:param float y2: **y** coordinate of final point
:return: false if biarc cannot be computed
:rtype: bool
)S")

.def("xMiddle", &Biarc::xMiddle,
R"S(
Returns the **x** coordinate of the junction point of the biarc

:return: **x** coordinates of the junction
:rtype: float
)S")

.def("yMiddle", &Biarc::yMiddle,
R"S(
Returns the **y** coordinate of the junction point of the biarc

:return: **y** coordinates of the junction
:rtype: float
)S")

.def("thetaMiddle", &Biarc::thetaMiddle,
R"S(
Returns the **x** coordinate of the junction point of the biarc

:return: **x** coordinates of the junction
:rtype: float
)S")

.def("kappa0", &Biarc::kappa0,
R"S(
Curvature of the first circle arc

:return: curvature of the first circle arc
:rtype: float
)S")

.def("kappa1", &Biarc::kappa1,
R"S(
Curvature of the second circle arc

:return: curvature of the second circle arc
:rtype: float
)S")

.def("length0", &Biarc::length0,
R"S(
Length of the first circle arc

:return: length of the first circle arc
:rtype: float
)S")

.def("length1", &Biarc::length1,
R"S(
Length of the second circle arc

:return: length of the second circle arc
:rtype: float
)S")

.def("delta_theta", &Biarc::delta_theta,
R"S(
Change of angle of the biarc :math:`\theta_1 - \theta_0`

:return: the angle difference
:rtype: float
)S");
}

void wrap_BiarcList(py::module & m) {
Expand Down Expand Up @@ -124,21 +233,6 @@ namespace G2lib {
.def("findAtS", &BiarcList::findAtS)
.def("segment_length", &BiarcList::segment_length)
.def("segment_length_ISO", &BiarcList::segment_length_ISO)
.def("bbTriangles", [](BiarcList * self, real_type max_angle = Utils::m_pi/6, real_type max_size = 1e100) {
std::vector<Triangle2D> tvec;
self->bbTriangles(tvec, max_angle, max_size);
return tvec;
}, py::arg("max_angle") = Utils::m_pi/6, py::arg("max_size") = 1e100)
.def("bbTriangles_ISO", [](BiarcList * self, real_type offs, real_type max_angle, real_type max_size) {
std::vector<Triangle2D> tvec;
self->bbTriangles_ISO(offs, tvec, max_angle, max_size);
return tvec;
})
.def("bbTriangles_SAE", [](BiarcList * self, real_type offs, real_type max_angle = Utils::m_pi/18, real_type max_size = 1e100) {
std::vector<Triangle2D> tvec;
self->bbTriangles_SAE(offs, tvec, max_angle, max_size);
return tvec;
}, py::arg("offs"), py::arg("max_angle") = Utils::m_pi/18, py::arg("max_size") = 1e100)
.def("build_AABBtree_ISO", &BiarcList::build_AABBtree_ISO)
.def("build_AABBtree_SAE", &BiarcList::build_AABBtree_SAE,
py::arg("offs"), py::arg("max_angle") = Utils::m_pi/6, py::arg("max_size") = 1e100)
Expand Down