当前位置: 首页>>代码示例>>C++>>正文


C++ List::append方法代码示例

本文整理汇总了C++中py::List::append方法的典型用法代码示例。如果您正苦于以下问题:C++ List::append方法的具体用法?C++ List::append怎么用?C++ List::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在py::List的用法示例。


在下文中一共展示了List::append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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;
    }
开发者ID:AjinkyaDahale,项目名称:FreeCAD,代码行数:31,代码来源:AppDrawingPy.cpp

示例2: getFacesByFace

PyObject* FemMeshPy::getFacesByFace(PyObject *args)
{
    PyObject *pW;
    if (!PyArg_ParseTuple(args, "O!", &(Part::TopoShapeFacePy::Type), &pW))
         return 0;

    try {
        const TopoDS_Shape& sh = static_cast<Part::TopoShapeFacePy*>(pW)->getTopoShapePtr()->getShape();
        if (sh.IsNull()) {
            PyErr_SetString(Base::BaseExceptionFreeCADError, "Face is empty");
            return 0;
        }

        const TopoDS_Face& fc = TopoDS::Face(sh);

        Py::List ret;
        std::list<int> resultSet = getFemMeshPtr()->getFacesByFace(fc);
        for (std::list<int>::const_iterator it = resultSet.begin();it!=resultSet.end();++it) {
#if PY_MAJOR_VERSION >= 3
            ret.append(Py::Long(*it));
#else
            ret.append(Py::Int(*it));
#endif
        }

        return Py::new_reference_to(ret);
    }
    catch (Standard_Failure& e) {
        PyErr_SetString(Base::BaseExceptionFreeCADError, e.GetMessageString());
        return 0;
    }
}
开发者ID:DevJohan,项目名称:FreeCAD_sf_master,代码行数:32,代码来源:FemMeshPyImp.cpp

示例3: getPoles

PyObject* BezierSurfacePy::getPoles(PyObject *args)
{
    if (!PyArg_ParseTuple(args, ""))
        return 0;
    try {
        Handle_Geom_BezierSurface surf = Handle_Geom_BezierSurface::DownCast
            (getGeometryPtr()->handle());
        TColgp_Array2OfPnt p(1,surf->NbUPoles(),1,surf->NbVPoles());
        surf->Poles(p);
        Py::List poles;
        for (Standard_Integer i=p.LowerRow(); i<=p.UpperRow(); i++) {
            Py::List row;
            for (Standard_Integer j=p.LowerCol(); j<=p.UpperCol(); j++) {
                const gp_Pnt& pole = p(i,j);
                row.append(Py::Object(new Base::VectorPy(
                    Base::Vector3d(pole.X(),pole.Y(),pole.Z()))));
            }
            poles.append(row);
        }
        return Py::new_reference_to(poles);
    }
    catch (Standard_Failure) {
        Handle_Standard_Failure e = Standard_Failure::Caught();
        PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
        return 0;
    }
}
开发者ID:PrLayton,项目名称:SeriousFractal,代码行数:27,代码来源:BezierSurfacePyImp.cpp

示例4: getTypeOfProperty

PyObject*  PropertyContainerPy::getTypeOfProperty(PyObject *args)
{
    Py::List ret;
    char *pstr;
    if (!PyArg_ParseTuple(args, "s", &pstr))     // convert args: Python->C
        return NULL;                             // NULL triggers exception

    Property* prop =  getPropertyContainerPtr()->getPropertyByName(pstr);
    if (!prop) {
        PyErr_Format(PyExc_AttributeError, "Property container has no property '%s'", pstr);
        return 0;
    }

    short Type =  prop->getType();
    if (Type & Prop_Hidden)
        ret.append(Py::String("Hidden"));
    if (Type & Prop_ReadOnly)
        ret.append(Py::String("ReadOnly"));
    if (Type & Prop_Output)
        ret.append(Py::String("Output"));
    if (Type & Prop_Transient)
        ret.append(Py::String("Transient"));

    return Py::new_reference_to(ret);
}
开发者ID:3DPrinterGuy,项目名称:FreeCAD,代码行数:25,代码来源:PropertyContainerPyImp.cpp

