mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-17 14:02:27 +00:00
BaseQuantities support in IfcConvert XmlSerializer
Added the export of BaseQuantities in the XML export of IfcConvert. Very similar to the export of properties.
This commit is contained in:
@@ -258,6 +258,9 @@ ptree& descend(IfcObjectDefinition* product, ptree& tree) {
|
|||||||
if (pset->is(Type::IfcPropertySet)) {
|
if (pset->is(Type::IfcPropertySet)) {
|
||||||
format_entity_instance(pset, child, true);
|
format_entity_instance(pset, child, true);
|
||||||
}
|
}
|
||||||
|
if (pset->is(Type::IfcElementQuantity)) {
|
||||||
|
format_entity_instance(pset, child, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_IFC4
|
#ifdef USE_IFC4
|
||||||
@@ -314,6 +317,14 @@ void format_properties(IfcProperty::list::ptr properties, ptree& node) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Format IfcElementQuantity instances and insert into the DOM.
|
||||||
|
void format_quantities(IfcPhysicalQuantity::list::ptr quantities, ptree& node) {
|
||||||
|
for (IfcPhysicalQuantity::list::it it = quantities->begin(); it != quantities->end(); ++it) {
|
||||||
|
IfcPhysicalQuantity* p = *it;
|
||||||
|
format_entity_instance(p, node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // ~unnamed namespace
|
} // ~unnamed namespace
|
||||||
|
|
||||||
void XmlSerializer::finalize() {
|
void XmlSerializer::finalize() {
|
||||||
@@ -326,7 +337,7 @@ void XmlSerializer::finalize() {
|
|||||||
}
|
}
|
||||||
IfcProject* project = *projects->begin();
|
IfcProject* project = *projects->begin();
|
||||||
|
|
||||||
ptree root, header, units, decomposition, properties, types, layers, materials;
|
ptree root, header, units, decomposition, properties, quantities, types, layers, materials;
|
||||||
|
|
||||||
// Write the SPF header as XML nodes.
|
// Write the SPF header as XML nodes.
|
||||||
foreach(const std::string& s, file->header().file_description().description()) {
|
foreach(const std::string& s, file->header().file_description().description()) {
|
||||||
@@ -359,6 +370,15 @@ void XmlSerializer::finalize() {
|
|||||||
format_properties(pset->HasProperties(), node);
|
format_properties(pset->HasProperties(), node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Write all quantities and values as XML nodes.
|
||||||
|
IfcElementQuantity::list::ptr qtosets = file->entitiesByType<IfcElementQuantity>();
|
||||||
|
for (IfcElementQuantity::list::it it = qtosets->begin(); it != qtosets->end(); ++it) {
|
||||||
|
IfcElementQuantity* qto = *it;
|
||||||
|
ptree& node = format_entity_instance(qto, quantities);
|
||||||
|
format_quantities(qto->Quantities(), node);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Write all type objects as XML nodes.
|
// Write all type objects as XML nodes.
|
||||||
IfcTypeObject::list::ptr type_objects = file->entitiesByType<IfcTypeObject>();
|
IfcTypeObject::list::ptr type_objects = file->entitiesByType<IfcTypeObject>();
|
||||||
for (IfcTypeObject::list::it it = type_objects->begin(); it != type_objects->end(); ++it) {
|
for (IfcTypeObject::list::it it = type_objects->begin(); it != type_objects->end(); ++it) {
|
||||||
@@ -439,8 +459,9 @@ void XmlSerializer::finalize() {
|
|||||||
root.add_child("ifc.header", header);
|
root.add_child("ifc.header", header);
|
||||||
root.add_child("ifc.units", units);
|
root.add_child("ifc.units", units);
|
||||||
root.add_child("ifc.properties", properties);
|
root.add_child("ifc.properties", properties);
|
||||||
|
root.add_child("ifc.quantities", quantities);
|
||||||
root.add_child("ifc.types", types);
|
root.add_child("ifc.types", types);
|
||||||
root.add_child("ifc.layers", layers);
|
root.add_child("ifc.layers", layers);
|
||||||
root.add_child("ifc.materials", materials);
|
root.add_child("ifc.materials", materials);
|
||||||
root.add_child("ifc.decomposition", decomposition);
|
root.add_child("ifc.decomposition", decomposition);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user