本文整理汇总了C++中py::Tuple::verify_length方法的典型用法代码示例。如果您正苦于以下问题:C++ Tuple::verify_length方法的具体用法?C++ Tuple::verify_length怎么用?C++ Tuple::verify_length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类py::Tuple
的用法示例。
在下文中一共展示了Tuple::verify_length方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: convert_path_to_polygons
Py::Object _path_module::convert_path_to_polygons(const Py::Tuple& args)
{
typedef agg::conv_transform<PathIterator> transformed_path_t;
typedef SimplifyPath<transformed_path_t> simplify_t;
typedef agg::conv_curve<simplify_t> curve_t;
typedef std::vector<double> vertices_t;
args.verify_length(4);
PathIterator path(args[0]);
agg::trans_affine trans = py_to_agg_transformation_matrix(args[1], false);
double width = Py::Float(args[2]);
double height = Py::Float(args[3]);
bool simplify = path.should_simplify() && width != 0.0 && height != 0.0;
transformed_path_t tpath(path, trans);
simplify_t simplified(tpath, false, simplify, width, height);
curve_t curve(simplified);
Py::List polygons;
vertices_t polygon;
double x, y;
unsigned code;
polygon.reserve(path.total_vertices() * 2);
while ((code = curve.vertex(&x, &y)) != agg::path_cmd_stop)
{
if ((code & agg::path_cmd_end_poly) == agg::path_cmd_end_poly) {
if (polygon.size() >= 2)
{
polygon.push_back(polygon[0]);
polygon.push_back(polygon[1]);
_add_polygon(polygons, polygon);
}
polygon.clear();
} else {
if (code == agg::path_cmd_move_to) {
_add_polygon(polygons, polygon);
polygon.clear();
}
polygon.push_back(x);
polygon.push_back(y);
}
}
_add_polygon(polygons, polygon);
return polygons;
}
示例2: point_in_path
Py::Object _path_module::point_in_path(const Py::Tuple& args)
{
args.verify_length(4);
double x = Py::Float(args[0]);
double y = Py::Float(args[1]);
PathIterator path(args[2]);
agg::trans_affine trans = py_to_agg_transformation_matrix(args[3], false);
if (::point_in_path(x, y, path, trans))
return Py::Int(1);
return Py::Int(0);
}
示例3: a
Py::Object
_path_module::path_in_path(const Py::Tuple& args)
{
args.verify_length(4);
PathIterator a(args[0]);
agg::trans_affine atrans = py_to_agg_transformation_matrix(
args[1].ptr(), false);
PathIterator b(args[2]);
agg::trans_affine btrans = py_to_agg_transformation_matrix(
args[3].ptr(), false);
return Py::Int(::path_in_path(a, atrans, b, btrans));
}
示例4: irrelevant
Py::Object CyPy_Task::irrelevant(const Py::Tuple& args)
{
m_value->irrelevant();
if (args.size() > 0) {
args.verify_length(1);
Atlas::Objects::Operation::Error e;
Atlas::Objects::Entity::Anonymous arg;
arg->setAttr("message", verifyString(args.front()));
e->modifyArgs().push_back(arg);
e->setTo(m_value->m_usageInstance.actor->getId());
return CyPy_Operation::wrap(e);
}
return Py::None();
}
示例5: create_contour
Py::Object TriContourGenerator::create_contour(const Py::Tuple &args)
{
_VERBOSE("TriContourGenerator::create_contour");
args.verify_length(1);
double level = (Py::Float)args[0];
clear_visited_flags(false);
Contour contour;
find_boundary_lines(contour, level);
find_interior_lines(contour, level, false, false);
return contour_to_segs(contour);
}
示例6: clip_path_to_rect
Py::Object _path_module::clip_path_to_rect(const Py::Tuple &args)
{
args.verify_length(3);
PathIterator path(args[0]);
Py::Object bbox_obj = args[1];
bool inside = Py::Int(args[2]);
double x0, y0, x1, y1;
if (!py_convert_bbox(bbox_obj.ptr(), x0, y0, x1, y1))
throw Py::TypeError("Argument 2 to clip_to_rect must be a Bbox object.");
std::vector<Polygon> results;
::clip_to_rect(path, x0, y0, x1, y1, inside, results);
npy_intp dims[2];
dims[1] = 2;
PyObject* py_results = PyList_New(results.size());
if (!py_results)
throw Py::RuntimeError("Error creating results list");
try
{
for (std::vector<Polygon>::const_iterator p = results.begin(); p != results.end(); ++p)
{
size_t size = p->size();
dims[0] = p->size();
PyArrayObject* pyarray = (PyArrayObject*)PyArray_SimpleNew(2, dims, PyArray_DOUBLE);
for (size_t i = 0; i < size; ++i)
{
((double *)pyarray->data)[2*i] = (*p)[i].x;
((double *)pyarray->data)[2*i+1] = (*p)[i].y;
}
if (PyList_SetItem(py_results, p - results.begin(), (PyObject *)pyarray) != -1)
{
throw Py::RuntimeError("Error creating results list");
}
}
}
catch (...)
{
Py_XDECREF(py_results);
throw;
}
return Py::Object(py_results, true);
}
示例7: count_bboxes_overlapping_bbox
Py::Object _path_module::count_bboxes_overlapping_bbox(const Py::Tuple& args)
{
args.verify_length(2);
Py::Object bbox = args[0];
Py::SeqBase<Py::Object> bboxes = args[1];
double ax0, ay0, ax1, ay1;
double bx0, by0, bx1, by1;
long count = 0;
if (py_convert_bbox(bbox.ptr(), ax0, ay0, ax1, ay1))
{
if (ax1 < ax0)
std::swap(ax0, ax1);
if (ay1 < ay0)
std::swap(ay0, ay1);
size_t num_bboxes = bboxes.size();
for (size_t i = 0; i < num_bboxes; ++i)
{
Py::Object bbox_b = bboxes[i];
if (py_convert_bbox(bbox_b.ptr(), bx0, by0, bx1, by1))
{
if (bx1 < bx0)
std::swap(bx0, bx1);
if (by1 < by0)
std::swap(by0, by1);
if (!((bx1 <= ax0) ||
(by1 <= ay0) ||
(bx0 >= ax1) ||
(by0 >= ay1)))
++count;
}
else
{
throw Py::ValueError("Non-bbox object in bboxes list");
}
}
}
else
{
throw Py::ValueError("First argument to count_bboxes_overlapping_bbox must be a Bbox object.");
}
return Py::Int(count);
}