示例5: getWeights

PyObject* BezierSurfacePy::getWeights(PyObject *args)
{
    if (!PyArg_ParseTuple(args, ""))
        return 0;
    try {
        Handle_Geom_BezierSurface surf = Handle_Geom_BezierSurface::DownCast
            (getGeometryPtr()->handle());
        TColStd_Array2OfReal w(1,surf->NbUPoles(),1,surf->NbVPoles());
        surf->Weights(w);
        Py::List weights;
        for (Standard_Integer i=w.LowerRow(); i<=w.UpperRow(); i++) {
            Py::List row;
            for (Standard_Integer j=w.LowerCol(); j<=w.UpperCol(); j++) {
                row.append(Py::Float(w(i,j)));
            }
            weights.append(row);
        }
        return Py::new_reference_to(weights);
    }
    catch (Standard_Failure) {
        Handle_Standard_Failure e = Standard_Failure::Caught();
        PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
        return 0;
    }
}
开发者ID:PrLayton,项目名称:SeriousFractal,代码行数:25,代码来源:BezierSurfacePyImp.cpp

示例6: Alg

static PyObject * 
projectEx(PyObject *self, PyObject *args)
{
    PyObject *pcObjShape;
    PyObject *pcObjDir=0;

    if (!PyArg_ParseTuple(args, "O!|O!", &(TopoShapePy::Type), &pcObjShape,&(Base::VectorPy::Type), &pcObjDir))     // convert args: Python->C
        return NULL;                             // NULL triggers exception

    PY_TRY {
        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()->_Shape,Base::Vector3f((float)Vector.x,(float)Vector.y,(float)Vector.z));

        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 Py::new_reference_to(list);

    } PY_CATCH;
}
开发者ID:lainegates,项目名称:FreeCAD,代码行数:33,代码来源:AppDrawingPy.cpp

示例7: parameters

PyObject* TopoShapeEdgePy::parameters(PyObject *args)
{
    PyObject* pyface = 0;
    if (!PyArg_ParseTuple(args, "|O!", &(TopoShapeFacePy::Type), &pyface))
        return 0;

    const TopoDS_Edge& e = TopoDS::Edge(getTopoShapePtr()->getShape());
    TopLoc_Location aLoc;
    Handle(Poly_Polygon3D) aPoly = BRep_Tool::Polygon3D(e, aLoc);
    if (!aPoly.IsNull()) {
        Py::List list;
        if (!aPoly->HasParameters()) {
            return Py::new_reference_to(list);
        }

        const TColStd_Array1OfReal& aNodes = aPoly->Parameters();
        for (int i=aNodes.Lower(); i<=aNodes.Upper(); i++) {
            list.append(Py::Float(aNodes(i)));
        }

        return Py::new_reference_to(list);
    }
    else if (pyface) {
        // build up map edge->face
        const TopoDS_Shape& face = static_cast<TopoShapeFacePy*>(pyface)->getTopoShapePtr()->getShape();
        TopTools_IndexedDataMapOfShapeListOfShape edge2Face;
        TopExp::MapShapesAndAncestors(TopoDS::Face(face), TopAbs_EDGE, TopAbs_FACE, edge2Face);
        if (edge2Face.Contains(e)) {
            Handle(Poly_Triangulation) aPolyTria = BRep_Tool::Triangulation(TopoDS::Face(face),aLoc);
            if (!aPolyTria.IsNull()) {
                Handle(Poly_PolygonOnTriangulation) aPoly = BRep_Tool::PolygonOnTriangulation(e, aPolyTria, aLoc);
                if (!aPoly.IsNull()) {
                    if (!aPoly->HasParameters()) {
                        Py::List list;
                        return Py::new_reference_to(list);
                    }

                    Handle(TColStd_HArray1OfReal) aNodes = aPoly->Parameters();
                    if (!aNodes.IsNull()) {
                        Py::List list;
                        for (int i=aNodes->Lower(); i<=aNodes->Upper(); i++) {
                            list.append(Py::Float(aNodes->Value(i)));
                        }

                        return Py::new_reference_to(list);
                    }
                }
            }
        }
        else {
            PyErr_SetString(PyExc_ValueError, "Edge is not part of the face");
            return 0;
        }
    }

    PyErr_SetString(PyExc_RuntimeError, "Edge has no polygon");
    return 0;
}
开发者ID:zhangli1049,项目名称:FreeCAD,代码行数:58,代码来源:TopoShapeEdgePyImp.cpp

