mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 06:58:56 +00:00
Hierarchy v1
This commit is contained in:
@@ -220,6 +220,24 @@ void ColladaSerializer::ColladaExporter::ColladaScene::add(
|
|||||||
node.end();
|
node.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ColladaSerializer::ColladaExporter::ColladaScene::addParent(const std::string& node_name){
|
||||||
|
|
||||||
|
if (!scene_opened) {
|
||||||
|
openVisualScene(scene_id);
|
||||||
|
scene_opened = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
current_node = new COLLADASW::Node(mSW);
|
||||||
|
current_node->setNodeId(node_name);
|
||||||
|
current_node->setNodeName(node_name);
|
||||||
|
current_node->setType(COLLADASW::Node::NODE);
|
||||||
|
current_node->start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColladaSerializer::ColladaExporter::ColladaScene::closeParent(){
|
||||||
|
current_node->end();
|
||||||
|
}
|
||||||
|
|
||||||
void ColladaSerializer::ColladaExporter::ColladaScene::write() {
|
void ColladaSerializer::ColladaExporter::ColladaScene::write() {
|
||||||
if (scene_opened) {
|
if (scene_opened) {
|
||||||
closeVisualScene();
|
closeVisualScene();
|
||||||
@@ -361,12 +379,25 @@ void ColladaSerializer::ColladaExporter::endDocument() {
|
|||||||
geometries.write(it->representation_id, it->type, it->vertices, it->normals, it->faces, it->edges, it->material_ids, it->materials, it->uvs);
|
geometries.write(it->representation_id, it->type, it->vertices, it->normals, it->faces, it->edges, it->material_ids, it->materials, it->uvs);
|
||||||
}
|
}
|
||||||
geometries.close();
|
geometries.close();
|
||||||
|
std::string parent_name;
|
||||||
|
bool is_parent_empty = true;
|
||||||
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 (parent_name != it->parent){
|
||||||
|
if (!is_parent_empty){
|
||||||
|
scene.closeParent();
|
||||||
|
}
|
||||||
|
parent_name = it->parent;
|
||||||
|
scene.addParent(parent_name);
|
||||||
|
is_parent_empty = false;
|
||||||
|
}
|
||||||
|
|
||||||
/// @todo redundant information using ID as both ID and Name, maybe omit Name or allow specifying what would be used as the name
|
/// @todo redundant information using ID as both ID and Name, maybe omit Name or allow specifying what would be used as the name
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scene.closeParent();
|
||||||
scene.write();
|
scene.write();
|
||||||
stream.endDocument();
|
stream.endDocument();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
#pragma GCC diagnostic ignored "-Wignored-qualifiers"
|
#pragma GCC diagnostic ignored "-Wignored-qualifiers"
|
||||||
#endif
|
#endif
|
||||||
#include <COLLADASWStreamWriter.h>
|
#include <COLLADASWStreamWriter.h>
|
||||||
|
#include <COLLADASWNode.h>
|
||||||
#include <COLLADASWLibraryGeometries.h>
|
#include <COLLADASWLibraryGeometries.h>
|
||||||
#include <COLLADASWLibraryVisualScenes.h>
|
#include <COLLADASWLibraryVisualScenes.h>
|
||||||
#include <COLLADASWLibraryEffects.h>
|
#include <COLLADASWLibraryEffects.h>
|
||||||
@@ -78,6 +79,7 @@ private:
|
|||||||
|
|
||||||
const std::string scene_id;
|
const std::string scene_id;
|
||||||
bool scene_opened;
|
bool scene_opened;
|
||||||
|
COLLADASW::Node *current_node;
|
||||||
public:
|
public:
|
||||||
ColladaScene(const std::string& scene_id, COLLADASW::StreamWriter& stream, ColladaSerializer *_serializer)
|
ColladaScene(const std::string& scene_id, COLLADASW::StreamWriter& stream, ColladaSerializer *_serializer)
|
||||||
: COLLADASW::LibraryVisualScenes(&stream)
|
: COLLADASW::LibraryVisualScenes(&stream)
|
||||||
@@ -87,6 +89,8 @@ private:
|
|||||||
{}
|
{}
|
||||||
void add(const std::string& node_id, const std::string& node_name, const std::string& geom_name,
|
void add(const std::string& node_id, const std::string& node_name, const std::string& geom_name,
|
||||||
const std::vector<std::string>& material_ids, const std::vector<real_t>& matrix);
|
const std::vector<std::string>& material_ids, const std::vector<real_t>& matrix);
|
||||||
|
void addParent(const std::string& node_name);
|
||||||
|
void closeParent();
|
||||||
void write();
|
void write();
|
||||||
ColladaSerializer *serializer;
|
ColladaSerializer *serializer;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user