jtsiomb / kdtree

A simple C library for working with KD-Trees
http://nuclear.mutantstargoat.com/sw/kdtree/
Other
395 stars 115 forks source link

bug in realse mode #5

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
the following test code acts differently in release and debug mode under
visual studio 2008.

int main(int argc, char **argv)
{
    int i, vcount = 10;
    kdtree *kd;

    kdres *set;
    unsigned int msec=0, start=0;

    if(argc > 1 && isdigit(argv[1][0])) {
        vcount = atoi(argv[1]);
    }
    printf("inserting %d random vectors... ", vcount);
    fflush(stdout);

    kd = kd_create(3);

            assert(kd_insert3(kd, 42.1f,44.1f,44.1f, 0)==0);
        assert(kd_insert3(kd, 43.2f,44.1f,44.1f, 0)==0);
        assert(kd_insert3(kd, 44.1f,43.1f,44.1f, 0)==0);
        assert(kd_insert3(kd, 44.1f,45.1f,44.1f, 0)==0);
        assert(kd_insert3(kd, 44.1f,42.1f,44.1f, 0)==0);
        assert(kd_insert3(kd, 44.1f,47.1f,44.1f, 0)==0);

            set = kd_nearest_range3(kd, 44.0f, 44.0f, 44.0f, 10.0f);

    printf("range query returned %d items in %.5f sec\n", kd_res_size(set),
(float)msec / 1000.0);
    kd_res_free(set);

    kd_free(kd);

    getchar();
    return 0;
} 

in the debug mode, there will be 6 nearby neighbors returned by the query,
which is correct. but in the release mode, 0 neighbor will return.

Original issue reported on code.google.com by billco...@gmail.com on 11 Aug 2009 at 4:04

GoogleCodeExporter commented 9 years ago
Hi billconan,

I've tested this issue and the point is that... "assert" is replaced by nothing 
in 
Release, so no points are added to the kd-tree.

So I think this bug can be closed.
Regards.

Original comment by joseluisblancoc@gmail.com on 21 Sep 2009 at 5:10

GoogleCodeExporter commented 9 years ago
Indeed it can :)

Original comment by jtsi...@gmail.com on 25 Nov 2011 at 12:09