2010-11-24 4 views
2

swigを使用してpythonコードで使用するc関数をラップする属性エラーが発生しました。私はちょうどうまく動作するチャップと一緒に他の機能がありますが、これはうまくいかないいくつかの理由があります:/_swig_getattr AttributeError

私はすべての粒子の凸包(チャップ)を決定するためにCGALを使用しようとしています。以下はchap関数とトレースバックです:

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 

答えて

2

関数は公開されていますか? Protectedとして宣言された関数を呼び出そうとしたときに同じエラーが発生しました。 The SWIG C++ manualは、プライベート関数とプロテクト関数はラップされないことに注意してください。