mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-14 19:34:34 +00:00
Experimental get_inverse_cardinality proposal. See #1904.
This commit is contained in:
committed by
Thomas Krijnen
parent
d1caa3242f
commit
cef1c86f6d
@@ -249,6 +249,7 @@ public:
|
||||
aggregate_of_instance::ptr traverse_breadth_first(IfcUtil::IfcBaseClass* instance, int max_level=-1);
|
||||
|
||||
aggregate_of_instance::ptr getInverse(int instance_id, const IfcParse::declaration* type, int attribute_index);
|
||||
int getInverseCardinality(int instance_id);
|
||||
|
||||
template <class T>
|
||||
typename T::list::ptr getInverse(int instance_id, int attribute_index) {
|
||||
|
||||
@@ -2387,6 +2387,25 @@ aggregate_of_instance::ptr IfcFile::getInverse(int instance_id, const IfcParse::
|
||||
return return_value;
|
||||
}
|
||||
|
||||
|
||||
int IfcFile::getInverseCardinality(int instance_id) {
|
||||
auto lower = byref_excl.lower_bound({ instance_id,-1,-1 });
|
||||
auto upper = byref_excl.upper_bound({ instance_id, std::numeric_limits<int>::max(), std::numeric_limits<int>::max() });
|
||||
|
||||
int total_references = 0;
|
||||
for (auto it = lower; it != upper; it++) {
|
||||
for (auto& i : it->second) {
|
||||
total_references++;
|
||||
if (total_references > 1) {
|
||||
return total_references;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return total_references;
|
||||
}
|
||||
|
||||
|
||||
void IfcFile::setDefaultHeaderValues() {
|
||||
const std::string empty_string = "";
|
||||
std::vector<std::string> file_description, schema_identifiers, empty_vector;
|
||||
|
||||
Reference in New Issue
Block a user