1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
/*
Copyright 2016 Martin Buck

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall
be included all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#![deny(warnings)]

//! rust-3d
//! =======
//! 3D/2D library written in Rust.
//! Offering useful containers, structures and algorithms for 2D and 3D space.
//! Meant as basis for numeric algorithms, viewers, game engines, ...
//!
//! Migration 0.29.0 -> 0.30.0
//! --------------------------
//! Note that the module structure changed. There's now only submodules for `io` and `impls`.  
//! Also `prelude` was removed.  
//! If you were using the prelude via `rust_3d::prelude::*;` you should now be able to just switch to
//! `rust_3d::*;`.  
//! If you were using explicit paths such as `rust_3d::filters::combinators::FilterAll` you should now use `rust_3d::FilterAll`.  
//! Note that `io` and `impls` are still part of the module path.  
//! This should make future usage easier, but might be painful for existing users.  
//! Sorry `:(`
//!
//! Notes
//! -----
//! `rust-3d` is still in really early stages, there might come breaking changes with each update.
//! The test coverage is far from perfect, so you might find some bugs (please report them).
//! Compiling with `stable`.
//!
//!
//! Tour
//! ----
//! Here's a little overview of some of `rust-3d`'s features.
//! The snippets / names might not be up-to-date, so please check `tests/` for compiling examples.
//!
//!
//! ### Proper error handling
//! No `.unwrap()` where it's not 100% safe.
//!
//! ### Strong / Smart Types
//! There's strong types for everything that might get mixed up easily.
//! This way e.g. ids of faces can't be mistaken for ids of vertices.
//! ```rust,ignore
//! fn edges_of_face(&self, faceid: FId) -> Result<(EId, EId, EId)>;
//! ```
//! There's also smart types which restrict the values they can hold.
//! This way distances can never be `< 0.0`, sizes can be enfored to be `> 0.0` etc.
//! ```rust,ignore
//! Positive
//! NonNegative
//! ```
//!
//! ### Generic Code Base
//! I try and keep all algorithms and types as generic as possible.
//! - Even rather basic types like `Is2D` are split into several versions: `IsEditable2D`, `IsBuildable2D`
//! - `IsMesh` is defined for any vertex type and any number of vertices / face
//! - There's traits for collections (no need to use `Vec`)
//!
//! This makes it possible to require as little implementation work as possible if you want to use your own types.
//!
//!
//! ### Combinators / Transformers
//! - Any `IsFilter<T>` can be combined via `FilterAND`, `FilterOR`, `FilterAny`, `FilterNegate`...
//! - Any `IsFilter<T>` can be transformed to work for any collection of `T`s (`IsFilterRandomAccessible`).
//! - `IsDirectionField2D` might be transformed to an `IsFilter<Is2D>`, which can then be transformed to an `IsFilterRandomAccessible<Is2D>`.
//!
//!
//! ### IO
//! Any `IO` method is defined on traits, so if you implement these, you'll get read/write of different file formats for free.
//!
//!
//! Documentation
//! -------------
//! The documentation is quite good already, come and [take a look](https://docs.rs/rust-3d/).
//!
//!
//! Examples
//! --------
//! Please take a look at the tests in `tests/`. These will be up-to-date and compiling.
//! I might add extensive tutorials / examples / demo projects in the future.
//!
//!
//! Links
//! -----
//! [crates.io](https://crates.io/crates/rust-3d)
//! [github.com](https://github.com/I3ck/rust-3d)
//! [docs.rs](https://docs.rs/rust-3d/)
//!
//!
//! Contribute
//! ----------
//! Feel free to open an issue in case you're missing something or found a bug.
//! Please avoid directly contributing since I might be working on breaking changes or the feature you want to implement.
//! Open an issue or email me beforehand.
//!
//!
//! License
//! ------
//! MIT (see LICENSE)

pub mod io;

mod distances_2d;
pub use self::distances_2d::*;

mod distances_3d;
pub use self::distances_3d::*;

mod distances_nd;
pub use self::distances_nd::*;

mod factory_2d;
pub use self::factory_2d::*;

mod functions;
pub use self::functions::*;

mod impls;
pub use self::impls::*;

mod interpolate_2d;
pub use interpolate_2d::*;

pub mod test_helper;

mod utils;
pub use self::utils::*;

mod aa_bb_tree_2d;
pub use self::aa_bb_tree_2d::AABBTree2D;

mod strong_types;
pub use self::strong_types::*;

mod aa_bb_tree_3d;
pub use self::aa_bb_tree_3d::AABBTree3D;

mod point_2d;
pub use self::point_2d::Point2D;

mod point_3d;
pub use self::point_3d::Point3D;

mod line_2d;
pub use self::line_2d::Line2D;

mod line_3d;
pub use self::line_3d::Line3D;

mod line_segment_2d;
pub use self::line_segment_2d::LineSegment2D;

mod line_segment_3d;
pub use self::line_segment_3d::LineSegment3D;

mod ray_2d;
pub use self::ray_2d::Ray2D;

mod ray_3d;
pub use self::ray_3d::Ray3D;

mod plane_3d;
pub use self::plane_3d::Plane3D;

mod point_cloud_2d;
pub use self::point_cloud_2d::PointCloud2D;

mod point_cloud_3d;
pub use self::point_cloud_3d::PointCloud3D;

mod point_cloud_3d_f32;
pub use self::point_cloud_3d_f32::PointCloud3Df32;

mod polygon_2d;
pub use self::polygon_2d::Polygon2D;

mod polygon_3d;
pub use self::polygon_3d::Polygon3D;

mod norm_2d;
pub use self::norm_2d::Norm2D;

mod norm_3d;
pub use self::norm_3d::Norm3D;

mod bounding_box_2d;
pub use self::bounding_box_2d::BoundingBox2D;

mod bounding_box_3d;
pub use self::bounding_box_3d::BoundingBox3D;

mod matrix3;
pub use self::matrix3::Matrix3;

mod matrix4;
pub use self::matrix4::Matrix4;

mod matrix3_pipe;
pub use self::matrix3_pipe::Matrix3Pipe;

mod matrix4_pipe;
pub use self::matrix4_pipe::Matrix4Pipe;

mod compressed_point_3d;
pub use self::compressed_point_3d::CompressedPoint3D;

mod compressed_point_cloud_3d;
pub use self::compressed_point_cloud_3d::CompressedPointCloud3D;

mod kd_tree;
pub use self::kd_tree::KdTree;

mod mesh_3d;
pub use self::mesh_3d::Mesh3D;

mod searchable_mesh;
pub use self::searchable_mesh::SearchableMesh;

mod oc_tree;
pub use self::oc_tree::OcTree;

mod view;
pub use self::view::View;

mod positive;
pub use self::positive::Positive;

mod non_negative;
pub use self::non_negative::NonNegative;

mod result;
pub use self::result::*;

mod rgb;
pub use self::rgb::Rgb;

mod face3;
pub use self::face3::Face3;

mod half_edge;
pub use self::half_edge::HalfEdge;

mod enums;
pub use self::enums::*;

mod cluster;
pub use self::cluster::*;

mod sat_collider;
pub use self::sat_collider::*;

mod box_unaligned_3d;
pub use self::box_unaligned_3d::*;

mod tri_face_3d;
pub use self::tri_face_3d::*;

mod collider_3d;
pub use self::collider_3d::*;

mod convex_hull_2d;
pub use self::convex_hull_2d::convex_hull_2d;

mod douglas_peucker_2d;
pub use self::douglas_peucker_2d::douglas_peucker_2d;

pub mod subdivide;

mod unify_faces;
pub use self::unify_faces::unify_faces;

mod heal_mesh;
pub use self::heal_mesh::heal_mesh;

mod cluster_vertices;
pub use self::cluster_vertices::cluster_vertices;

mod circle;
pub use self::circle::Circle;

mod box_2d;
pub use self::box_2d::Box2D;

mod sphere;
pub use self::sphere::Sphere;

mod box_3d;
pub use self::box_3d::Box3D;

mod has_bounding_box_2d;
pub use self::has_bounding_box_2d::{
    HasBoundingBox2D, HasBoundingBox2DConverted, HasBoundingBox2DMaybe,
};

mod has_bounding_box_3d;
pub use self::has_bounding_box_3d::{
    HasBoundingBox3D, HasBoundingBox3DConverted, HasBoundingBox3DMaybe,
};

mod has_center_of_gravity_2d;
pub use self::has_center_of_gravity_2d::HasCenterOfGravity2D;

mod has_center_of_gravity_3d;
pub use self::has_center_of_gravity_3d::HasCenterOfGravity3D;

mod has_length;
pub use self::has_length::HasLength;

mod is_editable_2d;
pub use self::is_editable_2d::IsEditable2D;

mod is_editable_3d;
pub use self::is_editable_3d::IsEditable3D;

mod is_editable_nd;
pub use self::is_editable_nd::IsEditableND;

mod is_editable_polygon;
pub use self::is_editable_polygon::IsEditablePolygon;

mod is_buildable_2d;
pub use self::is_buildable_2d::IsBuildable2D;

mod is_buildable_3d;
pub use self::is_buildable_3d::IsBuildable3D;

mod is_buildable_nd;
pub use self::is_buildable_nd::IsBuildableND;

mod is_2d;
pub use self::is_2d::Is2D;

mod is_3d;
pub use self::is_3d::Is3D;

mod is_random_accessible;
pub use self::is_random_accessible::IsRandomAccessible;

mod is_random_insertible;
pub use self::is_random_insertible::IsRandomInsertible;

mod is_pushable;
pub use self::is_pushable::IsPushable;

mod is_face_editable_mesh;
pub use self::is_face_editable_mesh::IsFaceEditableMesh;

mod is_vertex_editable_mesh;
pub use self::is_vertex_editable_mesh::IsVertexEditableMesh;

mod is_k_nearest_searchable;
pub use self::is_k_nearest_searchable::IsKNearestSearchable;

mod is_matrix3_transformable;
pub use self::is_matrix3_transformable::IsMatrix3Transformable;

mod is_matrix4_transformable;
pub use self::is_matrix4_transformable::IsMatrix4Transformable;

mod is_sphere_searchable;
pub use self::is_sphere_searchable::IsSphereSearchable;

mod is_box_3d_searchable;
pub use self::is_box_3d_searchable::IsBox3DSearchable;

mod is_mesh;
pub use self::is_mesh::IsMesh;

mod is_mesh_3d;
pub use self::is_mesh_3d::IsMesh3D;

mod is_topology_unit;
pub use self::is_topology_unit::IsTopologyUnit;

mod is_searchable_mesh;
pub use self::is_searchable_mesh::IsSearchableMesh;

mod is_movable_2d;
pub use self::is_movable_2d::IsMovable2D;

mod is_movable_3d;
pub use self::is_movable_3d::IsMovable3D;

mod is_normalized_2d;
pub use self::is_normalized_2d::IsNormalized2D;

mod is_normalized_3d;
pub use self::is_normalized_3d::IsNormalized3D;

mod is_oc_tree;
pub use self::is_oc_tree::IsOcTree;

mod is_plane_3d;
pub use self::is_plane_3d::IsPlane3D;

mod is_polygon;
pub use self::is_polygon::IsPolygon;

mod is_projection_to_plane;
pub use self::is_projection_to_plane::IsProjectionToPlane;

mod is_tree_3d;
pub use self::is_tree_3d::IsTree3D;

mod is_voxel_image;
pub use self::is_voxel_image::IsVoxelImage;

mod is_transformable_to_2d;
pub use self::is_transformable_to_2d::IsTransFormableTo2D;

mod is_transformable_to_3d;
pub use self::is_transformable_to_3d::IsTransFormableTo3D;

mod is_filter;
pub use self::is_filter::IsFilter;

mod is_filter_random_accessible;
pub use self::is_filter_random_accessible::IsFilterRandomAccessible;

mod is_scalable;
pub use self::is_scalable::IsScalable;

mod is_view_buildable;
pub use self::is_view_buildable::IsViewBuildable;

mod is_nd;
pub use self::is_nd::IsND;

mod is_sortable_nd;
pub use self::is_sortable_nd::IsSortableND;

mod is_sortable_2d;
pub use self::is_sortable_2d::IsSortable2D;

mod is_sortable_3d;
pub use self::is_sortable_3d::IsSortable3D;

mod is_mergeable;
pub use self::is_mergeable::IsMergeable;

mod has_distance_to;
pub use self::has_distance_to::HasDistanceTo;

mod is_direction_field_2d;
pub use self::is_direction_field_2d::IsDirectionField2D;

mod is_direction_field_3d;
pub use self::is_direction_field_3d::IsDirectionField3D;

mod is_sat_object;
pub use self::is_sat_object::IsSATObject;

mod has_colliders_3d;
pub use self::has_colliders_3d::HasColliders3D;

mod is_collider_container_3d;
pub use self::is_collider_container_3d::IsColliderContainer3D;

mod filter_all_random_accessible;
pub use self::filter_all_random_accessible::FilterAllRandomAccessible;

mod filter_any_random_accessible;
pub use self::filter_any_random_accessible::FilterAnyRandomAccessible;

mod filter_all;
pub use self::filter_all::FilterAll;

mod filter_any;
pub use self::filter_any::FilterAny;

mod filter_negate;
pub use self::filter_negate::FilterNegate;

mod filter_and;
pub use self::filter_and::FilterAND;

mod filter_or;
pub use self::filter_or::FilterOR;

mod filter_xor;
pub use self::filter_xor::FilterXOR;

mod filter_outer_inner;
pub use self::filter_outer_inner::FilterOuterInner;

mod filter_allow;
pub use self::filter_allow::FilterAllow;

mod filter_deny;
pub use self::filter_deny::FilterDeny;

mod filter_random_accessible;
pub use self::filter_random_accessible::FilterRandomAccessible;

mod filter_direction_field_2d;
pub use self::filter_direction_field_2d::FilterDirectionField2D;

mod filter_direction_field_3d;
pub use self::filter_direction_field_3d::FilterDirectionField3D;

mod filter_box_2d;
pub use self::filter_box_2d::FilterBox2D;

mod filter_box_3d;
pub use self::filter_box_3d::FilterBox3D;

mod filter_circle;
pub use self::filter_circle::FilterCircle;

mod filter_sphere;
pub use self::filter_sphere::FilterSphere;

mod filter_outlier_3d;
pub use self::filter_outlier_3d::FilterOutlier3D;

mod is_index_container;
pub use self::is_index_container::{IsIndexContainer, IsIndexContainerIterator};

mod dynamic_precision_index_vec;
pub use self::dynamic_precision_index_vec::DynamicPrecisionIndexVec;

mod u32_index_vec;
pub use self::u32_index_vec::U32IndexVec;

mod is_data_container;
pub use self::is_data_container::IsDataContainer;

mod skip_empty_string;
pub use self::skip_empty_string::*;

mod skip_empty;
pub use self::skip_empty::*;