Skip to content

Commit

Permalink
sync with headers (#15)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
district10 and zhixiong-tang authored Jun 23, 2023
1 parent cd6c8a1 commit 2b4582e
Show file tree
Hide file tree
Showing 13 changed files with 563 additions and 11 deletions.
29 changes: 24 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ docs_serve:
mkdocs serve -a 0.0.0.0:8088

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

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

DEV_CONTAINER_NAME ?= $(USER)_$(subst /,_,$(PROJECT_NAME)____$(PROJECT_SOURCE_DIR))
DEV_CONTAINER_IMAG ?= $(DOCKER_TAG_LINUX)
test_in_dev_container:
docker ps | grep $(DEV_CONTAINER_NAME) \
&& docker exec -it $(DEV_CONTAINER_NAME) bash \
|| docker run --rm --name $(DEV_CONTAINER_NAME) \
--network host --security-opt seccomp=unconfined \
-v `pwd`:`pwd` -w `pwd` -it $(DEV_CONTAINER_IMAG) bash

PYTHON ?= python3
python_install:
$(PYTHON) setup.py install
Expand Down Expand Up @@ -65,11 +74,13 @@ python_build_py39:
PYTHON=python conda run --no-capture-output -n py39 make python_build
python_build_py310:
PYTHON=python conda run --no-capture-output -n py310 make python_build
python_build_all: python_build_py36 python_build_py37 python_build_py38 python_build_py39 python_build_py310
python_build_py311:
PYTHON=python conda run --no-capture-output -n py311 make python_build
python_build_all: python_build_py36 python_build_py37 python_build_py38 python_build_py39 python_build_py310 python_build_py311
python_build_all_in_linux:
docker run --rm -w `pwd` -v `pwd`:`pwd` -v `pwd`/build/win:`pwd`/build -it $(DOCKER_TAG_LINUX) make python_build_all
docker run --rm -w `pwd` -v `pwd`:`pwd` -v `pwd`/build/linux:`pwd`/build -it $(DOCKER_TAG_LINUX) make python_build_all
make repair_wheels && rm -rf dist/*.whl && mv wheelhouse/*.whl dist && rm -rf wheelhouse
python_build_all_in_macos: python_build_py38 python_build_py39 python_build_py310
python_build_all_in_macos: python_build_py38 python_build_py39 python_build_py310 python_build_py311
python_build_all_in_windows: python_build_all

repair_wheels:
Expand Down Expand Up @@ -102,11 +113,19 @@ benchmark_point_in_polygon:
dist/mask_cubao.npy
.PHONY: benchmark_point_in_polygon

SYNC_OUTPUT_DIR := headers/include/cubao
SYNC_OUTPUT_DIR ?= headers/include/cubao
sync_headers:
cp src/densify_polyline.hpp $(SYNC_OUTPUT_DIR)
cp src/fast_crossing.hpp $(SYNC_OUTPUT_DIR)
cp src/flatbush.h $(SYNC_OUTPUT_DIR)
cp src/kd_quiver.hpp $(SYNC_OUTPUT_DIR)
cp src/nanoflann_kdtree.hpp $(SYNC_OUTPUT_DIR)
cp src/polyline_in_polygon.hpp $(SYNC_OUTPUT_DIR)
cp src/pybind11_fast_crossing.hpp $(SYNC_OUTPUT_DIR)
cp src/pybind11_flatbush.hpp $(SYNC_OUTPUT_DIR)
cp src/pybind11_nanoflann_kdtree.hpp $(SYNC_OUTPUT_DIR)
cp src/pybind11_quiver.hpp $(SYNC_OUTPUT_DIR)
cp src/quiver.hpp $(SYNC_OUTPUT_DIR)

# https://stackoverflow.com/a/25817631
echo-% : ; @echo -n $($*)
Expand Down
4 changes: 4 additions & 0 deletions docs/about/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ To upgrade `fast-crossing` to the latest version, use pip:
pip install -U fast-crossing
```

## Version 0.0.8 (2023-06-23)

* Sync with headers

## Version 0.0.7 (2023-03-18)

* Add polyline-in-polygon test, [youtube](https://www.youtube.com/watch?v=1dPJ3P84FxE), [bilibili](https://www.bilibili.com/video/BV1D24y1u7uB)
Expand Down
2 changes: 1 addition & 1 deletion headers
Submodule headers updated 77 files
+6 −0 README.md
+5 −0 include/README.md
+13 −7 include/cubao/cheap_ruler.hpp
+6 −0 include/cubao/crs_transform.hpp
+6 −0 include/cubao/densify_polyline.hpp
+367 −30 include/cubao/fast_crossing.hpp
+26 −22 include/cubao/flatbush.h
+312 −0 include/cubao/kd_quiver.hpp
+199 −0 include/cubao/nanoflann_kdtree.hpp
+76 −0 include/cubao/polyline_in_polygon.hpp
+68 −24 include/cubao/polyline_ruler.hpp
+79 −0 include/cubao/pybind11_cheap_ruler.hpp
+84 −2 include/cubao/pybind11_fast_crossing.hpp
+3 −2 include/cubao/pybind11_flatbush.hpp
+73 −0 include/cubao/pybind11_nanoflann_kdtree.hpp
+1 −1 include/cubao/pybind11_polyline_ruler.hpp
+283 −0 include/cubao/pybind11_quiver.hpp
+433 −0 include/cubao/quiver.hpp
+112 −0 include/jni/advanced_ownership.hpp
+147 −0 include/jni/array.hpp
+41 −0 include/jni/arraylike.hpp
+159 −0 include/jni/boxing.hpp
+137 −0 include/jni/class.hpp
+15 −0 include/jni/constructor.hpp
+125 −0 include/jni/errors.hpp
+27 −0 include/jni/field.hpp
+684 −0 include/jni/functions.hpp
+26 −0 include/jni/jni.hpp
+12 −0 include/jni/make.hpp
+31 −0 include/jni/method.hpp
+381 −0 include/jni/native_method.hpp
+24 −0 include/jni/npe.hpp
+153 −0 include/jni/object.hpp
+225 −0 include/jni/ownership.hpp
+27 −0 include/jni/static_field.hpp
+31 −0 include/jni/static_method.hpp
+35 −0 include/jni/string.hpp
+21 −0 include/jni/string_conversion.hpp
+131 −0 include/jni/tagging.hpp
+34 −0 include/jni/traits.hpp
+89 −0 include/jni/type_signature.hpp
+147 −0 include/jni/typed_methods.hpp
+97 −0 include/jni/types.hpp
+220 −0 include/jni/unique.hpp
+40 −0 include/jni/weak_reference.hpp
+152 −0 include/jni/wrapping.hpp
+220 −0 include/kdbush.hpp
+3 −3 include/mapbox/geojson_impl.hpp
+396 −0 include/mapbox/geometry/wagyu/active_bound_list.hpp
+277 −0 include/mapbox/geometry/wagyu/almost_equal.hpp
+99 −0 include/mapbox/geometry/wagyu/bound.hpp
+28 −0 include/mapbox/geometry/wagyu/bubble_sort.hpp
+183 −0 include/mapbox/geometry/wagyu/build_edges.hpp
+26 −0 include/mapbox/geometry/wagyu/build_local_minima_list.hpp
+68 −0 include/mapbox/geometry/wagyu/build_result.hpp
+50 −0 include/mapbox/geometry/wagyu/config.hpp
+120 −0 include/mapbox/geometry/wagyu/edge.hpp
+50 −0 include/mapbox/geometry/wagyu/interrupt.hpp
+70 −0 include/mapbox/geometry/wagyu/intersect.hpp
+365 −0 include/mapbox/geometry/wagyu/intersect_util.hpp
+117 −0 include/mapbox/geometry/wagyu/local_minimum.hpp
+314 −0 include/mapbox/geometry/wagyu/local_minimum_util.hpp
+110 −0 include/mapbox/geometry/wagyu/point.hpp
+256 −0 include/mapbox/geometry/wagyu/process_horizontal.hpp
+123 −0 include/mapbox/geometry/wagyu/process_maxima.hpp
+139 −0 include/mapbox/geometry/wagyu/quick_clip.hpp
+633 −0 include/mapbox/geometry/wagyu/ring.hpp
+836 −0 include/mapbox/geometry/wagyu/ring_util.hpp
+45 −0 include/mapbox/geometry/wagyu/scanbeam.hpp
+191 −0 include/mapbox/geometry/wagyu/snap_rounding.hpp
+1,347 −0 include/mapbox/geometry/wagyu/topology_correction.hpp
+98 −0 include/mapbox/geometry/wagyu/util.hpp
+64 −0 include/mapbox/geometry/wagyu/vatti.hpp
+145 −0 include/mapbox/geometry/wagyu/wagyu.hpp
+1 −5 include/mapbox/geometry_io.hpp
+178 −0 include/mapbox/polylabel.hpp
+446 −0 include/mapbox/supercluster.hpp
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def build_extension(self, ext):
# logic and declaration, and simpler if you include description/version in a file.
setup(
name="fast_crossing",
version="0.0.7",
version="0.0.8",
author="tzx",
author_email="[email protected]",
url="https://fast-crossing.readthedocs.io",
Expand Down
50 changes: 50 additions & 0 deletions src/densify_polyline.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// should sync
// - https://github.com/cubao/fast-crossing/blob/master/src/densify_polyline.hpp
// -
// https://github.com/cubao/headers/tree/main/include/cubao/densify_polyline.hpp

#ifndef CUBAO_DENSIFY_POLYLINE_HPP
#define CUBAO_DENSIFY_POLYLINE_HPP

#include <Eigen/Core>

namespace cubao
{
using RowVectors = Eigen::Matrix<double, Eigen::Dynamic, 3, Eigen::RowMajor>;
inline RowVectors densify_polyline(const Eigen::Ref<const RowVectors> &coords,
double max_gap)
{
if (coords.rows() < 2 || max_gap <= 0) {
return coords;
}
std::vector<Eigen::Vector3d> xyzs;
const int N = coords.rows();
xyzs.reserve(N);
for (int i = 0; i < N - 1; i++) {
const Eigen::RowVector3d &curr = coords.row(i);
const Eigen::RowVector3d &next = coords.row(i + 1);
Eigen::RowVector3d dir = next - curr;
double gap = dir.norm();
if (gap == 0) {
continue;
}
dir /= gap;
if (gap <= max_gap) {
xyzs.push_back(curr);
continue;
}
RowVectors pos(1 + int(std::ceil(gap / max_gap)), 3);
pos.col(0) = Eigen::ArrayXd::LinSpaced(pos.rows(), curr[0], next[0]);
pos.col(1) = Eigen::ArrayXd::LinSpaced(pos.rows(), curr[1], next[1]);
pos.col(2) = Eigen::ArrayXd::LinSpaced(pos.rows(), curr[2], next[2]);
int M = pos.rows() - 1;
int N = xyzs.size();
xyzs.resize(N + M);
Eigen::Map<RowVectors>(&xyzs[N][0], M, 3) = pos.topRows(M);
}
xyzs.push_back(coords.row(N - 1));
return Eigen::Map<const RowVectors>(&xyzs[0][0], xyzs.size(), 3);
}
} // namespace cubao

#endif
5 changes: 5 additions & 0 deletions src/fast_crossing.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// should sync
// - https://github.com/cubao/fast-crossing/blob/master/src/fast_crossing.hpp
// -
// https://github.com/cubao/headers/tree/main/include/cubao/fast_crossing.hpp

#ifndef CUBAO_FAST_CROSSING_HPP
#define CUBAO_FAST_CROSSING_HPP

Expand Down
Loading

0 comments on commit 2b4582e

Please sign in to comment.