MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / fix_quantities

Function fix_quantities

src/ifcconvert/IfcConvert.cpp:1536–1739  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1534}
1535
1536void fix_quantities(IfcParse::IfcFile& f, bool no_progress, bool quiet, bool stderr_progress) {
1537 {
1538 auto delete_reversed = [&f](const aggregate_of_instance::ptr& insts) {
1539 if (!insts) {
1540 return;
1541 }
1542 // Lists are traversed back to front as the list may be mutated when
1543 // instances are removed from the grouping by type.
1544 for (auto it = insts->end() - 1; it >= insts->begin(); --it) {
1545 IfcUtil::IfcBaseClass* const inst = *it;
1546 f.removeEntity(inst);
1547 }
1548 };
1549
1550 // Delete quantities
1551 auto quantities = f.instances_by_type("IfcPhysicalQuantity");
1552 if (quantities) {
1553 quantities = quantities->filtered({ f.schema()->declaration_by_name("IfcPhysicalComplexQuantity") });
1554 delete_reversed(quantities);
1555 }
1556
1557 // Delete complexes
1558 delete_reversed(f.instances_by_type("IfcPhysicalComplexQuantity"));
1559
1560 auto element_quantities = f.instances_by_type("IfcElementQuantity");
1561
1562 // Capture relationship nodes
1563 std::vector<IfcUtil::IfcBaseClass*> relationships;
1564 auto IfcRelDefinesByProperties = f.schema()->declaration_by_name("IfcRelDefinesByProperties");
1565 if (element_quantities) {
1566 for (auto& eq : *element_quantities) {
1567 auto rels = eq->file_->getInverse(eq->id(), IfcRelDefinesByProperties, -1);
1568 for (auto& rel : *rels) {
1569 relationships.push_back(rel);
1570 }
1571 }
1572
1573 // Delete element quantities
1574 delete_reversed(element_quantities);
1575 }
1576
1577
1578 // Delete relationship nodes
1579 for (auto& rel : relationships) {
1580 f.removeEntity(rel);
1581 }
1582 }
1583
1584 ifcopenshell::geometry::Settings settings;
1585 settings.get<ifcopenshell::geometry::settings::UseWorldCoords>().value = false;
1586 settings.get<ifcopenshell::geometry::settings::WeldVertices>().value = false;
1587 settings.get<ifcopenshell::geometry::settings::ReorientShells>().value = true;
1588 settings.get<ifcopenshell::geometry::settings::ConvertBackUnits>().value = true;
1589 settings.get<ifcopenshell::geometry::settings::IteratorOutput>().value = ifcopenshell::geometry::settings::NATIVE;
1590
1591 IfcGeom::Iterator context_iterator(ifcopenshell::geometry::kernels::construct(&f, "opencascade", settings), settings, &f, {}, 1);
1592
1593 if (!context_iterator.initialize()) {

Callers 1

IfcConvert.cppFile · 0.85

Calls 15

constructFunction · 0.85
StatusClass · 0.85
removeEntityMethod · 0.80
instances_by_typeMethod · 0.80
filteredMethod · 0.80
getInverseMethod · 0.80
push_backMethod · 0.80
productMethod · 0.80
calculate_volumeMethod · 0.80
createFunction · 0.70
setFunction · 0.70

Tested by

no test coverage detected