mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
Specific speed-ups
This commit is contained in:
@@ -616,6 +616,10 @@ public:
|
||||
using const_iterator = variant_iterator<impl::in_memory_file_storage::iterator, impl::rocks_db_file_storage::const_iterator>;
|
||||
using type_iterator = variant_iterator<impl::in_memory_file_storage::type_iterator, impl::rocks_db_file_storage::rocksdb_types_iterator>;
|
||||
using storage_t = std::variant<std::monostate, impl::in_memory_file_storage, impl::rocks_db_file_storage>;
|
||||
|
||||
bool check_existance_before_adding = true;
|
||||
bool calculate_unit_factors = true;
|
||||
|
||||
// @todo temporarily public for header
|
||||
storage_t storage_;
|
||||
private:
|
||||
|
||||
@@ -1741,8 +1741,10 @@ IfcUtil::IfcBaseClass* IfcFile::addEntity(IfcUtil::IfcBaseClass* entity, int id)
|
||||
if (id != -1) {
|
||||
bool id_already_exists = false;
|
||||
try {
|
||||
instance_by_id(id);
|
||||
id_already_exists = true;
|
||||
if (check_existance_before_adding) {
|
||||
instance_by_id(id);
|
||||
id_already_exists = true;
|
||||
}
|
||||
} catch (...) {}
|
||||
if (id_already_exists) {
|
||||
throw IfcParse::IfcException("An instance with id " + boost::lexical_cast<std::string>(id) + " is already part of this file");
|
||||
@@ -1846,7 +1848,7 @@ IfcUtil::IfcBaseClass* IfcFile::addEntity(IfcUtil::IfcBaseClass* entity, int id)
|
||||
|
||||
// In case an entity is added that contains geometry, the unit
|
||||
// information needs to be accounted for for IfcLengthMeasures.
|
||||
double conversion_factor = std::numeric_limits<double>::quiet_NaN();
|
||||
double conversion_factor = calculate_unit_factors ? std::numeric_limits<double>::quiet_NaN() : 1.0;
|
||||
|
||||
for (size_t i = 0; i < (new_entity->declaration().as_entity() ? new_entity->declaration().as_entity()->attribute_count() : 1); ++i) {
|
||||
// old attribute value
|
||||
|
||||
@@ -15,6 +15,11 @@ RocksDbSerializer::RocksDbSerializer(IfcParse::IfcFile* file, const std::string&
|
||||
options.merge_operator.reset(new ConcatenateIdMergeOperator());
|
||||
rocksdb::Status status = rocksdb::DB::Open(options, rocksdb_filename, &db_);*/
|
||||
output_file_ = new IfcParse::IfcFile(file_->schema(), IfcParse::FT_ROCKSDB, rocksdb_filename_);
|
||||
|
||||
// We promise never to add the same instance twice
|
||||
output_file_->check_existance_before_adding = false;
|
||||
// We only copy one file into an empty container so units will match
|
||||
output_file_->calculate_unit_factors = false;
|
||||
}
|
||||
|
||||
void RocksDbSerializer::finalize()
|
||||
@@ -74,11 +79,7 @@ void RocksDbSerializer::finalize()
|
||||
}
|
||||
|
||||
// Add them in topological order, so that add() never recurses into something not previously visited
|
||||
size_t n = 0;
|
||||
for (auto& i : deps_topo_order) {
|
||||
if (((n++) % 1000) == 0) {
|
||||
std::wcout << n * 100 / deps_topo_order.size() << "%";
|
||||
}
|
||||
output_file_->addEntity(file_->instance_by_id(i), i);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user