本文整理汇总了C++中py::Tuple::ptr方法的典型用法代码示例。如果您正苦于以下问题:C++ Tuple::ptr方法的具体用法?C++ Tuple::ptr怎么用?C++ Tuple::ptr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类py::Tuple
的用法示例。
在下文中一共展示了Tuple::ptr方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: exporter
Py::Object exporter(const Py::Tuple& args)
{
PyObject* object;
char* Name;
if (!PyArg_ParseTuple(args.ptr(), "Oet",&object,"utf-8",&Name))
throw Py::Exception();
std::string EncodedName = std::string(Name);
PyMem_Free(Name);
Py::Sequence list(object);
Base::Type meshId = Base::Type::fromName("Fem::FemMeshObject");
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
PyObject* item = (*it).ptr();
if (PyObject_TypeCheck(item, &(App::DocumentObjectPy::Type))) {
App::DocumentObject* obj = static_cast<App::DocumentObjectPy*>(item)->getDocumentObjectPtr();
if (obj->getTypeId().isDerivedFrom(meshId)) {
static_cast<FemMeshObject*>(obj)->FemMesh.getValue().write(EncodedName.c_str());
break;
}
}
}
return Py::None();
}
示例2: isEmpty
Py::Object ParameterGrpPy::isEmpty(const Py::Tuple& args)
{
if (!PyArg_ParseTuple(args.ptr(), ""))
throw Py::Exception();
return Py::Boolean(_cParamGrp->IsEmpty());
}
示例3: Exception
Py::Object View3DInventorViewerPy::seekToPoint(const Py::Tuple& args)
{
PyObject* object;
if (!PyArg_ParseTuple(args.ptr(), "O", &object))
throw Py::Exception();
try {
const Py::Tuple tuple(object);
// If the 3d point is given
if (tuple.size() == 3) {
Py::Float x = tuple[0];
Py::Float y = tuple[1];
Py::Float z = tuple[2];
SbVec3f hitpoint((float)x,(float)y,(float)z);
_viewer->seekToPoint(hitpoint);
}
else {
Py::Int x(tuple[0]);
Py::Int y(tuple[1]);
SbVec2s hitpoint ((long)x,(long)y);
_viewer->seekToPoint(hitpoint);
}
return Py::None();
}
catch (const Py::Exception&) {
throw;
}
}
示例4: stop
Py::Object ProgressIndicatorPy::stop(const Py::Tuple& args)
{
if (!PyArg_ParseTuple(args.ptr(), ""))
throw Py::Exception();
_seq.reset();
return Py::None();
}
示例5: removeSvgTags
Py::Object removeSvgTags(const Py::Tuple& args)
{
const char* svgcode;
if (!PyArg_ParseTuple(args.ptr(), "s",&svgcode))
throw Py::Exception();
std::string svg(svgcode);
std::string empty = "";
std::string endline = "--endOfLine--";
std::string linebreak = "\\n";
// removing linebreaks for regex to work
boost::regex e1 ("\\n");
svg = boost::regex_replace(svg, e1, endline);
// removing starting xml definition
boost::regex e2 ("<\\?xml.*?\\?>");
svg = boost::regex_replace(svg, e2, empty);
// removing starting svg tag
boost::regex e3 ("<svg.*?>");
svg = boost::regex_replace(svg, e3, empty);
// removing sodipodi tags -- DANGEROUS, some sodipodi tags are single, better leave it
//boost::regex e4 ("<sodipodi.*?>");
//svg = boost::regex_replace(svg, e4, empty);
// removing metadata tags
boost::regex e5 ("<metadata.*?</metadata>");
svg = boost::regex_replace(svg, e5, empty);
// removing closing svg tags
boost::regex e6 ("</svg>");
svg = boost::regex_replace(svg, e6, empty);
// restoring linebreaks
boost::regex e7 ("--endOfLine--");
svg = boost::regex_replace(svg, e7, linebreak);
Py::String result(svg);
return result;
}
示例6: projectEx
Py::Object projectEx(const Py::Tuple& args)
{
PyObject *pcObjShape;
PyObject *pcObjDir=0;
if (!PyArg_ParseTuple(args.ptr(), "O!|O!",
&(TopoShapePy::Type), &pcObjShape,
&(Base::VectorPy::Type), &pcObjDir))
throw Py::Exception();
TopoShapePy* pShape = static_cast<TopoShapePy*>(pcObjShape);
Base::Vector3d Vector(0,0,1);
if (pcObjDir)
Vector = *static_cast<Base::VectorPy*>(pcObjDir)->getVectorPtr();
ProjectionAlgos Alg(pShape->getTopoShapePtr()->getShape(),Vector);
Py::List list;
list.append(Py::Object(new TopoShapePy(new TopoShape(Alg.V)) , true));
list.append(Py::Object(new TopoShapePy(new TopoShape(Alg.V1)), true));
list.append(Py::Object(new TopoShapePy(new TopoShape(Alg.VN)), true));
list.append(Py::Object(new TopoShapePy(new TopoShape(Alg.VO)), true));
list.append(Py::Object(new TopoShapePy(new TopoShape(Alg.VI)), true));
list.append(Py::Object(new TopoShapePy(new TopoShape(Alg.H)) , true));
list.append(Py::Object(new TopoShapePy(new TopoShape(Alg.H1)), true));
list.append(Py::Object(new TopoShapePy(new TopoShape(Alg.HN)), true));
list.append(Py::Object(new TopoShapePy(new TopoShape(Alg.HO)), true));
list.append(Py::Object(new TopoShapePy(new TopoShape(Alg.HI)), true));
return list;
}
示例7: projectToDXF
Py::Object projectToDXF(const Py::Tuple& args)
{
PyObject *pcObjShape;
PyObject *pcObjDir=0;
const char *type=0;
float scale=1.0f;
float tol=0.1f;
if (!PyArg_ParseTuple(args.ptr(), "O!|O!sff",
&(TopoShapePy::Type), &pcObjShape,
&(Base::VectorPy::Type), &pcObjDir, &type, &scale, &tol))
throw Py::Exception();
TopoShapePy* pShape = static_cast<TopoShapePy*>(pcObjShape);
Base::Vector3d Vector(0,0,1);
if (pcObjDir)
Vector = static_cast<Base::VectorPy*>(pcObjDir)->value();
ProjectionAlgos Alg(pShape->getTopoShapePtr()->getShape(),Vector);
bool hidden = false;
if (type && std::string(type) == "ShowHiddenLines")
hidden = true;
Py::String result(Alg.getDXF(hidden?ProjectionAlgos::WithHidden:ProjectionAlgos::Plain, scale, tol));
return result;
}
示例8: wireFromSegment
Py::Object wireFromSegment(const Py::Tuple& args)
{
PyObject *o, *m;
if (!PyArg_ParseTuple(args.ptr(), "O!O!", &(Mesh::MeshPy::Type), &m,&PyList_Type,&o))
throw Py::Exception();
Py::List list(o);
Mesh::MeshObject* mesh = static_cast<Mesh::MeshPy*>(m)->getMeshObjectPtr();
std::vector<unsigned long> segm;
segm.reserve(list.size());
for (unsigned int i=0; i<list.size(); i++) {
segm.push_back((int)Py::Int(list[i]));
}
std::list<std::vector<Base::Vector3f> > bounds;
MeshCore::MeshAlgorithm algo(mesh->getKernel());
algo.GetFacetBorders(segm, bounds);
Py::List wires;
std::list<std::vector<Base::Vector3f> >::iterator bt;
for (bt = bounds.begin(); bt != bounds.end(); ++bt) {
BRepBuilderAPI_MakePolygon mkPoly;
for (std::vector<Base::Vector3f>::reverse_iterator it = bt->rbegin(); it != bt->rend(); ++it) {
mkPoly.Add(gp_Pnt(it->x,it->y,it->z));
}
if (mkPoly.IsDone()) {
PyObject* wire = new Part::TopoShapeWirePy(new Part::TopoShape(mkPoly.Wire()));
wires.append(Py::Object(wire, true));
}
}
return wires;
}
示例9: insert
Py::Object insert(const Py::Tuple& args)
{
char* Name;
const char* DocName = 0;
if (!PyArg_ParseTuple(args.ptr(), "et|s","utf-8",&Name,&DocName))
throw Py::Exception();
std::string EncodedName = std::string(Name);
PyMem_Free(Name);
App::Document *pcDoc = 0;
if (DocName)
pcDoc = App::GetApplication().getDocument(DocName);
else
pcDoc = App::GetApplication().getActiveDocument();
if (!pcDoc) {
pcDoc = App::GetApplication().newDocument(DocName);
}
std::auto_ptr<FemMesh> mesh(new FemMesh);
mesh->read(EncodedName.c_str());
Base::FileInfo file(EncodedName.c_str());
FemMeshObject *pcFeature = static_cast<FemMeshObject *>
(pcDoc->addObject("Fem::FemMeshObject", file.fileNamePure().c_str()));
pcFeature->Label.setValue(file.fileNamePure().c_str());
pcFeature->FemMesh.setValuePtr(mesh.get());
(void)mesh.release();
pcFeature->purgeTouched();
return Py::None();
}
示例10: write
Py::Object write(const Py::Tuple& args)
{
char* Name;
PyObject* pObj;
if (!PyArg_ParseTuple(args.ptr(), "Oet",&pObj,"utf-8",&Name))
throw Py::Exception();
std::string EncodedName = std::string(Name);
PyMem_Free(Name);
Base::FileInfo file(EncodedName.c_str());
if (PyObject_TypeCheck(pObj, &(App::DocumentObjectPy::Type))) {
App::DocumentObject* obj = static_cast<App::DocumentObjectPy*>(pObj)->getDocumentObjectPtr();
if (obj->getTypeId().isDerivedFrom(Base::Type::fromName("Path::Feature"))) {
const Toolpath& path = static_cast<Path::Feature*>(obj)->Path.getValue();
std::string gcode = path.toGCode();
std::ofstream ofile(EncodedName.c_str());
ofile << gcode;
ofile.close();
}
else {
throw Py::RuntimeError("The given file is not a path");
}
}
return Py::None();
}
示例11: show
Py::Object show(const Py::Tuple& args)
{
PyObject *pcObj;
if (!PyArg_ParseTuple(args.ptr(), "O!", &(PathPy::Type), &pcObj))
throw Py::Exception();
try {
App::Document *pcDoc = App::GetApplication().getActiveDocument();
if (!pcDoc)
pcDoc = App::GetApplication().newDocument();
PathPy* pPath = static_cast<PathPy*>(pcObj);
Path::Feature *pcFeature = (Path::Feature *)pcDoc->addObject("Path::Feature", "Path");
Path::Toolpath* pa = pPath->getToolpathPtr();
if (!pa) {
throw Py::Exception(PyExc_ReferenceError, "object doesn't reference a valid path");
}
// copy the data
pcFeature->Path.setValue(*pa);
}
catch (const Base::Exception& e) {
throw Py::RuntimeError(e.what());
}
return Py::None();
}
示例12: excepthook
Py::Object PythonDebugExcept::excepthook(const Py::Tuple& args)
{
PyObject *exc, *value, *tb;
if (!PyArg_UnpackTuple(args.ptr(), "excepthook", 3, 3, &exc, &value, &tb))
throw Py::Exception();
PyErr_NormalizeException(&exc, &value, &tb);
PyErr_Display(exc, value, tb);
/*
if (eEXCEPTMODE_IGNORE != g_eExceptionMode)
{
assert(tb);
if (tb && (tb != Py_None))
{
//get the pointer to the frame held by the bottom traceback object - this
//should be where the exception occurred.
tracebackobject* pTb = (tracebackobject*)tb;
while (pTb->tb_next != NULL)
{
pTb = pTb->tb_next;
}
PyFrameObject* frame = (PyFrameObject*)PyObject_GetAttr((PyObject*)pTb, PyString_FromString("tb_frame"));
EnterBreakState(frame, (PyObject*)pTb);
}
}*/
return Py::None();
}
示例13: recompute
Py::Object DocumentProtectorPy::recompute(const Py::Tuple& args)
{
if (!PyArg_ParseTuple(args.ptr(), ""))
throw Py::Exception();
Base::PyGILStateRelease unlock;
_dp->recompute();
return Py::None();
}
示例14: hasGroup
Py::Object ParameterGrpPy::hasGroup(const Py::Tuple& args)
{
char *pstr;
if (!PyArg_ParseTuple(args.ptr(), "s", &pstr))
throw Py::Exception();
return Py::Boolean(_cParamGrp->HasGroup(pstr));
}
示例15: Exception
Py::Object StdMeshers_Arithmetic1DPy::getLength(const Py::Tuple& args)
{
int start;
if (!PyArg_ParseTuple(args.ptr(), "i",&start))
throw Py::Exception();
return Py::Float(hypothesis<StdMeshers_Arithmetic1D>()->
GetLength(start ? true : false));
}