+
+
+ //-------------------------------------------------------
+ /*!
+ * \brief Class helping to use either SMDS_0DElementIterator,
+ * SMDS_EdgeIterator, SMDS_FaceIterator or SMDS_VolumeIterator
+ * in the same code
+ */
+ //-------------------------------------------------------
+ struct TElemIterator
+ {
+ virtual const SMDS_MeshElement* next() = 0;
+ virtual ~TElemIterator() {}
+ };
+ typedef boost::shared_ptr<TElemIterator> PElemIterator;
+
+ template< class SMDSIteratorPtr > class TypedElemIterator: public TElemIterator
+ {
+ SMDSIteratorPtr myItPtr;
+ public:
+ TypedElemIterator(SMDSIteratorPtr it): myItPtr(it) {}
+ virtual const SMDS_MeshElement* next() {
+ if ( myItPtr->more() ) return myItPtr->next();
+ else return 0;
+ }
+ };
+ typedef TypedElemIterator< SMDS_0DElementIteratorPtr > T0DElementIterator;
+ typedef TypedElemIterator< SMDS_EdgeIteratorPtr > TEdgeIterator;
+ typedef TypedElemIterator< SMDS_FaceIteratorPtr > TFaceIterator;
+ typedef TypedElemIterator< SMDS_VolumeIteratorPtr > TVolumeIterator;
+
+ //-------------------------------------------------------
+ /*!
+ * \brief Structure describing element type
+ */
+ //-------------------------------------------------------
+ struct TElemTypeData
+ {
+ EEntiteMaillage _entity;
+ EGeometrieElement _geomType;
+ TInt _nbElems;
+ SMDSAbs_ElementType _smdsType;
+
+ TElemTypeData (EEntiteMaillage entity, EGeometrieElement geom, TInt nb, SMDSAbs_ElementType type)
+ : _entity(entity), _geomType(geom), _nbElems( nb ), _smdsType( type ) {}
+ };
+
+
+ typedef NCollection_DataMap< Standard_Address, int > TElemFamilyMap;
+ //typedef map<const SMDS_MeshElement *, int> TElemFamilyMap;
+
+ //================================================================================
+ /*!
+ * \brief Fills element to famaly ID map for element type.
+ * Removes all families of anElemType
+ */
+ //================================================================================
+
+ void fillElemFamilyMap( TElemFamilyMap & anElemFamMap,
+ list<DriverMED_FamilyPtr> & aFamilies,
+ const SMDSAbs_ElementType anElemType)
+ {
+ anElemFamMap.Clear();
+ //anElemFamMap.clear();
+ list<DriverMED_FamilyPtr>::iterator aFamsIter = aFamilies.begin();
+ while ( aFamsIter != aFamilies.end() )
+ {
+ if ((*aFamsIter)->GetType() != anElemType) {
+ aFamsIter++;
+ }
+ else {
+ int aFamId = (*aFamsIter)->GetId();
+ const set<const SMDS_MeshElement *>& anElems = (*aFamsIter)->GetElements();
+ set<const SMDS_MeshElement *>::const_iterator anElemsIter = anElems.begin();
+ for (; anElemsIter != anElems.end(); anElemsIter++)
+ {
+ anElemFamMap.Bind( (Standard_Address)*anElemsIter, aFamId );
+ //anElemFamMap[*anElemsIter] = aFamId;
+ }
+ // remove a family from the list
+ aFamilies.erase( aFamsIter++ );
+ }
+ }
+ }
+
+ //================================================================================
+ /*!
+ * \brief For an element, return family ID found in the map or a default one
+ */
+ //================================================================================
+
+ int getFamilyId( const TElemFamilyMap & anElemFamMap,
+ const SMDS_MeshElement* anElement,
+ const int aDefaultFamilyId)
+ {
+ if ( anElemFamMap.IsBound( (Standard_Address) anElement ))
+ return anElemFamMap( (Standard_Address) anElement );
+// TElemFamilyMap::iterator elem_famNum = anElemFamMap.find( anElement );
+// if ( elem_famNum != anElemFamMap.end() )
+// return elem_famNum->second;
+ return aDefaultFamilyId;
+ }