Wrap more classes into ifcopenshell:: namespace

This commit is contained in:
Thomas Krijnen
2026-08-08 13:58:39 +02:00
parent 2c47c9d4fa
commit 02481b3247
149 changed files with 678 additions and 627 deletions
+1 -1
View File
@@ -453,7 +453,7 @@ std::string collada_serializer::object_id(const ifcopenshell::geom::element* o)
: "";
return o->type() + slabSuffix;
}
return geometry_serializer::object_id(o);
return ifcopenshell::geom::geometry_serializer::object_id(o);
}
void collada_serializer::collada_exporter::endDocument() {
+3 -3
View File
@@ -50,7 +50,7 @@
#include <boost/numeric/ublas/io.hpp>
class SERIALIZERS_API collada_serializer : public write_only_geometry_serializer
class SERIALIZERS_API collada_serializer : public ifcopenshell::geom::write_only_geometry_serializer
{
// TODO The vast amount of implement details of collada_serializer could be hidden to the cpp file.
private:
@@ -219,8 +219,8 @@ private:
std::string unit_name;
float unit_magnitude;
public:
collada_serializer(const std::string& dae_filename, const ifcopenshell::geom::settings& settings, ::logger* logger = nullptr)
: write_only_geometry_serializer(settings, logger)
collada_serializer(const std::string& dae_filename, const ifcopenshell::geom::settings& settings, ifcopenshell::logger* logger = nullptr)
: ifcopenshell::geom::write_only_geometry_serializer(settings, logger)
, exporter("IfcOpenShell", dae_filename, this, settings.get<ifcopenshell::geom::settings::FloatingPointDigits>().get() >= 15)
{
exporter.serializer = this;
+3 -3
View File
@@ -53,8 +53,8 @@ static const uint32_t PRIM_TRIANGLE_FAN = 6;
static const uint32_t ELEMENT_ARRAY_BUFFER = 34963;
static const uint32_t ARRAY_BUFFER = 34962;
gltf_serializer::gltf_serializer(const std::string& filename, const ifcopenshell::geom::settings& settings, ::logger* logger)
: write_only_geometry_serializer(settings, logger)
gltf_serializer::gltf_serializer(const std::string& filename, const ifcopenshell::geom::settings& settings, ifcopenshell::logger* logger)
: ifcopenshell::geom::write_only_geometry_serializer(settings, logger)
, filename_(filename)
, tmp_filename1_(filename + ".indices.tmp")
, tmp_filename2_(filename + ".vertices.tmp")
@@ -523,7 +523,7 @@ namespace {
}
void proj_log(void* data, int, const char* c) {
auto logger = static_cast<::logger*>(data);
auto logger = static_cast<ifcopenshell::logger*>(data);
if (logger) {
logger->error("SER", 1, "PROJ: " + std::string(c));
}
+2 -2
View File
@@ -30,7 +30,7 @@ using json = nlohmann::json;
#include <map>
class SERIALIZERS_API gltf_serializer : public write_only_geometry_serializer {
class SERIALIZERS_API gltf_serializer : public ifcopenshell::geom::write_only_geometry_serializer {
private:
std::string filename_, tmp_filename1_, tmp_filename2_;
std::ofstream fstream_, tmp_fstream1_, tmp_fstream2_;
@@ -43,7 +43,7 @@ private:
int writeMaterial(const ifcopenshell::geom::taxonomy::style::ptr style);
public:
gltf_serializer(const std::string& filename, const ifcopenshell::geom::settings& settings, ::logger* logger = nullptr);
gltf_serializer(const std::string& filename, const ifcopenshell::geom::settings& settings, ifcopenshell::logger* logger = nullptr);
virtual ~gltf_serializer();
bool ready();
void writeHeader();
+1 -1
View File
@@ -40,7 +40,7 @@ private:
public:
/// @note IGESControl_Controller::Init() must be called prior to instantiating iges_serializer.
/// See http://tracker.dev.opencascade.org/view.php?id=23679 for more information.
iges_serializer(const std::string& out_filename, const ifcopenshell::geom::settings& settings, ::logger* logger = nullptr)
iges_serializer(const std::string& out_filename, const ifcopenshell::geom::settings& settings, ifcopenshell::logger* logger = nullptr)
: open_cascade_based_serializer(out_filename, settings, logger)
{}
virtual ~iges_serializer() {}
+3 -3
View File
@@ -11,20 +11,20 @@
#include <boost/shared_ptr.hpp>
class json_serializer : public serializer {
class json_serializer : public ifcopenshell::geom::serializer {
public:
enum Dialect {
JSON_DIALECT_CREOOX
};
private:
boost::shared_ptr<serializer> implementation_;
boost::shared_ptr<ifcopenshell::geom::serializer> implementation_;
protected:
std::string json_filename;
Dialect dialect_;
public:
json_serializer(ifcopenshell::file* file, const std::string& json_filename, Dialect dialect = Dialect::JSON_DIALECT_CREOOX, ::logger& logger = ::logger::root())
json_serializer(ifcopenshell::file* file, const std::string& json_filename, Dialect dialect = Dialect::JSON_DIALECT_CREOOX, ifcopenshell::logger& logger = ifcopenshell::logger::root())
: json_filename(json_filename)
, dialect_(dialect)
{
+3 -3
View File
@@ -29,15 +29,15 @@
#include <TopoDS_Shape.hxx>
class SERIALIZERS_API open_cascade_based_serializer : public write_only_geometry_serializer {
class SERIALIZERS_API open_cascade_based_serializer : public ifcopenshell::geom::write_only_geometry_serializer {
open_cascade_based_serializer(const open_cascade_based_serializer&); //N/A
open_cascade_based_serializer& operator =(const open_cascade_based_serializer&); //N/A
protected:
const std::string out_filename;
const char* getSymbolForUnitMagnitude(float mag);
public:
explicit open_cascade_based_serializer(const std::string& out_filename, const ifcopenshell::geom::settings& settings, ::logger* logger = nullptr)
: write_only_geometry_serializer(settings, logger)
explicit open_cascade_based_serializer(const std::string& out_filename, const ifcopenshell::geom::settings& settings, ifcopenshell::logger* logger = nullptr)
: ifcopenshell::geom::write_only_geometry_serializer(settings, logger)
, out_filename(out_filename)
{}
virtual ~open_cascade_based_serializer() {}
+8 -8
View File
@@ -9,7 +9,7 @@
#include "../ifcparse/logger.h"
RocksDbSerializer::RocksDbSerializer(const std::string& input_filename, const std::string& rocksdb_filename, const std::vector<std::string>& skip_supertypes, ::logger* logger)
RocksDbSerializer::RocksDbSerializer(const std::string& input_filename, const std::string& rocksdb_filename, const std::vector<std::string>& skip_supertypes, ifcopenshell::logger* logger)
: input_filename_(input_filename)
, rocksdb_filename_(rocksdb_filename)
, skip_supertypes_(skip_supertypes)
@@ -22,7 +22,7 @@ namespace {
{
auto s = sizeof(size_t);
val.resize(s + 2);
val[0] = type_encoder::encode_type<express::base>();
val[0] = ifcopenshell::type_encoder::encode_type<express::base>();
// 1 = entity - stored by id (entity name)
// 2 = type - stored by identity (internal counter in class)
val[1] = t.index() == 0 ? 'i' : 't';
@@ -40,7 +40,7 @@ namespace {
{
// no attempt at alignment
val.resize(t.size() * (sizeof(size_t) + 1) + 1);
val[0] = type_encoder::encode_type<std::vector<express::base>>();
val[0] = ifcopenshell::type_encoder::encode_type<std::vector<express::base>>();
char* ptr = val.data() + 1;
for (auto it = t.begin(); it != t.end(); ++it) {
*ptr = it->index() == 0 ? 'i' : 't';
@@ -60,7 +60,7 @@ namespace {
bool serialize(std::string& val, const std::vector<std::vector<ifcopenshell::reference_or_simple_type>>& t)
{
std::ostringstream oss;
oss.put(type_encoder::encode_type<std::vector<std::vector<express::base>>>());
oss.put(ifcopenshell::type_encoder::encode_type<std::vector<std::vector<express::base>>>());
auto write_size = [&oss](size_t sz) {
std::string size_str;
@@ -160,7 +160,7 @@ void RocksDbSerializer::write_streaming_() {
// references
simple_type_instances.push_back(t);
}
rocks_db_attribute_storage{}.set(&storage, decl, name, i, t);
ifcopenshell::rocks_db_attribute_storage{}.set(&storage, decl, name, i, t);
});
}
@@ -174,7 +174,7 @@ void RocksDbSerializer::write_streaming_() {
(is_header ? decl->name() : std::to_string(p.first.name_)) + "|" +
std::to_string(index);
if (storage.db->Get(storage.ropts, key, &tmp) == rocksdb::Status::OK() && tmp.size() == (sizeof(size_t) + 2) && tmp[0] == type_encoder::encode_type<express::base>() && tmp[1] == 't')
if (storage.db->Get(storage.ropts, key, &tmp) == rocksdb::Status::OK() && tmp.size() == (sizeof(size_t) + 2) && tmp[0] == ifcopenshell::type_encoder::encode_type<express::base>() && tmp[1] == 't')
{
size_t iden;
memcpy(&iden, tmp.data() + 2, sizeof(size_t));
@@ -259,7 +259,7 @@ void RocksDbSerializer::write_streaming_() {
// @todo if statement?
// if (val.array_.storage_ptr->size() > 0) {
val.apply_visitor([&](const auto& t) {
rocks_db_attribute_storage{}.set(&storage, &inst.declaration(), inst.identity(), 0, t);
ifcopenshell::rocks_db_attribute_storage{}.set(&storage, &inst.declaration(), inst.identity(), 0, t);
});
// }
@@ -298,7 +298,7 @@ void RocksDbSerializer::write_streaming_() {
memcpy(s.data(), &v, sizeof(size_t));
storage.db->Put(storage.wopts, "g|" + (std::string)data->get_attribute_value(0), s);
} else {
::logger::root().error("Instance #" + std::to_string(name) + " has no GlobalId, omitted from guid index");
ifcopenshell::logger::root().error("Instance #" + std::to_string(name) + " has no GlobalId, omitted from guid index");
}
}
}
+2 -2
View File
@@ -8,7 +8,7 @@
#include <string>
#include <vector>
class SERIALIZERS_API RocksDbSerializer : public serializer {
class SERIALIZERS_API RocksDbSerializer : public ifcopenshell::geom::serializer {
private:
std::string input_filename_;
std::string rocksdb_filename_;
@@ -16,7 +16,7 @@ private:
void write_streaming_();
public:
RocksDbSerializer(const std::string& input_filename, const std::string& rocksdb_filename, const std::vector<std::string>& skip_supertypes = {}, ::logger* logger = nullptr);
RocksDbSerializer(const std::string& input_filename, const std::string& rocksdb_filename, const std::vector<std::string>& skip_supertypes = {}, ifcopenshell::logger* logger = nullptr);
virtual ~RocksDbSerializer() {}
+1 -1
View File
@@ -34,7 +34,7 @@ class step_serializer : public open_cascade_based_serializer
private:
STEPControl_Writer writer;
public:
explicit step_serializer(const std::string& out_filename, const ifcopenshell::geom::settings& settings, ::logger* logger = nullptr)
explicit step_serializer(const std::string& out_filename, const ifcopenshell::geom::settings& settings, ifcopenshell::logger* logger = nullptr)
: open_cascade_based_serializer(out_filename, settings, logger)
{}
virtual ~step_serializer() {}
+1 -1
View File
@@ -2753,7 +2753,7 @@ std::string svg_serializer::nameElement(express::base storey, const ifcopenshell
ifcopenshell::escape_xml(n);
return nameElement_({
{"id", with_section_heights_from_storey_ ? object_id(storey, elem) : geometry_serializer::object_id(elem)},
{"id", with_section_heights_from_storey_ ? object_id(storey, elem) : ifcopenshell::geom::geometry_serializer::object_id(elem)},
{"class", elem->type()},
{namespace_prefix_ + "name", n},
{namespace_prefix_ + "guid", elem->guid()}
+7 -7
View File
@@ -380,11 +380,11 @@ namespace {
// SVG edge classification (issue #3668): see add_classified_edges().
std::list<std::tuple<express::base, std::string, TopoDS_Shape>> classified_items_;
::logger& logger_;
ifcopenshell::logger& logger_;
public:
prefiltered_hlr(::logger& logger, bool use_prefiltering, bool use_hlr_poly, bool segment_projection, const gp_Pln& view_direction)
prefiltered_hlr(ifcopenshell::logger& logger, bool use_prefiltering, bool use_hlr_poly, bool segment_projection, const gp_Pln& view_direction)
: logger_(logger)
, use_prefiltering_(use_prefiltering)
, use_hlr_poly_(use_hlr_poly)
@@ -554,7 +554,7 @@ namespace {
typedef prefiltered_hlr hlr_t;
class SERIALIZERS_API svg_serializer : public write_only_geometry_serializer {
class SERIALIZERS_API svg_serializer : public ifcopenshell::geom::write_only_geometry_serializer {
public:
typedef std::pair<std::string, std::vector<util::string_buffer> > path_object;
typedef std::vector< boost::shared_ptr<util::string_buffer::float_item> > float_item_list;
@@ -625,8 +625,8 @@ protected:
subtract_before_project subtraction_settings_;
public:
svg_serializer(const stream_or_filename& out_filename, const ifcopenshell::geom::settings& settings, ::logger* logger = nullptr)
: write_only_geometry_serializer(settings, logger)
svg_serializer(const stream_or_filename& out_filename, const ifcopenshell::geom::settings& settings, ifcopenshell::logger* logger = nullptr)
: ifcopenshell::geom::write_only_geometry_serializer(settings, logger)
, svg_file(out_filename)
, xmin(+std::numeric_limits<double>::infinity())
, ymin(+std::numeric_limits<double>::infinity())
@@ -787,9 +787,9 @@ public:
std::string idElement(express::base elem);
std::string object_id(express::base storey, const ifcopenshell::geom::element* o) {
if (storey) {
return idElement(storey) + "-" + geometry_serializer::object_id(o);
return idElement(storey) + "-" + ifcopenshell::geom::geometry_serializer::object_id(o);
} else {
return geometry_serializer::object_id(o);
return ifcopenshell::geom::geometry_serializer::object_id(o);
}
}
+2 -2
View File
@@ -233,8 +233,8 @@ namespace {
}
}
ttl_wkt_serializer::ttl_wkt_serializer(const stream_or_filename& filename, const ifcopenshell::geom::settings& settings, ::logger* logger)
: write_only_geometry_serializer(settings, logger)
ttl_wkt_serializer::ttl_wkt_serializer(const stream_or_filename& filename, const ifcopenshell::geom::settings& settings, ifcopenshell::logger* logger)
: ifcopenshell::geom::write_only_geometry_serializer(settings, logger)
, filename_(filename)
{
const auto& tri_setting = settings.get<ifcopenshell::geom::settings::TriangulationType>().get();
+2 -2
View File
@@ -36,8 +36,8 @@
#include <math.h>
usd_serializer::usd_serializer(const std::string& out_filename, const ifcopenshell::geom::settings& settings, ::logger* logger):
write_only_geometry_serializer(settings, logger),
usd_serializer::usd_serializer(const std::string& out_filename, const ifcopenshell::geom::settings& settings, ifcopenshell::logger* logger):
ifcopenshell::geom::write_only_geometry_serializer(settings, logger),
filename_(out_filename)
{
std::size_t found = filename_.find_last_of("/\\");
+2 -2
View File
@@ -66,7 +66,7 @@ namespace usd_utils {
}
}
class SERIALIZERS_API usd_serializer : public write_only_geometry_serializer {
class SERIALIZERS_API usd_serializer : public ifcopenshell::geom::write_only_geometry_serializer {
private:
bool ready_ = false;
const std::string filename_;
@@ -86,7 +86,7 @@ private:
std::set<std::string> emitted_names_;
std::map<int, std::string> element_names_;
public:
usd_serializer(const std::string&, const ifcopenshell::geom::settings& settings, ::logger* logger = nullptr);
usd_serializer(const std::string&, const ifcopenshell::geom::settings& settings, ifcopenshell::logger* logger = nullptr);
virtual ~usd_serializer();
bool ready() { return ready_; }
void writeHeader();
+2 -2
View File
@@ -27,8 +27,8 @@
#include <boost/lexical_cast.hpp>
#include <iomanip>
wavefront_obj_serializer::wavefront_obj_serializer(const stream_or_filename& obj_filename, const stream_or_filename& mtl_filename, const ifcopenshell::geom::settings& settings, ::logger* logger)
: write_only_geometry_serializer(settings, logger)
wavefront_obj_serializer::wavefront_obj_serializer(const stream_or_filename& obj_filename, const stream_or_filename& mtl_filename, const ifcopenshell::geom::settings& settings, ifcopenshell::logger* logger)
: ifcopenshell::geom::write_only_geometry_serializer(settings, logger)
, obj_stream(obj_filename)
, mtl_stream(mtl_filename)
, vcount_total(1)
+2 -2
View File
@@ -28,14 +28,14 @@
#include "../ifcgeom/GeometrySerializer.h"
// http://people.sc.fsu.edu/~jburkardt/txt/obj_format.txt
class SERIALIZERS_API wavefront_obj_serializer : public write_only_geometry_serializer {
class SERIALIZERS_API wavefront_obj_serializer : public ifcopenshell::geom::write_only_geometry_serializer {
private:
stream_or_filename obj_stream;
stream_or_filename mtl_stream;
size_t vcount_total, ncount_total;
std::set<std::string> materials;
public:
wavefront_obj_serializer(const stream_or_filename& obj_filename, const stream_or_filename& mtl_filename, const ifcopenshell::geom::settings& settings, ::logger* logger = nullptr);
wavefront_obj_serializer(const stream_or_filename& obj_filename, const stream_or_filename& mtl_filename, const ifcopenshell::geom::settings& settings, ifcopenshell::logger* logger = nullptr);
virtual ~wavefront_obj_serializer() {}
bool ready();
void writeHeader();
+3 -3
View File
@@ -11,15 +11,15 @@
#include <boost/shared_ptr.hpp>
class xml_serializer : public serializer {
class xml_serializer : public ifcopenshell::geom::serializer {
private:
boost::shared_ptr<serializer> implementation_;
boost::shared_ptr<ifcopenshell::geom::serializer> implementation_;
protected:
std::string xml_filename;
public:
xml_serializer(ifcopenshell::file* file, const std::string& xml_filename, ::logger& logger = ::logger::root())
xml_serializer(ifcopenshell::file* file, const std::string& xml_filename, ifcopenshell::logger& logger = ifcopenshell::logger::root())
: xml_filename(xml_filename)
{
if (!file) {
+1 -1
View File
@@ -27,7 +27,7 @@
namespace {
boost::shared_ptr<serializer> create_serializer(const ifcopenshell::serializers::document_serializer_context& context) {
boost::shared_ptr<ifcopenshell::geom::serializer> create_serializer(const ifcopenshell::serializers::document_serializer_context& context) {
if (context.input_filename.empty()) {
throw ifcopenshell::exception("RocksDB document serializer requires an input filename");
}
@@ -125,7 +125,7 @@ const ifcopenshell::serializers::document_serializer_info* ifcopenshell::seriali
return entry ? &entry->info_ : nullptr;
}
boost::shared_ptr<serializer> ifcopenshell::serializers::document_serializer_registry::create(const std::string& format, const document_serializer_context& context) const {
boost::shared_ptr<ifcopenshell::geom::serializer> ifcopenshell::serializers::document_serializer_registry::create(const std::string& format, const document_serializer_context& context) const {
const auto schema_name = !context.schema_name.empty() ? context.schema_name :
(context.file ? context.file->schema()->name() : std::string());
auto* registry = const_cast<document_serializer_registry*>(this);
@@ -161,7 +161,7 @@ std::vector<ifcopenshell::serializers::document_serializer_info> ifcopenshell::s
try {
module = manager.load(path);
} catch (const std::exception& e) {
::logger::root().error(e);
ifcopenshell::logger::root().error(e);
continue;
}
if (module.meta().kind_ != ifcopenshell::plugin::kind::document_serializer) {
@@ -214,7 +214,7 @@ void ifcopenshell::serializers::load_document_serializer_plugins(document_serial
try {
module = manager.load(path);
} catch (const std::exception& e) {
::logger::root().error(e);
ifcopenshell::logger::root().error(e);
continue;
}
if (module.meta().kind_ != ifcopenshell::plugin::kind::document_serializer) {
@@ -246,7 +246,7 @@ bool ifcopenshell::serializers::load_document_serializer_plugin(document_seriali
try {
module = manager.load(path);
} catch (const std::exception& e) {
::logger::root().error(e);
ifcopenshell::logger::root().error(e);
continue;
}
if (module.meta().kind_ != ifcopenshell::plugin::kind::document_serializer ||
@@ -36,6 +36,8 @@
namespace ifcopenshell {
namespace serializers {
using ifcopenshell::geom::serializer;
struct SERIALIZERS_API document_serializer_info {
std::string format;
std::string name;
@@ -130,7 +130,7 @@ void ifcopenshell::serializers::geometry_serializer_registry::configure(const st
}
}
boost::shared_ptr<geometry_serializer> ifcopenshell::serializers::geometry_serializer_registry::create(const std::string& extension, const geometry_serializer_context& context) const {
boost::shared_ptr<ifcopenshell::geom::geometry_serializer> ifcopenshell::serializers::geometry_serializer_registry::create(const std::string& extension, const geometry_serializer_context& context) const {
const auto key = geometry_serializer_key(extension);
if (entries_.find(key) == entries_.end()) {
load_geometry_serializer_plugin(const_cast<geometry_serializer_registry&>(*this), extension);
@@ -159,7 +159,7 @@ std::vector<ifcopenshell::serializers::geometry_serializer_info> ifcopenshell::s
try {
module = manager.load(path);
} catch (const std::exception& e) {
::logger::root().error(e);
ifcopenshell::logger::root().error(e);
continue;
}
if (module.meta().kind_ != ifcopenshell::plugin::kind::geometry_serializer) {
@@ -204,7 +204,7 @@ void ifcopenshell::serializers::load_geometry_serializer_plugins(geometry_serial
try {
module = manager.load(path);
} catch (const std::exception& e) {
::logger::root().error(e);
ifcopenshell::logger::root().error(e);
continue;
}
if (module.meta().kind_ != ifcopenshell::plugin::kind::geometry_serializer) {
@@ -230,7 +230,7 @@ bool ifcopenshell::serializers::load_geometry_serializer_plugin(geometry_seriali
try {
module = manager.load(path);
} catch (const std::exception& e) {
::logger::root().error(e);
ifcopenshell::logger::root().error(e);
continue;
}
if (module.meta().kind_ != ifcopenshell::plugin::kind::geometry_serializer ||
@@ -35,6 +35,8 @@
namespace ifcopenshell {
namespace serializers {
using ifcopenshell::geom::geometry_serializer;
struct SERIALIZERS_API geometry_serializer_info {
std::string format;
std::string name;
@@ -40,14 +40,14 @@ class format_value_visitor : public boost::static_visitor<std::string> {
template <typename T>
json operator()(const T& t) const {
if constexpr (std::is_same_v<std::decay_t<T>, derived> || std::is_same_v<std::decay_t<T>, boost::dynamic_bitset<>> || std::is_same_v<std::decay_t<T>, express::base> || std::is_same_v<std::decay_t<T>, std::vector<int>> || std::is_same_v<std::decay_t<T>, std::vector<double>> || std::is_same_v<std::decay_t<T>, std::vector<std::string>> || std::is_same_v<std::decay_t<T>, std::vector<boost::dynamic_bitset<>>> || std::is_same_v<std::decay_t<T>, std::vector<express::base>> || std::is_same_v<std::decay_t<T>, std::vector<std::vector<express::base>>> || std::is_same_v<std::decay_t<T>, std::vector<std::vector<int>>> || std::is_same_v<std::decay_t<T>, std::vector<std::vector<double>>> || std::is_same_v<std::decay_t<T>, empty_aggregate_t> || std::is_same_v<std::decay_t<T>, empty_aggregate_of_aggregate_t> || std::is_same_v<std::decay_t<T>, blank>) {
if constexpr (std::is_same_v<std::decay_t<T>, ifcopenshell::derived> || std::is_same_v<std::decay_t<T>, boost::dynamic_bitset<>> || std::is_same_v<std::decay_t<T>, express::base> || std::is_same_v<std::decay_t<T>, std::vector<int>> || std::is_same_v<std::decay_t<T>, std::vector<double>> || std::is_same_v<std::decay_t<T>, std::vector<std::string>> || std::is_same_v<std::decay_t<T>, std::vector<boost::dynamic_bitset<>>> || std::is_same_v<std::decay_t<T>, std::vector<express::base>> || std::is_same_v<std::decay_t<T>, std::vector<std::vector<express::base>>> || std::is_same_v<std::decay_t<T>, std::vector<std::vector<int>>> || std::is_same_v<std::decay_t<T>, std::vector<std::vector<double>>> || std::is_same_v<std::decay_t<T>, ifcopenshell::empty_aggregate_t> || std::is_same_v<std::decay_t<T>, ifcopenshell::empty_aggregate_of_aggregate_t> || std::is_same_v<std::decay_t<T>, ifcopenshell::blank>) {
return "";
} else if constexpr (std::is_same_v<std::decay_t<T>, boost::logic::tribool>) {
// @todo handle indeterminate
return "";
} else if constexpr (std::is_same_v<std::decay_t<T>, std::string>) {
return t;
} else if constexpr (std::is_same_v<std::decay_t<T>, enumeration_reference>) {
} else if constexpr (std::is_same_v<std::decay_t<T>, ifcopenshell::enumeration_reference>) {
return t.value();
} else {
return t;
@@ -69,7 +69,7 @@ class get_type_visitor : public boost::static_visitor<std::string> {
// Returns related entity instances using IFC's objectified relationship
// model. The second and third argument require a member function pointer.
template <typename T, typename U, typename V, typename F, typename G>
auto get_related(::logger& log, T t, F f, G g) {
auto get_related(ifcopenshell::logger& log, T t, F f, G g) {
auto li = (t.*f)();
std::vector<V> acc;
for (auto& u : li) {
@@ -97,7 +97,7 @@ auto get_related(::logger& log, T t, F f, G g) {
return acc;
}
void format_entity_instance(::logger& log, express::base instance, json& tree, express::base parent = express::base()) {
void format_entity_instance(ifcopenshell::logger& log, express::base instance, json& tree, express::base parent = express::base()) {
/*
{
"id" : string, // Element GUID (IFC GloballyUniqueId)
@@ -119,7 +119,7 @@ void format_entity_instance(::logger& log, express::base instance, json& tree, e
json child;
auto write_to_json = [&](const std::string& keyJson, const std::string& keyIfc) {
attribute_value val;
ifcopenshell::attribute_value val;
try {
val = instance.as<express::entity>().get(keyIfc);
} catch (const ifcopenshell::exception&) {
@@ -168,7 +168,7 @@ void format_entity_instance(::logger& log, express::base instance, json& tree, e
// A function to be called recursively. Template specialization is used
// to descend into decomposition, containment and property relationships.
template <typename A>
void descend(::logger& log, A instance, json& tree, express::base parent = express::base()) {
void descend(ifcopenshell::logger& log, A instance, json& tree, express::base parent = express::base()) {
if (instance.declaration().is(IfcSchema::IfcObjectDefinition::Class())) {
descend(log, instance.template as<IfcSchema::IfcObjectDefinition>(), tree, parent);
} else {
@@ -181,7 +181,7 @@ void descend(::logger& log, A instance, json& tree, express::base parent = expre
// Descends into the tree by recursing into IfcRelContainedInSpatialStructure,
// IfcRelDecomposes, IfcRelDefinesByType, IfcRelDefinesByProperties relations.
template <>
void descend(::logger& log, IfcSchema::IfcObjectDefinition product, json& tree, express::base parent) {
void descend(ifcopenshell::logger& log, IfcSchema::IfcObjectDefinition product, json& tree, express::base parent) {
if (product.declaration().is(IfcSchema::IfcElement::Class())) {
auto voids = product.as<IfcSchema::IfcElement>().FillsVoids();
if (voids.size() == 1 && voids.front().RelatingOpeningElement() != parent) {
@@ -267,7 +267,7 @@ void POSTFIX_SCHEMA(json_serializer)::finalize() {
auto projects = file->instances_by_type<IfcSchema::IfcProject>();
if (projects.size() != 1) {
logger().message(::logger::LOG_ERROR, "SER", 7, "Expected a single IfcProject");
logger().message(ifcopenshell::logger::LOG_ERROR, "SER", 7, "Expected a single IfcProject");
return;
}
IfcSchema::IfcProject project = projects.front();
@@ -41,7 +41,7 @@ class POSTFIX_SCHEMA(json_serializer) : public json_serializer {
ifcopenshell::geom::abstract_mapping* mapping_;
public:
POSTFIX_SCHEMA(json_serializer)(ifcopenshell::file* file, const std::string& json_filename, json_serializer::Dialect dialect, ::logger& logger = ::logger::root())
POSTFIX_SCHEMA(json_serializer)(ifcopenshell::file* file, const std::string& json_filename, json_serializer::Dialect dialect, ifcopenshell::logger& logger = ifcopenshell::logger::root())
: json_serializer(0, "", dialect), mapping_(ifcopenshell::geom::impl::mapping_implementations().construct(file, settings_, logger))
{
this->file = file;
@@ -39,7 +39,7 @@ std::map<std::string, std::string> POSTFIX_SCHEMA(argument_name_map);
// Format an IFC attribute and maybe returns as string. Only literal scalar
// values are converted. Things like entity instances and lists are omitted.
std::optional<std::string> format_attribute(ifcopenshell::geom::abstract_mapping* mapping, attribute_value argument, ifcopenshell::argument_type argument_type, const std::string& argument_name) {
std::optional<std::string> format_attribute(ifcopenshell::geom::abstract_mapping* mapping, ifcopenshell::attribute_value argument, ifcopenshell::argument_type argument_type, const std::string& argument_name) {
std::optional<std::string> value;
// Hard-code lat-lon as it represents an array
@@ -131,7 +131,7 @@ std::optional<std::string> format_attribute(ifcopenshell::geom::abstract_mapping
}
// Appends to a node with possibly existing attributes
ptree* format_entity_instance(::logger& log, ifcopenshell::geom::abstract_mapping* mapping, const express::base& instance, ptree& child, ptree& tree, bool as_link = false) {
ptree* format_entity_instance(ifcopenshell::logger& log, ifcopenshell::geom::abstract_mapping* mapping, const express::base& instance, ptree& child, ptree& tree, bool as_link = false) {
const unsigned n = instance.declaration().as_entity()->attribute_count();
for (unsigned i = 0; i < n; ++i) {
try {
@@ -176,7 +176,7 @@ ptree* format_entity_instance(::logger& log, ifcopenshell::geom::abstract_mappin
// Formats an entity instances as a ptree node, and insert into the DOM. Recurses
// over the entity attributes and writes them as xml attributes of the node.
ptree* format_entity_instance(::logger& log, ifcopenshell::geom::abstract_mapping* mapping, const express::base& instance, ptree& tree, bool as_link = false) {
ptree* format_entity_instance(ifcopenshell::logger& log, ifcopenshell::geom::abstract_mapping* mapping, const express::base& instance, ptree& tree, bool as_link = false) {
ptree child;
return format_entity_instance(log, mapping, instance, child, tree, as_link);
}
@@ -188,7 +188,7 @@ std::string qualify_unrooted_instance(const express::base& inst) {
// A function to be called recursively. Template specialization is used
// to descend into decomposition, containment and property relationships.
template <typename A>
ptree* descend(::logger& log, ifcopenshell::geom::abstract_mapping* mapping, A instance, ptree& tree, express::base parent = express::base()) {
ptree* descend(ifcopenshell::logger& log, ifcopenshell::geom::abstract_mapping* mapping, A instance, ptree& tree, express::base parent = express::base()) {
if (instance.declaration().is(IfcSchema::IfcObjectDefinition::Class())) {
return descend(log, mapping, instance.template as<IfcSchema::IfcObjectDefinition>(), tree, parent);
} else {
@@ -199,7 +199,7 @@ ptree* descend(::logger& log, ifcopenshell::geom::abstract_mapping* mapping, A i
// Returns related entity instances using IFC's objectified relationship
// model. The second and third argument require a member function pointer.
template <typename T, typename U, typename V, typename F, typename G>
auto get_related(::logger& log, T t, F f, G g) {
auto get_related(ifcopenshell::logger& log, T t, F f, G g) {
auto li = (t.*f)();
std::vector<V> acc;
for (auto& u : li) {
@@ -230,7 +230,7 @@ auto get_related(::logger& log, T t, F f, G g) {
// Descends into the tree by recursing into IfcRelContainedInSpatialStructure,
// IfcRelDecomposes, IfcRelDefinesByType, IfcRelDefinesByProperties relations.
template <>
ptree* descend(::logger& log, ifcopenshell::geom::abstract_mapping* mapping, IfcSchema::IfcObjectDefinition product, ptree& tree, express::base parent) {
ptree* descend(ifcopenshell::logger& log, ifcopenshell::geom::abstract_mapping* mapping, IfcSchema::IfcObjectDefinition product, ptree& tree, express::base parent) {
if (product.declaration().is(IfcSchema::IfcElement::Class())) {
auto voids = product.as<IfcSchema::IfcElement>().FillsVoids();
if (voids.size() == 1 && voids.front().RelatingOpeningElement() != parent) {
@@ -365,7 +365,7 @@ ptree* descend(::logger& log, ifcopenshell::geom::abstract_mapping* mapping, Ifc
}
// Format IfcProperty instances and insert into the DOM. IfcComplexProperties are flattened out.
void format_properties(::logger& log, ifcopenshell::geom::abstract_mapping* mapping, const std::vector<IfcSchema::IfcProperty>& properties, ptree& node) {
void format_properties(ifcopenshell::logger& log, ifcopenshell::geom::abstract_mapping* mapping, const std::vector<IfcSchema::IfcProperty>& properties, ptree& node) {
for (auto& p : properties) {
if (auto complex = p.as<IfcSchema::IfcComplexProperty>()) {
format_properties(log, mapping, complex.HasProperties(), node);
@@ -375,7 +375,7 @@ void format_properties(::logger& log, ifcopenshell::geom::abstract_mapping* mapp
}
}
void writeGroupToNode(::logger& log, ifcopenshell::geom::abstract_mapping* mapping, IfcSchema::IfcGroup group, ptree& node, std::set<std::string> notRootGroups) {
void writeGroupToNode(ifcopenshell::logger& log, ifcopenshell::geom::abstract_mapping* mapping, IfcSchema::IfcGroup group, ptree& node, std::set<std::string> notRootGroups) {
// @todo tfk: instead of a set<string> shouldn't we just have a set<IfcGroup>, the current approach
// might not work with non-unique or NIL group names.
@@ -407,7 +407,7 @@ void writeGroupToNode(::logger& log, ifcopenshell::geom::abstract_mapping* mappi
}
// Format IfcElementQuantity instances and insert into the DOM.
void format_quantities(::logger& log, ifcopenshell::geom::abstract_mapping* mapping, const std::vector<IfcSchema::IfcPhysicalQuantity>& quantities, ptree& node) {
void format_quantities(ifcopenshell::logger& log, ifcopenshell::geom::abstract_mapping* mapping, const std::vector<IfcSchema::IfcPhysicalQuantity>& quantities, ptree& node) {
for (auto& p : quantities) {
ptree* node2 = format_entity_instance(log, mapping, p, node);
if (node2 && p.declaration().is(IfcSchema::IfcPhysicalComplexQuantity::Class())) {
@@ -417,7 +417,7 @@ void format_quantities(::logger& log, ifcopenshell::geom::abstract_mapping* mapp
}
// Format IfcTask instances and insert into the DOM.
void format_tasks(::logger& log, ifcopenshell::geom::abstract_mapping* mapping, IfcSchema::IfcTask task, ptree& node) {
void format_tasks(ifcopenshell::logger& log, ifcopenshell::geom::abstract_mapping* mapping, IfcSchema::IfcTask task, ptree& node) {
ptree* ntask = format_entity_instance(log, mapping, task, node);
if (ntask) {
@@ -532,7 +532,7 @@ void POSTFIX_SCHEMA(xml_serializer)::finalize() {
auto projects = file->instances_by_type<IfcSchema::IfcProject>();
if (projects.size() != 1) {
log.message(::logger::LOG_ERROR, "Expected a single IfcProject");
log.message(ifcopenshell::logger::LOG_ERROR, "Expected a single IfcProject");
return;
}
IfcSchema::IfcProject& project = projects.front();
@@ -568,7 +568,7 @@ void POSTFIX_SCHEMA(xml_serializer)::finalize() {
catch (const ifcopenshell::exception& ex) {
std::stringstream ss;
ss << "Failed to get ifc file header file_description implementation_level, error: '" << ex.what() << "'";
log.message(::logger::LOG_ERROR, "SER", 14, ss.str());
log.message(ifcopenshell::logger::LOG_ERROR, "SER", 14, ss.str());
}
try {
header.put("file_name.name", file->header().file_name().name());
@@ -576,7 +576,7 @@ void POSTFIX_SCHEMA(xml_serializer)::finalize() {
catch (const ifcopenshell::exception& ex) {
std::stringstream ss;
ss << "Failed to get ifc file header file_name name, error: '" << ex.what() << "'";
log.message(::logger::LOG_ERROR, "SER", 15, ss.str());
log.message(ifcopenshell::logger::LOG_ERROR, "SER", 15, ss.str());
}
try {
header.put("file_name.time_stamp", file->header().file_name().time_stamp());
@@ -584,7 +584,7 @@ void POSTFIX_SCHEMA(xml_serializer)::finalize() {
catch (const ifcopenshell::exception& ex) {
std::stringstream ss;
ss << "Failed to get ifc file header file_name time_stamp, error: '" << ex.what() << "'";
log.message(::logger::LOG_ERROR, "SER", 16, ss.str());
log.message(ifcopenshell::logger::LOG_ERROR, "SER", 16, ss.str());
}
try {
header.put("file_name.preprocessor_version", file->header().file_name().preprocessor_version());
@@ -592,7 +592,7 @@ void POSTFIX_SCHEMA(xml_serializer)::finalize() {
catch (const ifcopenshell::exception& ex) {
std::stringstream ss;
ss << "Failed to get ifc file header file_name preprocessor_version, error: '" << ex.what() << "'";
log.message(::logger::LOG_ERROR, "SER", 17, ss.str());
log.message(ifcopenshell::logger::LOG_ERROR, "SER", 17, ss.str());
}
try {
header.put("file_name.originating_system", file->header().file_name().originating_system());
@@ -600,7 +600,7 @@ void POSTFIX_SCHEMA(xml_serializer)::finalize() {
catch (const ifcopenshell::exception& ex) {
std::stringstream ss;
ss << "Failed to get ifc file header file_name originating_system, error: '" << ex.what() << "'";
log.message(::logger::LOG_ERROR, "SER", 18, ss.str());
log.message(ifcopenshell::logger::LOG_ERROR, "SER", 18, ss.str());
}
try {
// @nb inconsistent spelling
@@ -609,7 +609,7 @@ void POSTFIX_SCHEMA(xml_serializer)::finalize() {
catch (const ifcopenshell::exception& ex) {
std::stringstream ss;
ss << "Failed to get ifc file header file_name authorization, error: '" << ex.what() << "'";
log.message(::logger::LOG_ERROR, "SER", 19, ss.str());
log.message(ifcopenshell::logger::LOG_ERROR, "SER", 19, ss.str());
}
// Descend into the decomposition structure of the IFC file.
@@ -39,7 +39,7 @@ private:
ifcopenshell::geom::abstract_mapping* mapping_;
public:
POSTFIX_SCHEMA(xml_serializer)(ifcopenshell::file* file, const std::string& xml_filename, ::logger& logger = ::logger::root())
POSTFIX_SCHEMA(xml_serializer)(ifcopenshell::file* file, const std::string& xml_filename, ifcopenshell::logger& logger = ifcopenshell::logger::root())
: xml_serializer(0, "")
, mapping_(ifcopenshell::geom::impl::mapping_implementations().construct(file, settings_, logger))
{
@@ -29,7 +29,7 @@
namespace {
boost::shared_ptr<serializer> create_serializer(const ifcopenshell::serializers::document_serializer_context& context) {
boost::shared_ptr<ifcopenshell::geom::serializer> create_serializer(const ifcopenshell::serializers::document_serializer_context& context) {
return boost::make_shared<POSTFIX_SCHEMA(json_serializer)>(
context.file,
context.output_filename,
@@ -27,7 +27,7 @@
namespace {
boost::shared_ptr<serializer> create_serializer(const ifcopenshell::serializers::document_serializer_context& context) {
boost::shared_ptr<ifcopenshell::geom::serializer> create_serializer(const ifcopenshell::serializers::document_serializer_context& context) {
return boost::make_shared<POSTFIX_SCHEMA(xml_serializer)>(context.file, context.output_filename);
}