Files
IfcOpenShell/src/ifcgeom_schema_agnostic/Serialization.cpp
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

54 lines
1.9 KiB
C++
Raw Normal View History

2017-12-22 17:37:58 +01:00
#include "Serialization.h"
#include <boost/algorithm/string/case_conv.hpp>
2022-07-17 21:13:46 +02:00
#include <boost/preprocessor/stringize.hpp>
#include <boost/preprocessor/seq/for_each.hpp>
#include <boost/algorithm/string/case_conv.hpp>
#define EXTERNAL_DEFS_1(r, data, elem) \
BOOST_PP_CAT(BOOST_PP_CAT(IfcUtil::IfcBaseClass* tesselate_, elem), (const TopoDS_Shape& shape, double deflection);)
#define EXTERNAL_DEFS_2(r, data, elem) \
BOOST_PP_CAT(BOOST_PP_CAT(IfcUtil::IfcBaseClass* serialise_, elem), (const TopoDS_Shape& shape, bool advanced);)
#define CONDITIONAL_CALL(r, data, elem) \
if (schema_name_lower == BOOST_PP_STRINGIZE(BOOST_PP_CAT(elem,))) { \
return BOOST_PP_CAT(METHOD_NAME, elem)(shape, arg_2); \
}
2017-12-22 17:37:58 +01:00
namespace IfcGeom {
2022-07-17 21:13:46 +02:00
BOOST_PP_SEQ_FOR_EACH(EXTERNAL_DEFS_1, , SCHEMA_SEQ);
BOOST_PP_SEQ_FOR_EACH(EXTERNAL_DEFS_2, , SCHEMA_SEQ);
2017-12-22 17:37:58 +01:00
}
2022-07-17 21:13:46 +02:00
#define METHOD_NAME tesselate_
IfcUtil::IfcBaseClass* IfcGeom::tesselate(const std::string& schema_name, const TopoDS_Shape& shape, double arg_2) {
// @todo an ugly hack to guarantee schemas are initialised.
try {
IfcParse::schema_by_name("IFC2X3");
} catch (IfcParse::IfcException&) {}
2022-07-17 21:13:46 +02:00
const std::string schema_name_lower = boost::to_lower_copy(schema_name.substr(3));
2022-07-17 21:13:46 +02:00
BOOST_PP_SEQ_FOR_EACH(CONDITIONAL_CALL, , SCHEMA_SEQ);
throw IfcParse::IfcException("No geometry serialization available for " + schema_name);
2017-12-22 17:37:58 +01:00
}
2022-07-17 21:13:46 +02:00
#undef METHOD_NAME
#define METHOD_NAME serialise_
2017-12-22 17:37:58 +01:00
2022-07-17 21:13:46 +02:00
IfcUtil::IfcBaseClass* IfcGeom::serialise(const std::string& schema_name, const TopoDS_Shape& shape, bool arg_2) {
// @todo an ugly hack to guarantee schemas are initialised.
try {
IfcParse::schema_by_name("IFC2X3");
} catch (IfcParse::IfcException&) {}
const std::string schema_name_lower = boost::to_lower_copy(schema_name.substr(3));
BOOST_PP_SEQ_FOR_EACH(CONDITIONAL_CALL, , SCHEMA_SEQ);
throw IfcParse::IfcException("No geometry serialization available for " + schema_name);
2017-12-22 17:37:58 +01:00
}