-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add map edit module to Python API and expose crop_to_sphere methods
- Loading branch information
1 parent
f37f7f9
commit a815bc0
Showing
7 changed files
with
83 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import os | ||
import numpy as np | ||
import pywavemap as wave | ||
|
||
# Load the map | ||
user_home = os.path.expanduser('~') | ||
input_map_path = os.path.join(user_home, "your_map.wvmp") | ||
your_map = wave.Map.load(input_map_path) | ||
|
||
# Crop the map | ||
center = np.array([-2.2, -1.4, 0.0]) | ||
radius = 3.0 | ||
wave.edit.crop_to_sphere(your_map, center, radius) | ||
|
||
# Save the map | ||
output_map_path = os.path.join(user_home, "your_map_cropped.wvmp") | ||
your_map.store(output_map_path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#ifndef PYWAVEMAP_EDIT_H_ | ||
#define PYWAVEMAP_EDIT_H_ | ||
|
||
#include <nanobind/nanobind.h> | ||
|
||
namespace nb = nanobind; | ||
|
||
namespace wavemap { | ||
void add_edit_module(nb::module_& m_edit); | ||
} // namespace wavemap | ||
|
||
#endif // PYWAVEMAP_EDIT_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include "pywavemap/edit.h" | ||
|
||
#include <memory> | ||
|
||
#include <nanobind/eigen/dense.h> | ||
#include <wavemap/core/map/hashed_chunked_wavelet_octree.h> | ||
#include <wavemap/core/map/hashed_wavelet_octree.h> | ||
#include <wavemap/core/utils/edit/crop.h> | ||
|
||
using namespace nb::literals; // NOLINT | ||
|
||
namespace wavemap { | ||
void add_edit_module(nb::module_& m_edit) { | ||
// Map cropping methods | ||
m_edit.def( | ||
"crop_to_sphere", | ||
[](HashedWaveletOctree& map, const Point3D& t_W_center, | ||
FloatingPoint radius, IndexElement termination_height) { | ||
edit::crop_to_sphere(map, t_W_center, radius, termination_height, | ||
std::make_shared<ThreadPool>()); | ||
}, | ||
"map"_a, "center_point"_a, "radius"_a, "termination_height"_a = 0); | ||
m_edit.def( | ||
"crop_to_sphere", | ||
[](HashedChunkedWaveletOctree& map, const Point3D& t_W_center, | ||
FloatingPoint radius, IndexElement termination_height) { | ||
edit::crop_to_sphere(map, t_W_center, radius, termination_height, | ||
std::make_shared<ThreadPool>()); | ||
}, | ||
"map"_a, "center_point"_a, "radius"_a, "termination_height"_a = 0); | ||
} | ||
} // namespace wavemap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters