| 2141 | } |
| 2142 | |
| 2143 | void IfcFile::removeEntity(IfcUtil::IfcBaseClass* entity) { |
| 2144 | const unsigned id = entity->id(); |
| 2145 | |
| 2146 | IfcUtil::IfcBaseClass* file_entity = instance_by_id(id); |
| 2147 | |
| 2148 | // Attention when running removeEntity inside a loop over a list of entities to be removed. |
| 2149 | // This invalidates the iterator. A workaround is to reverse the loop: |
| 2150 | // boost::shared_ptr<aggregate_of_instance> entities = ...; |
| 2151 | // for (auto it = entities->end() - 1; it >= entities->begin(); --it) { |
| 2152 | // IfcUtil::IfcBaseClass *const inst = *it; |
| 2153 | // model->removeEntity(inst); |
| 2154 | // } |
| 2155 | |
| 2156 | // TODO: Create a set of weak relations. Inverse relations that do not dictate an |
| 2157 | // instance to be retained. For example: when deleting an IfcRepresentation, the |
| 2158 | // individual IfcRepresentationItems can not be deleted if an IfcStyledItem is |
| 2159 | // related. Hence, the IfcRepresentationItem::StyledByItem relation could be |
| 2160 | // characterized as weak. |
| 2161 | // std::set<IfcSchema::Type::Enum> weak_roots; |
| 2162 | |
| 2163 | if (entity != file_entity) { |
| 2164 | throw IfcParse::IfcException("Instance not part of this file"); |
| 2165 | } |
| 2166 | |
| 2167 | if (batch_mode_) { |
| 2168 | batch_deletion_ids_.push_back(id); |
| 2169 | } else { |
| 2170 | process_deletion_(entity); |
| 2171 | } |
| 2172 | } |
| 2173 | |
| 2174 | void IfcFile::process_deletion_(IfcUtil::IfcBaseClass* entity) { |
| 2175 |
no test coverage detected