mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 06:39:13 +00:00
Options added : --use-element-types and --use-element-hierarchy
This commit is contained in:
@@ -235,7 +235,7 @@ void ColladaSerializer::ColladaExporter::ColladaScene::addParent(const std::stri
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ColladaSerializer::ColladaExporter::ColladaScene::closeParent(){
|
void ColladaSerializer::ColladaExporter::ColladaScene::closeParent(){
|
||||||
current_node->end();
|
if (current_node != NULL) { current_node->end(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColladaSerializer::ColladaExporter::ColladaScene::write() {
|
void ColladaSerializer::ColladaExporter::ColladaScene::write() {
|
||||||
@@ -323,7 +323,8 @@ void ColladaSerializer::ColladaExporter::write(const IfcGeom::TriangulationEleme
|
|||||||
{
|
{
|
||||||
const IfcGeom::Representation::Triangulation<real_t>& mesh = o->geometry();
|
const IfcGeom::Representation::Triangulation<real_t>& mesh = o->geometry();
|
||||||
const std::string name = serializer->settings().get(SerializerSettings::USE_ELEMENT_GUIDS) ?
|
const std::string name = serializer->settings().get(SerializerSettings::USE_ELEMENT_GUIDS) ?
|
||||||
o->guid() : (serializer->settings().get(SerializerSettings::USE_ELEMENT_NAMES) ? o->name() : (o->type() + o->unique_id()));
|
o->guid() : (serializer->settings().get(SerializerSettings::USE_ELEMENT_NAMES) ?
|
||||||
|
o->name() : (serializer->settings().get(SerializerSettings::USE_ELEMENT_TYPES) ? o->type() + "_" + o->name() : o->unique_id()));
|
||||||
const std::string representation_id = "representation-" + boost::lexical_cast<std::string>(o->geometry().id());
|
const std::string representation_id = "representation-" + boost::lexical_cast<std::string>(o->geometry().id());
|
||||||
std::vector<std::string> material_references;
|
std::vector<std::string> material_references;
|
||||||
foreach(const IfcGeom::Material& material, mesh.materials()) {
|
foreach(const IfcGeom::Material& material, mesh.materials()) {
|
||||||
@@ -346,7 +347,8 @@ void ColladaSerializer::ColladaExporter::write(const IfcGeom::TriangulationEleme
|
|||||||
{
|
{
|
||||||
const IfcGeom::Representation::Triangulation<real_t>& mesh = o->geometry();
|
const IfcGeom::Representation::Triangulation<real_t>& mesh = o->geometry();
|
||||||
const std::string name = serializer->settings().get(SerializerSettings::USE_ELEMENT_GUIDS) ?
|
const std::string name = serializer->settings().get(SerializerSettings::USE_ELEMENT_GUIDS) ?
|
||||||
o->guid() : (serializer->settings().get(SerializerSettings::USE_ELEMENT_NAMES) ? o->name() : (o->type() + o->unique_id()));
|
o->guid() : (serializer->settings().get(SerializerSettings::USE_ELEMENT_NAMES) ?
|
||||||
|
o->name() : (serializer->settings().get(SerializerSettings::USE_ELEMENT_TYPES) ? o->type() + "_" + o->name() : o->unique_id()));
|
||||||
const std::string representation_id = "representation-" + boost::lexical_cast<std::string>(o->geometry().id());
|
const std::string representation_id = "representation-" + boost::lexical_cast<std::string>(o->geometry().id());
|
||||||
std::vector<std::string> material_references;
|
std::vector<std::string> material_references;
|
||||||
foreach(const IfcGeom::Material& material, mesh.materials()) {
|
foreach(const IfcGeom::Material& material, mesh.materials()) {
|
||||||
@@ -359,9 +361,11 @@ void ColladaSerializer::ColladaExporter::write(const IfcGeom::TriangulationEleme
|
|||||||
material_references.push_back(material_name);
|
material_references.push_back(material_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::string parent_name = (serializer->settings().get(SerializerSettings::USE_ELEMENT_HIERARCHY) ?
|
||||||
|
parent->name() : "");
|
||||||
deferreds.push_back(
|
deferreds.push_back(
|
||||||
DeferredObject(name, representation_id, o->type(), o->transformation().matrix().data(), mesh.verts(), mesh.normals(),
|
DeferredObject(name, representation_id, o->type(), o->transformation().matrix().data(), mesh.verts(), mesh.normals(),
|
||||||
mesh.faces(), mesh.edges(), mesh.material_ids(), mesh.materials(), material_references, mesh.uvs(), parent->name())
|
mesh.faces(), mesh.edges(), mesh.material_ids(), mesh.materials(), material_references, mesh.uvs(), parent_name)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -379,13 +383,15 @@ 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;
|
std::string parent_name = "";
|
||||||
bool is_parent_empty = true;
|
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 (parent_name != it->parent)
|
||||||
if (!is_parent_empty){
|
{
|
||||||
|
if (!is_parent_empty)
|
||||||
|
{
|
||||||
scene.closeParent();
|
scene.closeParent();
|
||||||
}
|
}
|
||||||
parent_name = it->parent;
|
parent_name = it->parent;
|
||||||
|
|||||||
@@ -43,8 +43,14 @@ public:
|
|||||||
/// Use material names instead of unique IDs for naming materials.
|
/// Use material names instead of unique IDs for naming materials.
|
||||||
/// Applicable for OBJ and DAE output.
|
/// Applicable for OBJ and DAE output.
|
||||||
USE_MATERIAL_NAMES = 1 << (IfcGeom::IteratorSettings::NUM_SETTINGS + 3),
|
USE_MATERIAL_NAMES = 1 << (IfcGeom::IteratorSettings::NUM_SETTINGS + 3),
|
||||||
|
/// Use element types and names instead of unique IDs for naming elements.
|
||||||
|
/// Applicable for DAE output.
|
||||||
|
USE_ELEMENT_TYPES = 1 << (IfcGeom::IteratorSettings::NUM_SETTINGS + 4),
|
||||||
|
/// Order the elements using their IfcBuildingStorey parent
|
||||||
|
/// Applicable for DAE output
|
||||||
|
USE_ELEMENT_HIERARCHY = 1 << (IfcGeom::IteratorSettings::NUM_SETTINGS + 5),
|
||||||
/// Number of different setting flags.
|
/// Number of different setting flags.
|
||||||
NUM_SETTINGS = 3
|
NUM_SETTINGS = 5
|
||||||
};
|
};
|
||||||
|
|
||||||
SerializerSettings()
|
SerializerSettings()
|
||||||
|
|||||||
@@ -267,6 +267,12 @@ int main(int argc, char** argv)
|
|||||||
("use-material-names",
|
("use-material-names",
|
||||||
"Use material names instead of unique IDs for naming materials upon serialization. "
|
"Use material names instead of unique IDs for naming materials upon serialization. "
|
||||||
"Applicable for OBJ and DAE output.")
|
"Applicable for OBJ and DAE output.")
|
||||||
|
("use-element-types",
|
||||||
|
"Use element types and names instead of unique IDs for naming elements upon serialization. "
|
||||||
|
"Applicable for DAE output.")
|
||||||
|
("use-element-hierarchy",
|
||||||
|
"Order the elements using their IfcBuildingStorey parent. "
|
||||||
|
"Applicable for DAE output.")
|
||||||
("center-model",
|
("center-model",
|
||||||
"Centers the elements upon serialization by applying the center point of "
|
"Centers the elements upon serialization by applying the center point of "
|
||||||
"all placements as an offset. Applicable for OBJ and DAE output.")
|
"all placements as an offset. Applicable for OBJ and DAE output.")
|
||||||
@@ -335,6 +341,8 @@ int main(int argc, char** argv)
|
|||||||
const bool use_element_names = vmap.count("use-element-names") != 0;
|
const bool use_element_names = vmap.count("use-element-names") != 0;
|
||||||
const bool use_element_guids = vmap.count("use-element-guids") != 0 ;
|
const bool use_element_guids = vmap.count("use-element-guids") != 0 ;
|
||||||
const bool use_material_names = vmap.count("use-material-names") != 0;
|
const bool use_material_names = vmap.count("use-material-names") != 0;
|
||||||
|
const bool use_element_types = vmap.count("use-element-types") != 0;
|
||||||
|
const bool use_element_hierarchy = vmap.count("use-element-hierarchy") != 0;
|
||||||
const bool no_normals = vmap.count("no-normals") != 0 ;
|
const bool no_normals = vmap.count("no-normals") != 0 ;
|
||||||
const bool center_model = vmap.count("center-model") != 0 ;
|
const bool center_model = vmap.count("center-model") != 0 ;
|
||||||
const bool model_offset = vmap.count("model-offset") != 0 ;
|
const bool model_offset = vmap.count("model-offset") != 0 ;
|
||||||
@@ -463,6 +471,8 @@ int main(int argc, char** argv)
|
|||||||
settings.set(SerializerSettings::USE_ELEMENT_NAMES, use_element_names);
|
settings.set(SerializerSettings::USE_ELEMENT_NAMES, use_element_names);
|
||||||
settings.set(SerializerSettings::USE_ELEMENT_GUIDS, use_element_guids);
|
settings.set(SerializerSettings::USE_ELEMENT_GUIDS, use_element_guids);
|
||||||
settings.set(SerializerSettings::USE_MATERIAL_NAMES, use_material_names);
|
settings.set(SerializerSettings::USE_MATERIAL_NAMES, use_material_names);
|
||||||
|
settings.set(SerializerSettings::USE_ELEMENT_TYPES, use_element_types);
|
||||||
|
settings.set(SerializerSettings::USE_ELEMENT_HIERARCHY, use_element_hierarchy);
|
||||||
settings.set_deflection_tolerance(deflection_tolerance);
|
settings.set_deflection_tolerance(deflection_tolerance);
|
||||||
settings.precision = precision;
|
settings.precision = precision;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user