示例8: listAsPyObject

Py::Object CyPy_Element::listAsPyObject(const ListType& list, bool useNativePythonType)
{
    Py::List pyList;
    for (auto& entry : list) {
        if (useNativePythonType) {
            pyList.append(CyPy_Element::asPyObject(entry, useNativePythonType));
        } else {
            pyList.append(CyPy_Element::wrap(entry));
        }
    }
    return pyList;
}
开发者ID:worldforge,项目名称:cyphesis,代码行数:12,代码来源:CyPy_Element.cpp

示例9: intersectSS

PyObject* GeometrySurfacePy::intersectSS(PyObject *args)
{
    Handle_Geom_Surface surf1 = Handle_Geom_Surface::DownCast(getGeometryPtr()->handle());
    try {
        if (!surf1.IsNull()) {
            PyObject *p;
            double prec = Precision::Confusion();
            if (!PyArg_ParseTuple(args, "O!|d", &(Part::GeometrySurfacePy::Type), &p, &prec))
                return 0;
            Handle_Geom_Surface surf2 = Handle_Geom_Surface::DownCast(static_cast<GeometryPy*>(p)->getGeometryPtr()->handle());
            GeomAPI_IntSS intersector(surf1, surf2, prec);
            if (!intersector.IsDone()) {
                PyErr_SetString(PyExc_Exception, "Intersection of surfaces failed");
                return 0;
            }

            Py::List result;
            for (int i = 1; i <= intersector.NbLines(); i++) {
                Handle_Geom_Curve line = intersector.Line(i);
                result.append(makeGeometryCurvePy(line));
            }

            return Py::new_reference_to(result);
        }
    }
    catch (Standard_Failure) {
        Handle_Standard_Failure e = Standard_Failure::Caught();
        PyErr_SetString(PyExc_Exception, e->GetMessageString());
        return 0;
    }

    PyErr_SetString(PyExc_Exception, "intersectSS(): Geometry is not a surface");
    return 0;
}
开发者ID:hemanshupa,项目名称:FreeCAD_sf_master,代码行数:34,代码来源:GeometrySurfacePyImp.cpp

示例10: new_reference_to

PyObject *SelectionSingleton::sGetSelection(PyObject * /*self*/, PyObject *args)
{
    char *documentName=0;
    if (!PyArg_ParseTuple(args, "|s", &documentName))
        return NULL;

    std::vector<SelectionSingleton::SelObj> sel;
    sel = Selection().getSelection(documentName);

    try {
        std::set<App::DocumentObject*> noduplicates;
        std::vector<App::DocumentObject*> selectedObjects; // keep the order of selection
        Py::List list;
        for (std::vector<SelectionSingleton::SelObj>::iterator it = sel.begin(); it != sel.end(); ++it) {
            if (noduplicates.insert(it->pObject).second) {
                selectedObjects.push_back(it->pObject);
            }
        }
        for (std::vector<App::DocumentObject*>::iterator it = selectedObjects.begin(); it != selectedObjects.end(); ++it) {
            list.append(Py::asObject((*it)->getPyObject()));
        }
        return Py::new_reference_to(list);
    }
    catch (Py::Exception&) {
        return 0;
    }
}
开发者ID:WandererFan,项目名称:FreeCAD,代码行数:27,代码来源:Selection.cpp

示例11: 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;
    }
开发者ID:neuroidss,项目名称:FreeCAD,代码行数:34,代码来源:AppMeshPartPy.cpp

示例12: getccxVolumesByFace

