mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-27 10:51:13 +00:00
Add coments
This commit is contained in:
@@ -369,11 +369,12 @@ void ColladaSerializer::ColladaExporter::endDocument() {
|
|||||||
// In fact due the XML based nature of Collada and its dependency on library nodes,
|
// In fact due the XML based nature of Collada and its dependency on library nodes,
|
||||||
// only at this point all objects are written to the stream.
|
// only at this point all objects are written to the stream.
|
||||||
materials.write();
|
materials.write();
|
||||||
|
bool use_hierarchy = serializer->settings().get(SerializerSettings::USE_ELEMENT_HIERARCHY);
|
||||||
|
|
||||||
std::set<std::string> geometries_written;
|
std::set<std::string> geometries_written;
|
||||||
|
|
||||||
//if the setting USE_ELEMENT_HIERARCHY is in use, we sort the deferreds objects by their parents.
|
//if the setting USE_ELEMENT_HIERARCHY is in use, we sort the deferreds objects by their parents.
|
||||||
if (serializer->settings().get(SerializerSettings::USE_ELEMENT_HIERARCHY)) {
|
if (use_hierarchy) {
|
||||||
std::sort(deferreds.begin(), deferreds.end());
|
std::sort(deferreds.begin(), deferreds.end());
|
||||||
}
|
}
|
||||||
for (std::vector<DeferredObject>::const_iterator it = deferreds.begin(); it != deferreds.end(); ++it) {
|
for (std::vector<DeferredObject>::const_iterator it = deferreds.begin(); it != deferreds.end(); ++it) {
|
||||||
@@ -386,22 +387,23 @@ void ColladaSerializer::ColladaExporter::endDocument() {
|
|||||||
geometries.close();
|
geometries.close();
|
||||||
|
|
||||||
int parent_id = -1;
|
int parent_id = -1;
|
||||||
bool is_parent_empty = true;
|
bool is_parent_tag_opened = false;
|
||||||
for (std::vector<DeferredObject>::const_iterator it = deferreds.begin(); it != deferreds.end(); ++it){
|
for (std::vector<DeferredObject>::const_iterator it = deferreds.begin(); it != deferreds.end(); ++it){
|
||||||
const std::string object_name = it->unique_id;
|
const std::string object_name = it->unique_id;
|
||||||
|
|
||||||
//if the setting USE_ELEMENT_HIERARCHY is in use, we check if the parent has changed
|
// if the setting USE_ELEMENT_HIERARCHY is used
|
||||||
if (serializer->settings().get(SerializerSettings::USE_ELEMENT_HIERARCHY) && ((it->parent == NULL && parent_id != -1) || (it->parent != NULL && parent_id != it->parent->id()))){
|
// And if "it" has not parent AND a parent node is opened, OR it has a parent AND another parent node is opened
|
||||||
|
if (use_hierarchy && ((it->parent == NULL && parent_id != -1) || (it->parent != NULL && parent_id != it->parent->id())))
|
||||||
//close the parent tag, if one is already open.
|
{
|
||||||
if (!is_parent_empty){
|
//close the parent tag if one is already open.
|
||||||
|
if (is_parent_tag_opened){
|
||||||
scene.closeParent();
|
scene.closeParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (it->parent != NULL){
|
if (it->parent != NULL){
|
||||||
parent_id = it->parent->id();
|
parent_id = it->parent->id();
|
||||||
scene.addParent(*it->parent);
|
scene.addParent(*it->parent);
|
||||||
is_parent_empty = false;
|
is_parent_tag_opened = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -409,7 +411,7 @@ void ColladaSerializer::ColladaExporter::endDocument() {
|
|||||||
scene.add(object_name, object_name, it->representation_id, it->material_references, it->matrix);
|
scene.add(object_name, object_name, it->representation_id, it->material_references, it->matrix);
|
||||||
}
|
}
|
||||||
//close the last parent tag.
|
//close the last parent tag.
|
||||||
if (!is_parent_empty) {
|
if (is_parent_tag_opened) {
|
||||||
scene.closeParent();
|
scene.closeParent();
|
||||||
};
|
};
|
||||||
scene.write();
|
scene.write();
|
||||||
|
|||||||
Reference in New Issue
Block a user