mirror of
https://github.com/jlblancoc/nanoflann.git
synced 2026-01-16 21:01:17 +01:00
- Added pkg-config file, support for installing, uninstalling, Debian packaging and unit testing
This commit is contained in:
@@ -30,11 +30,8 @@ STRING(REGEX REPLACE "0x.(.).*" "\\1" NANOFLANN_VERSION_MINOR "${NANOFLANN_VERSI
|
||||
STRING(REGEX REPLACE "0x..(.).*" "\\1" NANOFLANN_VERSION_PATCH "${NANOFLANN_VERSION_HEX}" )
|
||||
|
||||
MESSAGE(STATUS "nanoflann version: ${NANOFLANN_VERSION_MAJOR}.${NANOFLANN_VERSION_MINOR}.${NANOFLANN_VERSION_PATCH}")
|
||||
|
||||
# Generate the pkg-config file:
|
||||
CONFIGURE_FILE(
|
||||
"${nanoflann_SOURCE_DIR}/nanoflann.pc.in"
|
||||
"${nanoflann_BINARY_DIR}/nanoflann.pc" @ONLY IMMEDIATE )
|
||||
file(WRITE "${nanoflann_BINARY_DIR}/version" "${NANOFLANN_VERSION_MAJOR}.${NANOFLANN_VERSION_MINOR}.${NANOFLANN_VERSION_PATCH}")
|
||||
file(WRITE "${nanoflann_SOURCE_DIR}/version" "${NANOFLANN_VERSION_MAJOR}.${NANOFLANN_VERSION_MINOR}.${NANOFLANN_VERSION_PATCH}")
|
||||
|
||||
# Compiler options:
|
||||
IF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
@@ -69,43 +66,66 @@ SET(HAVE_GTEST 0)
|
||||
|
||||
IF( BUILD_TESTING)
|
||||
# Try using libgtest (Google testing library) from the system, if available
|
||||
IF(UNIX)
|
||||
FIND_FILE(GTEST_CONFIG_FILE gtest-config)
|
||||
IF(GTEST_CONFIG_FILE)
|
||||
MARK_AS_ADVANCED(GTEST_CONFIG_FILE)
|
||||
FIND_FILE(GTEST_HEADER_FILE gtest/gtest.h)
|
||||
IF(GTEST_HEADER_FILE)
|
||||
MARK_AS_ADVANCED(GTEST_HEADER_FILE)
|
||||
|
||||
SET(HAVE_GTEST 1)
|
||||
|
||||
# Get the config params:
|
||||
EXECUTE_PROCESS(COMMAND ${GTEST_CONFIG_FILE} --libs
|
||||
RESULT_VARIABLE CMAKE_GTEST_CONFIG_RES
|
||||
OUTPUT_VARIABLE CMAKE_GTEST_LIBS
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
IF(${CMAKE_GTEST_CONFIG_RES})
|
||||
MESSAGE("Error invoking GTEST config file:\n ${GTEST_CONFIG_FILE} --libs")
|
||||
ENDIF(${CMAKE_GTEST_CONFIG_RES})
|
||||
|
||||
EXECUTE_PROCESS(COMMAND ${GTEST_CONFIG_FILE} --cxxflags
|
||||
RESULT_VARIABLE CMAKE_GTEST_CONFIG_RES
|
||||
OUTPUT_VARIABLE CMAKE_GTEST_CFLAGS
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
IF(${CMAKE_GTEST_CONFIG_RES})
|
||||
MESSAGE("Error invoking GTEST config file:\n ${GTEST_CONFIG_FILE} --cxxflags")
|
||||
ENDIF(${CMAKE_GTEST_CONFIG_RES})
|
||||
|
||||
ELSE(GTEST_CONFIG_FILE)
|
||||
SET(HAVE_GTEST 0)
|
||||
ENDIF(GTEST_CONFIG_FILE)
|
||||
ENDIF(UNIX)
|
||||
SET(HAVE_GTEST 1)
|
||||
ENDIF(GTEST_HEADER_FILE)
|
||||
|
||||
IF(HAVE_GTEST)
|
||||
add_subdirectory(tests)
|
||||
ELSE(HAVE_GTEST)
|
||||
MESSAGE(STATUS "Warning: Not building unit test since gtest-config was not found")
|
||||
MESSAGE(STATUS "Warning: Not building unit test since gtest/gtest.h was not found")
|
||||
ENDIF(HAVE_GTEST)
|
||||
|
||||
ENDIF( BUILD_TESTING)
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# Install/uninstall targets
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
#--------------------------------------------------------------
|
||||
# If we are building the final step of the Debian package,
|
||||
# save each library files in the corresponding directories:
|
||||
#--------------------------------------------------------------
|
||||
IF(CMAKE_USE_DEB_POSTFIXS)
|
||||
# Values when building a Debian package ---------------
|
||||
MESSAGE(STATUS "** Using Debian post-fix for install directories **")
|
||||
SET(libnanoflann_dev_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/libnanoflann-dev/usr/")
|
||||
SET(nanoflann_pkgconfig_INSTALL_PREFIX "/usr") # Values when building a Debian package
|
||||
ELSE(CMAKE_USE_DEB_POSTFIXS)
|
||||
# Values under normal conditions -----------------------
|
||||
SET(libnanoflann_dev_INSTALL_PREFIX "")
|
||||
SET(nanoflann_pkgconfig_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") # Values under normal conditions
|
||||
ENDIF(CMAKE_USE_DEB_POSTFIXS)
|
||||
|
||||
# Generate the pkg-config file:
|
||||
CONFIGURE_FILE(
|
||||
"${nanoflann_SOURCE_DIR}/nanoflann.pc.in"
|
||||
"${nanoflann_BINARY_DIR}/nanoflann.pc" @ONLY IMMEDIATE )
|
||||
|
||||
|
||||
# Uninstall target, for "make uninstall"
|
||||
CONFIGURE_FILE(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
|
||||
@ONLY IMMEDIATE)
|
||||
|
||||
ADD_CUSTOM_TARGET(uninstall
|
||||
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
|
||||
|
||||
|
||||
INSTALL(
|
||||
FILES "${nanoflann_BINARY_DIR}/nanoflann.pc"
|
||||
DESTINATION ${libnanoflann_dev_INSTALL_PREFIX}lib${LIB_SUFFIX}/pkgconfig )
|
||||
|
||||
INSTALL(
|
||||
FILES "${nanoflann_SOURCE_DIR}/include/nanoflann.hpp"
|
||||
DESTINATION ${libnanoflann_dev_INSTALL_PREFIX}include/ )
|
||||
|
||||
IF(CMAKE_USE_DEB_POSTFIXS)
|
||||
INSTALL(
|
||||
FILES "${nanoflann_SOURCE_DIR}/copyright"
|
||||
DESTINATION ${libnanoflann_dev_INSTALL_PREFIX}share/doc/libnanoflann-dev/ )
|
||||
ENDIF(CMAKE_USE_DEB_POSTFIXS)
|
||||
|
||||
|
||||
1
README.txt
Normal file
1
README.txt
Normal file
@@ -0,0 +1 @@
|
||||
Documentation is available online: http://code.google.com/p/nanoflann/
|
||||
27
cmake_uninstall.cmake.in
Normal file
27
cmake_uninstall.cmake.in
Normal file
@@ -0,0 +1,27 @@
|
||||
# -----------------------------------------------
|
||||
# File that provides "make uninstall" target
|
||||
# We use the file 'install_manifest.txt'
|
||||
# -----------------------------------------------
|
||||
IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
||||
MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
|
||||
ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
||||
|
||||
FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
|
||||
STRING(REGEX REPLACE "\n" ";" files "${files}")
|
||||
FOREACH(file ${files})
|
||||
MESSAGE(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
|
||||
IF(EXISTS "$ENV{DESTDIR}${file}")
|
||||
EXEC_PROGRAM(
|
||||
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
|
||||
OUTPUT_VARIABLE rm_out
|
||||
RETURN_VALUE rm_retval
|
||||
)
|
||||
IF(NOT "${rm_retval}" STREQUAL 0)
|
||||
MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
|
||||
ENDIF(NOT "${rm_retval}" STREQUAL 0)
|
||||
ELSE(EXISTS "$ENV{DESTDIR}${file}")
|
||||
MESSAGE(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
|
||||
ENDIF(EXISTS "$ENV{DESTDIR}${file}")
|
||||
ENDFOREACH(file)
|
||||
|
||||
|
||||
87
configure
vendored
Executable file
87
configure
vendored
Executable file
@@ -0,0 +1,87 @@
|
||||
#!/bin/bash
|
||||
# A very simple configure script, just to act as a "bridge" between the
|
||||
# standard expected behavior and the cmake build system.
|
||||
|
||||
prefix=/usr/
|
||||
host=`uname -m`-`uname -o`
|
||||
build=`uname -m`-`uname -o`
|
||||
mandir='${prefix}/share/man'
|
||||
infodir='${prefix}/share/info'
|
||||
|
||||
|
||||
usage()
|
||||
{
|
||||
cat << EOF
|
||||
usage: $0 options
|
||||
|
||||
This script configures the cmake build system, only for compatibility
|
||||
with Debian packages tools. To compile manually, please use the CMake system.
|
||||
|
||||
Please see README or the help online
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
# Based on example in: /usr/share/doc/util-linux/examples
|
||||
# Note that we use `"$@"' to let each command-line parameter expand to a
|
||||
# separate word. The quotes around `$@' are essential!
|
||||
# We need TEMP as the `eval set --' would nuke the return value of getopt.
|
||||
|
||||
TEMP=`getopt -o h --long help,prefix:,host:,build:,mandir:,infodir:,target:,program-prefix:,exec-prefix:,bindir:,sbindir:,sysconfdir:,datadir:,includedir:,libdir:,libexecdir:,localstatedir:,sharedstatedir: \
|
||||
-n 'configure' -- "$@"`
|
||||
|
||||
|
||||
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
|
||||
|
||||
# Note the quotes around `$TEMP': they are essential!
|
||||
eval set -- "$TEMP"
|
||||
|
||||
while true ; do
|
||||
case "$1" in
|
||||
-h) usage; exit 0; ;;
|
||||
--help) usage; exit 0; ;;
|
||||
--prefix) prefix="$2" ; shift 2 ;;
|
||||
--host) host="$2" ; shift 2 ;;
|
||||
--build) build="$2" ; shift 2 ;;
|
||||
--mandir) mandir="$2" ; shift 2 ;;
|
||||
--infodir) infodir="$2" ; shift 2 ;;
|
||||
--target) target="$2" ; shift 2 ;;
|
||||
# --program-prefix) program-prefix="$2" ; shift 2 ;;
|
||||
# --exec-prefix) exec-prefix="$2" ; shift 2 ;;
|
||||
--bindir) bindir="$2" ; shift 2 ;;
|
||||
--sbindir) sbindir="$2" ; shift 2 ;;
|
||||
--sysconfdir) sysconfdir="$2" ; shift 2 ;;
|
||||
--datadir) datadir="$2" ; shift 2 ;;
|
||||
--includedir) includedir="$2" ; shift 2 ;;
|
||||
--libdir) libdir="$2" ; shift 2 ;;
|
||||
--libexecdir) libexecdir="$2" ; shift 2 ;;
|
||||
--localstatedir) localstatedir="$2" ; shift 2 ;;
|
||||
--sharedstatedir) sharedstatedir="$2" ; shift 2 ;;
|
||||
--) shift ; break ;;
|
||||
*) shift 1; break ;; # Ignore arg
|
||||
esac
|
||||
done
|
||||
|
||||
echo "nanoflann configure" 1>&2
|
||||
|
||||
# Now, parse the remaining args, to create local variables (A=VALUE)
|
||||
for arg do
|
||||
echo 'configure: Using: '"\`$arg'" ; 1>&2
|
||||
declare "$arg"
|
||||
done
|
||||
|
||||
# Only go on for Debian packages:
|
||||
if [ "${NANOFLANN_IS_DEB_PACKAGE}" != "1" ] && [ "${NANOFLANN_IS_RPM_PACKAGE}" != "1" ] ; then usage; exit 1 ; fi
|
||||
|
||||
#echo "Running configure with:"
|
||||
#echo " prefix: ${prefix}"
|
||||
#echo " host: ${host}"
|
||||
#echo " build: ${build}"
|
||||
#echo " mandir: ${mandir}"
|
||||
#echo " infodir: ${infodir}"
|
||||
#echo " CFLAGS: ${CFLAGS}"
|
||||
#echo " LDFLAGS: ${LDFLAGS}"
|
||||
|
||||
cmake . -DCMAKE_INSTALL_PREFIX="${prefix}" -DCMAKE_HOST=${host} -DCMAKE_BUILD=${build} -DCMAKE_MANDIR="${MANDIR}" -DCMAKE_INFODIR="${INFODIR}" -DCMAKE_CONFIGURE_CFLAGS="${CFLAGS}" -DCMAKE_CONFIGURE_LDFLAGS="${LDFLAGS}" -DCMAKE_USE_DEB_POSTFIXS="${CMAKE_MRPT_USE_DEB_POSTFIXS}" -DCMAKE_IS_RPM_PACKAGE="${CMAKE_IS_RPM_PACKAGE}"
|
||||
|
||||
|
||||
38
examples/example_with_pkgconfig/Makefile
Normal file
38
examples/example_with_pkgconfig/Makefile
Normal file
@@ -0,0 +1,38 @@
|
||||
# Example Makefile script
|
||||
# Purpose: Demonstrate usage of pkg-config with the nanoflann library
|
||||
# By: Jose Luis Blanco, 2011
|
||||
#
|
||||
# ========================= *IMPORTANT* ================================
|
||||
# For this method to work nanoflann must be installed in your
|
||||
# system in a path accesible to pkg-config. To check if pkg-config
|
||||
# sees nanoflann config files, execute:
|
||||
# pkg-config --list-all | grep nanoflann
|
||||
# ======================================================================
|
||||
#
|
||||
|
||||
# Set up basic variables:
|
||||
CC = g++
|
||||
CFLAGS = -c -Wall -O2 -mtune=native
|
||||
LDFLAGS =
|
||||
|
||||
# List of sources:
|
||||
SOURCES = pointcloud_example.cpp
|
||||
OBJECTS = $(SOURCES:.cpp=.o)
|
||||
|
||||
# Name of executable target:
|
||||
EXECUTABLE = pointcloud_example
|
||||
|
||||
# nanoflann flags:
|
||||
CFLAGS += `pkg-config --cflags nanoflann`
|
||||
|
||||
all: $(SOURCES) $(EXECUTABLE)
|
||||
|
||||
$(EXECUTABLE): $(OBJECTS)
|
||||
$(CC) $(LDFLAGS) $(OBJECTS) -o $@
|
||||
|
||||
.cpp.o:
|
||||
$(CC) $(CFLAGS) $< -o $@
|
||||
|
||||
clean:
|
||||
rm $(OBJECTS) $(EXECUTABLE)
|
||||
|
||||
134
examples/example_with_pkgconfig/pointcloud_example.cpp
Normal file
134
examples/example_with_pkgconfig/pointcloud_example.cpp
Normal file
@@ -0,0 +1,134 @@
|
||||
/***********************************************************************
|
||||
* Software License Agreement (BSD License)
|
||||
*
|
||||
* Copyright 2011 Jose Luis Blanco (joseluisblancoc@gmail.com).
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*************************************************************************/
|
||||
|
||||
#include <nanoflann.hpp>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
using namespace nanoflann;
|
||||
|
||||
// This is an exampleof a custom data set class
|
||||
template <typename T>
|
||||
struct PointCloud
|
||||
{
|
||||
struct Point
|
||||
{
|
||||
T x,y,z;
|
||||
};
|
||||
|
||||
std::vector<Point> pts;
|
||||
|
||||
// Must return the number of data points
|
||||
inline size_t kdtree_get_point_count() const { return pts.size(); }
|
||||
|
||||
// Returns the distance between the vector "p1[0:size-1]" and the data point with index "idx_p2" stored in the class:
|
||||
inline float kdtree_distance(const float *p1, const size_t idx_p2,size_t size) const
|
||||
{
|
||||
float d0=p1[0]-pts[idx_p2].x;
|
||||
float d1=p1[1]-pts[idx_p2].y;
|
||||
float d2=p1[2]-pts[idx_p2].z;
|
||||
return d0*d0+d1*d1+d2*d2;
|
||||
}
|
||||
|
||||
// Returns the dim'th component of the idx'th point in the class:
|
||||
// Since this is inlined and the "dim" argument is typically an immediate value, the
|
||||
// "if/else's" are actually solved at compile time.
|
||||
inline float kdtree_get_pt(const size_t idx, int dim) const
|
||||
{
|
||||
if (dim==0) return pts[idx].x;
|
||||
else if (dim==1) return pts[idx].y;
|
||||
else return pts[idx].z;
|
||||
}
|
||||
|
||||
// Optional bounding-box computation: return false to default to a standard bbox computation loop.
|
||||
// Return true if the BBOX was already computed by the class and returned in "bb" so it can be avoided to redo it again.
|
||||
// Look at bb.size() to find out the expected dimensionality (e.g. 2 or 3 for point clouds)
|
||||
template <class BBOX>
|
||||
bool kdtree_get_bbox(BBOX &bb) const { return false; }
|
||||
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
void generateRandomPointCloud(PointCloud<T> &point, const size_t N, const T max_range = 10)
|
||||
{
|
||||
std::cout << "Generating "<< N << " point cloud...";
|
||||
point.pts.resize(N);
|
||||
for (size_t i=0;i<N;i++)
|
||||
{
|
||||
point.pts[i].x = max_range * (rand() % 1000) / T(1000);
|
||||
point.pts[i].y = max_range * (rand() % 1000) / T(1000);
|
||||
point.pts[i].z = max_range * (rand() % 1000) / T(1000);
|
||||
}
|
||||
|
||||
std::cout << "done\n";
|
||||
}
|
||||
|
||||
template <typename num_t>
|
||||
void kdtree_demo(const size_t N)
|
||||
{
|
||||
PointCloud<num_t> cloud;
|
||||
|
||||
// Generate points:
|
||||
generateRandomPointCloud(cloud, N);
|
||||
|
||||
num_t query_pt[3] = { 0.5, 0.5, 0.5};
|
||||
|
||||
|
||||
// construct a kd-tree index:
|
||||
typedef KDTreeSingleIndexAdaptor<
|
||||
L2_Simple_Adaptor<num_t, PointCloud<num_t> > ,
|
||||
PointCloud<num_t>,
|
||||
3 /* dim */
|
||||
> my_kd_tree_t;
|
||||
|
||||
my_kd_tree_t index(3 /*dim*/, cloud, KDTreeSingleIndexAdaptorParams(10 /* max leaf */) );
|
||||
index.buildIndex();
|
||||
|
||||
// do a knn search
|
||||
const size_t num_results = 1;
|
||||
int ret_index;
|
||||
num_t out_dist_sqr;
|
||||
nanoflann::KNNResultSet<num_t> resultSet(num_results);
|
||||
resultSet.init(&ret_index, &out_dist_sqr );
|
||||
index.findNeighbors(resultSet, &query_pt[0], nanoflann::SearchParams(10));
|
||||
//index.knnSearch(query, indices, dists, num_results, mrpt_flann::SearchParams(10));
|
||||
|
||||
std::cout << "knnSearch(nn="<<num_results<<"): \n";
|
||||
std::cout << "ret_index=" << ret_index << " out_dist_sqr=" << out_dist_sqr << endl;
|
||||
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
kdtree_demo<float>(1e5);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
prefix=@CMAKE_INSTALL_PREFIX@
|
||||
prefix=@nanoflann_pkgconfig_INSTALL_PREFIX@
|
||||
exec_prefix=${prefix}
|
||||
libdir=${exec_prefix}/lib@LIB_SUFFIX@
|
||||
includedir=${prefix}/include
|
||||
@@ -10,5 +10,5 @@ Requires:
|
||||
Version: @NANOFLANN_VERSION_MAJOR@.@NANOFLANN_VERSION_MINOR@.@NANOFLANN_VERSION_PATCH@
|
||||
Libs:
|
||||
Libs.private:
|
||||
Cflags:
|
||||
Cflags: -I${includedir}
|
||||
|
||||
|
||||
6
packaging/README.txt
Normal file
6
packaging/README.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
This directory contains the scripts I've been using to maintain Debian, Ubuntu and Fedora
|
||||
packages for MRPT. They should NOT appear in source tarballs (that's the rule according
|
||||
to Debian policies) but I'll keep them in SVN HEAD.
|
||||
|
||||
JL
|
||||
|
||||
6
packaging/debian/changelog
Normal file
6
packaging/debian/changelog
Normal file
@@ -0,0 +1,6 @@
|
||||
nanoflann (1.0.0-1) unstable; urgency=low
|
||||
|
||||
* Initial packaging
|
||||
|
||||
-- Jose Luis Blanco (University of Malaga) <joseluisblancoc@gmail.com> Tue, 30 Aug 2011 18:06:00 +0200
|
||||
|
||||
1
packaging/debian/compat
Normal file
1
packaging/debian/compat
Normal file
@@ -0,0 +1 @@
|
||||
5
|
||||
30
packaging/debian/control
Normal file
30
packaging/debian/control
Normal file
@@ -0,0 +1,30 @@
|
||||
Source: nanoflann
|
||||
Section: science
|
||||
Priority: optional
|
||||
Maintainer: Jose Luis Blanco (University of Malaga) <joseluisblancoc@gmail.com>
|
||||
Build-Depends: debhelper (>= 5),
|
||||
autotools-dev,
|
||||
cmake,
|
||||
perl,
|
||||
libgtest-dev,
|
||||
libeigen3-dev | perl
|
||||
Standards-Version: 3.9.2
|
||||
Homepage: http://code.google.com/p/nanoflann/
|
||||
|
||||
Package: libnanoflann-dev
|
||||
Section: libdevel
|
||||
Architecture: all
|
||||
Depends: ${misc:Depends}
|
||||
Description: C++ header-only fork of the FLANN library for KD-trees
|
||||
nanoflann is a C++ header-only library for building KD-Trees, mostly optimized
|
||||
for 2D or 3D point clouds. Queries for neighbors around any arbitrary location
|
||||
in space can then be solved quickly and efficiently using Approximate Nearest
|
||||
Neighbor (ANN) algorithms.
|
||||
.
|
||||
nanoflann does not require compiling or installing, just
|
||||
an #include <nanoflann.hpp> in your code.
|
||||
.
|
||||
This library is a fork (and a subset) of the `flann` library, by Marius Muja
|
||||
and David G. Lowe. Following the original license terms, nanoflann is
|
||||
distributed under the BSD license.
|
||||
|
||||
40
packaging/debian/copyright
Normal file
40
packaging/debian/copyright
Normal file
@@ -0,0 +1,40 @@
|
||||
This package was debianized by Jose Luis Blanco <joseluisblancoc@gmail.com> on
|
||||
Tue, 30 Aug 2011.
|
||||
|
||||
The package is available from http://code.google.com/p/nanoflann/
|
||||
|
||||
Upstream Authors:
|
||||
|
||||
Software License Agreement (BSD License)
|
||||
|
||||
Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved.
|
||||
Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved.
|
||||
Copyright 2011 Jose L. Blanco (joseluisblancoc@gmail.com). All rights reserved.
|
||||
|
||||
THE BSD LICENSE
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
The Debian packaging is Copyright 2010, Jose Luis Blanco <joseluisblancoc@gmail.com>
|
||||
and is licensed under the BSD.
|
||||
|
||||
3
packaging/debian/libnanoflann-dev.install
Normal file
3
packaging/debian/libnanoflann-dev.install
Normal file
@@ -0,0 +1,3 @@
|
||||
usr/include/*
|
||||
usr/lib/pkgconfig/*
|
||||
usr/share/pkgconfig/*
|
||||
89
packaging/debian/rules
Executable file
89
packaging/debian/rules
Executable file
@@ -0,0 +1,89 @@
|
||||
#!/usr/bin/make -f
|
||||
# -*- makefile -*-
|
||||
# Makefile for nanoflann Debian package.
|
||||
|
||||
# Uncomment this to turn on verbose mode.
|
||||
export DH_DEBUG=1
|
||||
export DH_VERBOSE=1
|
||||
|
||||
|
||||
# These are used for cross-compiling and for saving the configure script
|
||||
# from having to guess our platform (since we know it already)
|
||||
DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
|
||||
DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
|
||||
|
||||
config.status: configure
|
||||
dh_testdir
|
||||
# Add here commands to configure the package.
|
||||
./configure NANOFLANN_IS_DEB_PACKAGE=1 --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info CFLAGS="$(CFLAGS)" LDFLAGS="-Wl,-z,defs"
|
||||
|
||||
build: build-arch build-indep
|
||||
|
||||
build-arch: build-stamp
|
||||
build-indep: build-stamp
|
||||
|
||||
build-stamp: config.status
|
||||
dh_testdir
|
||||
|
||||
touch $@
|
||||
|
||||
distclean:
|
||||
# Nothing to do (do not remove this line!)
|
||||
|
||||
clean:
|
||||
dh_testdir
|
||||
dh_testroot
|
||||
rm -f build-stamp
|
||||
|
||||
# Add here commands to clean up after the build process.
|
||||
rm -f config.sub config.guess
|
||||
|
||||
dh_clean
|
||||
|
||||
install: build
|
||||
dh_testdir
|
||||
dh_testroot
|
||||
dh_clean -k
|
||||
dh_installdirs
|
||||
|
||||
# Add here commands to install the package into debian/...
|
||||
./configure NANOFLANN_IS_DEB_PACKAGE=1 --prefix=$(CURDIR)/debian/ CMAKE_MRPT_USE_DEB_POSTFIXS="1"
|
||||
|
||||
# Build all
|
||||
$(MAKE) VERBOSE=1
|
||||
# Run tests
|
||||
make test || echo "*** Ignoring failed tests! ***"
|
||||
|
||||
# Install
|
||||
$(MAKE) install
|
||||
|
||||
# Build architecture-independent files here.
|
||||
binary-indep: build install
|
||||
# We have nothing to do by default.
|
||||
|
||||
# Build architecture-dependent files here.
|
||||
binary-arch: build install
|
||||
dh_testdir
|
||||
dh_testroot
|
||||
dh_installchangelogs
|
||||
# dh_installdocs
|
||||
# dh_installmenu
|
||||
# dh_installmime -p mrpt-core
|
||||
# dh_installman -p mrpt-apps $(CURDIR)/man-pages/*.1*
|
||||
# Register .desktop files with a MIME type:
|
||||
# dh_desktop -p mrpt-apps
|
||||
dh_link
|
||||
# dh_strip --dbg-package=libmrpt-core-dbg
|
||||
dh_strip
|
||||
dh_compress
|
||||
dh_fixperms
|
||||
dh_makeshlibs -a
|
||||
dh_installdeb
|
||||
dh_shlibdeps
|
||||
dh_gencontrol
|
||||
dh_md5sums
|
||||
dh_builddeb
|
||||
|
||||
binary: binary-indep binary-arch
|
||||
.PHONY: build clean binary-indep binary-arch binary install
|
||||
|
||||
152
scripts/prepare_debian.sh
Executable file
152
scripts/prepare_debian.sh
Executable file
@@ -0,0 +1,152 @@
|
||||
#!/bin/bash
|
||||
# Copies sources from SVN tree and prepare a Debian package.
|
||||
# JLBC, 2008-2011
|
||||
|
||||
#set -o verbose # echo on
|
||||
set +o verbose # echo off
|
||||
|
||||
APPEND_SVN_NUM=0
|
||||
IS_FOR_UBUNTU=0
|
||||
APPEND_LINUX_DISTRO=""
|
||||
while getopts "sud:" OPTION
|
||||
do
|
||||
case $OPTION in
|
||||
s)
|
||||
APPEND_SVN_NUM=1
|
||||
;;
|
||||
u)
|
||||
IS_FOR_UBUNTU=1
|
||||
;;
|
||||
d)
|
||||
APPEND_LINUX_DISTRO=$OPTARG
|
||||
;;
|
||||
?)
|
||||
echo "Unknown command line argument!"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Checks
|
||||
# --------------------------------
|
||||
if [ -f version ];
|
||||
then
|
||||
NANOFLANN_VERSION_STR=`cat version`
|
||||
NANOFLANN_VERSION_MAJOR=${NANOFLANN_VERSION_STR:0:1}
|
||||
NANOFLANN_VERSION_MINOR=${NANOFLANN_VERSION_STR:2:1}
|
||||
NANOFLANN_VERSION_PATCH=${NANOFLANN_VERSION_STR:4:1}
|
||||
NANOFLANN_VER_MM="${NANOFLANN_VERSION_MAJOR}.${NANOFLANN_VERSION_MINOR}"
|
||||
NANOFLANN_VER_MMP="${NANOFLANN_VERSION_MAJOR}.${NANOFLANN_VERSION_MINOR}.${NANOFLANN_VERSION_PATCH}"
|
||||
echo "nanoflann version: ${NANOFLANN_VER_MMP}"
|
||||
else
|
||||
echo "ERROR: Run this script from the nanoflann root directory."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
NANOFLANNSRC=`pwd`
|
||||
NANOFLANN_DEB_DIR="$HOME/nanoflann_debian"
|
||||
NANOFLANN_EXTERN_DEBIAN_DIR="$NANOFLANNSRC/packaging/debian/"
|
||||
|
||||
if [ -f ${NANOFLANN_EXTERN_DEBIAN_DIR}/control ];
|
||||
then
|
||||
echo "Using debian dir: ${NANOFLANN_EXTERN_DEBIAN_DIR}"
|
||||
else
|
||||
echo "ERROR: Cannot find ${NANOFLANN_EXTERN_DEBIAN_DIR}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Prepare a directory for building the debian package:
|
||||
#
|
||||
rm -fR $NANOFLANN_DEB_DIR
|
||||
mkdir $NANOFLANN_DEB_DIR
|
||||
|
||||
# Are we in svn?
|
||||
NANOFLANN_SVN_VERSION=`svnversion -n`
|
||||
|
||||
if [ $NANOFLANN_SVN_VERSION = "exported" ];
|
||||
then
|
||||
echo "Copying sources to $NANOFLANN_DEB_DIR/nanoflann-${NANOFLANN_VERSION_STR}"
|
||||
cp -R . $NANOFLANN_DEB_DIR/nanoflann-${NANOFLANN_VERSION_STR}
|
||||
else
|
||||
# Strip the last "M", if any:
|
||||
if [ ${NANOFLANN_SVN_VERSION:(-1)} = "M" ];
|
||||
then
|
||||
NANOFLANN_SVN_VERSION=${NANOFLANN_SVN_VERSION:0:${#NANOFLANN_SVN_VERSION}-1}
|
||||
fi
|
||||
|
||||
if [ $APPEND_SVN_NUM == "1" ];
|
||||
then
|
||||
NANOFLANN_VERSION_STR="${NANOFLANN_VERSION_STR}svn${NANOFLANN_SVN_VERSION}${APPEND_LINUX_DISTRO}"
|
||||
else
|
||||
NANOFLANN_VERSION_STR="${NANOFLANN_VERSION_STR}${APPEND_LINUX_DISTRO}"
|
||||
fi
|
||||
|
||||
echo "Exporting to $NANOFLANN_DEB_DIR/nanoflann-${NANOFLANN_VERSION_STR}"
|
||||
svn export . $NANOFLANN_DEB_DIR/nanoflann-${NANOFLANN_VERSION_STR}
|
||||
fi
|
||||
|
||||
cd $NANOFLANN_DEB_DIR/nanoflann-${NANOFLANN_VERSION_STR}
|
||||
|
||||
# Deletions:
|
||||
rm -fR bin 2>/dev/null
|
||||
rm -fR packaging
|
||||
|
||||
# Orig tarball:
|
||||
cd ..
|
||||
echo "Creating orig tarball: nanoflann_${NANOFLANN_VERSION_STR}.orig.tar.gz"
|
||||
tar czf nanoflann_${NANOFLANN_VERSION_STR}.orig.tar.gz nanoflann-${NANOFLANN_VERSION_STR}
|
||||
|
||||
# Copy debian directory:
|
||||
mkdir nanoflann-${NANOFLANN_VERSION_STR}/debian
|
||||
cp -r ${NANOFLANN_EXTERN_DEBIAN_DIR}/* nanoflann-${NANOFLANN_VERSION_STR}/debian
|
||||
cp ${NANOFLANN_EXTERN_DEBIAN_DIR}/copyright nanoflann-${NANOFLANN_VERSION_STR}/copyright
|
||||
|
||||
# Strip my custom files...
|
||||
rm nanoflann-${NANOFLANN_VERSION_STR}/debian/*.new
|
||||
# debian/source file issues for old Ubuntu distros:
|
||||
if [ $IS_FOR_UBUNTU == "1" ];
|
||||
then
|
||||
rm -fr nanoflann-${NANOFLANN_VERSION_STR}/debian/source
|
||||
fi
|
||||
|
||||
|
||||
# Prepare install files:
|
||||
cd nanoflann-${NANOFLANN_VERSION_STR}
|
||||
|
||||
# Figure out the next Debian version number:
|
||||
echo "Detecting next Debian version number..."
|
||||
|
||||
CHANGELOG_UPSTREAM_VER=$( dpkg-parsechangelog | sed -n 's/Version:.*\([0-9]\.[0-9]*\.[0-9]*.*svn.*\)-.*/\1/p' )
|
||||
CHANGELOG_LAST_DEBIAN_VER=$( dpkg-parsechangelog | sed -n 's/Version:.*\([0-9]\.[0-9]*\.[0-9]*\).*-\([0-9]*\).*/\2/p' )
|
||||
|
||||
echo " -> PREVIOUS UPSTREAM: $CHANGELOG_UPSTREAM_VER -> New: ${NANOFLANN_VERSION_STR}"
|
||||
echo " -> PREVIOUS DEBIAN VERSION: $CHANGELOG_LAST_DEBIAN_VER"
|
||||
|
||||
# If we have the same upstream versions, increase the Debian version, otherwise create a new entry:
|
||||
if [ "$CHANGELOG_UPSTREAM_VER" = "$NANOFLANN_VERSION_STR" ];
|
||||
then
|
||||
NEW_DEBIAN_VER=$[$CHANGELOG_LAST_DEBIAN_VER + 1]
|
||||
echo "Changing to a new Debian version: ${NANOFLANN_VERSION_STR}-${NEW_DEBIAN_VER}"
|
||||
DEBCHANGE_CMD="--newversion ${NANOFLANN_VERSION_STR}-${NEW_DEBIAN_VER}"
|
||||
else
|
||||
DEBCHANGE_CMD="--newversion ${NANOFLANN_VERSION_STR}-1"
|
||||
fi
|
||||
|
||||
echo "Adding a new entry to debian/changelog..."
|
||||
echo DEBEMAIL="Jose Luis Blanco (University of Malaga) <joseluisblancoc@gmail.com>" debchange $DEBCHANGE_CMD --distribution unstable --force-distribution New version of upstream sources.
|
||||
|
||||
DEBEMAIL="Jose Luis Blanco (University of Malaga) <joseluisblancoc@gmail.com>" debchange $DEBCHANGE_CMD -b --distribution unstable --force-distribution New version of upstream sources.
|
||||
|
||||
echo "Copying back the new changelog to a temporary file in: ${NANOFLANN_EXTERN_DEBIAN_DIR}changelog.new"
|
||||
cp debian/changelog ${NANOFLANN_EXTERN_DEBIAN_DIR}changelog.new
|
||||
|
||||
set +o verbose # echo off
|
||||
|
||||
echo "Now, you can build the source Deb package with 'debuild -S -sa'"
|
||||
|
||||
cd ..
|
||||
ls -lh
|
||||
|
||||
|
||||
exit 0
|
||||
|
||||
97
scripts/prepare_release.sh
Executable file
97
scripts/prepare_release.sh
Executable file
@@ -0,0 +1,97 @@
|
||||
#!/bin/bash
|
||||
# Copies sources from SVN tree and prepare a release package.
|
||||
# JLBC, 2008-2011
|
||||
|
||||
#set -o verbose # echo on
|
||||
set +o verbose # echo off
|
||||
|
||||
APPEND_SVN_NUM=0
|
||||
IS_FOR_UBUNTU=0
|
||||
APPEND_LINUX_DISTRO=""
|
||||
while getopts "sud:" OPTION
|
||||
do
|
||||
case $OPTION in
|
||||
s)
|
||||
APPEND_SVN_NUM=1
|
||||
;;
|
||||
u)
|
||||
IS_FOR_UBUNTU=1
|
||||
;;
|
||||
d)
|
||||
APPEND_LINUX_DISTRO=$OPTARG
|
||||
;;
|
||||
?)
|
||||
echo "Unknown command line argument!"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Checks
|
||||
# --------------------------------
|
||||
if [ -f version ];
|
||||
then
|
||||
NANOFLANN_VERSION_STR=`cat version`
|
||||
NANOFLANN_VERSION_MAJOR=${NANOFLANN_VERSION_STR:0:1}
|
||||
NANOFLANN_VERSION_MINOR=${NANOFLANN_VERSION_STR:2:1}
|
||||
NANOFLANN_VERSION_PATCH=${NANOFLANN_VERSION_STR:4:1}
|
||||
NANOFLANN_VER_MM="${NANOFLANN_VERSION_MAJOR}.${NANOFLANN_VERSION_MINOR}"
|
||||
NANOFLANN_VER_MMP="${NANOFLANN_VERSION_MAJOR}.${NANOFLANN_VERSION_MINOR}.${NANOFLANN_VERSION_PATCH}"
|
||||
echo "nanoflann version: ${NANOFLANN_VER_MMP}"
|
||||
else
|
||||
echo "ERROR: Run this script from the nanoflann root directory."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
NANOFLANNSRC=`pwd`
|
||||
NANOFLANN_DEB_DIR="$HOME/nanoflann_release"
|
||||
NANOFLANN_EXTERN_DEBIAN_DIR="$NANOFLANNSRC/packaging/debian/"
|
||||
|
||||
if [ -f ${NANOFLANN_EXTERN_DEBIAN_DIR}/control ];
|
||||
then
|
||||
echo "Using debian dir: ${NANOFLANN_EXTERN_DEBIAN_DIR}"
|
||||
else
|
||||
echo "ERROR: Cannot find ${NANOFLANN_EXTERN_DEBIAN_DIR}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Prepare a directory for building the debian package:
|
||||
#
|
||||
rm -fR $NANOFLANN_DEB_DIR
|
||||
mkdir $NANOFLANN_DEB_DIR
|
||||
|
||||
# Are we in svn?
|
||||
NANOFLANN_SVN_VERSION=`svnversion -n`
|
||||
|
||||
if [ $NANOFLANN_SVN_VERSION = "exported" ];
|
||||
then
|
||||
echo "Copying sources to $NANOFLANN_DEB_DIR/nanoflann-${NANOFLANN_VERSION_STR}"
|
||||
cp -R . $NANOFLANN_DEB_DIR/nanoflann-${NANOFLANN_VERSION_STR}
|
||||
else
|
||||
# Strip the last "M", if any:
|
||||
if [ ${NANOFLANN_SVN_VERSION:(-1)} = "M" ];
|
||||
then
|
||||
NANOFLANN_SVN_VERSION=${NANOFLANN_SVN_VERSION:0:${#NANOFLANN_SVN_VERSION}-1}
|
||||
fi
|
||||
|
||||
if [ $APPEND_SVN_NUM == "1" ];
|
||||
then
|
||||
NANOFLANN_VERSION_STR="${NANOFLANN_VERSION_STR}svn${NANOFLANN_SVN_VERSION}${APPEND_LINUX_DISTRO}"
|
||||
else
|
||||
NANOFLANN_VERSION_STR="${NANOFLANN_VERSION_STR}${APPEND_LINUX_DISTRO}"
|
||||
fi
|
||||
|
||||
echo "Exporting to $NANOFLANN_DEB_DIR/nanoflann-${NANOFLANN_VERSION_STR}"
|
||||
svn export . $NANOFLANN_DEB_DIR/nanoflann-${NANOFLANN_VERSION_STR}
|
||||
fi
|
||||
|
||||
cd $NANOFLANN_DEB_DIR/nanoflann-${NANOFLANN_VERSION_STR}
|
||||
|
||||
# Orig tarball:
|
||||
cd ..
|
||||
echo "Creating orig tarball: nanoflann-${NANOFLANN_VERSION_STR}.tar.gz"
|
||||
tar czf nanoflann-${NANOFLANN_VERSION_STR}.tar.gz nanoflann-${NANOFLANN_VERSION_STR}
|
||||
|
||||
|
||||
exit 0
|
||||
|
||||
82
scripts/prepare_ubuntu_pkgs_for_ppa.sh
Normal file
82
scripts/prepare_ubuntu_pkgs_for_ppa.sh
Normal file
@@ -0,0 +1,82 @@
|
||||
#!/bin/bash
|
||||
# Creates a set of packages for each different Ubuntu distribution, with the
|
||||
# intention of uploading them to:
|
||||
# https://launchpad.net/~joseluisblancoc/+archive/nanoflann
|
||||
#
|
||||
# JLBC, 2010-2011
|
||||
|
||||
# Checks
|
||||
# --------------------------------
|
||||
if [ -f version ];
|
||||
then
|
||||
NANOFLANN_VERSION_STR=`cat version`
|
||||
NANOFLANN_VERSION_MAJOR=${NANOFLANN_VERSION_STR:0:1}
|
||||
NANOFLANN_VERSION_MINOR=${NANOFLANN_VERSION_STR:2:1}
|
||||
NANOFLANN_VERSION_PATCH=${NANOFLANN_VERSION_STR:4:1}
|
||||
AUX_SVN=$(svnversion)
|
||||
#Remove the trailing "M":
|
||||
NANOFLANN_VERSION_SVN=${AUX_SVN%M}
|
||||
|
||||
NANOFLANN_VER_MM="${NANOFLANN_VERSION_MAJOR}.${NANOFLANN_VERSION_MINOR}"
|
||||
NANOFLANN_VER_MMP="${NANOFLANN_VERSION_MAJOR}.${NANOFLANN_VERSION_MINOR}.${NANOFLANN_VERSION_PATCH}"
|
||||
echo "nanoflann version: ${NANOFLANN_VER_MMP} (SVN: ${NANOFLANN_VERSION_SVN})"
|
||||
else
|
||||
echo "ERROR: Run this script from the nanoflann root directory."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
NANOFLANN_UBUNTU_OUT_DIR="$HOME/nanoflann_ubuntu"
|
||||
NANOFLANNSRC=`pwd`
|
||||
NANOFLANN_DEB_DIR="$HOME/nanoflann_debian"
|
||||
NANOFLANN_EXTERN_DEBIAN_DIR="$NANOFLANNSRC/packaging/debian/"
|
||||
EMAIL4DEB="Jose Luis Blanco (University of Malaga) <joseluisblancoc@gmail.com>"
|
||||
|
||||
# Clean out dirs:
|
||||
rm -fr $NANOFLANN_UBUNTU_OUT_DIR/
|
||||
|
||||
# -------------------------------------------------------------------
|
||||
# And now create the custom packages for each Ubuntu distribution
|
||||
# -------------------------------------------------------------------
|
||||
LST_DISTROS=(oneiric natty karmic lucid maverick)
|
||||
|
||||
count=${#LST_DISTROS[@]}
|
||||
IDXS=$(seq 0 $(expr $count - 1))
|
||||
|
||||
cp ${NANOFLANN_EXTERN_DEBIAN_DIR}/changelog /tmp/my_changelog
|
||||
|
||||
|
||||
for IDX in ${IDXS};
|
||||
do
|
||||
DEBIAN_DIST=${LST_DISTROS[$IDX]}
|
||||
|
||||
# -------------------------------------------------------------------
|
||||
# Call the standard "prepare_debian.sh" script:
|
||||
# -------------------------------------------------------------------
|
||||
cd ${NANOFLANNSRC}
|
||||
bash scripts/prepare_debian.sh -u -d ${DEBIAN_DIST} # -s
|
||||
|
||||
echo
|
||||
echo "===== Distribution: ${DEBIAN_DIST} ========="
|
||||
cd ${NANOFLANN_DEB_DIR}/nanoflann-${NANOFLANN_VER_MMP}${DEBIAN_DIST}/debian
|
||||
cp /tmp/my_changelog changelog
|
||||
DEBCHANGE_CMD="--newversion ${NANOFLANN_VERSION_STR}${DEBIAN_DIST}-1~ppa1~${DEBIAN_DIST}"
|
||||
echo "Changing to a new Debian version: ${DEBCHANGE_CMD}"
|
||||
echo "Adding a new entry to debian/changelog for distribution ${DEBIAN_DIST}"
|
||||
DEBEMAIL=${EMAIL4DEB} debchange $DEBCHANGE_CMD -b --distribution ${DEBIAN_DIST} --force-distribution New version of upstream sources.
|
||||
|
||||
cp changelog /tmp/my_changelog
|
||||
|
||||
echo "Now, let's build the source Deb package with 'debuild -S -sa':"
|
||||
cd ..
|
||||
debuild -S -sa
|
||||
|
||||
# Make a copy of all these packages:
|
||||
cd ..
|
||||
mkdir -p $NANOFLANN_UBUNTU_OUT_DIR/$DEBIAN_DIST
|
||||
cp nanoflann_* $NANOFLANN_UBUNTU_OUT_DIR/$DEBIAN_DIST/
|
||||
echo ">>>>>> Saving packages to: $NANOFLANN_UBUNTU_OUT_DIR/$DEBIAN_DIST/"
|
||||
done
|
||||
|
||||
|
||||
exit 0
|
||||
|
||||
@@ -14,7 +14,9 @@ ADD_CUSTOM_TARGET(test)
|
||||
# -----------------------------
|
||||
|
||||
# If using system library, add C++ flags:
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_GTEST_CFLAGS}")
|
||||
IF (UNIX)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
|
||||
ENDIF (UNIX)
|
||||
|
||||
# Test project:
|
||||
ADD_EXECUTABLE(unit_tests test_main.cpp)
|
||||
|
||||
@@ -30,7 +30,13 @@
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <nanoflann.hpp>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
using namespace nanoflann;
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
@@ -41,4 +47,112 @@ int main(int argc, char **argv)
|
||||
|
||||
|
||||
|
||||
// This is an exampleof a custom data set class
|
||||
template <typename T>
|
||||
struct PointCloud
|
||||
{
|
||||
struct Point
|
||||
{
|
||||
T x,y,z;
|
||||
};
|
||||
|
||||
std::vector<Point> pts;
|
||||
|
||||
// Must return the number of data points
|
||||
inline size_t kdtree_get_point_count() const { return pts.size(); }
|
||||
|
||||
// Returns the distance between the vector "p1[0:size-1]" and the data point with index "idx_p2" stored in the class:
|
||||
inline float kdtree_distance(const float *p1, const size_t idx_p2,size_t size) const
|
||||
{
|
||||
float d0=p1[0]-pts[idx_p2].x;
|
||||
float d1=p1[1]-pts[idx_p2].y;
|
||||
float d2=p1[2]-pts[idx_p2].z;
|
||||
return d0*d0+d1*d1+d2*d2;
|
||||
}
|
||||
|
||||
// Returns the dim'th component of the idx'th point in the class:
|
||||
// Since this is inlined and the "dim" argument is typically an immediate value, the
|
||||
// "if/else's" are actually solved at compile time.
|
||||
inline float kdtree_get_pt(const size_t idx, int dim) const
|
||||
{
|
||||
if (dim==0) return pts[idx].x;
|
||||
else if (dim==1) return pts[idx].y;
|
||||
else return pts[idx].z;
|
||||
}
|
||||
|
||||
// Optional bounding-box computation: return false to default to a standard bbox computation loop.
|
||||
// Return true if the BBOX was already computed by the class and returned in "bb" so it can be avoided to redo it again.
|
||||
// Look at bb.size() to find out the expected dimensionality (e.g. 2 or 3 for point clouds)
|
||||
template <class BBOX>
|
||||
bool kdtree_get_bbox(BBOX &bb) const { return false; }
|
||||
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
void generateRandomPointCloud(PointCloud<T> &point, const size_t N, const T max_range = 10)
|
||||
{
|
||||
point.pts.resize(N);
|
||||
for (size_t i=0;i<N;i++)
|
||||
{
|
||||
point.pts[i].x = max_range * (rand() % 1000) / T(1000);
|
||||
point.pts[i].y = max_range * (rand() % 1000) / T(1000);
|
||||
point.pts[i].z = max_range * (rand() % 1000) / T(1000);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename num_t>
|
||||
void L2_vs_L2_simple_test(const size_t N, const size_t num_results)
|
||||
{
|
||||
PointCloud<num_t> cloud;
|
||||
|
||||
// Generate points:
|
||||
generateRandomPointCloud(cloud, N);
|
||||
|
||||
num_t query_pt[3] = { 0.5, 0.5, 0.5};
|
||||
|
||||
// construct a kd-tree index:
|
||||
typedef KDTreeSingleIndexAdaptor<
|
||||
L2_Simple_Adaptor<num_t, PointCloud<num_t> > ,
|
||||
PointCloud<num_t>,
|
||||
3 /* dim */
|
||||
> my_kd_tree_simple_t;
|
||||
|
||||
typedef KDTreeSingleIndexAdaptor<
|
||||
L2_Adaptor<num_t, PointCloud<num_t> > ,
|
||||
PointCloud<num_t>,
|
||||
3 /* dim */
|
||||
> my_kd_tree_t;
|
||||
|
||||
my_kd_tree_simple_t index1(3 /*dim*/, cloud, KDTreeSingleIndexAdaptorParams(10 /* max leaf */) );
|
||||
index1.buildIndex();
|
||||
|
||||
my_kd_tree_t index2(3 /*dim*/, cloud, KDTreeSingleIndexAdaptorParams(10 /* max leaf */) );
|
||||
index2.buildIndex();
|
||||
|
||||
// do a knn search
|
||||
std::vector<int> ret_index(num_results);
|
||||
std::vector<num_t> out_dist_sqr(num_results);
|
||||
nanoflann::KNNResultSet<num_t> resultSet(num_results);
|
||||
resultSet.init(&ret_index[0], &out_dist_sqr[0] );
|
||||
index1.findNeighbors(resultSet, &query_pt[0], nanoflann::SearchParams(10));
|
||||
|
||||
std::vector<int> ret_index1 = ret_index;
|
||||
std::vector<num_t> out_dist_sqr1 = out_dist_sqr;
|
||||
|
||||
resultSet.init(&ret_index[0], &out_dist_sqr[0] );
|
||||
|
||||
index2.findNeighbors(resultSet, &query_pt[0], nanoflann::SearchParams(10));
|
||||
|
||||
for (int i=0;i<num_results;i++)
|
||||
{
|
||||
EXPECT_EQ(ret_index1[i],ret_index[i]);
|
||||
EXPECT_EQ(out_dist_sqr1[i],out_dist_sqr[i]);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(kdtree,L2_vs_L2_simple)
|
||||
{
|
||||
for (int nResults=1;nResults<10;nResults++)
|
||||
L2_vs_L2_simple_test<float>(100, nResults);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user