Hello,<br><br>I am trying to use boost.python in order to bind a library called CGAL (and also to test if it's diffcult to bind such a library ;-). <a href="http://www.cgal.org/">http://www.cgal.org/</a><br>This library provide a class CGAL::Delaunay_Triangulation_2 which represent a Delaunay triangulation in two dimensions. 
<br><br>I want to build a delaunay triangultion using the &quot;push_back&quot; method (which add a Point to the mesh).<br>Then, I want to iter over the vertexes, the faces and the edges of the mesh using a Python iterator which use the following methods :
<br>&nbsp;- Finite_vertices_iterator&nbsp;&nbsp;&nbsp;&nbsp;t.finite_vertices_begin ()&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;- Finite_vertices_iterator&nbsp;&nbsp;&nbsp;&nbsp;t.finite_vertices_end ()&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br><br><br>I added the following line in my C++ boost code :<br>
<br><span style="font-weight: bold;">&nbsp;&nbsp; class_&lt;Delaunay&gt;(&quot;Delaunay&quot;)</span><br style="font-weight: bold;"><span style="font-weight: bold;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //...</span><br style="font-weight: bold;"><span style="font-weight: bold;">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .def(&quot;finite_vertices&quot;, range(&amp;Delaunay::finite_vertices_begin, &amp;Delaunay::finite_vertices_end))</span><br style="font-weight: bold;"><br><br>And the following code in my unit tests : <br><br><span style="font-weight: bold;">
class TestSequenceFunctions(unittest.TestCase):</span><br style="font-weight: bold;"><span style="font-weight: bold;">&nbsp;&nbsp; def init_delaunay(self):</span><br style="font-weight: bold;"><span style="font-weight: bold;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;d = 
pygale.Delaunay()</span><br style="font-weight: bold;"><span style="font-weight: bold;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for x, y in self.seq:</span><br style="font-weight: bold;"><span style="font-weight: bold;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;d.push_back(pygale.Point
(x, y))</span><br style="font-weight: bold;"><span style="font-weight: bold;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return d</span><br style="font-weight: bold;"><br style="font-weight: bold;"><span style="font-weight: bold;">&nbsp;&nbsp;&nbsp; def test_delaunay_2(self):
</span><br style="font-weight: bold;"><span style="font-weight: bold;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;d = self.init_delaunay()</span><br style="font-weight: bold;"><span style="font-weight: bold;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;it = d.finite_vertices()</span><br style="font-weight: bold;">
<br><br>But when I call the method &quot;finite_vertices&quot;, I get the following error : <br><br><span style="font-weight: bold;">Traceback (most recent call last):</span><br style="font-weight: bold;"><span style="font-weight: bold;">
&nbsp;&nbsp; File &quot;testPygale.py&quot;, line 40, in test_delaunay_2</span><br style="font-weight: bold;"><span style="font-weight: bold;">&nbsp;&nbsp;&nbsp;&nbsp; it = d.finite_vertices()</span><br style="font-weight: bold;"><span style="font-weight: bold;">
 ArgumentError: Python argument types in</span><br style="font-weight: bold;"><span style="font-weight: bold;">&nbsp;&nbsp;&nbsp;&nbsp; Delaunay.finite_vertices(Delaunay)</span><br style="font-weight: bold;"><span style="font-weight: bold;">
 did not match C++ signature:</span><br style="font-weight: bold;"><span style="font-weight: bold;">&nbsp;&nbsp;&nbsp;&nbsp; finite_vertices(boost::python::back_reference&lt;CGAL::Triangulation_2&lt;CGAL::Cartesian&lt;double&gt;, CGAL::Tds2&lt;CGAL::Tvb&lt;CGAL::Cartesian&lt;double&gt;, CGAL::Tdsvb&lt;void&gt; &gt;, CGAL::Tdsfb&lt;void&gt; &gt; &gt;&amp;&gt;)
</span><br style="font-weight: bold;"> <br><br>If you can help me to solve this error, please... <br><br>Thanks in advance.<br><br><br>Cyril BAZIN<br><br><br>Annexes: <br>The classes to bind<br>The C++ code for boost<br>The python unittests
<br>The execution trace <br><br><br>--------------------------------------------------------- The classes to bind ---------------------------------------------<br>#include &lt;CGAL/Cartesian.h&gt;<br>#include &lt;CGAL/squared_distance_2.h&gt;
<br>#include &lt;CGAL/Delaunay_triangulation_2.h&gt;<br>#include &lt;CGAL/Triangulation_2.h&gt;<br>#include &lt;CGAL/Triangulation_face_base_2.h&gt;<br>#include &lt;CGAL/Triangulation_euclidean_traits_2.h&gt;<br><br><br>#include &lt;CGAL/Delaunay_triangulation_2.h&gt;
<br><br>#include &lt;iostream&gt;<br>#include &lt;sstream&gt;<br><br>typedef CGAL::Cartesian&lt;double&gt;&nbsp;&nbsp;&nbsp; Gt;<br>typedef Gt::FT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; F_T;<br>typedef Gt::RT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; R_T;<br>typedef Gt::Point_2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Point;
<br>typedef Gt::Segment_2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Segment;<br>typedef Gt::Line_2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Line;<br>typedef Gt::Triangle_2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Triangle;<br>///typedef Gt::Bbox_2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Bbox;<br>typedef CGAL::Delaunay_triangulation_2&lt;Gt&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Delaunay;
<br>typedef Delaunay::Finite_vertices_iterator&nbsp;&nbsp; Finite_vertices_iterator;<br>typedef Delaunay::Vertex_handle&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Vertex_handle;<br>typedef Delaunay::Vertex&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Vertex;<br><br>-----------------------------------------------------------------------------------------------------------------------------
<br><br><br>---------------------------------------------------------- C++ code for boost --------------------------------------------<br>#include &lt;boost/python.hpp&gt;<br>#include &quot;pygale2.cpp&quot;<br>using namespace boost::python;
<br><br>BOOST_PYTHON_MODULE(pygale2)<br>{<br>&nbsp;&nbsp; //......<br><br>&nbsp;&nbsp; class_&lt;Vertex&gt;(&quot;Vertex&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;;<br><br>&nbsp;&nbsp; class_&lt;Vertex_handle&gt;(&quot;Vertex_handle&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;;<br><br>&nbsp;&nbsp; class_&lt;Finite_vertices_iterator&gt;(&quot;Finite_vertices_iterator&quot;)
<br>&nbsp;&nbsp;&nbsp;&nbsp;;<br><br>&nbsp;&nbsp; class_&lt;Delaunay&gt;(&quot;Delaunay&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.def(init&lt;&gt;())<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.def(&quot;number_of_vertices&quot;, &amp;Delaunay::number_of_vertices )<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.def(&quot;number_of_faces&quot;, &amp;Delaunay::number_of_faces )
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.def(&quot;push_back&quot;, &amp;Delaunay::push_back )<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.def(&quot;finite_vertices&quot;, range(&amp;Delaunay::finite_vertices_begin, &amp;Delaunay::finite_vertices_end))<br>&nbsp;&nbsp;&nbsp;&nbsp;;<br>&nbsp;&nbsp; //.....<br>}<br>
------------------------------------------------------------------------------------------------------------------------------------<br><br><br>----------------------------------------------------The python unit tests ----------------------------------------------------
<br>import pygale2 as pygale<br>import unittest<br><br>class TestSequenceFunctions(unittest.TestCase):<br><br>&nbsp;&nbsp;&nbsp;&nbsp;def setUp(self):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.seq = [(5, 8), (9, 6), (5, 2), (12, 9), (0, 0), (2, 7)]<br><br>&nbsp;&nbsp;&nbsp;&nbsp;#...<br>
<br>&nbsp;&nbsp;&nbsp;&nbsp;def init_delaunay(self):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;d = pygale.Delaunay()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for x, y in self.seq:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;d.push_back(pygale.Point(x, y))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return d<br><br>&nbsp;&nbsp;&nbsp;&nbsp;def test_delaunay(self):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;d = self.init_delaunay
()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.assertEqual(d.number_of_vertices(), len(self.seq))<br><br>&nbsp;&nbsp;&nbsp;&nbsp;def test_delaunay_2(self):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;d = self.init_delaunay()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;it = d.finite_vertices()<br><br><br>if __name__ == '__main__':<br>
&nbsp;&nbsp;&nbsp;&nbsp;suite = unittest.makeSuite(TestSequenceFunctions)<br>&nbsp;&nbsp;&nbsp;&nbsp;unittest.TextTestRunner(verbosity=2).run(suite)<br>&nbsp;&nbsp;&nbsp;&nbsp;#unittest.main()<br>-----------------------------------------------------------------------------------------------------------------------------------------
<br><br>------------------------------------------- The execution trace --------------------------------------------------------------<br>$make all test<br>g++ -I/export/home/cbazin/python/Python-2.4/ -I/usr/include/python2.4 -I/usr/local/include/boost-1_33_1/boost/ -I/usr/local/include 
pygale2.boost.cpp -c -o pygale2.o<br>g++ pygale2.o -L/usr/local/lib/ -lboost_python -L/usr/lib/CGAL/ -lCGAL -o pygale2.so --shared<br>python testPygale.py<br>test_delaunay (__main__.TestSequenceFunctions) ... ok<br>test_delaunay_2 (__main__.TestSequenceFunctions) ... ERROR
<br>test_points (__main__.TestSequenceFunctions) ... ok<br>test_segments (__main__.TestSequenceFunctions) ... ok<br><br>======================================================================<br>ERROR: test_delaunay_2 (__main__.TestSequenceFunctions)
<br>----------------------------------------------------------------------<br>Traceback (most recent call last):<br>&nbsp;&nbsp;File &quot;testPygale.py&quot;, line 40, in test_delaunay_2<br>&nbsp;&nbsp;&nbsp;&nbsp;it = d.finite_vertices()<br>ArgumentError: Python argument types in
<br>&nbsp;&nbsp;&nbsp;&nbsp;Delaunay.finite_vertices(Delaunay)<br>did not match C++ signature:<br>&nbsp;&nbsp;&nbsp;&nbsp;finite_vertices(boost::python::back_reference&lt;CGAL::Triangulation_2&lt;CGAL::Cartesian&lt;double&gt;, CGAL::Tds2&lt;CGAL::Tvb&lt;CGAL::Cartesian&lt;double&gt;, CGAL::Tdsvb&lt;void&gt; &gt;, CGAL::Tdsfb&lt;void&gt; &gt; &gt;&amp;&gt;)
<br><br>----------------------------------------------------------------------<br>Ran 4 tests in 0.003s<br><br>FAILED (errors=1)<br>----------------------------------------------------------------------------------------------------------------------------------------
<br><br>