Logo Search packages:      
Sourcecode: madlib version File versions  Download package

pFace MAd::F_exist ( pEntity  e1,
pEntity  e2,
pEntity  e3,
pEntity  e4 
)

Returns face defined by at most 4 entities, return 0 on failure.

entities e1..4 may be either vertices or edges

Definition at line 3037 of file MeshDataBaseInterface.cc.

References MAd::EN_type().

Referenced by MAd::F_createInfoInterface().

                                                               {
    int typeEnt = EN_type(e1);
    switch(typeEnt) {
    case 0:
      { pVertex p1 = (pVertex) e1;
        pVertex p2 = (pVertex) e2;
        pVertex p3 = (pVertex) e3;
        pVertex p4 = (pVertex) e4;
        MDB_ListFace listFaces;
        p1->getFaces(listFaces);
        MDB_ListFace::iterator it  = listFaces.begin();
        MDB_ListFace::iterator ite = listFaces.end();
        while(it!=ite){
          pVertex p[4]={NULL,NULL,NULL,NULL};
          (*it)->getNodes(p);
          if (   (p[0]==p1 || p[0]==p2 || p[0]==p3 || p[0]==p4)
              && (p[1]==p1 || p[1]==p2 || p[1]==p3 || p[1]==p4)
              && (p[2]==p1 || p[2]==p2 || p[2]==p3 || p[2]==p4)
              && (p[3]==p1 || p[3]==p2 || p[3]==p3 || p[3]==p4))
                return (*it);
          ++it;
        }      
        return 0;
      }
      break;
    case 1:
      {
        pEdge ped1 = (pEdge) e1;
        pEdge ped2 = (pEdge) e2;
        pEdge ped3 = (pEdge) e3;
        pEdge ped4 = (pEdge) e4;
        for(int k=0 ; k<ped1->numfaces() ; k++) {
          pFace pface = ped1->faces(k);
          if ((pface->getEdge(0)==ped1 || pface->getEdge(1)==ped1 || pface->getEdge(2)==ped1  || pface->getEdge(3)==ped1)
            &&(pface->getEdge(0)==ped2 || pface->getEdge(1)==ped2 || pface->getEdge(2)==ped2  || pface->getEdge(3)==ped2)
            &&(pface->getEdge(0)==ped3 || pface->getEdge(1)==ped3 || pface->getEdge(2)==ped3  || pface->getEdge(3)==ped3)
            &&(pface->getEdge(0)==ped4 || pface->getEdge(1)==ped4 || pface->getEdge(2)==ped4  || pface->getEdge(3)==ped4))
              return (pface);
        }
        return 0;
      }
      break;
    default:
      throw;  
    }
    return 0;
  }


Generated by  Doxygen 1.6.0   Back to index