mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
clean WIP
This commit is contained in:
@@ -335,30 +335,6 @@ void ColladaSerializer::ColladaExporter::startDocument(const std::string& unit_n
|
||||
asset.add();
|
||||
}
|
||||
|
||||
void ColladaSerializer::ColladaExporter::write(const IfcGeom::TriangulationElement<real_t>* o)
|
||||
{
|
||||
const IfcGeom::Representation::Triangulation<real_t>& mesh = o->geometry();
|
||||
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() : o->unique_id()));
|
||||
const std::string representation_id = "representation-" + boost::lexical_cast<std::string>(o->geometry().id());
|
||||
std::vector<std::string> material_references;
|
||||
foreach(const IfcGeom::Material& material, mesh.materials()) {
|
||||
if (!materials.contains(material)) {
|
||||
materials.add(material);
|
||||
}
|
||||
std::string material_name = (serializer->settings().get(SerializerSettings::USE_MATERIAL_NAMES)
|
||||
? material.original_name() : material.name());
|
||||
collada_id(material_name);
|
||||
material_references.push_back(material_name);
|
||||
}
|
||||
|
||||
deferreds.push_back(
|
||||
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())
|
||||
);
|
||||
}
|
||||
|
||||
void ColladaSerializer::ColladaExporter::write(const IfcGeom::TriangulationElement<real_t>* o, const IfcGeom::Element<real_t>* parent)
|
||||
{
|
||||
const IfcGeom::Representation::Triangulation<real_t>& mesh = o->geometry();
|
||||
@@ -433,7 +409,7 @@ void ColladaSerializer::writeHeader() {
|
||||
}
|
||||
|
||||
void ColladaSerializer::write(const IfcGeom::TriangulationElement<real_t>* o) {
|
||||
exporter.write(o);
|
||||
exporter.write(o, NULL);
|
||||
}
|
||||
|
||||
void ColladaSerializer::write(const IfcGeom::TriangulationElement<real_t>* o, const IfcGeom::Element<real_t>* parent)
|
||||
|
||||
@@ -129,12 +129,20 @@ private:
|
||||
{
|
||||
const IfcGeom::Element<real_t>* parent1 = def_obj1.parent;
|
||||
const IfcGeom::Element<real_t>* parent2 = def_obj2.parent;
|
||||
|
||||
std::cout << "comparing..\n";
|
||||
|
||||
if (parent1 == NULL || parent2 == NULL)
|
||||
{
|
||||
return (def_obj1.unique_id < def_obj2.unique_id ? true : false);
|
||||
bool res = (def_obj1.unique_id < def_obj2.unique_id ? true : false);
|
||||
std::cout << "done\n";
|
||||
return res;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool res = parent1->name() < parent2->name() ? true : false;
|
||||
std::cout << "done\n";
|
||||
return res;
|
||||
}
|
||||
else return parent1->name() < parent2->name() ? true : false;
|
||||
}
|
||||
public:
|
||||
std::string unique_id, representation_id, type;
|
||||
@@ -164,8 +172,9 @@ private:
|
||||
, materials(materials)
|
||||
, material_references(material_references)
|
||||
, uvs(uvs)
|
||||
, parent(&_parent)
|
||||
{
|
||||
parent = &_parent;
|
||||
|
||||
}
|
||||
|
||||
DeferredObject(const std::string& unique_id, const std::string& representation_id, const std::string& type, const std::vector<real_t>& matrix,
|
||||
@@ -184,8 +193,9 @@ private:
|
||||
, materials(materials)
|
||||
, material_references(material_references)
|
||||
, uvs(uvs)
|
||||
, parent(NULL)
|
||||
{
|
||||
parent = NULL;
|
||||
|
||||
}
|
||||
};
|
||||
COLLADABU::NativeString filename;
|
||||
@@ -209,7 +219,7 @@ private:
|
||||
std::vector<DeferredObject> deferreds;
|
||||
virtual ~ColladaExporter() {}
|
||||
void startDocument(const std::string& unit_name, float unit_magnitude);
|
||||
void write(const IfcGeom::TriangulationElement<real_t>* o);
|
||||
void write(const IfcGeom::TriangulationElement<real_t>* o) {};
|
||||
void write(const IfcGeom::TriangulationElement<real_t>* o, const IfcGeom::Element<real_t>* parent);
|
||||
void endDocument();
|
||||
};
|
||||
@@ -228,7 +238,7 @@ public:
|
||||
}
|
||||
bool ready();
|
||||
void writeHeader();
|
||||
void write(const IfcGeom::TriangulationElement<real_t>* o);
|
||||
void write(const IfcGeom::TriangulationElement<real_t>* o);
|
||||
void write(const IfcGeom::TriangulationElement<real_t>* o, const IfcGeom::Element<real_t>* parent);
|
||||
void write(const IfcGeom::BRepElement<real_t>* /*o*/) {}
|
||||
void finalize();
|
||||
|
||||
@@ -587,11 +587,12 @@ int main(int argc, char** argv)
|
||||
|
||||
do {
|
||||
IfcGeom::Element<real_t> *geom_object = context_iterator.get();
|
||||
|
||||
|
||||
// if the target is a .dae file, get the parent of the object
|
||||
if (output_extension == ".dae" && geom_object->parent_id() != -1)
|
||||
if (serializer->settings().get(SerializerSettings::USE_ELEMENT_HIERARCHY) && output_extension == ".dae" && geom_object->parent_id() != -1)
|
||||
{
|
||||
const IfcGeom::Element<real_t> *parent_object = NULL;
|
||||
|
||||
bool hasParent = true;
|
||||
try { parent_object = context_iterator.getObject(geom_object->parent_id()); }
|
||||
catch (std::exception e)
|
||||
@@ -610,8 +611,9 @@ int main(int argc, char** argv)
|
||||
hasParent = hasParent && parent_object->parent_id() != 1;
|
||||
}
|
||||
|
||||
if (parent_object != NULL) serializer->write(static_cast<const IfcGeom::TriangulationElement<real_t>*>(geom_object), parent_object);
|
||||
else serializer->write(static_cast<const IfcGeom::TriangulationElement<real_t>*>(geom_object));
|
||||
serializer->write(static_cast<const IfcGeom::TriangulationElement<real_t>*>(geom_object), parent_object);
|
||||
//delete parent_object;
|
||||
//parent_object = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user