本文整理汇总了C++中py::SeqBase::length方法的典型用法代码示例。如果您正苦于以下问题:C++ SeqBase::length方法的具体用法?C++ SeqBase::length怎么用?C++ SeqBase::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类py::SeqBase
的用法示例。
在下文中一共展示了SeqBase::length方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ValueError
Py::Object
_path_module::point_in_path_collection(const Py::Tuple& args)
{
args.verify_length(9);
//segments, trans, clipbox, colors, linewidths, antialiaseds
double x = Py::Float(args[0]);
double y = Py::Float(args[1]);
double radius = Py::Float(args[2]);
agg::trans_affine master_transform = py_to_agg_transformation_matrix(args[3].ptr());
Py::SeqBase<Py::Object> paths = args[4];
Py::SeqBase<Py::Object> transforms_obj = args[5];
Py::SeqBase<Py::Object> offsets_obj = args[6];
agg::trans_affine offset_trans = py_to_agg_transformation_matrix(args[7].ptr());
bool filled = Py::Boolean(args[8]);
PyArrayObject* offsets = (PyArrayObject*)PyArray_FromObject(
offsets_obj.ptr(), PyArray_DOUBLE, 0, 2);
if (!offsets ||
(PyArray_NDIM(offsets) == 2 && PyArray_DIM(offsets, 1) != 2) ||
(PyArray_NDIM(offsets) == 1 && PyArray_DIM(offsets, 0) != 0))
{
Py_XDECREF(offsets);
throw Py::ValueError("Offsets array must be Nx2");
}
size_t Npaths = paths.length();
size_t Noffsets = offsets->dimensions[0];
size_t N = std::max(Npaths, Noffsets);
size_t Ntransforms = std::min(transforms_obj.length(), N);
size_t i;
// Convert all of the transforms up front
typedef std::vector<agg::trans_affine> transforms_t;
transforms_t transforms;
transforms.reserve(Ntransforms);
for (i = 0; i < Ntransforms; ++i)
{
agg::trans_affine trans = py_to_agg_transformation_matrix
(transforms_obj[i].ptr(), false);
trans *= master_transform;
transforms.push_back(trans);
}
Py::List result;
agg::trans_affine trans;
for (i = 0; i < N; ++i)
{
PathIterator path(paths[i % Npaths]);
if (Ntransforms)
{
trans = transforms[i % Ntransforms];
}
else
{
trans = master_transform;
}
if (Noffsets)
{
double xo = *(double*)PyArray_GETPTR2(offsets, i % Noffsets, 0);
double yo = *(double*)PyArray_GETPTR2(offsets, i % Noffsets, 1);
offset_trans.transform(&xo, &yo);
trans *= agg::trans_affine_translation(xo, yo);
}
if (filled)
{
if (::point_in_path(x, y, path, trans))
result.append(Py::Int((int)i));
}
else
{
if (::point_on_path(x, y, radius, path, trans))
result.append(Py::Int((int)i));
}
}
return result;
}