mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 15:08:51 +00:00
Fix #248
This commit is contained in:
@@ -33,12 +33,12 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
using namespace IfcSchema;
|
using namespace IfcSchema;
|
||||||
using namespace boost::numeric::ublas;
|
|
||||||
|
|
||||||
static void collada_id(std::string &s)
|
static std::string& collada_id(std::string& s)
|
||||||
{
|
{
|
||||||
IfcUtil::sanitate_material_name(s);
|
IfcUtil::sanitate_material_name(s);
|
||||||
IfcUtil::escape_xml(s);
|
IfcUtil::escape_xml(s);
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColladaSerializer::ColladaExporter::ColladaGeometries::addFloatSource(const std::string& mesh_id,
|
void ColladaSerializer::ColladaExporter::ColladaGeometries::addFloatSource(const std::string& mesh_id,
|
||||||
@@ -270,6 +270,7 @@ void ColladaSerializer::ColladaExporter::ColladaScene::addParent(const IfcGeom::
|
|||||||
} else {
|
} else {
|
||||||
name = parent.unique_id();
|
name = parent.unique_id();
|
||||||
}
|
}
|
||||||
|
collada_id(name);
|
||||||
|
|
||||||
const std::string& id = name;
|
const std::string& id = name;
|
||||||
|
|
||||||
@@ -396,10 +397,18 @@ void ColladaSerializer::ColladaExporter::write(const IfcGeom::TriangulationEleme
|
|||||||
slabSuffix = differentiateSlabTypes(o);
|
slabSuffix = differentiateSlabTypes(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string name = serializer->settings().get(SerializerSettings::USE_ELEMENT_GUIDS) ?
|
std::string name = serializer->settings().get(SerializerSettings::USE_ELEMENT_GUIDS)
|
||||||
o->guid() : (serializer->settings().get(SerializerSettings::USE_ELEMENT_NAMES) ?
|
? o->guid()
|
||||||
o->name() : (serializer->settings().get(SerializerSettings::USE_ELEMENT_TYPES) ? o->type() + slabSuffix : o->unique_id()));
|
: (serializer->settings().get(SerializerSettings::USE_ELEMENT_NAMES)
|
||||||
const std::string representation_id = "representation-" + o->geometry().id();
|
? o->name()
|
||||||
|
: (serializer->settings().get(SerializerSettings::USE_ELEMENT_TYPES)
|
||||||
|
? (o->type() + slabSuffix)
|
||||||
|
: o->unique_id()));
|
||||||
|
collada_id(name);
|
||||||
|
|
||||||
|
std::string representation_id = "representation-" + o->geometry().id();
|
||||||
|
collada_id(representation_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()) {
|
||||||
if (!materials.contains(material)) {
|
if (!materials.contains(material)) {
|
||||||
@@ -423,28 +432,31 @@ void ColladaSerializer::ColladaExporter::write(const IfcGeom::TriangulationEleme
|
|||||||
|
|
||||||
std::string ColladaSerializer::ColladaExporter::differentiateSlabTypes(const IfcGeom::TriangulationElement<real_t>* o) {
|
std::string ColladaSerializer::ColladaExporter::differentiateSlabTypes(const IfcGeom::TriangulationElement<real_t>* o) {
|
||||||
IfcSlab* slab = (IfcSlab*)o->product();
|
IfcSlab* slab = (IfcSlab*)o->product();
|
||||||
|
std::string result;
|
||||||
switch (slab->PredefinedType())
|
switch (slab->PredefinedType())
|
||||||
{
|
{
|
||||||
case (IfcSlabTypeEnum::IfcSlabType_FLOOR):
|
case (IfcSlabTypeEnum::IfcSlabType_FLOOR):
|
||||||
return "_Floor";
|
result = "_Floor";
|
||||||
break;
|
break;
|
||||||
case (IfcSlabTypeEnum::IfcSlabType_ROOF):
|
case (IfcSlabTypeEnum::IfcSlabType_ROOF):
|
||||||
return "_Roof";
|
result = "_Roof";
|
||||||
break;
|
break;
|
||||||
case (IfcSlabTypeEnum::IfcSlabType_LANDING):
|
case (IfcSlabTypeEnum::IfcSlabType_LANDING):
|
||||||
return "_Landing";
|
result = "_Landing";
|
||||||
break;
|
break;
|
||||||
case (IfcSlabTypeEnum::IfcSlabType_BASESLAB):
|
case (IfcSlabTypeEnum::IfcSlabType_BASESLAB):
|
||||||
return "_BaseSlab";
|
result = "_BaseSlab";
|
||||||
break;
|
break;
|
||||||
case (IfcSlabTypeEnum::IfcSlabType_NOTDEFINED):
|
case (IfcSlabTypeEnum::IfcSlabType_NOTDEFINED):
|
||||||
return "_NotDefined";
|
result = "_NotDefined";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (slab->hasObjectType()) { return "_" + slab->ObjectType(); }
|
if (slab->hasObjectType()) { result = "_" + slab->ObjectType(); }
|
||||||
else { return "_Unknown"; }
|
else { result = "_Unknown"; }
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
collada_id(result);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColladaSerializer::ColladaExporter::endDocument() {
|
void ColladaSerializer::ColladaExporter::endDocument() {
|
||||||
@@ -532,7 +544,6 @@ void ColladaSerializer::write(const IfcGeom::TriangulationElement<real_t>* o) {
|
|||||||
exporter.write(o);
|
exporter.write(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ColladaSerializer::finalize() {
|
void ColladaSerializer::finalize() {
|
||||||
exporter.endDocument();
|
exporter.endDocument();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -161,20 +161,20 @@ void IfcUtil::sanitate_material_name(std::string &str)
|
|||||||
|
|
||||||
void IfcUtil::escape_xml(std::string &str)
|
void IfcUtil::escape_xml(std::string &str)
|
||||||
{
|
{
|
||||||
|
boost::replace_all(str, "&", "&");
|
||||||
boost::replace_all(str, "\"", """);
|
boost::replace_all(str, "\"", """);
|
||||||
boost::replace_all(str, "'", "'");
|
boost::replace_all(str, "'", "'");
|
||||||
boost::replace_all(str, "<", "<");
|
boost::replace_all(str, "<", "<");
|
||||||
boost::replace_all(str, ">", ">");
|
boost::replace_all(str, ">", ">");
|
||||||
boost::replace_all(str, "&", "&");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IfcUtil::unescape_xml(std::string &str)
|
void IfcUtil::unescape_xml(std::string &str)
|
||||||
{
|
{
|
||||||
|
boost::replace_all(str, "&", "&");
|
||||||
boost::replace_all(str, """, "\"");
|
boost::replace_all(str, """, "\"");
|
||||||
boost::replace_all(str, "'", "'");
|
boost::replace_all(str, "'", "'");
|
||||||
boost::replace_all(str, "<", "<");
|
boost::replace_all(str, "<", "<");
|
||||||
boost::replace_all(str, ">", ">");
|
boost::replace_all(str, ">", ">");
|
||||||
boost::replace_all(str, "&", "&");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> IfcUtil::IfcBaseEntity::getAttributeNames() const {
|
std::vector<std::string> IfcUtil::IfcBaseEntity::getAttributeNames() const {
|
||||||
|
|||||||
Reference in New Issue
Block a user