2017-12-22 17:37:58 +01:00
|
|
|
#include "Serialization.h"
|
|
|
|
|
|
|
|
|
|
#include <boost/algorithm/string/case_conv.hpp>
|
|
|
|
|
|
|
|
|
|
namespace IfcGeom {
|
|
|
|
|
extern IfcUtil::IfcBaseClass* tesselate_Ifc2x3(const TopoDS_Shape& shape, double deflection);
|
|
|
|
|
extern IfcUtil::IfcBaseClass* tesselate_Ifc4(const TopoDS_Shape& shape, double deflection);
|
2020-06-15 12:48:30 +02:00
|
|
|
extern IfcUtil::IfcBaseClass* tesselate_Ifc4x1(const TopoDS_Shape& shape, double deflection);
|
|
|
|
|
extern IfcUtil::IfcBaseClass* tesselate_Ifc4x2(const TopoDS_Shape& shape, double deflection);
|
|
|
|
|
extern IfcUtil::IfcBaseClass* tesselate_Ifc4x3_rc1(const TopoDS_Shape& shape, double deflection);
|
2021-02-14 12:43:27 +01:00
|
|
|
extern IfcUtil::IfcBaseClass* tesselate_Ifc4x3_rc2(const TopoDS_Shape& shape, double deflection);
|
2020-06-15 12:48:30 +02:00
|
|
|
|
2017-12-22 17:37:58 +01:00
|
|
|
extern IfcUtil::IfcBaseClass* serialise_Ifc2x3(const TopoDS_Shape& shape, bool advanced);
|
|
|
|
|
extern IfcUtil::IfcBaseClass* serialise_Ifc4(const TopoDS_Shape& shape, bool advanced);
|
2020-06-15 12:48:30 +02:00
|
|
|
extern IfcUtil::IfcBaseClass* serialise_Ifc4x1(const TopoDS_Shape& shape, bool advanced);
|
|
|
|
|
extern IfcUtil::IfcBaseClass* serialise_Ifc4x2(const TopoDS_Shape& shape, bool advanced);
|
|
|
|
|
extern IfcUtil::IfcBaseClass* serialise_Ifc4x3_rc1(const TopoDS_Shape& shape, bool advanced);
|
2021-02-14 12:43:27 +01:00
|
|
|
extern IfcUtil::IfcBaseClass* serialise_Ifc4x3_rc2(const TopoDS_Shape& shape, bool advanced);
|
2017-12-22 17:37:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename Fn, typename T>
|
2021-02-14 12:43:27 +01:00
|
|
|
IfcUtil::IfcBaseClass* execute_based_on_schema(Fn fn_2x3, Fn fn_4, Fn fn_4x1, Fn fn_4x2, Fn fn_4x3_rc1, Fn fn_4x3_rc2, const std::string& schema_name, const TopoDS_Shape& shape, T t) {
|
2020-04-08 15:04:17 +02:00
|
|
|
// @todo an ugly hack to guarantee schemas are initialised.
|
|
|
|
|
try {
|
|
|
|
|
IfcParse::schema_by_name("IFC2X3");
|
|
|
|
|
} catch (IfcParse::IfcException&) {}
|
|
|
|
|
|
2017-12-22 17:37:58 +01:00
|
|
|
const std::string schema_name_lower = boost::to_lower_copy(schema_name);
|
2020-04-08 15:04:17 +02:00
|
|
|
|
2018-08-13 11:43:28 +02:00
|
|
|
if (schema_name_lower == "ifc2x3") {
|
2020-06-15 12:48:30 +02:00
|
|
|
return fn_2x3(shape, t);
|
2018-08-13 11:43:28 +02:00
|
|
|
} else if (schema_name_lower == "ifc4") {
|
2020-06-15 12:48:30 +02:00
|
|
|
return fn_4(shape, t);
|
|
|
|
|
} else if (schema_name_lower == "ifc4x1") {
|
|
|
|
|
return fn_4x1(shape, t);
|
|
|
|
|
} else if (schema_name_lower == "ifc4x2") {
|
|
|
|
|
return fn_4x2(shape, t);
|
|
|
|
|
} else if (schema_name_lower == "ifc4x3_rc1") {
|
|
|
|
|
return fn_4x3_rc1(shape, t);
|
2021-02-14 12:43:27 +01:00
|
|
|
} else if (schema_name_lower == "ifc4x3_rc2") {
|
|
|
|
|
return fn_4x3_rc2(shape, t);
|
2017-12-22 17:37:58 +01:00
|
|
|
} else {
|
|
|
|
|
throw IfcParse::IfcException("No geometry serialization available for " + schema_name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IfcUtil::IfcBaseClass* IfcGeom::tesselate(const std::string& schema_name, const TopoDS_Shape& shape, double deflection) {
|
2020-06-15 12:48:30 +02:00
|
|
|
return execute_based_on_schema(
|
|
|
|
|
IfcGeom::tesselate_Ifc2x3,
|
|
|
|
|
IfcGeom::tesselate_Ifc4,
|
|
|
|
|
IfcGeom::tesselate_Ifc4x1,
|
|
|
|
|
IfcGeom::tesselate_Ifc4x2,
|
|
|
|
|
IfcGeom::tesselate_Ifc4x3_rc1,
|
2021-02-14 12:43:27 +01:00
|
|
|
IfcGeom::tesselate_Ifc4x3_rc2,
|
|
|
|
|
schema_name, shape, deflection);
|
2017-12-22 17:37:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IfcUtil::IfcBaseClass* IfcGeom::serialise(const std::string& schema_name, const TopoDS_Shape& shape, bool advanced) {
|
2020-06-15 12:48:30 +02:00
|
|
|
return execute_based_on_schema(
|
|
|
|
|
IfcGeom::serialise_Ifc2x3,
|
|
|
|
|
IfcGeom::serialise_Ifc4,
|
|
|
|
|
IfcGeom::serialise_Ifc4x1,
|
|
|
|
|
IfcGeom::serialise_Ifc4x2,
|
|
|
|
|
IfcGeom::serialise_Ifc4x3_rc1,
|
2021-02-14 12:43:27 +01:00
|
|
|
IfcGeom::serialise_Ifc4x3_rc2,
|
|
|
|
|
schema_name, shape, advanced);
|
2017-12-22 17:37:58 +01:00
|
|
|
}
|