void findFacesInMesh()
{
multimap<indexPair, int> mapface;
multimap<indexPair, int> ::iterator it, it2,it3;
pair<multimap<indexPair, int> ::iterator,multimap<indexPair, int> ::iterator> rangeit;
int ip1, ip2;
for(int k=0; k!=cells.size(); k++)
{
for(int i=0; i< ( cells[k].getNbPoints() ); i++) {
if(i== (cells[k].getNbPoints()-1) ){ ip1=cells[k].getListPointsIndex(i) ; ip2=cells[k].getListPointsIndex(0);}
else {ip1=cells[k].getListPointsIndex(i); ip2=cells[k].getListPointsIndex(i+1); }
mapface.insert( multimap<indexPair, int> ::value_type( indexPair(ip1,ip2), k) );
}
}
for ( it=mapface.begin() ; it != mapface.end(); it++ ){
indexPair c=it->first; rangeit=mapface.equal_range(c);
for (it2=rangeit.first; it2!=rangeit.second; ++it2)
{
int ip1=it2->first.originIndex1;
int ip2=it2->first.originIndex2;
int ip3=it2->second;
faces.push_back( Face( points[ip1] , points[ip2] ) );
faces[faces.size()-1].pushBackAdjCells(ip3);
}
mapface.erase( rangeit.first,rangeit.second);
Dear friends:
I set up a multimap mapface from a finite element mesh file which recorde the connectivity of each cell. The mapface.first is IndexPair (int ,int) which records the indexes of the two ending points of a face, and the mapface.second records the index of master cell which contains the face. A face has at most two neighbor cells in the mesh.
My mission is to collect all the faces and their neighbor cells from the multimap. the faces are stoed in the faces list, and the neighbour cell are stored by faces.pushBackAdjCells().
I want to iterate from the first of mapface, then find all the repeated items by
mapface.equal_range(), then delete its from the mapface to make the face unique. but the code doesn't work and gives me the following error" map/set iterator not derefercable".
Could you please give me some ideas about this.
Regards