mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 18:43:26 +00:00
Detect units from project libraries, and convert nested double aggregates
This commit is contained in:
committed by
Thomas Krijnen
parent
1187ad5fea
commit
cb4001b47b
@@ -1744,6 +1744,18 @@ IfcUtil::IfcBaseClass* IfcFile::addEntity(IfcUtil::IfcBaseClass* entity, int id)
|
||||
(*it) *= conversion_factor;
|
||||
}
|
||||
|
||||
IfcWrite::IfcWriteArgument* copy = new IfcWrite::IfcWriteArgument();
|
||||
copy->set(v);
|
||||
we->setArgument(i, copy);
|
||||
} else if (attr_type == IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_DOUBLE) {
|
||||
std::vector<std::vector<double>> v = *attr;
|
||||
for (std::vector<std::vector<double>>::iterator it = v.begin(); it != v.end(); ++it) {
|
||||
std::vector<double>& v2 = (*it);
|
||||
for (std::vector<double>::iterator jt = v2.begin(); jt != v2.end(); ++jt) {
|
||||
(*jt) *= conversion_factor;
|
||||
}
|
||||
}
|
||||
|
||||
IfcWrite::IfcWriteArgument* copy = new IfcWrite::IfcWriteArgument();
|
||||
copy->set(v);
|
||||
we->setArgument(i, copy);
|
||||
@@ -2247,6 +2259,11 @@ void IfcFile::setDefaultHeaderValues() {
|
||||
std::pair<IfcUtil::IfcBaseClass*, double> IfcFile::getUnit(const std::string& unit_type) {
|
||||
std::pair<IfcUtil::IfcBaseClass*, double> return_value(0, 1.);
|
||||
IfcEntityList::ptr projects = instances_by_type(schema()->declaration_by_name("IfcProject"));
|
||||
if ( ! projects) {
|
||||
try {
|
||||
projects = instances_by_type(schema()->declaration_by_name("IfcContext"));
|
||||
} catch ( IfcException& e ) {}
|
||||
}
|
||||
|
||||
if (projects && projects->size() == 1) {
|
||||
IfcUtil::IfcBaseClass* project = *projects->begin();
|
||||
|
||||
Reference in New Issue
Block a user