Skip to content

Commit e60202b

Browse files
committed
Unique filter on IfcEntityList
1 parent 1e8b1d9 commit e60202b

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

src/ifcparse/IfcEntityList.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class IFC_PARSE_API IfcEntityList {
5050
}
5151
void remove(IfcUtil::IfcBaseClass*);
5252
IfcEntityList::ptr filtered(const std::set<IfcSchema::Type::Enum>& entities);
53+
IfcEntityList::ptr unique();
5354
};
5455

5556
template <class T>

src/ifcparse/IfcUtil.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ void IfcEntityList::remove(IfcUtil::IfcBaseClass* instance) {
6262
ls.erase(it);
6363
}
6464
}
65+
6566
IfcEntityList::ptr IfcEntityList::filtered(const std::set<IfcSchema::Type::Enum>& entities) {
6667
IfcEntityList::ptr return_value(new IfcEntityList);
6768
for (it it = begin(); it != end(); ++it) {
@@ -79,6 +80,18 @@ IfcEntityList::ptr IfcEntityList::filtered(const std::set<IfcSchema::Type::Enum>
7980
return return_value;
8081
}
8182

83+
IfcEntityList::ptr IfcEntityList::unique() {
84+
std::set<IfcUtil::IfcBaseClass*> encountered;
85+
IfcEntityList::ptr return_value(new IfcEntityList);
86+
for (it it = begin(); it != end(); ++it) {
87+
if (encountered.find(*it) == encountered.end()) {
88+
return_value->push(*it);
89+
encountered.insert(*it);
90+
}
91+
}
92+
return return_value;
93+
}
94+
8295

8396
unsigned int IfcUtil::IfcBaseType::getArgumentCount() const { return 1; }
8497
Argument* IfcUtil::IfcBaseType::getArgument(unsigned int i) const { return entity->getArgument(i); }

0 commit comments

Comments
 (0)