curvo/
lib.rs

1#![allow(clippy::needless_range_loop)]
2#![allow(clippy::needless_doctest_main)]
3//! Curvo is a NURBS modeling library for Rust.
4//!
5//! This library enables not only the creation of NURBS curves from control points, knot vectors, and weights associated with each control point, but also supports generating curves that precisely pass through the given control points and creating periodic curves. Additionally, it allows for the construction of NURBS surfaces through operations such as _extruding_ and _lofting_ based on NURBS curves as inputs.
6//!
7//! The modeling operations for NURBS surfaces supported by this library currently include the following:
8//! - Extrude
9//! - Loft
10//! - Sweep
11//! - Revolve
12//!
13//! ## Example
14//!
15//! ```
16//! use curvo::prelude::*;
17//! use nalgebra::{Point3, Rotation3, Translation3, Vector3};
18//! use std::f64::consts::FRAC_PI_2;
19//!
20//! fn main() {
21//!     // Create a set of points to interpolate
22//!     let points = vec![
23//!         Point3::new(-1.0, -1.0, 0.),
24//!         Point3::new(1.0, -1.0, 0.),
25//!         Point3::new(1.0, 1.0, 0.),
26//!         Point3::new(-1.0, 1.0, 0.),
27//!         Point3::new(-1.0, 2.0, 0.),
28//!         Point3::new(1.0, 2.5, 0.),
29//!     ];
30//!
31//!     // Create a NURBS curve that interpolates the given points with degree 3
32//!     // You can also specify the precision of the curve by generic type (f32 or f64)
33//!     let interpolated = NurbsCurve3D::<f64>::try_interpolate(&points, 3).unwrap();
34//!
35//!     // NURBS curve & surface can be transformed by nalgebra's matrix
36//!     let rotation = Rotation3::from_axis_angle(&Vector3::z_axis(), FRAC_PI_2);
37//!     let translation = Translation3::new(0., 0., 3.);
38//!     let transform_matrix = translation * rotation; // nalgebra::Isometry3
39//!
40//!     // Transform the curve by the given matrix (nalgebra::Isometry3 into nalgebra::Matrix4)
41//!     let offsetted = interpolated.transformed(&transform_matrix.into());
42//!
43//!     // Create a NURBS surface by lofting two NURBS curves
44//!     let lofted = NurbsSurface::try_loft(
45//!         &[interpolated, offsetted],
46//!         Some(3), // degree of v direction
47//!     ).unwrap();
48//!
49//!     // Tessellate the surface in adaptive manner about curvature for efficient rendering
50//!     let option = AdaptiveTessellationOptions {
51//!         norm_tolerance: 1e-4,
52//!         ..Default::default()
53//!     };
54//!     let tessellation = lofted.tessellate(Some(option));
55//! }
56//! ```
57
58mod boolean;
59mod bounding_box;
60mod closest_parameter;
61mod contains;
62mod curve;
63mod dimension;
64mod intersects;
65mod knot;
66mod misc;
67mod offset;
68mod polygon_mesh;
69mod region;
70mod split;
71mod surface;
72mod tessellation;
73mod trim;
74use closest_parameter::*;
75
76pub mod prelude {
77    pub use crate::boolean::*;
78    pub use crate::bounding_box::*;
79    pub use crate::contains::*;
80    pub use crate::curve::*;
81    pub use crate::dimension::*;
82    pub use crate::intersects::*;
83    pub use crate::knot::*;
84    pub use crate::misc::*;
85    pub use crate::offset::*;
86    pub use crate::polygon_mesh::*;
87    pub use crate::region::*;
88    pub use crate::split::*;
89    pub use crate::surface::*;
90    pub use crate::tessellation::{
91        adaptive_tessellation_option::AdaptiveTessellationOptions,
92        boundary_constraints::BoundaryConstraints, surface_tessellation::*,
93        trimmed_surface_constraints::TrimmedSurfaceConstraints, ConstrainedTessellation,
94        Tessellation,
95    };
96    pub use crate::trim::*;
97}