Note on the MS VC 2005, I&#39;ve already come across and resolved some of problems in my copy.&nbsp; <br><br>See below for notes<br><br><br><div class="gmail_quote">2008/11/11 Sylvain Bougerel <span dir="ltr">&lt;<a href="mailto:sylvain.bougerel.devel@gmail.com">sylvain.bougerel.devel@gmail.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">On Tue, Nov 11, 2008 at 2:19 AM, Sam Hayne &lt;<a href="mailto:Sam.Hayne@gmx.de">Sam.Hayne@gmx.de</a>&gt; wrote:<br>

&gt; Hello! :)<br>
<div class="Ih2E3d">&gt;<br>
&gt;<br>
&gt; As the posting is a bit longer, a short summary:<br>
&gt;<br>
&gt;<br>
&gt; =====================================<br>
&gt; 1) compiler errors in VC2005 + solution<br>
</div><div class="Ih2E3d">&gt; =====================================<br>
&gt;<br>
&gt; allocator.hpp:<br>
&gt;<br>
&gt; typedef confusion<br>
&gt;<br>
&gt; error: kdtree++/kdtree.hpp(95) : error C2059: syntax error : &#39;&lt;&#39;<br>
&gt;<br>
&gt; solved by:<br>
&gt; rename all _Node to e.g. _Node_Ab in this file starting from line 21:<br>
&gt;<br>
&gt; old: typedef typename _Node&lt;_Tp&gt; _Node;<br>
&gt; new: typedef typename _Node&lt;_Tp&gt; _Node_Ab;<br>
&gt;<br>
<br>
</div>Okay, that&#39;s not nice, although I think that VC++ does not respect the<br>
standard here, we should still make the library portable.<br>
<br>
Just one question? why did you put _Ab as a suffix? A particular reason?<br>
<div class="Ih2E3d"></div></blockquote><div><br>Its to do with multiple definitions of the same type, IIRC<br>&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d"><br>
&gt;<br>
&gt; node.hpp:<br>
&gt;<br>
&gt; confusion:<br>
&gt; reserved #defines (in windef.h) &quot;near&quot; and &quot;far&quot; used as variable names:<br>
&gt; =&gt; rename near and far to something like near_N and far_N, starting from<br>
&gt; line 337<br>
&gt;<br>
<br>
</div>Ah yeah, I remember dealing with something like that once. Hum, well,<br>
it should be changed too, I guess.<br>
<div class="Ih2E3d"></div></blockquote><div><br>i don&#39;t remember seeing this one<br>&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d"><br>
&gt;<br>
&gt;<br>
&gt; iterator.hpp:<br>
&gt;<br>
&gt; error: error C2248: &#39;KDTree::_Iterator&lt;_Val,_Ref,_Ptr&gt;::operator *&#39; : cannot<br>
&gt; access private member declared in class &#39;KDTree::_Iterator&lt;_Val,_Ref,_Ptr&gt;&#39;<br>
&gt;<br>
&gt; solved by:<br>
&gt;<br>
&gt; add &quot;public:&quot; in line 110:<br>
&gt;<br>
&gt; &nbsp;template &lt;typename _Val, typename _Ref, typename _Ptr&gt;<br>
&gt; &nbsp; &nbsp;class _Iterator : protected _Base_iterator<br>
&gt; &nbsp; &nbsp;{<br>
&gt; &nbsp; &nbsp; public: &nbsp; &nbsp;//added<br>
&gt; &nbsp; &nbsp; &nbsp; typedef _Val value_type;<br>
&gt; &nbsp; &nbsp; &nbsp; ...<br>
&gt;<br>
&gt;<br>
</div></blockquote><div><br>I don&#39;t remember seeing this one either, maybe i did<br><br>&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d"><br>
</div>Ok I dunno weather it was g++ error of VC2005 error. But this rings a big:<br>
&quot;DON&#39;T DO THIS&quot; bell in my mind.<br>
<div class="Ih2E3d"></div></blockquote><div class="Ih2E3d"><br>
&gt;<br>
&gt;<br>
&gt; error C2247: &#39;KDTree::_Base_iterator::_M_node&#39; not accessible because<br>
&gt; &#39;KDTree::_Iterator&lt;_Val,_Ref,_Ptr&gt;&#39; uses &#39;protected&#39; to inherit from<br>
&gt; &#39;KDTree::_Base_iterator&#39;<br>
&gt;<br>
&gt; solved by:<br>
&gt;<br>
&gt; line 108: change &quot;protected&quot; to public<br>
&gt; old: class _Iterator : protected _Base_iterator<br>
&gt; new: class _Iterator : public _Base_iterator<br>
&gt;<br>
&gt; (may be really bad though..)<br>
&gt;<br>
<br>
</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Same as above, ;-)<br>
<div class="Ih2E3d"><br>
&gt;<br>
&gt;<br>
&gt; kdtree.hpp:<br>
&gt;<br>
&gt; comment away &quot;__throw_exception_again;&quot; in line 1175 =&gt; unknown identifier<br>
&gt;<br>
<br>
</div>Ohla, okay this is not nice: I think we should not use it cause it&#39;s<br>
pure libstdc++ stuff. It should be equivalent in most case to a<br>
simple:<br>
 &nbsp; &nbsp; throw;<br>
