This commit is contained in:
Thomas Krijnen
2017-09-10 16:59:05 +02:00
parent f6645b19ef
commit 4f31b9467a
2 changed files with 27 additions and 16 deletions
+25 -14
View File
@@ -33,12 +33,12 @@
#include <cmath>
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::escape_xml(s);
return s;
}
void ColladaSerializer::ColladaExporter::ColladaGeometries::addFloatSource(const std::string& mesh_id,
@@ -270,6 +270,7 @@ void ColladaSerializer::ColladaExporter::ColladaScene::addParent(const IfcGeom::
} else {
name = parent.unique_id();
}
collada_id(name);
const std::string& id = name;
@@ -396,10 +397,18 @@ void ColladaSerializer::ColladaExporter::write(const IfcGeom::TriangulationEleme
slabSuffix = differentiateSlabTypes(o);
}
const std::string name = serializer->settings().get(SerializerSettings::USE_ELEMENT_GUIDS) ?
o->guid() : (serializer->settings().get(SerializerSettings::USE_ELEMENT_NAMES) ?
o->name() : (serializer->settings().get(SerializerSettings::USE_ELEMENT_TYPES) ? o->type() + slabSuffix : o->unique_id()));
const std::string representation_id = "representation-" + o->geometry().id();
std::string name = serializer->settings().get(SerializerSettings::USE_ELEMENT_GUIDS)
? o->guid()
: (serializer->settings().get(SerializerSettings::USE_ELEMENT_NAMES)
? 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;
foreach(const IfcGeom::Material& material, mesh.materials()) {
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) {
IfcSlab* slab = (IfcSlab*)o->product();
std::string result;
switch (slab->PredefinedType())
{
case (IfcSlabTypeEnum::IfcSlabType_FLOOR):
return "_Floor";
result = "_Floor";
break;
case (IfcSlabTypeEnum::IfcSlabType_ROOF):
return "_Roof";
result = "_Roof";
break;
case (IfcSlabTypeEnum::IfcSlabType_LANDING):
return "_Landing";
result = "_Landing";
break;
case (IfcSlabTypeEnum::IfcSlabType_BASESLAB):
return "_BaseSlab";
result = "_BaseSlab";
break;
case (IfcSlabTypeEnum::IfcSlabType_NOTDEFINED):
return "_NotDefined";
result = "_NotDefined";
break;
default:
if (slab->hasObjectType()) { return "_" + slab->ObjectType(); }
else { return "_Unknown"; }
if (slab->hasObjectType()) { result = "_" + slab->ObjectType(); }
else { result = "_Unknown"; }
break;
}
collada_id(result);
return result;
}
void ColladaSerializer::ColladaExporter::endDocument() {
@@ -532,7 +544,6 @@ void ColladaSerializer::write(const IfcGeom::TriangulationElement<real_t>* o) {
exporter.write(o);
}
void ColladaSerializer::finalize() {
exporter.endDocument();
}
+2 -2
View File
@@ -161,20 +161,20 @@ void IfcUtil::sanitate_material_name(std::string &str)
void IfcUtil::escape_xml(std::string &str)
{
boost::replace_all(str, "&", "&amp;");
boost::replace_all(str, "\"", "&quot;");
boost::replace_all(str, "'", "&apos;");
boost::replace_all(str, "<", "&lt;");
boost::replace_all(str, ">", "&gt;");
boost::replace_all(str, "&", "&amp;");
}
void IfcUtil::unescape_xml(std::string &str)
{
boost::replace_all(str, "&amp;", "&");
boost::replace_all(str, "&quot;", "\"");
boost::replace_all(str, "&apos;", "'");
boost::replace_all(str, "&lt;", "<");
boost::replace_all(str, "&gt;", ">");
boost::replace_all(str, "&amp;", "&");
}
std::vector<std::string> IfcUtil::IfcBaseEntity::getAttributeNames() const {