本文整理汇总了C++中py::Tuple类的典型用法代码示例。如果您正苦于以下问题:C++ Tuple类的具体用法?C++ Tuple怎么用?C++ Tuple使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Tuple类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: read
py::Object read ( py::Object self, py::Tuple args )
try
{
std::istream& stream = *static_cast<std::istream*>
(py::TypeBuilder::get_baton(self));
std::ostringstream payload;
if ( args.size() == 1 )
{
char data[1024];
long size = py::Int(args[0]);
for (; (size > 0); size -= stream.gcount()) {
stream.read(data, std::min(size, long(sizeof(data))));
payload.write(data, stream.gcount());
}
}
else {
payload << stream.rdbuf();
}
return (py::Bytes(payload.str()));
}
catch ( const std::bad_cast& )
{
std::cerr << "Bad cast!" << std::endl;
return (py::None());
}
示例2: write
py::Object write ( py::Object self, py::Tuple args )
{
std::ostream& stream = *static_cast<std::ostream*>
(py::TypeBuilder::get_baton(self));
if (args.size() == 1)
{
stream << (std::string)py::Bytes(args[0]);
}
return (py::None());
}
示例3: writelines
py::Object writelines ( py::Object self, py::Tuple args )
{
std::ostream& stream = *static_cast<std::ostream*>
(py::TypeBuilder::get_baton(self));
if (args.size() == 1)
{
py::Iterator iterator(args[0]);
while (iterator.next()) {
stream << (std::string)py::Bytes(iterator.item());
}
}
return (py::None());
}
示例4: openBrowser
Py::Object openBrowser(const Py::Tuple& args)
{
const char* url;
if (!PyArg_ParseTuple(args.ptr(), "s",&url))
throw Py::Exception();
WebGui::BrowserView* pcBrowserView;
pcBrowserView = new WebGui::BrowserView(Gui::getMainWindow());
pcBrowserView->setWindowTitle(QObject::tr("Browser"));
pcBrowserView->resize(400, 300);
pcBrowserView->load(url);
Gui::getMainWindow()->addWindow(pcBrowserView);
return Py::None();
}
示例5: openBrowserHTML
Py::Object openBrowserHTML(const Py::Tuple& args)
{
const char* HtmlCode;
const char* BaseUrl;
const char* TabName = "Browser";
if (! PyArg_ParseTuple(args.ptr(), "ss|s",&HtmlCode,&BaseUrl,&TabName))
throw Py::Exception();
WebGui::BrowserView* pcBrowserView = 0;
pcBrowserView = new WebGui::BrowserView(Gui::getMainWindow());
pcBrowserView->resize(400, 300);
pcBrowserView->setHtml(QString::fromUtf8(HtmlCode),QUrl(QString::fromLatin1(BaseUrl)),QString::fromUtf8(TabName));
Gui::getMainWindow()->addWindow(pcBrowserView);
return Py::None();
}
示例6: writeProjectFile
Py::Object writeProjectFile(const Py::Tuple& args)
{
char *fromPython;
if (! PyArg_ParseTuple(args.ptr(), "(s)", &fromPython))
throw Py::Exception();
std::ofstream fout;
if (fromPython)
fout.open(fromPython);
else
fout.open("FreeCAD.pov");
fout << FreeCAD ;
fout.close();
return Py::None();
}
示例7: Exception
Py::Object View3DInventorViewerPy::getSceneGraph(const Py::Tuple& args)
{
if (!PyArg_ParseTuple(args.ptr(), ""))
throw Py::Exception();
try {
SoNode* scene = _viewer->getSceneGraph();
PyObject* proxy = 0;
proxy = Base::Interpreter().createSWIGPointerObj("pivy.coin", "SoSeparator *", (void*)scene, 1);
scene->ref();
return Py::Object(proxy, true);
}
catch (const Base::Exception& e) {
throw Py::Exception(e.what());
}
}
示例8: Exception
Py::Object View3DInventorViewerPy::getSoRenderManager(const Py::Tuple& args)
{
if (!PyArg_ParseTuple(args.ptr(), ""))
throw Py::Exception();
try {
SoRenderManager* manager = _viewer->getSoRenderManager();
PyObject* proxy = 0;
proxy = Base::Interpreter().createSWIGPointerObj("pivy.coin", "SoRenderManager *", (void*)manager, 0);
return Py::Object(proxy, true);
}
catch (const Base::Exception& e) {
throw Py::Exception(e.what());
}
}
示例9: next
Py::Object ProgressIndicatorPy::next(const Py::Tuple& args)
{
int b=0;
if (!PyArg_ParseTuple(args.ptr(), "|i",&b))
throw Py::Exception();
if (_seq.get()) {
try {
_seq->next(b ? true : false);
}
catch (const Base::AbortException&) {
_seq.reset();
throw Py::Exception("abort progress indicator");
}
}
return Py::None();
}
示例10: 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].ptr(), false);
if (::point_in_path(x, y, path, trans))
{
return Py::Int(1);
}
return Py::Int(0);
}
示例11: 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);
}
示例12: 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);
}
示例13: triangulate
Py::Object triangulate(const Py::Tuple& args)
{
PyObject *pcObj;
double searchRadius;
double mu=2.5;
if (!PyArg_ParseTuple(args.ptr(), "O!d|d", &(Points::PointsPy::Type), &pcObj, &searchRadius, &mu))
throw Py::Exception();
Points::PointsPy* pPoints = static_cast<Points::PointsPy*>(pcObj);
Points::PointKernel* points = pPoints->getPointKernelPtr();
Mesh::MeshObject* mesh = new Mesh::MeshObject();
SurfaceTriangulation tria(*points, *mesh);
tria.perform(searchRadius, mu);
return Py::asObject(new Mesh::MeshPy(mesh));
}
示例14: Exception
Py::Object View3DInventorViewerPy::setSceneGraph(const Py::Tuple& args)
{
PyObject* proxy;
if (!PyArg_ParseTuple(args.ptr(), "O", &proxy))
throw Py::Exception();
void* ptr = 0;
try {
Base::Interpreter().convertSWIGPointerObj("pivy.coin", "SoNode *", proxy, &ptr, 0);
SoNode* node = static_cast<SoNode*>(ptr);
_viewer->setSceneGraph(node);
return Py::None();
}
catch (const Base::Exception& e) {
throw Py::Exception(e.what());
}
}
示例15: create_filled_contour
Py::Object TriContourGenerator::create_filled_contour(const Py::Tuple &args)
{
_VERBOSE("TriContourGenerator::create_filled_contour");
args.verify_length(2);
double lower_level = (Py::Float)args[0];
double upper_level = (Py::Float)args[1];
clear_visited_flags(true);
Contour contour;
find_boundary_lines_filled(contour, lower_level, upper_level);
find_interior_lines(contour, lower_level, false, true);
find_interior_lines(contour, upper_level, true, true);
return contour_to_segs_and_kinds(contour);
}