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
//! Entities of a type *including its subtypes*.
//!
//! [`Model::ids_of_type`] is exact-type only: asking for `IfcElement` returns
//! nothing, because no instance is ever declared as the abstract supertype.
//! The inheritance tree lives in the schema, and ADR 0003 forbids
//! `ifc-model` and `ifc-schema` from depending on each other, so the join is
//! made here in the orchestration layer.
//!
//! # The caller supplies the schema
//!
//! The subtype tree differs between versions (`IfcBuiltElement` exists only
//! in IFC4X3), so the answer depends on which schema the file uses. This
//! module does not guess it from the header. A file whose header is missing
//! or wrong would otherwise be queried against a silently substituted tree.
//! Resolve the schema once, for example with
//! [`crate::SchemaVersion::from_header_token`] and
//! [`crate::schema::for_version`], and pass it in:
//!
//! ```
//! let model = ifc::Model::new();
//! let schema = ifc::schema::ifc4();
//! let elements = ifc::ids_of_type_including_subtypes(&model, schema, "IfcElement");
//! assert!(elements.is_empty());
//! ```
use ;
use Schema;
/// Ids of every entity whose type is `type_name` or any subtype of it.
///
/// Results are in the file's original order, the same order
/// [`Model::ids`] yields, so the output is deterministic and diffable.
///
/// Returns an empty list when `schema` does not declare `type_name`. An
/// undeclared name is not treated as its own exact type: a misspelled query
/// such as `IfcWal` should find nothing rather than silently match nothing
/// for a different reason.
///
/// # Cost
///
/// One exact-type index lookup per type in the subtree, then a sort of the
/// matched ids by file position. The subtree for `IfcElement` in IFC4X3 is
/// about 120 types, nearly all of which are absent from a typical file and
/// cost a hash miss.