Example #1
0
	NearestNeighbourSearch(const object pycloud, const SearchType searchType = NNSNabo::KDTREE_LINEAR_HEAP, const Index dim = maxI, const dict params = dict())
	{
		// build cloud
		eigenFromBoostPython(cloud, pycloud, "cloud");
		
		// build params
		Nabo::Parameters _params;
		object it = params.iteritems();
		for(int i = 0; i < len(params); ++i)
		{
			const tuple item(it.attr("next")());
			const std::string key = extract<std::string>(item[0]);
			const object val(item[1]);
			const std::string valType(val.ptr()->ob_type->tp_name);
			if (valType == "int")
			{
				const int iVal = extract<int>(val);
				if (iVal >= 0)
					_params[key] = (unsigned)iVal;
				else
					_params[key] = iVal;
			}
		}
		
		// create search
		nns = NNSNabo ::create(cloud, dim, searchType, 0, _params);
	}
Example #2
0
    inline std::map<T1, T2> dict_to_map(const dict& d) {
        std::map<T1, T2> result;

        stl_input_iterator<tuple> begin(d.iteritems()), end;
        std::transform(begin, end, map_inserter(result),
            boost::bind(tuple_to_pair<T1, T2>(), _1));
    
        return result;
    }