mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-13 10:57:49 +00:00
Merge branch 'master' into v0.6.0
This commit is contained in:
@@ -40,6 +40,7 @@ public:
|
||||
it end();
|
||||
IfcUtil::IfcBaseClass* operator[] (int i);
|
||||
unsigned int size() const;
|
||||
void reserve(unsigned capacity);
|
||||
bool contains(IfcUtil::IfcBaseClass*) const;
|
||||
template <class U>
|
||||
typename U::list::ptr as() {
|
||||
|
||||
@@ -41,6 +41,7 @@ public:
|
||||
typedef boost::unordered_map<unsigned int, IfcUtil::IfcBaseClass*> entity_by_id_t;
|
||||
typedef std::map<std::string, IfcUtil::IfcBaseClass*> entity_by_guid_t;
|
||||
typedef std::map<unsigned int, std::vector<unsigned int> > entities_by_ref_t;
|
||||
typedef std::map<unsigned int, IfcEntityList::ptr> ref_map_t;
|
||||
typedef entity_by_id_t::const_iterator const_iterator;
|
||||
|
||||
class type_iterator : private entities_by_type_t::const_iterator {
|
||||
@@ -86,6 +87,7 @@ private:
|
||||
entities_by_type_t bytype;
|
||||
entities_by_type_t bytype_excl;
|
||||
entities_by_ref_t byref;
|
||||
ref_map_t by_ref_cached_;
|
||||
entity_by_guid_t byguid;
|
||||
entity_entity_map_t entity_file_map;
|
||||
|
||||
@@ -181,6 +183,10 @@ public:
|
||||
|
||||
IfcEntityList::ptr getInverse(int instance_id, const IfcParse::declaration* type, int attribute_index);
|
||||
|
||||
/// Marks entity as modified so that potential cache for it is invalidated.
|
||||
/// @todo Currently the whole cache is invalidated. Implement more fine-grained invalidation.
|
||||
void mark_entity_as_modified(int id);
|
||||
|
||||
unsigned int FreshId() { return ++MaxId; }
|
||||
|
||||
IfcUtil::IfcBaseClass* addEntity(IfcUtil::IfcBaseClass* entity);
|
||||
|
||||
+25
-10
@@ -1257,7 +1257,9 @@ void IfcEntityInstanceData::setArgument(unsigned int i, Argument* a, IfcUtil::Ar
|
||||
if (this->file) {
|
||||
register_inverse_visitor visitor(*this->file, *this);
|
||||
apply_individual_instance_visitor(copy).apply(visitor);
|
||||
}
|
||||
|
||||
this->file->mark_entity_as_modified(id_);
|
||||
}
|
||||
|
||||
attributes_[i] = copy;
|
||||
}
|
||||
@@ -1504,6 +1506,11 @@ IfcEntityList::ptr IfcFile::traverse(IfcUtil::IfcBaseClass* instance, int max_le
|
||||
return IfcParse::traverse(instance, max_level);
|
||||
}
|
||||
|
||||
void IfcFile::mark_entity_as_modified(int /*id*/)
|
||||
{
|
||||
by_ref_cached_.clear();
|
||||
}
|
||||
|
||||
void IfcFile::addEntities(IfcEntityList::ptr es) {
|
||||
for( IfcEntityList::it i = es->begin(); i != es->end(); ++ i ) {
|
||||
addEntity(*i);
|
||||
@@ -1868,17 +1875,25 @@ IfcEntityList::ptr IfcFile::instances_by_type(const std::string& t) {
|
||||
|
||||
IfcEntityList::ptr IfcFile::instances_by_reference(int t) {
|
||||
entities_by_ref_t::const_iterator it = byref.find(t);
|
||||
IfcEntityList::ptr return_value;
|
||||
IfcEntityList::ptr ret;
|
||||
if (it != byref.end()) {
|
||||
const std::vector<unsigned>& ids = it->second;
|
||||
for (std::vector<unsigned>::const_iterator jt = ids.begin(); jt != ids.end(); ++jt) {
|
||||
if (!return_value) {
|
||||
return_value.reset(new IfcEntityList);
|
||||
}
|
||||
return_value->push(instance_by_id(*jt));
|
||||
}
|
||||
ref_map_t::const_iterator cached_it = by_ref_cached_.find(t);
|
||||
if (cached_it != by_ref_cached_.end()) {
|
||||
ret = cached_it->second;
|
||||
}
|
||||
else {
|
||||
if (it->second.size()) {
|
||||
ret.reset(new IfcEntityList);
|
||||
ret->reserve((unsigned)it->second.size());
|
||||
const std::vector<unsigned>& ids = it->second;
|
||||
for (std::vector<unsigned>::const_iterator jt = ids.begin(); jt != ids.end(); ++jt) {
|
||||
ret->push(instance_by_id(*jt));
|
||||
}
|
||||
}
|
||||
by_ref_cached_[t] = ret;
|
||||
}
|
||||
}
|
||||
return return_value;
|
||||
return ret;
|
||||
}
|
||||
|
||||
IfcUtil::IfcBaseClass* IfcFile::instance_by_id(int id) {
|
||||
|
||||
@@ -42,6 +42,7 @@ void IfcEntityList::push(const IfcEntityList::ptr& l) {
|
||||
}
|
||||
}
|
||||
unsigned int IfcEntityList::size() const { return (unsigned int) ls.size(); }
|
||||
void IfcEntityList::reserve(unsigned capacity) { ls.reserve((size_t)capacity); }
|
||||
IfcEntityList::it IfcEntityList::begin() { return ls.begin(); }
|
||||
IfcEntityList::it IfcEntityList::end() { return ls.end(); }
|
||||
IfcUtil::IfcBaseClass* IfcEntityList::operator[] (int i) {
|
||||
|
||||
Reference in New Issue
Block a user