mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 10:33:20 +00:00
Introduce unique error codes
This commit is contained in:
@@ -519,7 +519,7 @@ namespace {
|
||||
}
|
||||
|
||||
void proj_log(void *, int, const char* c) {
|
||||
Logger::Error("PROJ: " + std::string(c));
|
||||
Logger::Error("SER", 1, "PROJ: " + std::string(c));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -650,7 +650,7 @@ void GltfSerializer::setFile(IfcParse::IfcFile* f) {
|
||||
NULL);
|
||||
|
||||
if (!P) {
|
||||
Logger::Error("Failed to create PROJ transformation object");
|
||||
Logger::Error("SER", 2, "Failed to create PROJ transformation object");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -662,7 +662,7 @@ void GltfSerializer::setFile(IfcParse::IfcFile* f) {
|
||||
|
||||
wgs84_point = proj_trans(P, PJ_FWD, a);
|
||||
|
||||
Logger::Notice("Calculated latitude: " + std::to_string(wgs84_point.lp.lam) + " longitude: " + std::to_string(wgs84_point.lp.phi));
|
||||
Logger::Notice("SER", 3, "Calculated latitude: " + std::to_string(wgs84_point.lp.lam) + " longitude: " + std::to_string(wgs84_point.lp.phi));
|
||||
}
|
||||
|
||||
std::swap(wgs84_point.lp.phi, wgs84_point.lp.lam);
|
||||
@@ -687,7 +687,7 @@ void GltfSerializer::setFile(IfcParse::IfcFile* f) {
|
||||
PJ *ellipsoid_crs = proj_create(C, ellipsoid_def);
|
||||
|
||||
if (!ellipsoid_crs) {
|
||||
Logger::Error("Failed to create ellipsoid CRS");
|
||||
Logger::Error("SER", 4, "Failed to create ellipsoid CRS");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
const char* symbol = getSymbolForUnitMagnitude(magnitude);
|
||||
if (symbol) {
|
||||
#ifdef HAVE_CONFIG_H
|
||||
Logger::Warning("Setting IGES units not supported on OCE");
|
||||
Logger::Warning("SER", 5, "Setting IGES units not supported on OCE");
|
||||
#else
|
||||
Interface_Static::SetCVal("xstep.cascade.unit", symbol);
|
||||
Interface_Static::SetCVal("write.iges.unit", symbol);
|
||||
|
||||
@@ -139,13 +139,13 @@ void SvgSerializer::write(path_object& p, const TopoDS_Shape& comp_or_wire, boos
|
||||
BRep_Tool::CurveOnSurface(edge, curve2d, surf, loc, u1, u2);
|
||||
|
||||
if (curve2d.IsNull()) {
|
||||
Logger::Error("Failed to obtain 2d and 3d curve from edge");
|
||||
Logger::Error("SER", 20, "Failed to obtain 2d and 3d curve from edge");
|
||||
continue;
|
||||
}
|
||||
|
||||
Handle(Standard_Type) sty = surf->DynamicType();
|
||||
if (sty != STANDARD_TYPE(Geom_Plane)) {
|
||||
Logger::Error("Non-planar p-curves are not supported by this serializer");
|
||||
Logger::Error("SER", 21, "Non-planar p-curves are not supported by this serializer");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -222,7 +222,7 @@ void SvgSerializer::write(path_object& p, const TopoDS_Shape& comp_or_wire, boos
|
||||
std::stringstream ss;
|
||||
ss << "Skipping full circle/ellipse inside aggregated <path> (id "
|
||||
<< p.first << ")";
|
||||
Logger::Warning(ss.str());
|
||||
Logger::Warning("SER", 22, ss.str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -650,7 +650,7 @@ void SvgSerializer::write(const IfcGeom::BRepElement* brep_obj) {
|
||||
BRepBndLib::AddOBB(compound_unmirrored, *view_box_3d_, false, false, false);
|
||||
#endif
|
||||
} else {
|
||||
Logger::Error("Failed to box or edge from drawing annotation");
|
||||
Logger::Error("SER", 23, "Failed to box or edge from drawing annotation");
|
||||
}
|
||||
|
||||
std::vector<string_property> props;
|
||||
@@ -797,7 +797,7 @@ void SvgSerializer::write(const geometry_data& data) {
|
||||
if (data.storey) {
|
||||
section_heights_storage.push_back(horizontal_plan{ data.storey, data.storey_elevation, +1. });
|
||||
} else {
|
||||
Logger::Warning("No global section height and unable to determine building storey for:", data.product);
|
||||
Logger::Warning("SER", 24, "No global section height and unable to determine building storey for:", data.product);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -812,7 +812,7 @@ void SvgSerializer::write(const geometry_data& data) {
|
||||
Bnd_OBB obb;
|
||||
BRepBndLib::AddOBB(compound_unmirrored, obb, false, false, false);
|
||||
if (view_box_3d_->IsOut(obb)) {
|
||||
Logger::Notice("Not including element due to viewBox", data.product);
|
||||
Logger::Notice("SER", 25, "Not including element due to viewBox", data.product);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -859,7 +859,7 @@ void SvgSerializer::write(const geometry_data& data) {
|
||||
}
|
||||
}
|
||||
} catch (std::exception& e) {
|
||||
Logger::Error(e);
|
||||
Logger::Error("SER", 26, e);
|
||||
}
|
||||
|
||||
if (operation_type && ((*operation_type == "SINGLE_SWING_LEFT") || (*operation_type == "SINGLE_SWING_RIGHT"))) {
|
||||
@@ -1112,7 +1112,7 @@ void SvgSerializer::write(const geometry_data& data) {
|
||||
|
||||
compound_to_hlr = &subtracted_shape;
|
||||
} catch (...) {
|
||||
Logger::Error("Failed to cut element for HLR", data.product);
|
||||
Logger::Error("SER", 27, "Failed to cut element for HLR", data.product);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1208,7 +1208,7 @@ void SvgSerializer::write(const geometry_data& data) {
|
||||
}
|
||||
it->second.add(*compound_to_hlr, data.product);
|
||||
} else {
|
||||
Logger::Warning("Unable to invoke HLR due to absence of storey containment", data.product);
|
||||
Logger::Warning("SER", 28, "Unable to invoke HLR due to absence of storey containment", data.product);
|
||||
}
|
||||
} else if (hlr) {
|
||||
hlr->add(*compound_to_hlr, data.product);
|
||||
@@ -1681,7 +1681,7 @@ void SvgSerializer::write(const geometry_data& data) {
|
||||
}
|
||||
|
||||
if (!emitted) {
|
||||
Logger::Warning("Element not written to SVG due to section heights", data.product);
|
||||
Logger::Warning("SER", 29, "Element not written to SVG due to section heights", data.product);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2337,7 +2337,7 @@ void SvgSerializer::setFile(IfcParse::IfcFile* f) {
|
||||
#ifdef TAXONOMY_USE_NAKED_PTR
|
||||
delete matrix;
|
||||
#endif
|
||||
Logger::Warning("No building storeys encountered, used for reference:", product);
|
||||
Logger::Warning("SER", 30, "No building storeys encountered, used for reference:", product);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -2347,7 +2347,7 @@ void SvgSerializer::setFile(IfcParse::IfcFile* f) {
|
||||
|
||||
delete mapping;
|
||||
|
||||
Logger::Warning("No building storeys encountered, output might be invalid or missing");
|
||||
Logger::Warning("SER", 31, "No building storeys encountered, output might be invalid or missing");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2358,7 +2358,7 @@ void SvgSerializer::setSectionHeight(double h, const IfcUtil::IfcBaseEntity* sto
|
||||
|
||||
void SvgSerializer::setSectionHeightsFromStoreys(double offset) {
|
||||
if (!file) {
|
||||
Logger::Error("No file specified");
|
||||
Logger::Error("SER", 32, "No file specified");
|
||||
return;
|
||||
}
|
||||
with_section_heights_from_storey_ = true;
|
||||
@@ -2373,7 +2373,7 @@ void SvgSerializer::setSectionHeightsFromStoreys(double offset) {
|
||||
try {
|
||||
elev = attr_value;
|
||||
} catch (std::exception& e) {
|
||||
Logger::Error(e);
|
||||
Logger::Error("SER", 33, e);
|
||||
continue;
|
||||
}
|
||||
if (!section_data_->empty()) {
|
||||
|
||||
@@ -468,7 +468,7 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
Logger::Notice("Included " + std::to_string(n_faces_included) + " faces out of " + std::to_string(n_total) + " after prefiltering");
|
||||
Logger::Notice("SER", 34, "Included " + std::to_string(n_faces_included) + " faces out of " + std::to_string(n_total) + " after prefiltering");
|
||||
|
||||
auto it = items_.insert(items_.end(), { product, C });
|
||||
|
||||
@@ -517,7 +517,7 @@ namespace {
|
||||
}
|
||||
}
|
||||
if (use_prefiltering_) {
|
||||
Logger::Notice("Included " + std::to_string(n_included) + " elements out of " + std::to_string(items_.size()) + " after prefiltering");
|
||||
Logger::Notice("SER", 35, "Included " + std::to_string(n_included) + " elements out of " + std::to_string(items_.size()) + " after prefiltering");
|
||||
}
|
||||
|
||||
hlr_calc vis(projector_);
|
||||
|
||||
@@ -473,11 +473,11 @@ void TtlWktSerializer::write(const IfcGeom::BRepElement* brep_obj) {
|
||||
if ((polygons_by_area.rbegin()->first > (0.6 * rectangle_area)) || (height < (1. + 1.e-5))) {
|
||||
// Found sufficiently large polygon
|
||||
if (emitted_warning) {
|
||||
Logger::Warning("Found larger polygon area (" + std::to_string(polygons_by_area.rbegin()->first) + ").");
|
||||
Logger::Warning("SER", 36, "Found larger polygon area (" + std::to_string(polygons_by_area.rbegin()->first) + ").");
|
||||
}
|
||||
break;
|
||||
} else if (!emitted_warning) {
|
||||
Logger::Warning("Section polygon area is small compared to bounding box area (" + std::to_string(polygons_by_area.rbegin()->first) + " < " + std::to_string(0.6 * rectangle_area) + "). Trying again with different section height.");
|
||||
Logger::Warning("SER", 37, "Section polygon area is small compared to bounding box area (" + std::to_string(polygons_by_area.rbegin()->first) + " < " + std::to_string(0.6 * rectangle_area) + "). Trying again with different section height.");
|
||||
emitted_warning = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ auto get_related(T* t, F f, G g) {
|
||||
try {
|
||||
acc->push((*u.*g)()->template as<V>());
|
||||
} catch (IfcParse::IfcException& e) {
|
||||
Logger::Error(e);
|
||||
Logger::Error("SER", 6, e);
|
||||
}
|
||||
}
|
||||
return acc;
|
||||
@@ -264,7 +264,7 @@ void POSTFIX_SCHEMA(JsonSerializer)::finalize() {
|
||||
|
||||
IfcSchema::IfcProject::list::ptr projects = file->instances_by_type<IfcSchema::IfcProject>();
|
||||
if (projects->size() != 1) {
|
||||
Logger::Message(Logger::LOG_ERROR, "Expected a single IfcProject");
|
||||
Logger::Message(Logger::LOG_ERROR, "SER", 7, "Expected a single IfcProject");
|
||||
return;
|
||||
}
|
||||
IfcSchema::IfcProject* project = *projects->begin();
|
||||
@@ -273,7 +273,7 @@ void POSTFIX_SCHEMA(JsonSerializer)::finalize() {
|
||||
try {
|
||||
return fn();
|
||||
} catch (const std::exception& e) {
|
||||
Logger::Error(e);
|
||||
Logger::Error("SER", 8, e);
|
||||
static std::invoke_result_t<decltype(fn)> v;
|
||||
return v;
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ ptree* format_entity_instance(ifcopenshell::geometry::abstract_mapping* mapping,
|
||||
try {
|
||||
instance->get_attribute_value(i);
|
||||
} catch (const std::exception&) {
|
||||
Logger::Error("Expected " + boost::lexical_cast<std::string>(n) + " attributes for:", instance);
|
||||
Logger::Error("SER", 9, "Expected " + boost::lexical_cast<std::string>(n) + " attributes for:", instance);
|
||||
break;
|
||||
}
|
||||
auto argument = instance->get_attribute_value(i);
|
||||
@@ -176,7 +176,7 @@ ptree* format_entity_instance(ifcopenshell::geometry::abstract_mapping* mapping,
|
||||
try {
|
||||
value = format_attribute(mapping, argument, argument_type, qualified_name);
|
||||
} catch (const std::exception& e) {
|
||||
Logger::Error(e);
|
||||
Logger::Error("SER", 10, e);
|
||||
}
|
||||
|
||||
if (value) {
|
||||
@@ -227,7 +227,7 @@ auto get_related(T* t, F f, G g) {
|
||||
try {
|
||||
acc->push((*u.*g)()->template as<V>());
|
||||
} catch (IfcParse::IfcException& e) {
|
||||
Logger::Error(e);
|
||||
Logger::Error("SER", 11, e);
|
||||
}
|
||||
}
|
||||
return acc;
|
||||
@@ -552,7 +552,7 @@ void POSTFIX_SCHEMA(XmlSerializer)::finalize() {
|
||||
|
||||
IfcSchema::IfcProject::list::ptr projects = file->instances_by_type<IfcSchema::IfcProject>();
|
||||
if (projects->size() != 1) {
|
||||
Logger::Message(Logger::LOG_ERROR, "Expected a single IfcProject");
|
||||
Logger::Message(Logger::LOG_ERROR, "SER", 12, "Expected a single IfcProject");
|
||||
return;
|
||||
}
|
||||
IfcSchema::IfcProject* project = *projects->begin();
|
||||
@@ -563,7 +563,7 @@ void POSTFIX_SCHEMA(XmlSerializer)::finalize() {
|
||||
try {
|
||||
return fn();
|
||||
} catch(const std::exception& e) {
|
||||
Logger::Error(e);
|
||||
Logger::Error("SER", 13, e);
|
||||
static std::invoke_result_t<decltype(fn)> v;
|
||||
return v;
|
||||
}
|
||||
@@ -588,7 +588,7 @@ void POSTFIX_SCHEMA(XmlSerializer)::finalize() {
|
||||
catch (const IfcParse::IfcException& ex) {
|
||||
std::stringstream ss;
|
||||
ss << "Failed to get ifc file header file_description implementation_level, error: '" << ex.what() << "'";
|
||||
Logger::Message(Logger::LOG_ERROR, ss.str());
|
||||
Logger::Message(Logger::LOG_ERROR, "SER", 14, ss.str());
|
||||
}
|
||||
try {
|
||||
header.put("file_name.name", file->header().file_name()->name());
|
||||
@@ -596,7 +596,7 @@ void POSTFIX_SCHEMA(XmlSerializer)::finalize() {
|
||||
catch (const IfcParse::IfcException& ex) {
|
||||
std::stringstream ss;
|
||||
ss << "Failed to get ifc file header file_name name, error: '" << ex.what() << "'";
|
||||
Logger::Message(Logger::LOG_ERROR, ss.str());
|
||||
Logger::Message(Logger::LOG_ERROR, "SER", 15, ss.str());
|
||||
}
|
||||
try {
|
||||
header.put("file_name.time_stamp", file->header().file_name()->time_stamp());
|
||||
@@ -604,7 +604,7 @@ void POSTFIX_SCHEMA(XmlSerializer)::finalize() {
|
||||
catch (const IfcParse::IfcException& ex) {
|
||||
std::stringstream ss;
|
||||
ss << "Failed to get ifc file header file_name time_stamp, error: '" << ex.what() << "'";
|
||||
Logger::Message(Logger::LOG_ERROR, ss.str());
|
||||
Logger::Message(Logger::LOG_ERROR, "SER", 16, ss.str());
|
||||
}
|
||||
try {
|
||||
header.put("file_name.preprocessor_version", file->header().file_name()->preprocessor_version());
|
||||
@@ -612,7 +612,7 @@ void POSTFIX_SCHEMA(XmlSerializer)::finalize() {
|
||||
catch (const IfcParse::IfcException& ex) {
|
||||
std::stringstream ss;
|
||||
ss << "Failed to get ifc file header file_name preprocessor_version, error: '" << ex.what() << "'";
|
||||
Logger::Message(Logger::LOG_ERROR, ss.str());
|
||||
Logger::Message(Logger::LOG_ERROR, "SER", 17, ss.str());
|
||||
}
|
||||
try {
|
||||
header.put("file_name.originating_system", file->header().file_name()->originating_system());
|
||||
@@ -620,7 +620,7 @@ void POSTFIX_SCHEMA(XmlSerializer)::finalize() {
|
||||
catch (const IfcParse::IfcException& ex) {
|
||||
std::stringstream ss;
|
||||
ss << "Failed to get ifc file header file_name originating_system, error: '" << ex.what() << "'";
|
||||
Logger::Message(Logger::LOG_ERROR, ss.str());
|
||||
Logger::Message(Logger::LOG_ERROR, "SER", 18, ss.str());
|
||||
}
|
||||
try {
|
||||
// @nb inconsistent spelling
|
||||
@@ -629,7 +629,7 @@ void POSTFIX_SCHEMA(XmlSerializer)::finalize() {
|
||||
catch (const IfcParse::IfcException& ex) {
|
||||
std::stringstream ss;
|
||||
ss << "Failed to get ifc file header file_name authorization, error: '" << ex.what() << "'";
|
||||
Logger::Message(Logger::LOG_ERROR, ss.str());
|
||||
Logger::Message(Logger::LOG_ERROR, "SER", 19, ss.str());
|
||||
}
|
||||
|
||||
// Descend into the decomposition structure of the IFC file.
|
||||
|
||||
Reference in New Issue
Block a user