Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit09ff6c2

Browse files
committed
Add a pybind11 type caster for e_snap_mode
1 parent37e2848 commit09ff6c2

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

‎src/_path_wrapper.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -301,15 +301,11 @@ Py_convert_path_to_polygons(mpl::PathIterator path, agg::trans_affine trans,
301301

302302
static py::tuple
303303
Py_cleanup_path(mpl::PathIterator path, agg::trans_affine trans,bool remove_nans,
304-
agg::rect_d clip_rect,py::object snap_mode_obj,double stroke_width,
304+
agg::rect_d clip_rect,e_snap_mode snap_mode,double stroke_width,
305305
std::optional<bool> simplify,bool return_curves, py::object sketch_obj)
306306
{
307-
e_snap_mode snap_mode;
308307
SketchParams sketch;
309308

310-
if (!convert_snap(snap_mode_obj.ptr(), &snap_mode)) {
311-
throwpy::error_already_set();
312-
}
313309
if (!convert_sketch_params(sketch_obj.ptr(), &sketch)) {
314310
throwpy::error_already_set();
315311
}

‎src/py_converters_11.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ namespace py = pybind11;
1010

1111
#include"agg_basics.h"
1212
#include"agg_trans_affine.h"
13+
#include"path_converters.h"
1314

1415
voidconvert_trans_affine(const py::object& transform, agg::trans_affine& affine);
1516

@@ -85,6 +86,22 @@ namespace PYBIND11_NAMESPACE { namespace detail {
8586
}
8687
};
8788

89+
template<>structtype_caster<e_snap_mode> {
90+
public:
91+
PYBIND11_TYPE_CASTER(e_snap_mode, const_name("e_snap_mode"));
92+
93+
boolload(handle src,bool) {
94+
if (src.is_none()) {
95+
value = SNAP_AUTO;
96+
returntrue;
97+
}
98+
99+
value = py::cast<bool>(src) ? SNAP_TRUE : SNAP_FALSE;
100+
101+
returntrue;
102+
}
103+
};
104+
88105
/* Remove all this macro magic after dropping NumPy usage and just include `py_adaptors.h`.*/
89106
#ifdef MPL_PY_ADAPTORS_H
90107
template<>structtype_caster<mpl::PathIterator> {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp