diff --git a/src/ifcparse/IfcEntityList.h b/src/ifcparse/IfcEntityList.h index 72ecac8d0c..3953a29715 100644 --- a/src/ifcparse/IfcEntityList.h +++ b/src/ifcparse/IfcEntityList.h @@ -50,6 +50,7 @@ public: } void remove(IfcUtil::IfcBaseClass*); IfcEntityList::ptr filtered(const std::set& entities); + IfcEntityList::ptr unique(); }; template diff --git a/src/ifcparse/IfcUtil.cpp b/src/ifcparse/IfcUtil.cpp index c07fff5379..abda4e25cd 100644 --- a/src/ifcparse/IfcUtil.cpp +++ b/src/ifcparse/IfcUtil.cpp @@ -62,6 +62,7 @@ void IfcEntityList::remove(IfcUtil::IfcBaseClass* instance) { ls.erase(it); } } + IfcEntityList::ptr IfcEntityList::filtered(const std::set& entities) { IfcEntityList::ptr return_value(new IfcEntityList); for (it it = begin(); it != end(); ++it) { @@ -79,6 +80,18 @@ IfcEntityList::ptr IfcEntityList::filtered(const std::set return return_value; } +IfcEntityList::ptr IfcEntityList::unique() { + std::set encountered; + IfcEntityList::ptr return_value(new IfcEntityList); + for (it it = begin(); it != end(); ++it) { + if (encountered.find(*it) == encountered.end()) { + return_value->push(*it); + encountered.insert(*it); + } + } + return return_value; +} + unsigned int IfcUtil::IfcBaseType::getArgumentCount() const { return 1; } Argument* IfcUtil::IfcBaseType::getArgument(unsigned int i) const { return entity->getArgument(i); }