I&#39;m gonna check why they use this in the library and not the above.<br>
<div class="Ih2E3d"></div></blockquote><div><br><br>i&#39;ve actually made a patch for this, using a class constructor+destructor to do the cleanups automatically... thats what the try/catch/rethrow was for<br><br>i think i posted some of it on the mailing list just recently, its not in the git repository yet<br>
&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d"><br>
&gt;<br>
&gt;<br>
&gt; error in test_kdtree.cpp:<br>
&gt;<br>
&gt; warning C4003: not enough actual parameters for macro &#39;max&#39;<br>
&gt; error C2589: &#39;(&#39; : illegal token on right side of &#39;::&#39;<br>
&gt; error C2059: syntax error : &#39;::&#39;<br>
&gt;<br>
&gt; caused by: *t.find_nearest(s,std::numeric_limits&lt;double&gt;::max()).first;<br>
&gt;<br>
&gt; Solved by: Undefine min/max previously defined in windows.h:<br>
&gt;<br>
&gt; #undef max;<br>
&gt; #undef min;<br>
&gt; triplet result =<br>
&gt; *t.find_nearest(s,std::numeric_limits&lt;double&gt;::max()).first;<br>
&gt;<br>
&gt;<br>
</div></blockquote><div><br>yeah i&#39;ve come across this a bunch of times, windows.h #defines min and max in some situations.&nbsp; this is a common problem not just for kdtree<br><br>one solution is to #include kdtree before windows.h, which may not be possible for your application.<br>
<br>&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d"><br>
</div>Urg, this is really ugly... can you tell us why you actually had<br>
&quot;windows.h&quot; included here? Did you added it for some reason, or does<br>
it get included by another file?<br>
<br>
test_kdtree.cpp should be plain standard... like it should not require<br>
platform specific headers...<br>
<div class="Ih2E3d"><br>
&gt;<br>
&gt;<br>
&gt; change in triplet definition:<br>
&gt;<br>
&gt; struct triplet {<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp;typedef int value_type;<br>
&gt;<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp;inline value_type operator[](size_t const N) const { return d[N]; }<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp;inline bool operator==(triplet const&amp; other) {<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return this-&gt;d[0] == other.d[0] &amp;&amp; this-&gt;d[1] == other.d[1]<br>
&gt; &amp;&amp; this-&gt;d[2] == other.d[2];<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp;}<br>
&gt;<br>
&gt;<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp;value_type d[3];<br>
&gt; };<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; ===========================<br>
&gt; 2) Nearest neighbor search<br>
&gt; ===========================<br>
&gt;<br>
&gt; One thing: As I was really unable to do a pointer comparison of the &quot;duplet&quot;<br>
&gt; struct I chose to compare coordinates.<br>
<br>
</div>Yeah, you won&#39;t actually get to do this in the nearest neighbor<br>
search, because, well, it compares by coordinates... I know it my<br>
sound patronizing here, but I don&#39;t know how to put it otherwise :)<br>
<div><div></div><div class="Wj3C7c"></div></div></blockquote><div><br>i can add to this, that is why there is a find_exact(), so that you can find *that* node, not just another node that has the same coordinates.<br><br>
<br>i&#39;ll stop here since the main thing i wanted to expand on was the VS 2005 stuff.<br></div></div><br>