Skip to content

Commit 2b4582e

Browse files
sync with headers (#15)
* update docker * update headers * fix * init flatbush from headers * minor fix, more test * add densify polyline * more syncs * more syncs * lint code * update headers * trivial update * update * rebase headers --------- Co-authored-by: TANG ZHIXIONG <zhixiong.tang@momenta.ai>
1 parent cd6c8a1 commit 2b4582e

13 files changed

+563
-11
lines changed

Makefile

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ docs_serve:
2626
mkdocs serve -a 0.0.0.0:8088
2727

2828
DOCKER_TAG_WINDOWS ?= ghcr.io/cubao/build-env-windows-x64:v0.0.1
29-
DOCKER_TAG_LINUX ?= ghcr.io/cubao/build-env-manylinux2014-x64:v0.0.1
29+
DOCKER_TAG_LINUX ?= ghcr.io/cubao/build-env-manylinux2014-x64:v0.0.3
3030
DOCKER_TAG_MACOS ?= ghcr.io/cubao/build-env-macos-arm64:v0.0.1
3131

3232
test_in_win:
@@ -36,6 +36,15 @@ test_in_mac:
3636
test_in_linux:
3737
docker run --rm -w `pwd` -v `pwd`:`pwd` -v `pwd`/build/linux:`pwd`/build -it $(DOCKER_TAG_LINUX) bash
3838

39+
DEV_CONTAINER_NAME ?= $(USER)_$(subst /,_,$(PROJECT_NAME)____$(PROJECT_SOURCE_DIR))
40+
DEV_CONTAINER_IMAG ?= $(DOCKER_TAG_LINUX)
41+
test_in_dev_container:
42+
docker ps | grep $(DEV_CONTAINER_NAME) \
43+
&& docker exec -it $(DEV_CONTAINER_NAME) bash \
44+
|| docker run --rm --name $(DEV_CONTAINER_NAME) \
45+
--network host --security-opt seccomp=unconfined \
46+
-v `pwd`:`pwd` -w `pwd` -it $(DEV_CONTAINER_IMAG) bash
47+
3948
PYTHON ?= python3
4049
python_install:
4150
$(PYTHON) setup.py install
@@ -65,11 +74,13 @@ python_build_py39:
6574
PYTHON=python conda run --no-capture-output -n py39 make python_build
6675
python_build_py310:
6776
PYTHON=python conda run --no-capture-output -n py310 make python_build
68-
python_build_all: python_build_py36 python_build_py37 python_build_py38 python_build_py39 python_build_py310
77+
python_build_py311:
78+
PYTHON=python conda run --no-capture-output -n py311 make python_build
79+
python_build_all: python_build_py36 python_build_py37 python_build_py38 python_build_py39 python_build_py310 python_build_py311
6980
python_build_all_in_linux:
70-
docker run --rm -w `pwd` -v `pwd`:`pwd` -v `pwd`/build/win:`pwd`/build -it $(DOCKER_TAG_LINUX) make python_build_all
81+
docker run --rm -w `pwd` -v `pwd`:`pwd` -v `pwd`/build/linux:`pwd`/build -it $(DOCKER_TAG_LINUX) make python_build_all
7182
make repair_wheels && rm -rf dist/*.whl && mv wheelhouse/*.whl dist && rm -rf wheelhouse
72-
python_build_all_in_macos: python_build_py38 python_build_py39 python_build_py310
83+
python_build_all_in_macos: python_build_py38 python_build_py39 python_build_py310 python_build_py311
7384
python_build_all_in_windows: python_build_all
7485

7586
repair_wheels:
@@ -102,11 +113,19 @@ benchmark_point_in_polygon:
102113
dist/mask_cubao.npy
103114
.PHONY: benchmark_point_in_polygon
104115

105-
SYNC_OUTPUT_DIR := headers/include/cubao
116+
SYNC_OUTPUT_DIR ?= headers/include/cubao
106117
sync_headers:
118+
cp src/densify_polyline.hpp $(SYNC_OUTPUT_DIR)
107119
cp src/fast_crossing.hpp $(SYNC_OUTPUT_DIR)
120+
cp src/flatbush.h $(SYNC_OUTPUT_DIR)
121+
cp src/kd_quiver.hpp $(SYNC_OUTPUT_DIR)
122+
cp src/nanoflann_kdtree.hpp $(SYNC_OUTPUT_DIR)
123+
cp src/polyline_in_polygon.hpp $(SYNC_OUTPUT_DIR)
108124
cp src/pybind11_fast_crossing.hpp $(SYNC_OUTPUT_DIR)
109125
cp src/pybind11_flatbush.hpp $(SYNC_OUTPUT_DIR)
126+
cp src/pybind11_nanoflann_kdtree.hpp $(SYNC_OUTPUT_DIR)
127+
cp src/pybind11_quiver.hpp $(SYNC_OUTPUT_DIR)
128+
cp src/quiver.hpp $(SYNC_OUTPUT_DIR)
110129

111130
# https://stackoverflow.com/a/25817631
112131
echo-% : ; @echo -n $($*)

docs/about/release-notes.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ To upgrade `fast-crossing` to the latest version, use pip:
1010
pip install -U fast-crossing
1111
```
1212

13+
## Version 0.0.8 (2023-06-23)
14+
15+
* Sync with headers
16+
1317
## Version 0.0.7 (2023-03-18)
1418

1519
* Add polyline-in-polygon test, [youtube](https://www.youtube.com/watch?v=1dPJ3P84FxE), [bilibili](https://www.bilibili.com/video/BV1D24y1u7uB)

headers

Submodule headers updated 77 files

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def build_extension(self, ext):
124124
# logic and declaration, and simpler if you include description/version in a file.
125125
setup(
126126
name="fast_crossing",
127-
version="0.0.7",
127+
version="0.0.8",
128128
author="tzx",
129129
author_email="dvorak4tzx@gmail.com",
130130
url="https://fast-crossing.readthedocs.io",

src/densify_polyline.hpp

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// should sync
2+
// - https://github.com/cubao/fast-crossing/blob/master/src/densify_polyline.hpp
3+
// -
4+
// https://github.com/cubao/headers/tree/main/include/cubao/densify_polyline.hpp
5+
6+
#ifndef CUBAO_DENSIFY_POLYLINE_HPP
7+
#define CUBAO_DENSIFY_POLYLINE_HPP
8+
9+
#include <Eigen/Core>
10+
11+
namespace cubao
12+
{
13+
using RowVectors = Eigen::Matrix<double, Eigen::Dynamic, 3, Eigen::RowMajor>;
14+
inline RowVectors densify_polyline(const Eigen::Ref<const RowVectors> &coords,
15+
double max_gap)
16+
{
17+
if (coords.rows() < 2 || max_gap <= 0) {
18+
return coords;
19+
}
20+
std::vector<Eigen::Vector3d> xyzs;
21+
const int N = coords.rows();
22+
xyzs.reserve(N);
23+
for (int i = 0; i < N - 1; i++) {
24+
const Eigen::RowVector3d &curr = coords.row(i);
25+
const Eigen::RowVector3d &next = coords.row(i + 1);
26+
Eigen::RowVector3d dir = next - curr;
27+
double gap = dir.norm();
28+
if (gap == 0) {
29+
continue;
30+
}
31+
dir /= gap;
32+
if (gap <= max_gap) {
33+
xyzs.push_back(curr);
34+
continue;
35+
}
36+
RowVectors pos(1 + int(std::ceil(gap / max_gap)), 3);
37+
pos.col(0) = Eigen::ArrayXd::LinSpaced(pos.rows(), curr[0], next[0]);
38+
pos.col(1) = Eigen::ArrayXd::LinSpaced(pos.rows(), curr[1], next[1]);
39+
pos.col(2) = Eigen::ArrayXd::LinSpaced(pos.rows(), curr[2], next[2]);
40+
int M = pos.rows() - 1;
41+
int N = xyzs.size();
42+
xyzs.resize(N + M);
43+
Eigen::Map<RowVectors>(&xyzs[N][0], M, 3) = pos.topRows(M);
44+
}
45+
xyzs.push_back(coords.row(N - 1));
46+
return Eigen::Map<const RowVectors>(&xyzs[0][0], xyzs.size(), 3);
47+
}
48+
} // namespace cubao
49+
50+
#endif

src/fast_crossing.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// should sync
2+
// - https://github.com/cubao/fast-crossing/blob/master/src/fast_crossing.hpp
3+
// -
4+
// https://github.com/cubao/headers/tree/main/include/cubao/fast_crossing.hpp
5+
16
#ifndef CUBAO_FAST_CROSSING_HPP
27
#define CUBAO_FAST_CROSSING_HPP
38

0 commit comments

Comments
 (0)