+
+ //================================================================================
+ /*!
+ * \brief Iterator returning unique elements from a vector and another iterator
+ */
+ //================================================================================
+
+ class TUniqueIterator : public SMDS_ElemIterator
+ {
+ typedef boost::container::flat_set< const SMDS_MeshElement* > TElemSet;
+ typedef SMDS_SetIterator< const SMDS_MeshElement*, TElemSet::const_iterator > TSetIterator;
+
+ TElemSet _uniqueElems;
+ TSetIterator* _iterator;
+
+ public:
+ TUniqueIterator( const std::vector< const SMDS_MeshElement* >& elems,
+ const SMDS_ElemIteratorPtr& elemIterator )
+ : _uniqueElems( elems.begin(), elems.end() )
+ {
+ if ( elemIterator )
+ while ( elemIterator->more() )
+ _uniqueElems.insert( elemIterator->next() );
+
+ _iterator = new TSetIterator( _uniqueElems.begin(), _uniqueElems.end() );
+ }
+ ~TUniqueIterator()
+ {
+ delete _iterator;
+ }
+ virtual bool more()
+ {
+ return _iterator->more();
+ }
+ virtual const SMDS_MeshElement* next()
+ {
+ return _iterator->next();
+ }
+ };
+
+ //================================================================================
+ /*!
+ * \brief Return iterator on 2 element iterators
+ */
+ //================================================================================
+
+ SMDS_ElemIteratorPtr iteratorOn2Iterators( SMDS_ElemIteratorPtr it1, SMDS_ElemIteratorPtr it2 )
+ {
+ std::vector< SMDS_ElemIteratorPtr > iters; iters.reserve(2);
+ if ( it1 ) iters.push_back( it1 );
+ if ( it2 ) iters.push_back( it2 );
+
+ typedef std::vector< SMDS_ElemIteratorPtr > TElemIterVector;
+ typedef SMDS_IteratorOnIterators<const SMDS_MeshElement *, TElemIterVector> TItersIter;
+ return SMDS_ElemIteratorPtr( new TItersIter( iters ));
+ }