Skip to content

Commit

Permalink
Manual clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
w1th0utnam3 committed Feb 5, 2025
1 parent 47d4556 commit 52996aa
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 23 deletions.
8 changes: 4 additions & 4 deletions splashsurf/src/reconstruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,17 +459,17 @@ mod arguments {
}

fn try_aabb_from_min_max(
min: &Vec<f64>,
max: &Vec<f64>,
min: &[f64],
max: &[f64],
error_str: &'static str,
) -> Result<Aabb3d<f64>, anyhow::Error> {
// This should already be ensured by StructOpt parsing
assert_eq!(min.len(), 3);
assert_eq!(max.len(), 3);

let aabb = Aabb3d::new(
Vector3::from_iterator(min.clone()),
Vector3::from_iterator(max.clone()),
Vector3::from_column_slice(min),
Vector3::from_column_slice(max),
);

if !aabb.is_consistent() {
Expand Down
4 changes: 2 additions & 2 deletions splashsurf_lib/src/aabb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ where

/// Returns the geometric centroid of the AABB (mean of the corner points)
pub fn centroid(&self) -> SVector<R, D> {
&self.min + (self.extents() / (R::one() + R::one()))
self.min + (self.extents() / (R::one() + R::one()))
}

/// Checks if the given AABB is inside of the AABB, the AABB is considered to be half-open to its max coordinate
Expand All @@ -236,7 +236,7 @@ where
/// Multiplies a uniform, local scaling to the AABB (i.e. multiplying its extents as if it was centered at the origin)
pub fn scale_uniformly(&mut self, scaling: R) {
let center = self.centroid();
self.translate(&(&center * R::one().neg()));
self.translate(&(center * R::one().neg()));
self.min *= scaling;
self.max *= scaling;
self.translate(&center);
Expand Down
5 changes: 1 addition & 4 deletions splashsurf_lib/src/io/bgeo_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -719,10 +719,7 @@ mod error {
impl BgeoParserErrorKind {
/// Returns whether the variant is an internal nom error
pub fn is_nom_error(&self) -> bool {
match self {
BgeoParserErrorKind::NomError(_) => true,
_ => false,
}
matches!(self, BgeoParserErrorKind::NomError(_))
}
}

Expand Down
2 changes: 1 addition & 1 deletion splashsurf_lib/src/io/vtk_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ fn try_map_scalars_to_real<R: Real, T: Copy, F: Fn(T) -> Result<R, anyhow::Error

/// Tries to convert a vector of consecutive coordinate triplets into a vector of `Vector3`, also converts between floating point types
fn particles_from_coords<RealOut: Real, RealIn: Real>(
coords: &Vec<RealIn>,
coords: &[RealIn],
) -> Result<Vec<Vector3<RealOut>>, anyhow::Error> {
if coords.len() % 3 != 0 {
return Err(anyhow!(
Expand Down
20 changes: 10 additions & 10 deletions splashsurf_lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@
//! The following features are all non-default features to reduce the amount of additional dependencies.
//!
//! - **`vtk_extras`**: Enables helper functions and trait implementations to export meshes using [`vtkio`](https://github.com/elrnv/vtkio).
//! In particular it adds `From` impls for the [mesh] types used by this crate to convert them to
//! [`vtkio::model::UnstructuredGridPiece`](https://docs.rs/vtkio/0.6.*/vtkio/model/struct.UnstructuredGridPiece.html) and [`vtkio::model::DataSet`](https://docs.rs/vtkio/0.6.*/vtkio/model/enum.DataSet.html)
//! types. If the feature is enabled, The crate exposes its `vtkio` dependency as `splashsurflib::vtkio`.
//! In particular it adds `From` impls for the [mesh] types used by this crate to convert them to
//! [`vtkio::model::UnstructuredGridPiece`](https://docs.rs/vtkio/0.6.*/vtkio/model/struct.UnstructuredGridPiece.html) and [`vtkio::model::DataSet`](https://docs.rs/vtkio/0.6.*/vtkio/model/enum.DataSet.html)
//! types. If the feature is enabled, The crate exposes its `vtkio` dependency as `splashsurflib::vtkio`.
//! - **`io`**: Enables the [`io`] module, containing functions to load and store particle and mesh files
//! from various file formats, e.g. `VTK`, `OBJ`, `BGEO` etc. This feature implies the `vtk_extras` feature.
//! It is disabled by default because a pure "online" surface reconstruction might not need any file IO.
//! The feature adds several dependencies to support the file formats.
//! from various file formats, e.g. `VTK`, `OBJ`, `BGEO` etc. This feature implies the `vtk_extras` feature.
//! It is disabled by default because a pure "online" surface reconstruction might not need any file IO.
//! The feature adds several dependencies to support the file formats.
//! - **`profiling`**: Enables profiling of internal functions. The resulting data can be displayed using the functions
//! from the [`profiling`] module of this crate. Furthermore, it exposes the [`profile`] macro that can be used e.g.
//! by binary crates calling into this library to add their own profiling scopes to the measurements.
//! If this features is not enabled, the macro will just expend to a no-op and remove the (small)
//! performance overhead of the profiling.
//! from the [`profiling`] module of this crate. Furthermore, it exposes the [`profile`] macro that can be used e.g.
//! by binary crates calling into this library to add their own profiling scopes to the measurements.
//! If this features is not enabled, the macro will just expend to a no-op and remove the (small)
//! performance overhead of the profiling.
//!
use log::info;
Expand Down
4 changes: 2 additions & 2 deletions splashsurf_lib/src/marching_cubes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ pub fn check_mesh_consistency<I: Index, R: Real>(
.get_point(*cell_index.index())
.expect("Unable to get point index of cell");
let cell_center = grid.point_coordinates(&point_index)
+ &Vector3::repeat(grid.cell_size().times_f64(0.5));
+ Vector3::repeat(grid.cell_size().times_f64(0.5));

*error_string += &format!("\n\tTriangle {}, boundary edge {:?} is located in cell with {:?} with center coordinates {:?} and edge length {}.", tri_idx, edge, cell_index, cell_center, grid.cell_size());
} else {
Expand Down Expand Up @@ -242,7 +242,7 @@ fn check_mesh_with_cell_data<I: Index, R: Real>(
.get_point(*cell_index.index())
.expect("Unable to get point index of cell");
let cell_center = grid.point_coordinates(&point_index)
+ &Vector3::repeat(grid.cell_size().times_f64(0.5));
+ Vector3::repeat(grid.cell_size().times_f64(0.5));

let cell_data = marching_cubes_data
.cell_data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pub(crate) fn construct_mc_input<I: Index, R: Real>(
/// For each cell, this function collects
/// 1) an array with a flag per corner vertex, indicating whether it's above/below the iso-surface threshold
/// 2) an array with an optional index per edge, referring to the interpolated vertex if the edge crosses the iso-surface
///
/// Note: The threshold flags in the resulting cell data are not complete and still have to be updated after
/// this procedure using the [update_cell_data_threshold_flags] function.
///
Expand Down

0 comments on commit 52996aa

Please sign in to comment.