Restructure and rename

This commit is contained in:
Thomas Krijnen
2026-03-31 15:32:36 +02:00
parent 724cdb446e
commit a07f56db6f
237 changed files with 72532 additions and 72535 deletions
+4 -4
View File
@@ -38,8 +38,8 @@
static std::string& collada_id(std::string& s)
{
IfcUtil::sanitate_material_name(s);
IfcUtil::escape_xml(s);
ifcopenshell::sanitate_material_name(s);
ifcopenshell::escape_xml(s);
return s;
}
@@ -219,7 +219,7 @@ void ColladaSerializer::ColladaExporter::ColladaScene::add(
BOOST_FOREACH(const std::string &material_name, material_ids) {
// Unescape to avoid double escaping because OpenCollada's material URI parameter escapes XML internally
std::string unescaped = material_name;
IfcUtil::unescape_xml(unescaped);
ifcopenshell::unescape_xml(unescaped);
COLLADASW::InstanceMaterial material(material_name, "#" + unescaped);
instanceGeometry.getBindMaterial().getInstanceMaterialList().push_back(material);
@@ -366,7 +366,7 @@ void ColladaSerializer::ColladaExporter::ColladaMaterials::write() {
openMaterial(material_name);
// Unescape to avoid double escaping because OpenCollada's addInstanceEffect escapes XML internally
IfcUtil::unescape_xml(material_name);
ifcopenshell::unescape_xml(material_name);
addInstanceEffect("#" + material_name + "-fx");
closeMaterial();
+1 -1
View File
@@ -238,7 +238,7 @@ public:
unit_name = name;
unit_magnitude = magnitude;
}
void setFile(IfcParse::IfcFile*) {}
void setFile(ifcopenshell::file*) {}
std::string object_id(const IfcGeom::Element* o) /*override*/;
+15 -15
View File
@@ -56,17 +56,17 @@ GltfSerializer::GltfSerializer(const std::string& filename, const ifcopenshell::
, filename_(filename)
, tmp_filename1_(filename + ".indices.tmp")
, tmp_filename2_(filename + ".vertices.tmp")
, fstream_(IfcUtil::path::from_utf8(filename).c_str(), std::ios_base::binary)
, tmp_fstream1_(IfcUtil::path::from_utf8(tmp_filename1_).c_str(), std::ios_base::binary)
, tmp_fstream2_(IfcUtil::path::from_utf8(tmp_filename2_).c_str(), std::ios_base::binary)
, fstream_(ifcopenshell::path::from_utf8(filename).c_str(), std::ios_base::binary)
, tmp_fstream1_(ifcopenshell::path::from_utf8(tmp_filename1_).c_str(), std::ios_base::binary)
, tmp_fstream2_(ifcopenshell::path::from_utf8(tmp_filename2_).c_str(), std::ios_base::binary)
, bufferViewId(0)
{}
GltfSerializer::~GltfSerializer() {
tmp_fstream1_.close();
tmp_fstream2_.close();
IfcUtil::path::delete_file(tmp_filename1_);
IfcUtil::path::delete_file(tmp_filename2_);
ifcopenshell::path::delete_file(tmp_filename1_);
ifcopenshell::path::delete_file(tmp_filename2_);
}
bool GltfSerializer::ready() {
@@ -444,12 +444,12 @@ void GltfSerializer::finalize() {
// nb: uint32_t is the max buffer size in glTF
uint32_t indices_length, binary_length;
{
std::ifstream ifs(IfcUtil::path::from_utf8(tmp_filename1_).c_str(), std::ios::binary);
std::ifstream ifs(ifcopenshell::path::from_utf8(tmp_filename1_).c_str(), std::ios::binary);
ifs.ignore(std::numeric_limits<std::streamsize>::max());
indices_length = ifs.gcount();
}
{
std::ifstream ifs(IfcUtil::path::from_utf8(tmp_filename2_).c_str(), std::ios::binary);
std::ifstream ifs(ifcopenshell::path::from_utf8(tmp_filename2_).c_str(), std::ios::binary);
ifs.ignore(std::numeric_limits<std::streamsize>::max());
binary_length = indices_length + ifs.gcount();
}
@@ -490,12 +490,12 @@ void GltfSerializer::finalize() {
write_header<BIN>(fstream_, binary_length);
{
//First, write the indices buffer into our glb file
std::ifstream ifs(IfcUtil::path::from_utf8(tmp_filename1_).c_str(), std::ios::binary);
std::ifstream ifs(ifcopenshell::path::from_utf8(tmp_filename1_).c_str(), std::ios::binary);
fstream_ << ifs.rdbuf();
}
{
//Next, write the vertices buffer into our glb file
std::ifstream ifs(IfcUtil::path::from_utf8(tmp_filename2_).c_str(), std::ios::binary);
std::ifstream ifs(ifcopenshell::path::from_utf8(tmp_filename2_).c_str(), std::ios::binary);
fstream_ << ifs.rdbuf();
}
write_padding<BIN>(fstream_, binary_length);
@@ -517,11 +517,11 @@ namespace {
}
void proj_log(void *, int, const char* c) {
Logger::Error("PROJ: " + std::string(c));
logger::error("PROJ: " + std::string(c));
}
}
void GltfSerializer::setFile(IfcParse::IfcFile* f) {
void GltfSerializer::setFile(ifcopenshell::file* f) {
if (!settings_.get<ifcopenshell::geometry::settings::WriteGltfEcef>().get()) {
return;
}
@@ -533,7 +533,7 @@ void GltfSerializer::setFile(IfcParse::IfcFile* f) {
std::vector<express::Base> coordops;
try {
coordops = f->instances_by_type("IfcCoordinateOperation");
} catch (IfcParse::IfcException&) {
} catch (ifcopenshell::exception&) {
// Ignored. Schema likely doesn't support IfcCoordinateOperation.
}
for (auto& coordop : coordops) {
@@ -646,7 +646,7 @@ void GltfSerializer::setFile(IfcParse::IfcFile* f) {
NULL);
if (!P) {
Logger::Error("Failed to create PROJ transformation object");
logger::error("Failed to create PROJ transformation object");
return;
}
@@ -658,7 +658,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("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);
@@ -683,7 +683,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("Failed to create ellipsoid CRS");
return;
}
+1 -1
View File
@@ -52,7 +52,7 @@ public:
void finalize();
bool isTesselated() const { return true; }
void setUnitNameAndMagnitude(const std::string& /*name*/, float /*magnitude*/) {}
void setFile(IfcParse::IfcFile*);
void setFile(ifcopenshell::file*);
};
#endif
+3 -3
View File
@@ -67,7 +67,7 @@ HdfSerializer::HdfSerializer(const std::string& hdf_filename, const ifcopenshell
? H5F_ACC_RDONLY
: (H5F_ACC_RDWR | H5F_ACC_CREAT));
} catch (H5::Exception& e) {
throw IfcParse::IfcException(e.getDetailMsg());
throw ifcopenshell::exception(e.getDetailMsg());
}
str_type = H5::StrType(H5::PredType::C_S1, H5T_VARIABLE);
@@ -236,7 +236,7 @@ namespace {
void HdfSerializer::read_surface_style(const surface_style_serialization& s,
ifcopenshell::geometry::taxonomy::style& gss,
IfcParse::IfcFile& f) {
ifcopenshell::file& f) {
if (strlen(s.name) || s.id) {
if (!std::isnan(s.diffuse[0])) {
gss.diffuse = ifcopenshell::geometry::taxonomy::colour(s.diffuse[0], s.diffuse[1], s.diffuse[2]);
@@ -263,7 +263,7 @@ void HdfSerializer::remove(const std::string& guid) {
}
}
IfcGeom::Element* HdfSerializer::read(IfcParse::IfcFile& f, const std::string& guid, const std::string& representation_id_str, read_type rt) {
IfcGeom::Element* HdfSerializer::read(ifcopenshell::file& f, const std::string& guid, const std::string& representation_id_str, read_type rt) {
if (!H5Lexists(file.getId(), guid.c_str(), H5P_DEFAULT)) {
return nullptr;
}
+3 -3
View File
@@ -92,7 +92,7 @@ private:
H5::Group createRepresentationGroup(const H5::Group& element_group, const std::string& gid);
void read_surface_style(const surface_style_serialization& s,
ifcopenshell::geometry::taxonomy::style& gss,
IfcParse::IfcFile& f);
ifcopenshell::file& f);
void write_style(surface_style_serialization& data, const ifcopenshell::geometry::taxonomy::style::ptr& s);
public:
@@ -106,12 +106,12 @@ public:
void write(const IfcGeom::TriangulationElement* o);
void remove(const std::string& guid);
IfcGeom::Element* read(IfcParse::IfcFile& f, const std::string& guid, const std::string&, read_type rt = READ_BREP);
IfcGeom::Element* read(ifcopenshell::file& f, const std::string& guid, const std::string&, read_type rt = READ_BREP);
void finalize() {}
bool isTesselated() const { return false; }
void setUnitNameAndMagnitude(const std::string& /*name*/, float /*magnitude*/) {}
void setFile(IfcParse::IfcFile*) {}
void setFile(ifcopenshell::file*) {}
};
#endif
+2 -2
View File
@@ -23,7 +23,7 @@
#define IGESSERIALIZER_H
#include "OpenCascadeBasedSerializer.h"
#include "../ifcparse/IfcLogger.h"
#include "../ifcparse/logger.h"
#include <IGESControl_Writer.hxx>
@@ -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("Setting IGES units not supported on OCE");
#else
Interface_Static::SetCVal("xstep.cascade.unit", symbol);
Interface_Static::SetCVal("write.iges.unit", symbol);
+3 -3
View File
@@ -42,16 +42,16 @@ void JsonSerializerFactory::Factory::bind(const std::string& schema_name, fn f)
this->insert(std::make_pair(schema_name_lower, f));
}
JsonSerializer* JsonSerializerFactory::Factory::construct(const std::string& schema_name, IfcParse::IfcFile* file, std::string json_filename, JsonSerializer::Dialect dialect) {
JsonSerializer* JsonSerializerFactory::Factory::construct(const std::string& schema_name, ifcopenshell::file* file, std::string json_filename, JsonSerializer::Dialect dialect) {
const std::string schema_name_lower = boost::to_lower_copy(schema_name);
auto it = this->find(schema_name_lower);
if (it == this->end()) {
throw IfcParse::IfcException("No Json serializer registered for " + schema_name);
throw ifcopenshell::exception("No Json serializer registered for " + schema_name);
}
return it->second(file, json_filename, dialect);
}
JsonSerializer::JsonSerializer(IfcParse::IfcFile* file, const std::string& json_filename, JsonSerializer::Dialect dialect) {
JsonSerializer::JsonSerializer(ifcopenshell::file* file, const std::string& json_filename, JsonSerializer::Dialect dialect) {
if (file) {
implementation_ = JsonSerializerFactory::implementations().construct(file->schema()->name(), file, json_filename, dialect);
}
+5 -5
View File
@@ -4,7 +4,7 @@
#ifdef WITH_GLTF
#include "../ifcgeom/Serializer.h"
#include "../ifcparse/IfcFile.h"
#include "../ifcparse/file.h"
#include "../serializers/serializers_api.h"
#include <boost/function.hpp>
@@ -23,7 +23,7 @@ class SERIALIZERS_API JsonSerializer : public Serializer {
Dialect dialect_;
public:
JsonSerializer(IfcParse::IfcFile* file, const std::string& json_filename, Dialect dialect = Dialect::JSON_DIALECT_CREOOX);
JsonSerializer(ifcopenshell::file* file, const std::string& json_filename, Dialect dialect = Dialect::JSON_DIALECT_CREOOX);
virtual ~JsonSerializer() {}
@@ -31,17 +31,17 @@ class SERIALIZERS_API JsonSerializer : public Serializer {
void writeHeader() {}
void finalize() { implementation_->finalize(); }
void setFile(IfcParse::IfcFile*) { throw IfcParse::IfcException("Should be supplied on construction"); }
void setFile(ifcopenshell::file*) { throw ifcopenshell::exception("Should be supplied on construction"); }
};
struct SERIALIZERS_API JsonSerializerFactory {
typedef boost::function3<JsonSerializer*, IfcParse::IfcFile*, std::string, JsonSerializer::Dialect> fn;
typedef boost::function3<JsonSerializer*, ifcopenshell::file*, std::string, JsonSerializer::Dialect> fn;
class Factory : public std::map<std::string, fn> {
public:
Factory();
void bind(const std::string& schema_name, fn);
JsonSerializer* construct(const std::string& schema_name, IfcParse::IfcFile*, std::string, JsonSerializer::Dialect);
JsonSerializer* construct(const std::string& schema_name, ifcopenshell::file*, std::string, JsonSerializer::Dialect);
};
static Factory& implementations();
@@ -32,10 +32,10 @@
#include <BRepBuilderAPI_Transform.hxx>
bool OpenCascadeBasedSerializer::ready() {
std::ofstream test_file(IfcUtil::path::from_utf8(out_filename).c_str(), std::ios_base::binary);
std::ofstream test_file(ifcopenshell::path::from_utf8(out_filename).c_str(), std::ios_base::binary);
bool succeeded = test_file.is_open();
test_file.close();
IfcUtil::path::delete_file(out_filename);
ifcopenshell::path::delete_file(out_filename);
return succeeded;
}
+1 -1
View File
@@ -47,7 +47,7 @@ public:
void write(const IfcGeom::TriangulationElement* /*o*/) {}
void write(const IfcGeom::BRepElement* o);
bool isTesselated() const { return false; }
void setFile(IfcParse::IfcFile*) {}
void setFile(ifcopenshell::file*) {}
};
#endif
+23 -23
View File
@@ -4,18 +4,18 @@
#include <rocksdb/options.h>
#include "../ifcparse/IfcLogger.h"
#include "../ifcparse/logger.h"
RocksDbSerializer::RocksDbSerializer(IfcParse::IfcFile* file, const std::string& rocksdb_filename)
RocksDbSerializer::RocksDbSerializer(ifcopenshell::file* file, const std::string& rocksdb_filename)
: file_(file)
, rocksdb_filename_(rocksdb_filename)
{
/*rocksdb::Options options;
options.create_if_missing = true;
options.merge_operator.reset(new ConcatenateIdMergeOperator());
rocksdb::Status status = rocksdb::DB::Open(options, rocksdb_filename, &db_);*/
rocksdb::status status = rocksdb::DB::Open(options, rocksdb_filename, &db_);*/
output_file_ = new IfcParse::IfcFile(file->schema(), IfcParse::FT_ROCKSDB, rocksdb_filename_);
output_file_ = new ifcopenshell::file(file->schema(), ifcopenshell::FT_ROCKSDB, rocksdb_filename_);
// We promise never to add the same instance twice
output_file_->check_existance_before_adding = false;
@@ -30,8 +30,8 @@ RocksDbSerializer::RocksDbSerializer(const std::string& input_filename, const st
}
namespace {
// @nb copied from InstanceData.cpp but operating on unresolved instances
bool serialize(std::string& val, const IfcParse::reference_or_simple_type& t)
// @nb copied from instance_data.cpp but operating on unresolved instances
bool serialize(std::string& val, const ifcopenshell::reference_or_simple_type& t)
{
auto s = sizeof(size_t);
val.resize(s + 2);
@@ -40,7 +40,7 @@ namespace {
// 2 = type - stored by identity (internal counter in class)
val[1] = t.index() == 0 ? 'i' : 't';
size_t iden;
if (auto* name = std::get_if<IfcParse::InstanceReference>(&t)) {
if (auto* name = std::get_if<ifcopenshell::instance_reference>(&t)) {
iden = *name;
} else if (auto* inst = std::get_if<express::Base>(&t)) {
iden = (*inst).identity();
@@ -49,7 +49,7 @@ namespace {
return true;
}
bool serialize(std::string& val, const std::vector<IfcParse::reference_or_simple_type>& t)
bool serialize(std::string& val, const std::vector<ifcopenshell::reference_or_simple_type>& t)
{
// no attempt at alignment
val.resize(t.size() * (sizeof(size_t) + 1) + 1);
@@ -59,7 +59,7 @@ namespace {
*ptr = it->index() == 0 ? 'i' : 't';
ptr++;
size_t iden = 0;
if (auto* name = std::get_if<IfcParse::InstanceReference>(&*it)) {
if (auto* name = std::get_if<ifcopenshell::instance_reference>(&*it)) {
iden = *name;
} else if (auto* inst = std::get_if<express::Base>(&*it)) {
iden = (*inst).identity();
@@ -70,7 +70,7 @@ namespace {
return true;
}
bool serialize(std::string& val, const std::vector<std::vector<IfcParse::reference_or_simple_type>>& t)
bool serialize(std::string& val, const std::vector<std::vector<ifcopenshell::reference_or_simple_type>>& t)
{
std::ostringstream oss;
oss.put(TypeEncoder::encode_type<std::vector<std::vector<express::Base>>>());
@@ -93,7 +93,7 @@ namespace {
char c = jt->index() == 0 ? 'i' : 't';
oss.put(c);
size_t iden = 0;
if (auto* name = std::get_if<IfcParse::InstanceReference>(&*jt)) {
if (auto* name = std::get_if<ifcopenshell::instance_reference>(&*jt)) {
iden = *name;
} else if (auto* inst = std::get_if<express::Base>(&*jt)) {
iden = (*inst).identity();
@@ -124,18 +124,18 @@ namespace {
void RocksDbSerializer::write_streaming_() {
const auto& input_filename = std::get<std::string>(file_);
IfcParse::impl::rocks_db_file_storage storage(rocksdb_filename_, nullptr);
ifcopenshell::impl::rocks_db_file_storage storage(rocksdb_filename_, nullptr);
std::string tmp;
IfcParse::InstanceStreamer streamer(input_filename);
ifcopenshell::instance_streamer streamer(input_filename);
// We do not want to coerce attribute counts here, because we want
// to store exactly what is in the file for validation purposes
streamer.coerce_attribute_count = false;
while (streamer) {
auto inst = streamer.readInstance();
auto inst = streamer.read_instance();
if (inst) {
// name can be zero in case of header instances
auto name = std::get<0>(*inst);
@@ -183,18 +183,18 @@ void RocksDbSerializer::write_streaming_() {
using T = std::decay_t<decltype(v)>;
if constexpr (std::is_same_v<T, IfcParse::reference_or_simple_type>) {
if constexpr (std::is_same_v<T, ifcopenshell::reference_or_simple_type>) {
if (auto* inst = std::get_if<express::Base>(&v)) {
// So this never happens?
simple_type_instances.push_back(*inst);
}
} else if constexpr (std::is_same_v<T, std::vector<IfcParse::reference_or_simple_type>>) {
} else if constexpr (std::is_same_v<T, std::vector<ifcopenshell::reference_or_simple_type>>) {
for (auto const& inner : v) {
if (auto* inst = std::get_if<express::Base>(&inner)) {
simple_type_instances.push_back(*inst);
}
}
} else if constexpr (std::is_same_v<T, std::vector<std::vector<IfcParse::reference_or_simple_type>>>) {
} else if constexpr (std::is_same_v<T, std::vector<std::vector<ifcopenshell::reference_or_simple_type>>>) {
for (auto const& inner : v) {
for (auto const& innermost : inner) {
if (auto* inst = std::get_if<express::Base>(&innermost)) {
@@ -209,8 +209,8 @@ void RocksDbSerializer::write_streaming_() {
storage.wopts,
key, tmp);
auto write_inverse = [&](const IfcParse::reference_or_simple_type& v) {
if (auto* ref = std::get_if<IfcParse::InstanceReference>(&v)) {
auto write_inverse = [&](const ifcopenshell::reference_or_simple_type& v) {
if (auto* ref = std::get_if<ifcopenshell::instance_reference>(&v)) {
auto key = "v|" + to_string_fixed_width(*ref, 10) + "|" + to_string_fixed_width(decl->index_in_schema(), 4) + "|" + to_string_fixed_width(index, 2);
static std::string s;
uint32_t vv = name;
@@ -224,11 +224,11 @@ void RocksDbSerializer::write_streaming_() {
std::visit([&](auto const& val) {
using T = std::decay_t<decltype(val)>;
if constexpr (std::is_same_v<T, IfcParse::reference_or_simple_type>) {
if constexpr (std::is_same_v<T, ifcopenshell::reference_or_simple_type>) {
write_inverse(val);
} else if constexpr (std::is_same_v<T, std::vector<IfcParse::reference_or_simple_type>>) {
} else if constexpr (std::is_same_v<T, std::vector<ifcopenshell::reference_or_simple_type>>) {
std::for_each(val.begin(), val.end(), write_inverse);
} else if constexpr (std::is_same_v<T, std::vector<std::vector<IfcParse::reference_or_simple_type>>>) {
} else if constexpr (std::is_same_v<T, std::vector<std::vector<ifcopenshell::reference_or_simple_type>>>) {
for (auto const& inner : val) {
std::for_each(inner.begin(), inner.end(), write_inverse);
}
@@ -296,4 +296,4 @@ void RocksDbSerializer::finalize() {
}
#endif
#endif
+5 -5
View File
@@ -4,7 +4,7 @@
#include "../serializers/serializers_api.h"
#include "../ifcgeom/Serializer.h"
#include "../ifcparse/IfcFile.h"
#include "../ifcparse/file.h"
#include <rocksdb/db.h>
@@ -12,12 +12,12 @@ class SERIALIZERS_API RocksDbSerializer : public Serializer {
private:
rocksdb::DB* db_;
std::string rocksdb_filename_;
std::variant<IfcParse::IfcFile*, std::string> file_;
IfcParse::IfcFile* output_file_;
std::variant<ifcopenshell::file*, std::string> file_;
ifcopenshell::file* output_file_;
void write_streaming_();
public:
RocksDbSerializer(IfcParse::IfcFile* file, const std::string& rocksdb_filename);
RocksDbSerializer(ifcopenshell::file* file, const std::string& rocksdb_filename);
RocksDbSerializer(const std::string& input_filename, const std::string& rocksdb_filename, bool stream);
virtual ~RocksDbSerializer() {}
@@ -26,7 +26,7 @@ public:
void writeHeader() {}
void finalize();
void setFile(IfcParse::IfcFile*) { throw IfcParse::IfcException("Should be supplied on construction"); }
void setFile(ifcopenshell::file*) { throw ifcopenshell::exception("Should be supplied on construction"); }
};
#endif
+29 -29
View File
@@ -79,7 +79,7 @@
#include <Extrema_ExtPElS.hxx>
#include "../ifcparse/IfcGlobalId.h"
#include "../ifcparse/global_id.h"
#include "../ifcgeom/kernels/opencascade/base_utils.h"
#include "../ifcgeom/kernels/opencascade/boolean_utils.h"
#include "../ifcgeom/kernels/opencascade/wire_utils.h"
@@ -139,13 +139,13 @@ void SvgSerializer::write(path_object& p, const TopoDS_Shape& comp_or_wire, std:
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("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("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, std:
std::stringstream ss;
ss << "Skipping full circle/ellipse inside aggregated <path> (id "
<< p.first << ")";
Logger::Warning(ss.str());
logger::warning(ss.str());
}
}
@@ -512,7 +512,7 @@ namespace {
}
express::Base v = prop.as<express::Entity>().get("NominalValue");
auto value = v.get_attribute_value(0);
if (value.type() == IfcUtil::Argument_STRING) {
if (value.type() == ifcopenshell::Argument_STRING) {
std::string v_str = value;
*output_it++ = string_property{ pset_name, name, v_str };
}
@@ -649,7 +649,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("Failed to box or edge from drawing annotation");
}
std::vector<string_property> props;
@@ -796,7 +796,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("No global section height and unable to determine building storey for:", data.product);
return;
}
}
@@ -811,7 +811,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("Not including element due to viewBox", data.product);
return;
}
}
@@ -858,7 +858,7 @@ void SvgSerializer::write(const geometry_data& data) {
}
}
} catch (std::exception& e) {
Logger::Error(e);
logger::error(e);
}
if (operation_type && ((*operation_type == "SINGLE_SWING_LEFT") || (*operation_type == "SINGLE_SWING_RIGHT"))) {
@@ -1111,7 +1111,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("Failed to cut element for HLR", data.product);
}
}
}
@@ -1207,7 +1207,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("Unable to invoke HLR due to absence of storey containment", data.product);
}
} else if (hlr) {
hlr->add(*compound_to_hlr, data.product);
@@ -1369,7 +1369,7 @@ void SvgSerializer::write(const geometry_data& data) {
for (auto lit = labels.begin(); lit != labels.end(); ++lit) {
auto l = *lit;
IfcUtil::escape_xml(l);
ifcopenshell::escape_xml(l);
double dy = labels.begin() == lit
? 0.35 - (labels.size() - 1.) / 2.
: 1.0; // <- dy is relative to the previous text element, so
@@ -1478,7 +1478,7 @@ void SvgSerializer::write(const geometry_data& data) {
std::string elev_str;
const double lu = file->getUnit("LENGTHUNIT").second;
const double lu = file->get_unit("LENGTHUNIT").second;
auto a = data.product.as<express::Entity>().get("Elevation");
if (!a.isNull()) {
double elev = a;
@@ -1538,7 +1538,7 @@ void SvgSerializer::write(const geometry_data& data) {
path.add("\">");
for (auto lit = labels.begin(); lit != labels.end(); ++lit) {
auto l = *lit;
IfcUtil::escape_xml(l);
ifcopenshell::escape_xml(l);
double dy = labels.begin() == lit
? 0.35 - (labels.size() - 1.) / 2.
: 1.0; // <- dy is relative to the previous text element, so
@@ -1656,7 +1656,7 @@ void SvgSerializer::write(const geometry_data& data) {
path.add(">");
for (auto lit = labels.begin(); lit != labels.end(); ++lit) {
auto l = *lit;
IfcUtil::escape_xml(l);
ifcopenshell::escape_xml(l);
double dy = labels.begin() == lit
? 0.35 - (labels.size() - 1.) / 2.
: 1.0; // <- dy is relative to the previous text element, so
@@ -1680,7 +1680,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("Element not written to SVG due to section heights", data.product);
}
}
@@ -1947,7 +1947,7 @@ void SvgSerializer::addTextAnnotations(const drawing_key& k) {
for (auto lit = labels.begin(); lit != labels.end(); ++lit) {
auto l = *lit;
IfcUtil::escape_xml(l);
ifcopenshell::escape_xml(l);
double dy = labels.begin() == lit
? 0.0 // align bottom
: 1.0; // <- dy is relative to the previous text element, so
@@ -2082,7 +2082,7 @@ void SvgSerializer::finalize() {
if (file && storey_height_display_ != SH_NONE && pln && std::abs(pln->Position().Direction().Z()) < 1.e-5) {
auto storeys = file->instances_by_type("IfcBuildingStorey");
const double lu = file->getUnit("LENGTHUNIT").second;
const double lu = file->get_unit("LENGTHUNIT").second;
for (auto& s : storeys) {
auto storey = s.as<express::Entity>();
auto a = storey.get("Elevation");
@@ -2152,7 +2152,7 @@ void SvgSerializer::finalize() {
svg_file.stream << " <g " << nameElement(it->first.first) << " " << writeMetadata(drawing_metadata[it->first]) << ">\n";
} else {
auto n = it->first.second;
IfcUtil::escape_xml(n);
ifcopenshell::escape_xml(n);
svg_file.stream << " <g " << namespace_prefix_ << "name=\"" << n << "\" class=\"section\" " << writeMetadata(drawing_metadata[it->first]) << ">\n";
}
}
@@ -2266,7 +2266,7 @@ return oss.str();
std::string SvgSerializer::nameElement(express::Base storey, const IfcGeom::Element* elem) {
auto n = elem->name();
IfcUtil::escape_xml(n);
ifcopenshell::escape_xml(n);
return nameElement_({
{"id", with_section_heights_from_storey_ ? object_id(storey, elem) : GeometrySerializer::object_id(elem)},
@@ -2286,7 +2286,7 @@ std::string SvgSerializer::idElement(express::Base elem_) {
? static_cast<std::string>(elem.get("Name"))
: (settings().get<ifcopenshell::geometry::settings::UseElementStepIds>().get())
? ("id-" + boost::lexical_cast<std::string>(elem.id()))
: IfcParse::IfcGlobalId(elem.get("GlobalId")).formatted());
: ifcopenshell::global_id(elem.get("GlobalId")).formatted());
return type + "-" + name;
}
@@ -2298,7 +2298,7 @@ std::string SvgSerializer::nameElement(express::Base elem_) {
std::string ifc_name;
if (!elem.get("Name").isNull()) {
ifc_name = (std::string) elem.get("Name");
IfcUtil::escape_xml(ifc_name);
ifcopenshell::escape_xml(ifc_name);
}
return nameElement_({
@@ -2309,14 +2309,14 @@ std::string SvgSerializer::nameElement(express::Base elem_) {
});
}
void SvgSerializer::setFile(IfcParse::IfcFile* f) {
void SvgSerializer::setFile(ifcopenshell::file* f) {
file = f;
auto storeys = f->instances_by_type("IfcBuildingStorey");
if (storeys.empty()) {
auto mapping = ifcopenshell::geometry::impl::mapping_implementations().construct(file, geometry_settings_);
std::vector<const IfcParse::declaration*> to_derive_from;
std::vector<const ifcopenshell::declaration*> to_derive_from;
to_derive_from.push_back(f->schema()->declaration_by_name("IfcBuilding"));
to_derive_from.push_back(f->schema()->declaration_by_name("IfcSite"));
for (auto it = to_derive_from.begin(); it != to_derive_from.end(); ++it) {
@@ -2333,7 +2333,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("No building storeys encountered, used for reference:", product);
return;
}
}
@@ -2342,7 +2342,7 @@ void SvgSerializer::setFile(IfcParse::IfcFile* f) {
delete mapping;
Logger::Warning("No building storeys encountered, output might be invalid or missing");
logger::warning("No building storeys encountered, output might be invalid or missing");
}
}
@@ -2353,13 +2353,13 @@ void SvgSerializer::setSectionHeight(double h, express::Base storey) {
void SvgSerializer::setSectionHeightsFromStoreys(double offset) {
if (!file) {
Logger::Error("No file specified");
logger::error("No file specified");
return;
}
with_section_heights_from_storey_ = true;
section_data_.emplace();
auto storeys = file->instances_by_type("IfcBuildingStorey");
const double lu = file->getUnit("LENGTHUNIT").second;
const double lu = file->get_unit("LENGTHUNIT").second;
if (!storeys.empty()) {
for (auto& s : storeys) {
auto attr_value = s.as<express::Entity>().get("Elevation");
@@ -2368,7 +2368,7 @@ void SvgSerializer::setSectionHeightsFromStoreys(double offset) {
try {
elev = attr_value;
} catch (std::exception& e) {
Logger::Error(e);
logger::error(e);
continue;
}
if (!section_data_->empty()) {
+4 -4
View File
@@ -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("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("Included " + std::to_string(n_included) + " elements out of " + std::to_string(items_.size()) + " after prefiltering");
}
hlr_calc vis(projector_);
@@ -567,7 +567,7 @@ protected:
int profile_threshold_;
IfcParse::IfcFile* file;
ifcopenshell::file* file;
express::Base storey_;
std::multimap<drawing_key, path_object, storey_sorter> paths;
std::map<drawing_key, drawing_meta> drawing_metadata;
@@ -644,7 +644,7 @@ public:
bool isTesselated() const { return false; }
void finalize();
void setUnitNameAndMagnitude(const std::string& /*name*/, float /*magnitude*/) {}
void setFile(IfcParse::IfcFile* f);
void setFile(ifcopenshell::file* f);
void setBoundingRectangle(double width, double height);
void setSectionHeight(double h, express::Base storey = express::Base());
void setSectionHeightsFromStoreys(double offset=1.2);
+10 -10
View File
@@ -266,16 +266,16 @@ void TtlWktSerializer::write(const IfcGeom::TriangulationElement* o)
{
filename_.stream << ttl_object_id(o) << " a geo:Feature ;\n";
filename_.stream << " dcterms:identifier " << escape_for_turtle(
IfcUtil::convert_utf8(o->guid())) << " ;\n";
ifcopenshell::convert_utf8(o->guid())) << " ;\n";
filename_.stream << " rdfs:label " << escape_for_turtle(
IfcUtil::convert_utf8(o->name())
ifcopenshell::convert_utf8(o->name())
) << " ;\n";
filename_.stream << " geo:hasGeometry " << ttl_object_id(o, "_geometry") << " .\n\n";
if (!o->geometry().polyhedral_faces_with_holes().empty()) {
filename_.stream << ttl_object_id(o, "_geometry") << " a geo:Geometry ;\n";
filename_.stream << " geo:asWKT " << escape_for_turtle(
IfcUtil::convert_utf8(
ifcopenshell::convert_utf8(
capture_output(
emit_polyhedral_surface,
o->geometry().verts(),
@@ -318,7 +318,7 @@ void TtlWktSerializer::write(const IfcGeom::TriangulationElement* o)
filename_.stream << ttl_object_id(o) << " geo:hasGeometry " << ttl_object_id(o, "_footprint_geometry") << " .\n\n";
filename_.stream << ttl_object_id(o, "_footprint_geometry") << " a geo:Geometry ;\n";
filename_.stream << " geo:asWKT " << escape_for_turtle(
IfcUtil::convert_utf8(
ifcopenshell::convert_utf8(
capture_output(
// @nb this is line_component, because this is the linestring
// from a faceboundary, not the edges as pairs of indices.
@@ -345,7 +345,7 @@ void TtlWktSerializer::write(const IfcGeom::TriangulationElement* o)
}
}
filename_.stream << " geo:asWKT " << escape_for_turtle(
IfcUtil::convert_utf8(
ifcopenshell::convert_utf8(
capture_output(
emit_line_strings,
o->geometry().verts(),
@@ -359,9 +359,9 @@ void TtlWktSerializer::write(const IfcGeom::BRepElement* brep_obj) {
#ifdef IFOPSH_WITH_OPENCASCADE
filename_.stream << ttl_object_id(brep_obj) << " a geo:Feature ;\n";
filename_.stream << " dcterms:identifier " << escape_for_turtle(
IfcUtil::convert_utf8(brep_obj->guid())) << " ;\n";
ifcopenshell::convert_utf8(brep_obj->guid())) << " ;\n";
filename_.stream << " rdfs:label " << escape_for_turtle(
IfcUtil::convert_utf8(brep_obj->name())
ifcopenshell::convert_utf8(brep_obj->name())
) << " .\n";
// @todo unify logic with SVG serializer
@@ -463,7 +463,7 @@ void TtlWktSerializer::write(const IfcGeom::BRepElement* brep_obj) {
oss << ttl_object_id(brep_obj) << " geo:hasGeometry " << ttl_object_id(brep_obj, postfix.c_str()) << " .\n\n";
oss << ttl_object_id(brep_obj, postfix.c_str()) << " a geo:Geometry ;\n";
oss << " geo:asWKT " << escape_for_turtle(IfcUtil::convert_utf8(capture_output(emit_line_component, loop_coords, loop_idxs, true, POLYGON))) << "^^geo:wktLiteral .\n\n";
oss << " geo:asWKT " << escape_for_turtle(ifcopenshell::convert_utf8(capture_output(emit_line_component, loop_coords, loop_idxs, true, POLYGON))) << "^^geo:wktLiteral .\n\n";
polygons_by_area[area] = oss.str();
}
@@ -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("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("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;
}
}
+1 -1
View File
@@ -41,7 +41,7 @@ public:
void finalize() {}
bool isTesselated() const;
void setUnitNameAndMagnitude(const std::string& /*name*/, float /*magnitude*/) {}
void setFile(IfcParse::IfcFile*) {}
void setFile(ifcopenshell::file*) {}
std::string ttl_object_id(const IfcGeom::Element* o, const char* const postfix = nullptr);
};
+1 -1
View File
@@ -90,7 +90,7 @@ public:
void finalize();
bool isTesselated() const { return true; }
void setUnitNameAndMagnitude(const std::string&, float) {}
void setFile(IfcParse::IfcFile*) {}
void setFile(ifcopenshell::file*) {}
std::string object_id_unique(const IfcGeom::Element* o);
};
+3 -3
View File
@@ -63,7 +63,7 @@ void WaveFrontOBJSerializer::writeMaterial(const ifcopenshell::geometry::taxonom
{
auto& style = *styleptr;
std::string material_name = style.name;
IfcUtil::sanitate_material_name(material_name);
ifcopenshell::sanitate_material_name(material_name);
mtl_stream.stream << "newmtl " << material_name << "\n";
{
@@ -132,7 +132,7 @@ void WaveFrontOBJSerializer::write(const IfcGeom::TriangulationElement* o)
if (material_id != previous_material_id) {
const ifcopenshell::geometry::taxonomy::style::ptr material = mesh.materials()[material_id];
std::string material_name = material->name;
IfcUtil::sanitate_material_name(material_name);
ifcopenshell::sanitate_material_name(material_name);
obj_stream.stream << "usemtl " << material_name << "\n";
if (materials.find(material_name) == materials.end()) {
writeMaterial(material);
@@ -178,7 +178,7 @@ void WaveFrontOBJSerializer::write(const IfcGeom::TriangulationElement* o)
if (material_id != previous_material_id) {
const ifcopenshell::geometry::taxonomy::style::ptr material = mesh.materials()[material_id];
std::string material_name = material->name;
IfcUtil::sanitate_material_name(material_name);
ifcopenshell::sanitate_material_name(material_name);
obj_stream.stream << "usemtl " << material_name << "\n";
if (materials.find(material_name) == materials.end()) {
writeMaterial(material);
+1 -1
View File
@@ -45,7 +45,7 @@ public:
void finalize() {}
bool isTesselated() const { return true; }
void setUnitNameAndMagnitude(const std::string& /*name*/, float /*magnitude*/) {}
void setFile(IfcParse::IfcFile*) {}
void setFile(ifcopenshell::file*) {}
};
#endif
+3 -3
View File
@@ -21,17 +21,17 @@ void XmlSerializerFactory::Factory::bind(const std::string& schema_name, fn f) {
this->insert(std::make_pair(schema_name_lower, f));
}
XmlSerializer* XmlSerializerFactory::Factory::construct(const std::string& schema_name, IfcParse::IfcFile* file, std::string xml_filename) {
XmlSerializer* XmlSerializerFactory::Factory::construct(const std::string& schema_name, ifcopenshell::file* file, std::string xml_filename) {
const std::string schema_name_lower = boost::to_lower_copy(schema_name);
typename std::map<std::string, fn>::const_iterator it;
it = this->find(schema_name_lower);
if (it == this->end()) {
throw IfcParse::IfcException("No XML serializer registered for " + schema_name);
throw ifcopenshell::exception("No XML serializer registered for " + schema_name);
}
return it->second(file, xml_filename);
}
XmlSerializer::XmlSerializer(IfcParse::IfcFile* file, const std::string& xml_filename) {
XmlSerializer::XmlSerializer(ifcopenshell::file* file, const std::string& xml_filename) {
if (file) {
implementation_ = XmlSerializerFactory::implementations().construct(file->schema()->name(), file, xml_filename);
}
+5 -5
View File
@@ -2,7 +2,7 @@
#include "../serializers/serializers_api.h"
#include "../ifcgeom/Serializer.h"
#include "../ifcparse/IfcFile.h"
#include "../ifcparse/file.h"
#include <boost/function.hpp>
@@ -16,7 +16,7 @@ protected:
std::string xml_filename;
public:
XmlSerializer(IfcParse::IfcFile* file, const std::string& xml_filename);
XmlSerializer(ifcopenshell::file* file, const std::string& xml_filename);
virtual ~XmlSerializer() {}
@@ -24,17 +24,17 @@ public:
void writeHeader() {}
void finalize() { implementation_->finalize(); }
void setFile(IfcParse::IfcFile*) { throw IfcParse::IfcException("Should be supplied on construction"); }
void setFile(ifcopenshell::file*) { throw ifcopenshell::exception("Should be supplied on construction"); }
};
struct SERIALIZERS_API XmlSerializerFactory {
typedef boost::function2<XmlSerializer*, IfcParse::IfcFile*, std::string> fn;
typedef boost::function2<XmlSerializer*, ifcopenshell::file*, std::string> fn;
class Factory : public std::map<std::string, fn> {
public:
Factory();
void bind(const std::string& schema_name, fn);
XmlSerializer* construct(const std::string& schema_name, IfcParse::IfcFile*, std::string);
XmlSerializer* construct(const std::string& schema_name, ifcopenshell::file*, std::string);
};
static Factory& implementations();
@@ -26,15 +26,15 @@
#include <nlohmann/json.hpp>
#include "../../ifcparse/IfcSIPrefix.h"
#include "../../ifcparse/si_prefix.h"
#include "../../ifcparse/utils.h"
#include "../../ifcparse/IfcLogger.h"
#include "../../ifcparse/logger.h"
using json = nlohmann::json;
namespace {
struct POSTFIX_SCHEMA(factory_t) {
JsonSerializer* operator()(IfcParse::IfcFile* file, const std::string& json_filename, JsonSerializer::Dialect dialect) const {
JsonSerializer* operator()(ifcopenshell::file* file, const std::string& json_filename, JsonSerializer::Dialect dialect) const {
POSTFIX_SCHEMA(JsonSerializer)* s = new POSTFIX_SCHEMA(JsonSerializer)(file, json_filename, dialect);
s->setFile(file);
return s;
@@ -56,14 +56,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>, 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>) {
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>, EnumerationReference>) {
} else if constexpr (std::is_same_v<std::decay_t<T>, enumeration_reference>) {
return t.value();
} else {
return t;
@@ -106,8 +106,8 @@ auto get_related(T t, F f, G g) {
}
}
}
} catch (IfcParse::IfcException& e) {
Logger::Error(e);
} catch (ifcopenshell::exception& e) {
logger::error(e);
}
}
return acc;
@@ -135,10 +135,10 @@ void format_entity_instance(express::Base instance, json& tree, express::Base pa
json child;
auto write_to_json = [&](const std::string& keyJson, const std::string& keyIfc) {
AttributeValue val;
attribute_value val;
try {
val = instance.as<express::Entity>().get(keyIfc);
} catch (const IfcParse::IfcException&) {
} catch (const ifcopenshell::exception&) {
// simply laziness like no attribute Tag on IfcProject
return;
}
@@ -278,7 +278,7 @@ void POSTFIX_SCHEMA(JsonSerializer)::finalize() {
auto 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, "Expected a single IfcProject");
return;
}
IfcSchema::IfcProject project = projects.front();
@@ -287,7 +287,7 @@ void POSTFIX_SCHEMA(JsonSerializer)::finalize() {
try {
return fn();
} catch (const std::exception& e) {
Logger::Error(e);
logger::error(e);
static std::invoke_result_t<decltype(fn)> v;
return v;
}
@@ -594,7 +594,7 @@ void POSTFIX_SCHEMA(JsonSerializer)::finalize() {
descend(project, output["metaObjects"]);
std::ofstream f(IfcUtil::path::from_utf8(json_filename).c_str());
std::ofstream f(ifcopenshell::path::from_utf8(json_filename).c_str());
f << output.dump(4);
}
@@ -34,14 +34,14 @@
class POSTFIX_SCHEMA(JsonSerializer) : public JsonSerializer {
private:
IfcParse::IfcFile* file;
ifcopenshell::file* file;
// @todo
ifcopenshell::geometry::Settings settings_;
ifcopenshell::geometry::abstract_mapping* mapping_;
public:
POSTFIX_SCHEMA(JsonSerializer)(IfcParse::IfcFile* file, const std::string& json_filename, JsonSerializer::Dialect dialect)
POSTFIX_SCHEMA(JsonSerializer)(ifcopenshell::file* file, const std::string& json_filename, JsonSerializer::Dialect dialect)
: JsonSerializer(0, "", dialect), mapping_(ifcopenshell::geometry::impl::mapping_implementations().construct(file, settings_))
{
this->file = file;
@@ -50,7 +50,7 @@ class POSTFIX_SCHEMA(JsonSerializer) : public JsonSerializer {
}
void finalize();
void setFile(IfcParse::IfcFile*) {}
void setFile(ifcopenshell::file*) {}
};
#endif
@@ -26,9 +26,9 @@
#include <algorithm>
#include "../../ifcparse/IfcSIPrefix.h"
#include "../../ifcparse/si_prefix.h"
#include "../../ifcparse/utils.h"
#include "../../ifcparse/IfcLogger.h"
#include "../../ifcparse/logger.h"
using boost::property_tree::ptree;
@@ -36,7 +36,7 @@ using boost::property_tree::ptree;
namespace {
struct POSTFIX_SCHEMA(factory_t) {
XmlSerializer* operator()(IfcParse::IfcFile* file, const std::string& xml_filename) const {
XmlSerializer* operator()(ifcopenshell::file* file, const std::string& xml_filename) const {
POSTFIX_SCHEMA(XmlSerializer)* s = new POSTFIX_SCHEMA(XmlSerializer)(file, xml_filename);
s->setFile(file);
return s;
@@ -57,7 +57,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::geometry::abstract_mapping* mapping, AttributeValue argument, IfcUtil::ArgumentType argument_type, const std::string& argument_name) {
std::optional<std::string> format_attribute(ifcopenshell::geometry::abstract_mapping* mapping, 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
@@ -82,28 +82,28 @@ std::optional<std::string> format_attribute(ifcopenshell::geometry::abstract_map
}
switch(argument_type) {
case IfcUtil::Argument_BOOL:
case IfcUtil::Argument_LOGICAL:{
case ifcopenshell::Argument_BOOL:
case ifcopenshell::Argument_LOGICAL:{
const boost::logic::tribool b = argument;
value = b.value == boost::logic::tribool::indeterminate_value ? "unknown" : b ? "true" : "false";
break; }
case IfcUtil::Argument_DOUBLE: {
case ifcopenshell::Argument_DOUBLE: {
const double d = argument;
std::stringstream stream;
stream << std::setprecision (std::numeric_limits< double >::max_digits10) << d;
value = stream.str();
break; }
case IfcUtil::Argument_STRING:
case IfcUtil::Argument_ENUMERATION: {
case ifcopenshell::Argument_STRING:
case ifcopenshell::Argument_ENUMERATION: {
value = static_cast<std::string>(argument);
break; }
case IfcUtil::Argument_INT: {
case ifcopenshell::Argument_INT: {
const int v = argument;
std::stringstream stream;
stream << v;
value = stream.str();
break; }
case IfcUtil::Argument_ENTITY_INSTANCE: {
case ifcopenshell::Argument_ENTITY_INSTANCE: {
express::Base e = argument;
if (e.declaration().as_entity() == nullptr) {
auto f = e.as<express::DeclaredType>();
@@ -155,7 +155,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("Expected " + boost::lexical_cast<std::string>(n) + " attributes for:", instance);
break;
}
auto argument = instance.get_attribute_value(i);
@@ -167,14 +167,14 @@ ptree* format_entity_instance(ifcopenshell::geometry::abstract_mapping* mapping,
if (argument_name_it != POSTFIX_SCHEMA(argument_name_map).end()) {
argument_name = argument_name_it->second;
}
const IfcUtil::ArgumentType argument_type = instance.get_attribute_value(i).type();
const ifcopenshell::argument_type argument_type = instance.get_attribute_value(i).type();
const std::string qualified_name = instance.declaration().name() + "." + argument_name;
std::optional<std::string> value;
try {
value = format_attribute(mapping, argument, argument_type, qualified_name);
} catch (const std::exception& e) {
Logger::Error(e);
logger::error(e);
}
if (value) {
@@ -238,8 +238,8 @@ auto get_related(T t, F f, G g) {
}
}
}
} catch (IfcParse::IfcException& e) {
Logger::Error(e);
} catch (ifcopenshell::exception& e) {
logger::error(e);
}
}
return acc;
@@ -545,7 +545,7 @@ void POSTFIX_SCHEMA(XmlSerializer)::finalize() {
auto 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, "Expected a single IfcProject");
return;
}
IfcSchema::IfcProject& project = projects.front();
@@ -556,7 +556,7 @@ void POSTFIX_SCHEMA(XmlSerializer)::finalize() {
try {
return fn();
} catch(const std::exception& e) {
Logger::Error(e);
logger::error(e);
static std::invoke_result_t<decltype(fn)> v;
return v;
}
@@ -578,51 +578,51 @@ void POSTFIX_SCHEMA(XmlSerializer)::finalize() {
try {
header.put("file_description.implementation_level", file->header().file_description().implementation_level());
}
catch (const IfcParse::IfcException& ex) {
catch (const ifcopenshell::exception& 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, ss.str());
}
try {
header.put("file_name.name", file->header().file_name().name());
}
catch (const IfcParse::IfcException& ex) {
catch (const ifcopenshell::exception& 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, ss.str());
}
try {
header.put("file_name.time_stamp", file->header().file_name().time_stamp());
}
catch (const IfcParse::IfcException& ex) {
catch (const ifcopenshell::exception& 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, ss.str());
}
try {
header.put("file_name.preprocessor_version", file->header().file_name().preprocessor_version());
}
catch (const IfcParse::IfcException& ex) {
catch (const ifcopenshell::exception& 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, ss.str());
}
try {
header.put("file_name.originating_system", file->header().file_name().originating_system());
}
catch (const IfcParse::IfcException& ex) {
catch (const ifcopenshell::exception& 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, ss.str());
}
try {
// @nb inconsistent spelling
header.put("file_name.authorization", file->header().file_name().authorization());
}
catch (const IfcParse::IfcException& ex) {
catch (const ifcopenshell::exception& 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, ss.str());
}
// Descend into the decomposition structure of the IFC file.
@@ -756,7 +756,7 @@ void POSTFIX_SCHEMA(XmlSerializer)::finalize() {
if (auto named_unit = unit.as<IfcSchema::IfcNamedUnit>()) {
ptree* node = format_entity_instance(mapping_, named_unit, units);
if (node) {
node->put("<xmlattr>.SI_equivalent", IfcParse::get_SI_equivalent<IfcSchema>(named_unit));
node->put("<xmlattr>.SI_equivalent", ifcopenshell::get_SI_equivalent<IfcSchema>(named_unit));
}
} else if (auto mon_unit = unit.as<IfcSchema::IfcMonetaryUnit>()) {
format_entity_instance(mapping_, mon_unit, units);
@@ -835,6 +835,6 @@ void POSTFIX_SCHEMA(XmlSerializer)::finalize() {
boost::property_tree::xml_writer_settings<char> settings('\t', 1);
#endif
std::ofstream f(IfcUtil::path::from_utf8(xml_filename).c_str());
std::ofstream f(ifcopenshell::path::from_utf8(xml_filename).c_str());
boost::property_tree::write_xml(f, root, settings);
}
@@ -32,14 +32,14 @@
class POSTFIX_SCHEMA(XmlSerializer) : public XmlSerializer {
private:
IfcParse::IfcFile* file;
ifcopenshell::file* file;
// @todo
ifcopenshell::geometry::Settings settings_;
ifcopenshell::geometry::abstract_mapping* mapping_;
public:
POSTFIX_SCHEMA(XmlSerializer)(IfcParse::IfcFile* file, const std::string& xml_filename)
POSTFIX_SCHEMA(XmlSerializer)(ifcopenshell::file* file, const std::string& xml_filename)
: XmlSerializer(0, "")
, mapping_(ifcopenshell::geometry::impl::mapping_implementations().construct(file, settings_))
{
@@ -48,7 +48,7 @@ public:
}
void finalize();
void setFile(IfcParse::IfcFile*) {}
void setFile(ifcopenshell::file*) {}
};
#endif