mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-13 02:47:48 +00:00
Hierarchy v1
This commit is contained in:
@@ -220,6 +220,24 @@ void ColladaSerializer::ColladaExporter::ColladaScene::add(
|
||||
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() {
|
||||
if (scene_opened) {
|
||||
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.close();
|
||||
std::string parent_name;
|
||||
bool is_parent_empty = true;
|
||||
for (std::vector<DeferredObject>::const_iterator it = deferreds.begin(); it != deferreds.end(); ++it) {
|
||||
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
|
||||
scene.add(object_name, object_name, it->representation_id, it->material_references, it->matrix);
|
||||
}
|
||||
|
||||
scene.closeParent();
|
||||
scene.write();
|
||||
stream.endDocument();
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#pragma GCC diagnostic ignored "-Wignored-qualifiers"
|
||||
#endif
|
||||
#include <COLLADASWStreamWriter.h>
|
||||
#include <COLLADASWNode.h>
|
||||
#include <COLLADASWLibraryGeometries.h>
|
||||
#include <COLLADASWLibraryVisualScenes.h>
|
||||
#include <COLLADASWLibraryEffects.h>
|
||||
@@ -78,6 +79,7 @@ private:
|
||||
|
||||
const std::string scene_id;
|
||||
bool scene_opened;
|
||||
COLLADASW::Node *current_node;
|
||||
public:
|
||||
ColladaScene(const std::string& scene_id, COLLADASW::StreamWriter& stream, ColladaSerializer *_serializer)
|
||||
: 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,
|
||||
const std::vector<std::string>& material_ids, const std::vector<real_t>& matrix);
|
||||
void addParent(const std::string& node_name);
|
||||
void closeParent();
|
||||
void write();
|
||||
ColladaSerializer *serializer;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user