rust_3d/
lib.rs

1/*
2Copyright 2016 Martin Buck
3
4Permission is hereby granted, free of charge, to any person obtaining a copy
5of this software and associated documentation files (the "Software"),
6to deal in the Software without restriction, including without limitation the
7rights to use, copy, modify, merge, publish, distribute, sublicense,
8and/or sell copies of the Software, and to permit persons to whom the Software
9is furnished to do so, subject to the following conditions:
10
11The above copyright notice and this permission notice shall
12be included all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
20OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21*/
22
23#![deny(warnings)]
24
25//! rust-3d
26//! =======
27//! 3D/2D library written in Rust.
28//! Offering useful containers, structures and algorithms for 2D and 3D space.
29//! Meant as basis for numeric algorithms, viewers, game engines, ...
30//!
31//!
32//! Migration 0.29.0 -> 0.30.0
33//! --------------------------
34//! Note that the module structure changed. There's now only submodules for `io` and `impls`.  
35//! Also `prelude` was removed.  
36//! If you were using the prelude via `rust_3d::prelude::*;` you should now be able to just switch to
37//! `rust_3d::*;`.  
38//! If you were using explicit paths such as `rust_3d::filters::combinators::FilterAll` you should now use `rust_3d::FilterAll`.  
39//! Note that `io` and `impls` are still part of the module path.  
40//! This should make future usage easier, but might be painful for existing users.  
41//!
42//!
43//! Tour
44//! ----
45//! Here's a little overview of some of `rust-3d`'s features.
46//! The snippets / names might not be up-to-date, so please check `tests/` for compiling examples.
47//!
48//!
49//! ### Proper error handling
50//! No `.unwrap()` where it's not 100% safe.
51//!
52//! ### Strong / Smart Types
53//! There's strong types for everything that might get mixed up easily.  
54//! This way e.g. ids of faces can't be mistaken for ids of vertices.
55//! ```rust,ignore
56//! fn edges_of_face(&self, faceid: FId) -> Result<(EId, EId, EId)>;
57//! ```
58//! There's also smart types which restrict the values they can hold.  
59//! This way distances can never be `< 0.0`, sizes can be enfored to be `> 0.0` etc.
60//! ```rust,ignore
61//! Positive  
62//! NonNegative
63//! ```
64//!
65//! ### Generic Code Base
66//! I try and keep all algorithms and types as generic as possible.
67//! - Even rather basic types like `Is2D` are split into several versions: `IsEditable2D`, `IsBuildable2D`
68//! - `IsMesh` is defined for any vertex type and any number of vertices / face
69//! - There's traits for collections (no need to use `Vec`)  
70//!
71//! This makes it possible to require as little implementation work as possible if you want to use your own types.  
72//!
73//!
74//! ### Combinators / Transformers
75//! - Any `IsFilter<T>` can be combined via `FilterAND`, `FilterOR`, `FilterAny`, `FilterNegate`...  
76//! - Any `IsFilter<T>` can be transformed to work for any collection of `T`s (`IsFilterRandomAccessible`).
77//! - `IsDirectionField2D` might be transformed to an `IsFilter<Is2D>`, which can then be transformed to an `IsFilterRandomAccessible<Is2D>`.
78//!
79//!
80//! ### IO
81//! Any `IO` method is defined on traits, so if you implement these, you'll get read/write of different file formats for free.
82//!
83//!
84//! Documentation
85//! -------------
86//! You can find the documentation [here](https://docs.rs/rust-3d/).
87//!
88//!
89//! Examples
90//! --------
91//! Please take a look at the tests in `tests/`. These will be up-to-date and compiling.  
92//! I might add extensive tutorials / examples / demo projects in the future.
93//!
94//!
95//! Links
96//! -----
97//! [crates.io](https://crates.io/crates/rust-3d)  
98//! [github.com](https://github.com/I3ck/rust-3d)  
99//! [docs.rs](https://docs.rs/rust-3d/)
100//!
101//!
102//! Contribute
103//! ----------
104//! Feel free to open an issue in case you're missing something or found a bug.
105//! Please avoid directly contributing since I might be working on breaking changes or the feature you want to implement.
106//! Open an issue or email me beforehand.
107//!
108//!
109//! License
110//! ------
111//! MIT (see LICENSE)
112
113pub mod io;
114
115mod distances_2d;
116pub use self::distances_2d::*;
117
118mod distances_3d;
119pub use self::distances_3d::*;
120
121mod distances_nd;
122pub use self::distances_nd::*;
123
124mod factory_2d;
125pub use self::factory_2d::*;
126
127mod functions;
128pub use self::functions::*;
129
130mod impls;
131pub use self::impls::*;
132
133mod interpolate_2d;
134pub use interpolate_2d::*;
135
136pub mod test_helper;
137
138mod utils;
139pub use self::utils::*;
140
141mod aa_bb_tree_2d;
142pub use self::aa_bb_tree_2d::AABBTree2D;
143
144mod strong_types;
145pub use self::strong_types::*;
146
147mod aa_bb_tree_3d;
148pub use self::aa_bb_tree_3d::AABBTree3D;
149
150mod point_2d;
151pub use self::point_2d::Point2D;
152
153mod point_3d;
154pub use self::point_3d::Point3D;
155
156mod line_2d;
157pub use self::line_2d::Line2D;
158
159mod line_3d;
160pub use self::line_3d::Line3D;
161
162mod line_segment_2d;
163pub use self::line_segment_2d::LineSegment2D;
164
165mod line_segment_3d;
166pub use self::line_segment_3d::LineSegment3D;
167
168mod ray_2d;
169pub use self::ray_2d::Ray2D;
170
171mod ray_3d;
172pub use self::ray_3d::Ray3D;
173
174mod plane_3d;
175pub use self::plane_3d::Plane3D;
176
177mod point_cloud_2d;
178pub use self::point_cloud_2d::PointCloud2D;
179
180mod point_cloud_3d;
181pub use self::point_cloud_3d::PointCloud3D;
182
183mod point_cloud_3d_f32;
184pub use self::point_cloud_3d_f32::PointCloud3Df32;
185
186mod polygon_2d;
187pub use self::polygon_2d::Polygon2D;
188
189mod polygon_3d;
190pub use self::polygon_3d::Polygon3D;
191
192mod norm_2d;
193pub use self::norm_2d::Norm2D;
194
195mod norm_3d;
196pub use self::norm_3d::Norm3D;
197
198mod bounding_box_2d;
199pub use self::bounding_box_2d::BoundingBox2D;
200
201mod bounding_box_3d;
202pub use self::bounding_box_3d::BoundingBox3D;
203
204mod matrix3;
205pub use self::matrix3::Matrix3;
206
207mod matrix4;
208pub use self::matrix4::Matrix4;
209
210mod matrix3_pipe;
211pub use self::matrix3_pipe::Matrix3Pipe;
212
213mod matrix4_pipe;
214pub use self::matrix4_pipe::Matrix4Pipe;
215
216mod compressed_point_3d;
217pub use self::compressed_point_3d::CompressedPoint3D;
218
219mod compressed_point_cloud_3d;
220pub use self::compressed_point_cloud_3d::CompressedPointCloud3D;
221
222mod kd_tree;
223pub use self::kd_tree::KdTree;
224
225mod mesh_3d;
226pub use self::mesh_3d::Mesh3D;
227
228mod searchable_mesh;
229pub use self::searchable_mesh::SearchableMesh;
230
231mod oc_tree;
232pub use self::oc_tree::OcTree;
233
234mod view;
235pub use self::view::View;
236
237mod positive;
238pub use self::positive::Positive;
239
240mod non_negative;
241pub use self::non_negative::NonNegative;
242
243mod result;
244pub use self::result::*;
245
246mod rgb;
247pub use self::rgb::Rgb;
248
249mod face3;
250pub use self::face3::Face3;
251
252mod half_edge;
253pub use self::half_edge::HalfEdge;
254
255mod enums;
256pub use self::enums::*;
257
258mod cluster;
259pub use self::cluster::*;
260
261mod sat_collider;
262pub use self::sat_collider::*;
263
264mod box_unaligned_3d;
265pub use self::box_unaligned_3d::*;
266
267mod tri_face_3d;
268pub use self::tri_face_3d::*;
269
270mod collider_3d;
271pub use self::collider_3d::*;
272
273mod convex_hull_2d;
274pub use self::convex_hull_2d::convex_hull_2d;
275
276mod douglas_peucker_2d;
277pub use self::douglas_peucker_2d::douglas_peucker_2d;
278
279pub mod subdivide;
280
281mod unify_faces;
282pub use self::unify_faces::unify_faces;
283
284mod heal_mesh;
285pub use self::heal_mesh::heal_mesh;
286
287mod cluster_vertices;
288pub use self::cluster_vertices::cluster_vertices;
289
290mod circle;
291pub use self::circle::Circle;
292
293mod box_2d;
294pub use self::box_2d::Box2D;
295
296mod sphere;
297pub use self::sphere::Sphere;
298
299mod box_3d;
300pub use self::box_3d::Box3D;
301
302mod has_bounding_box_2d;
303pub use self::has_bounding_box_2d::{
304    HasBoundingBox2D, HasBoundingBox2DConverted, HasBoundingBox2DMaybe,
305};
306
307mod has_bounding_box_3d;
308pub use self::has_bounding_box_3d::{
309    HasBoundingBox3D, HasBoundingBox3DConverted, HasBoundingBox3DMaybe,
310};
311
312mod has_center_of_gravity_2d;
313pub use self::has_center_of_gravity_2d::HasCenterOfGravity2D;
314
315mod has_center_of_gravity_3d;
316pub use self::has_center_of_gravity_3d::HasCenterOfGravity3D;
317
318mod has_length;
319pub use self::has_length::HasLength;
320
321mod is_editable_2d;
322pub use self::is_editable_2d::IsEditable2D;
323
324mod is_editable_3d;
325pub use self::is_editable_3d::IsEditable3D;
326
327mod is_editable_nd;
328pub use self::is_editable_nd::IsEditableND;
329
330mod is_editable_polygon;
331pub use self::is_editable_polygon::IsEditablePolygon;
332
333mod is_buildable_2d;
334pub use self::is_buildable_2d::IsBuildable2D;
335
336mod is_buildable_3d;
337pub use self::is_buildable_3d::IsBuildable3D;
338
339mod is_buildable_nd;
340pub use self::is_buildable_nd::IsBuildableND;
341
342mod is_2d;
343pub use self::is_2d::Is2D;
344
345mod is_3d;
346pub use self::is_3d::Is3D;
347
348mod is_random_accessible;
349pub use self::is_random_accessible::IsRandomAccessible;
350
351mod is_random_insertible;
352pub use self::is_random_insertible::IsRandomInsertible;
353
354mod is_pushable;
355pub use self::is_pushable::IsPushable;
356
357mod is_face_editable_mesh;
358pub use self::is_face_editable_mesh::IsFaceEditableMesh;
359
360mod is_vertex_editable_mesh;
361pub use self::is_vertex_editable_mesh::IsVertexEditableMesh;
362
363mod is_k_nearest_searchable;
364pub use self::is_k_nearest_searchable::IsKNearestSearchable;
365
366mod is_matrix3_transformable;
367pub use self::is_matrix3_transformable::IsMatrix3Transformable;
368
369mod is_matrix4_transformable;
370pub use self::is_matrix4_transformable::IsMatrix4Transformable;
371
372mod is_sphere_searchable;
373pub use self::is_sphere_searchable::IsSphereSearchable;
374
375mod is_box_3d_searchable;
376pub use self::is_box_3d_searchable::IsBox3DSearchable;
377
378mod is_mesh;
379pub use self::is_mesh::IsMesh;
380
381mod is_mesh_3d;
382pub use self::is_mesh_3d::IsMesh3D;
383
384mod is_topology_unit;
385pub use self::is_topology_unit::IsTopologyUnit;
386
387mod is_searchable_mesh;
388pub use self::is_searchable_mesh::IsSearchableMesh;
389
390mod is_movable_2d;
391pub use self::is_movable_2d::IsMovable2D;
392
393mod is_movable_3d;
394pub use self::is_movable_3d::IsMovable3D;
395
396mod is_normalized_2d;
397pub use self::is_normalized_2d::IsNormalized2D;
398
399mod is_normalized_3d;
400pub use self::is_normalized_3d::IsNormalized3D;
401
402mod is_oc_tree;
403pub use self::is_oc_tree::IsOcTree;
404
405mod is_plane_3d;
406pub use self::is_plane_3d::IsPlane3D;
407
408mod is_polygon;
409pub use self::is_polygon::IsPolygon;
410
411mod is_tree_3d;
412pub use self::is_tree_3d::IsTree3D;
413
414mod is_voxel_image;
415pub use self::is_voxel_image::IsVoxelImage;
416
417mod is_transformable_to_2d;
418pub use self::is_transformable_to_2d::IsTransFormableTo2D;
419
420mod is_transformable_to_3d;
421pub use self::is_transformable_to_3d::IsTransFormableTo3D;
422
423mod is_filter;
424pub use self::is_filter::IsFilter;
425
426mod is_filter_random_accessible;
427pub use self::is_filter_random_accessible::IsFilterRandomAccessible;
428
429mod is_scalable;
430pub use self::is_scalable::IsScalable;
431
432mod is_view_buildable;
433pub use self::is_view_buildable::IsViewBuildable;
434
435mod is_nd;
436pub use self::is_nd::IsND;
437
438mod is_sortable_nd;
439pub use self::is_sortable_nd::IsSortableND;
440
441mod is_sortable_2d;
442pub use self::is_sortable_2d::IsSortable2D;
443
444mod is_sortable_3d;
445pub use self::is_sortable_3d::IsSortable3D;
446
447mod is_mergeable;
448pub use self::is_mergeable::IsMergeable;
449
450mod has_distance_to;
451pub use self::has_distance_to::HasDistanceTo;
452
453mod is_direction_field_2d;
454pub use self::is_direction_field_2d::IsDirectionField2D;
455
456mod is_direction_field_3d;
457pub use self::is_direction_field_3d::IsDirectionField3D;
458
459mod is_sat_object;
460pub use self::is_sat_object::IsSATObject;
461
462mod has_colliders_3d;
463pub use self::has_colliders_3d::HasColliders3D;
464
465mod is_collider_container_3d;
466pub use self::is_collider_container_3d::IsColliderContainer3D;
467
468mod filter_all_random_accessible;
469pub use self::filter_all_random_accessible::FilterAllRandomAccessible;
470
471mod filter_any_random_accessible;
472pub use self::filter_any_random_accessible::FilterAnyRandomAccessible;
473
474mod filter_all;
475pub use self::filter_all::FilterAll;
476
477mod filter_any;
478pub use self::filter_any::FilterAny;
479
480mod filter_negate;
481pub use self::filter_negate::FilterNegate;
482
483mod filter_and;
484pub use self::filter_and::FilterAND;
485
486mod filter_or;
487pub use self::filter_or::FilterOR;
488
489mod filter_xor;
490pub use self::filter_xor::FilterXOR;
491
492mod filter_outer_inner;
493pub use self::filter_outer_inner::FilterOuterInner;
494
495mod filter_allow;
496pub use self::filter_allow::FilterAllow;
497
498mod filter_deny;
499pub use self::filter_deny::FilterDeny;
500
501mod filter_random_accessible;
502pub use self::filter_random_accessible::FilterRandomAccessible;
503
504mod filter_direction_field_2d;
505pub use self::filter_direction_field_2d::FilterDirectionField2D;
506
507mod filter_direction_field_3d;
508pub use self::filter_direction_field_3d::FilterDirectionField3D;
509
510mod filter_box_2d;
511pub use self::filter_box_2d::FilterBox2D;
512
513mod filter_box_3d;
514pub use self::filter_box_3d::FilterBox3D;
515
516mod filter_circle;
517pub use self::filter_circle::FilterCircle;
518
519mod filter_sphere;
520pub use self::filter_sphere::FilterSphere;
521
522mod filter_outlier_3d;
523pub use self::filter_outlier_3d::FilterOutlier3D;
524
525mod is_index_container;
526pub use self::is_index_container::{IsIndexContainer, IsIndexContainerIterator};
527
528mod dynamic_precision_index_vec;
529pub use self::dynamic_precision_index_vec::DynamicPrecisionIndexVec;
530
531mod u32_index_vec;
532pub use self::u32_index_vec::U32IndexVec;
533
534mod is_data_container;
535pub use self::is_data_container::IsDataContainer;
536
537mod skip_empty_string;
538pub use self::skip_empty_string::*;
539
540mod skip_empty;
541pub use self::skip_empty::*;