mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-25 09:32:37 +00:00
Handle errors : when an object has no parent
This commit is contained in:
@@ -177,7 +177,6 @@ private:
|
|||||||
ColladaExporter exporter;
|
ColladaExporter exporter;
|
||||||
std::string unit_name;
|
std::string unit_name;
|
||||||
float unit_magnitude;
|
float unit_magnitude;
|
||||||
IfcParse::IfcFile* file;
|
|
||||||
public:
|
public:
|
||||||
ColladaSerializer(const std::string& dae_filename, const SerializerSettings& settings)
|
ColladaSerializer(const std::string& dae_filename, const SerializerSettings& settings)
|
||||||
: GeometrySerializer(settings)
|
: GeometrySerializer(settings)
|
||||||
@@ -198,7 +197,7 @@ public:
|
|||||||
unit_name = name;
|
unit_name = name;
|
||||||
unit_magnitude = magnitude;
|
unit_magnitude = magnitude;
|
||||||
}
|
}
|
||||||
void setFile(IfcParse::IfcFile* f) { file = f; }
|
void setFile(IfcParse::IfcFile*) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -578,23 +578,33 @@ int main(int argc, char** argv)
|
|||||||
do {
|
do {
|
||||||
IfcGeom::Element<real_t> *geom_object = context_iterator.get();
|
IfcGeom::Element<real_t> *geom_object = context_iterator.get();
|
||||||
|
|
||||||
// Note : Ici on envoie au Serializer les obj à traier.
|
|
||||||
// Un tri a déjà été fait, on envoie pas tous les objets. Les IfcBuildingStorey ne sont déjà plus là ...
|
|
||||||
|
|
||||||
// if the target is a .dae file, get the parent of the object
|
// if the target is a .dae file, get the parent of the object
|
||||||
if (output_extension == ".dae" && geom_object->parent_id() != -1)
|
if (output_extension == ".dae" && geom_object->parent_id() != -1)
|
||||||
{
|
{
|
||||||
const IfcGeom::Element<real_t> *parent_object = context_iterator.getObject(geom_object->parent_id());
|
const IfcGeom::Element<real_t> *parent_object = NULL;
|
||||||
|
bool hasParent = true;
|
||||||
int cptSecure = 0;
|
try { parent_object = context_iterator.getObject(geom_object->parent_id()); }
|
||||||
while (parent_object->type() != "IfcBuildingStorey" && cptSecure < 1000 && parent_object->parent_id() != 1)
|
catch (std::exception e)
|
||||||
{
|
{
|
||||||
cptSecure++;
|
std::cout << e.what() << '\n';
|
||||||
parent_object = context_iterator.getObject(parent_object->parent_id());
|
hasParent = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (parent_object != NULL && parent_object->type() != "IfcBuildingStorey" && hasParent)
|
||||||
|
{
|
||||||
|
try { parent_object = context_iterator.getObject(parent_object->parent_id()); }
|
||||||
|
catch (std::exception e)
|
||||||
|
{
|
||||||
|
std::cout << e.what() << '\n';
|
||||||
|
hasParent = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
hasParent = hasParent && parent_object->parent_id() != 1;
|
||||||
}
|
}
|
||||||
//Debug
|
//Debug
|
||||||
if (geom_object->parent_id() == -1) std::cout << "Parent = -1 : " << geom_object->name();
|
//if (parent_object != NULL) std::cout << '\n' << "obj " << geom_object->unique_id() << " parent = " << parent_object->name() << " of type " << parent_object->type() << '\n';
|
||||||
std::cout << '\n' << "obj " << geom_object->unique_id() << " parent = " << parent_object->name() << " of type " << parent_object->type() << '\n';
|
//else std::cout << "No parent found : " << geom_object->unique_id() << " of type : " << geom_object->type();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_tesselated)
|
if (is_tesselated)
|
||||||
|
|||||||
Reference in New Issue
Block a user