PyObject* FemMeshPy::getccxVolumesByFace(PyObject *args)
{
    PyObject *pW;
    if (!PyArg_ParseTuple(args, "O!", &(Part::TopoShapeFacePy::Type), &pW))
         return 0;

    try {
        const TopoDS_Shape& sh = static_cast<Part::TopoShapeFacePy*>(pW)->getTopoShapePtr()->getShape();
        if (sh.IsNull()) {
            PyErr_SetString(Base::BaseExceptionFreeCADError, "Face is empty");
            return 0;
        }

        const TopoDS_Face& fc = TopoDS::Face(sh);

        Py::List ret;
        std::map<int, int> resultSet = getFemMeshPtr()->getccxVolumesByFace(fc);
        for (std::map<int, int>::const_iterator it = resultSet.begin();it!=resultSet.end();++it) {
            Py::Tuple vol_face(2);
            vol_face.setItem(0, Py::Long(it->first));
            vol_face.setItem(1, Py::Long(it->second));
            ret.append(vol_face);
        }

        return Py::new_reference_to(ret);
    }
    catch (Standard_Failure& e) {
        PyErr_SetString(Base::BaseExceptionFreeCADError, e.GetMessageString());
        return 0;
    }
}
开发者ID:DevJohan,项目名称:FreeCAD_sf_master,代码行数:31,代码来源:FemMeshPyImp.cpp

示例13: getNodesByVertex

PyObject* FemMeshPy::getNodesByVertex(PyObject *args)
{
    PyObject *pW;
    if (!PyArg_ParseTuple(args, "O!", &(Part::TopoShapeVertexPy::Type), &pW))
         return 0;

    try {
        const TopoDS_Shape& sh = static_cast<Part::TopoShapeVertexPy*>(pW)->getTopoShapePtr()->getShape();
        const TopoDS_Vertex& fc = TopoDS::Vertex(sh);
        if (sh.IsNull()) {
            PyErr_SetString(Base::BaseExceptionFreeCADError, "Vertex is empty");
            return 0;
        }
        Py::List ret;
        std::set<int> resultSet = getFemMeshPtr()->getNodesByVertex(fc);
        for (std::set<int>::const_iterator it = resultSet.begin();it!=resultSet.end();++it)
            ret.append(Py::Long(*it));

        return Py::new_reference_to(ret);

    }
    catch (Standard_Failure& e) {
        PyErr_SetString(Base::BaseExceptionFreeCADError, e.GetMessageString());
        return 0;
    }
}
开发者ID:DevJohan,项目名称:FreeCAD_sf_master,代码行数:26,代码来源:FemMeshPyImp.cpp

示例14: getCommands

Py::List PathPy::getCommands(void) const
{
    Py::List list;
    for(unsigned int i = 0; i < getToolpathPtr()->getSize(); i++)
        list.append(Py::Object(new Path::CommandPy(new Path::Command(getToolpathPtr()->getCommand(i)))));
    return list;
}
开发者ID:mumme74,项目名称:FreeCAD,代码行数:7,代码来源:PathPyImp.cpp

示例15: p

PyObject* BSplineCurve2dPy::getPolesAndWeights(PyObject * args)
{
    if (!PyArg_ParseTuple(args, ""))
        return 0;
    try {
        Handle_Geom2d_BSplineCurve curve = Handle_Geom2d_BSplineCurve::DownCast
            (getGeometry2dPtr()->handle());
        TColgp_Array1OfPnt2d p(1,curve->NbPoles());
        curve->Poles(p);
        TColStd_Array1OfReal w(1,curve->NbPoles());
        curve->Weights(w);

        Py::List poles;
        for (Standard_Integer i=p.Lower(); i<=p.Upper(); i++) {
            gp_Pnt2d pnt = p(i);
            double weight = w(i);
            Py::Tuple t(3);
            t.setItem(0, Py::Float(pnt.X()));
            t.setItem(1, Py::Float(pnt.Y()));
            t.setItem(2, Py::Float(weight));
            poles.append(t);
        }
        return Py::new_reference_to(poles);
    }
    catch (Standard_Failure) {
        Handle_Standard_Failure e = Standard_Failure::Caught();
        PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
        return 0;
    }
}
开发者ID:abdullahtahiriyo,项目名称:FreeCAD_sf_master,代码行数:30,代码来源:BSplineCurve2dPyImp.cpp


注:本文中的py::List::append方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。