我想知道是否可以使用SWIG混合来自两个模块的对象,例如,模块a的函数是否可以返回模块B的对象?
我的用例如下:
类a.hpp:
class ClassA
{
public:
const OGRPolygon& get_geom() const;
void set_geom(OGRPolygon* geom);
protected:
OGRPolygon* _footprint;
};
class_a.cpp:
const OGRPolygon& ForCity::SPreC_cpp::ClassA::get_geom() const
{
return *(this->_footprint);
}
void ForCity::SPreC_cpp::ClassA::set_geom(OGRPolygon* geom)
{
this->_footprint = geom;
}
测试.i:
%module test
%include "class_A.hpp"
然后,在Python中,我希望能够执行以下操作:
A = test.ClassA()
G = ogr.Geometry(ogr.wkbLinearRing)
# filling the geometry...
A.set_geom(G) # set the geometry of A
A.get_geom().GetArea() # use the geometry of A as a usual OGR geometry
这是可能的吗?请怎么做?