-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
45de7ff
commit 2f3b1bf
Showing
34 changed files
with
894 additions
and
190 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- develop | ||
pull_request: {} | ||
|
||
|
||
jobs: | ||
|
||
build: | ||
name: cargo build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/rust-toolchain@stable | ||
- name: Build | ||
run: cargo build | ||
|
||
test: | ||
name: cargo test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/rust-toolchain@stable | ||
with: | ||
components: rustfmt clippy | ||
- name: rustfmt | ||
run: cargo fmt --all -- --check | ||
- name: clippy | ||
run: cargo clippy | ||
- name: test | ||
run: cargo test --verbose |
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
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 |
---|---|---|
@@ -1 +1,10 @@ | ||
# evoxel | ||
|
||
A Rust library for processing 3D voxel grids. | ||
|
||
> [!WARNING] | ||
> The library is at an early stage of development. | ||
## Contributing | ||
|
||
The library is developed at the [TUM Chair of Geoinformatics](https://github.com/tum-gis) and contributions are highly welcome. |
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,10 @@ | ||
# evoxel-cli | ||
|
||
CLI tool for processing 3D voxel grids. | ||
|
||
> [!WARNING] | ||
> The library is at an early stage of development. | ||
## Contributing | ||
|
||
The library is developed at the [TUM Chair of Geoinformatics](https://github.com/tum-gis) and contributions are highly welcome. |
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,22 @@ | ||
use clap::{Parser, Subcommand}; | ||
|
||
#[derive(Parser)] | ||
#[clap(author, version, about, long_about = None, propagate_version = true)] | ||
pub struct Arguments { | ||
#[clap(subcommand)] | ||
pub command: Commands, | ||
} | ||
|
||
#[derive(Subcommand)] | ||
pub enum Commands { | ||
/// Run some tests | ||
Test { | ||
/// Input directory | ||
#[clap(long)] | ||
input_directory_path: String, | ||
|
||
/// Output directory | ||
#[clap(long)] | ||
output_directory_path: String, | ||
}, | ||
} |
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 @@ | ||
pub(crate) mod test; |
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,44 @@ | ||
use evoxel::io::{EvoxelReader, EvoxelWriter}; | ||
use nalgebra::Point3; | ||
use std::path::Path; | ||
use std::time::Instant; | ||
use tracing::info; | ||
|
||
pub fn run(input_directory_path: impl AsRef<Path>, output_directory_path: impl AsRef<Path>) { | ||
// let path = PathBuf::from("/submap_0"); | ||
let start = Instant::now(); | ||
let voxel_grid = EvoxelReader::new(input_directory_path).finish().unwrap(); | ||
let duration = start.elapsed(); | ||
info!( | ||
"Read voxel grid with {} cells in {:?}.", | ||
voxel_grid.size(), | ||
duration | ||
); | ||
|
||
let voxel_grid = evoxel::transform::aggregate_by_index(&voxel_grid).unwrap(); | ||
let voxel_grid = evoxel::transform::filter_by_count(&voxel_grid, 3).unwrap(); | ||
let voxel_grid = evoxel::transform::explode(&voxel_grid).unwrap(); | ||
let voxel_grid = evoxel::transform::filter_by_index_bounds( | ||
&voxel_grid, | ||
Point3::new(676, 95, 0), | ||
Point3::new(1271, 135, 86), | ||
) | ||
.unwrap(); | ||
|
||
info!("Start"); | ||
let start = Instant::now(); | ||
let c = voxel_grid.get_all_cell_indices_in_local_frame(); | ||
let duration = start.elapsed(); | ||
info!("Calculated {} points in {:?}.", c.len(), duration); | ||
//let all = voxel_grid.get_all_center_points(); | ||
|
||
info!( | ||
"Start writing voxel grid with {} cells to {}", | ||
voxel_grid.size(), | ||
output_directory_path.as_ref().display() | ||
); | ||
EvoxelWriter::new(output_directory_path) | ||
.with_compressed(false) | ||
.finish(&voxel_grid) | ||
.expect("should work"); | ||
} |
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 |
---|---|---|
@@ -1,26 +1,23 @@ | ||
use evoxel::io::EvoxelReader; | ||
use std::path::PathBuf; | ||
use std::time::Instant; | ||
use tracing::info; | ||
mod arguments; | ||
mod commands; | ||
|
||
use crate::arguments::{Arguments, Commands}; | ||
use clap::Parser; | ||
use std::path::{Path, PathBuf}; | ||
|
||
fn main() { | ||
tracing_subscriber::fmt::init(); | ||
info!("Hello, world!"); | ||
let arguments = Arguments::parse(); | ||
|
||
let path = PathBuf::from("/submap_0"); | ||
let start = Instant::now(); | ||
let voxel_grid = EvoxelReader::new(path).finish().unwrap(); | ||
let duration = start.elapsed(); | ||
info!( | ||
"Read voxel grid with {} cells in {:?}.", | ||
voxel_grid.size(), | ||
duration | ||
); | ||
match &arguments.command { | ||
Commands::Test { | ||
input_directory_path, | ||
output_directory_path, | ||
} => { | ||
let input_directory_path = Path::new(input_directory_path).canonicalize().unwrap(); | ||
let output_directory_path = PathBuf::from(output_directory_path); | ||
|
||
info!("Start"); | ||
let start = Instant::now(); | ||
let c = voxel_grid.get_all_cell_indices_in_local_frame(); | ||
let duration = start.elapsed(); | ||
info!("Calculated {} points in {:?}.", c.len(), duration); | ||
//let all = voxel_grid.get_all_center_points(); | ||
commands::test::run(input_directory_path, output_directory_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,10 @@ | ||
# evoxel-core | ||
|
||
Core primitives and operations for processing 3D voxel grids. | ||
|
||
> [!WARNING] | ||
> The library is at an early stage of development. | ||
## Contributing | ||
|
||
The library is developed at the [TUM Chair of Geoinformatics](https://github.com/tum-gis) and contributions are highly welcome. |
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,39 @@ | ||
use crate::Error::{ColumnNameMisMatch, NoData, TypeMisMatch}; | ||
use crate::{Error, VoxelDataColumnNames, VoxelGridInfo}; | ||
use ecoord::ReferenceFrames; | ||
use polars::datatypes::DataType; | ||
use polars::frame::DataFrame; | ||
|
||
pub fn check_data_integrity( | ||
voxel_data: &DataFrame, | ||
_info: &VoxelGridInfo, | ||
_reference_frames: &ReferenceFrames, | ||
) -> Result<(), Error> { | ||
if voxel_data.is_empty() { | ||
return Err(NoData("voxel_data")); | ||
} | ||
|
||
let column_names = voxel_data.get_column_names(); | ||
if column_names[0] != VoxelDataColumnNames::X.as_str() { | ||
return Err(ColumnNameMisMatch); | ||
} | ||
if column_names[1] != VoxelDataColumnNames::Y.as_str() { | ||
return Err(ColumnNameMisMatch); | ||
} | ||
if column_names[2] != VoxelDataColumnNames::Z.as_str() { | ||
return Err(ColumnNameMisMatch); | ||
} | ||
|
||
let data_types = voxel_data.dtypes(); | ||
if data_types[0] != DataType::Int64 { | ||
return Err(TypeMisMatch("x")); | ||
} | ||
if data_types[1] != DataType::Int64 { | ||
return Err(TypeMisMatch("y")); | ||
} | ||
if data_types[2] != DataType::Int64 { | ||
return Err(TypeMisMatch("z")); | ||
} | ||
|
||
Ok(()) | ||
} |
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,19 @@ | ||
use thiserror::Error; | ||
|
||
#[derive(Error, Debug)] | ||
pub enum Error { | ||
#[error(transparent)] | ||
EcoordError(#[from] ecoord::Error), | ||
#[error(transparent)] | ||
Polars(#[from] polars::error::PolarsError), | ||
|
||
#[error("No data: {0}")] | ||
NoData(&'static str), | ||
#[error("Lengths don't match: {0}")] | ||
ShapeMisMatch(&'static str), | ||
|
||
#[error("Field {0} does not match type")] | ||
TypeMisMatch(&'static str), | ||
#[error("unknown data store error")] | ||
ColumnNameMisMatch, | ||
} |
Oops, something went wrong.