首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >_swig_getattr AttributeError

_swig_getattr AttributeError
EN

Stack Overflow用户
提问于 2010-11-25 05:05:57
回答 1查看 1.6K关注 0票数 2

在python代码中使用swig包装c函数时,我遇到了一个属性错误。除了chap之外,我还有其他函数可以很好地工作,但是有一些奇怪的原因这个函数不能工作:/

我正在尝试使用CGAL来确定所有粒子的凸包(chap)。以下是chap函数和回溯:

代码语言:javascript
复制
std::vector<Vec2d> World::chap() const
{
    std::vector<Point_2> ch;
    std::vector<Point_2> points;
    std::vector<Vec2d> result;
    for(size_t i = 0, sz = particles.size(); i < sz; ++i)
    {
        points.push_back(Point_2(particles[i]->position.x, particles[i]->position.y));
    }
    CGAL::convex_hull_2(points.begin(), points.end(), std::back_inserter(ch));
    for(size_t i = 0, sz = ch.size(); i < sz; ++i)
    {
        result.push_back(Vec2d(ch[i].x(), ch[i].y()));
    }
    return result;
}

Traceback (most recent call last):
  File "keiro.py", line 64, in <module>
    if scenario.run():
  File "/Users/marcstrauss/Desktop/keiro/scenario.py", line 56, in run
    dt = self.world.advance()
  File "/Users/marcstrauss/Desktop/keiro/world.py", line 87, in advance
    view.add_ch(self.chap())
  File "/Users/marcstrauss/Desktop/keiro/fast/physics.py", line 312, in <lambda>
    __getattr__ = lambda self, name: _swig_getattr(self, World, name)
  File "/Users/marcstrauss/Desktop/keiro/fast/physics.py", line 34, in _swig_getattr
    raise AttributeError,name
AttributeError: chap
EN

回答 1

Stack Overflow用户

发布于 2012-01-19 23:25:26

该函数是公共的吗?当我试图调用一个声明为受保护的函数时,我得到了同样的错误。The SWIG C++ manual指出,私有和受保护的函数将不会被包装

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4271549

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档