本文整理汇总了C++中Simplex::getHash方法的典型用法代码示例。如果您正苦于以下问题:C++ Simplex::getHash方法的具体用法?C++ Simplex::getHash怎么用?C++ Simplex::getHash使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Simplex
的用法示例。
在下文中一共展示了Simplex::getHash方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getHashMod
bool SToplex<C,PS,BT>::buildTopSimpMap (const vector<Simplex<C,PS,BT>*>& topsimps, bool makeverlist = true)
{
verlist.clear();
//cout<<" top simp size "<<topsimps.size(); cin.get();
if (topsimps.size()==0 || topsimps.front()==NULL) return false; // no simplices to add
num topd;
Simplex<C,PS,BT>* cursimp;
set<Point<PS>*, ptcomplex<PS> > vertices; // store all vertices
typename PT_SET::const_iterator viter; //
// iterate over top simplices and extract vertices:
typename vector<Simplex<C,PS,BT>*>::const_iterator curtop;
for (curtop = topsimps.begin(); curtop != topsimps.end(); ++curtop)
{
cursimp = *curtop;
topd = cursimp->getDim(); // get top simplex's dimension
// update top dim of toplex!
if (topd > topdim) topdim = topd;
// now extract vertices!
for (viter = cursimp->begin(); viter != cursimp->end(); ++viter)
{
vertices.insert(*viter);
}
if (makeverlist) verlist.insert(vertices.begin(),vertices.end());
}
if (SIMTOPTALK)
{
cout<<"\n built vertex list";
if (MAKEBPS) cin.get();
}
// set number of distinct vertices:
psize = vertices.size();
typename SIMP_MAP::iterator mit;
SIMP_RG* currg;
num hmod = getHashMod();
// now we can compute the hashes using topdim and psize, and hence
// store the top simplices. sweep over them again...
for (curtop = topsimps.begin(); curtop != topsimps.end(); ++curtop)
{
cursimp = *curtop;
mit = mymap.find(cursimp->getDim()); // seek this hash
if(mit == mymap.end()) // not found!
{
currg = new SIMP_RG; // define range, and...
mymap.insert(mymap.end(),make_pair(cursimp->getDim(),currg));
}
else currg = mit->second;
currg->insert(currg->end(),make_pair(cursimp->getHash(hmod),cursimp));
}
if (SIMTOPTALK)
{
cout<<"\n top map size: "<<mymap.size();
if (MAKEBPS) cin.get();
}
//cout<<" top map size: "<<mymap.size(); cin.get();
return true;
}
示例2: isIn
bool SToplex<C,PS,BT>::makeFacesOf(Simplex<C,PS,BT>* simp, bool inheritBirths = true)
{
if (simp == NULL) return false; // can't handle null simplex
if (simp->getDim()==0) return true; // no faces for 0 dimensional/already faced simplices!
PT_SET verts = simp->getVerts(); // boundary vertex set
typename PT_SET::iterator hat; // points to vertex which is being ignored when making face
C coeff; // coefficient of this face
num facect = 0;
typename SIMP_MAP::iterator finddim;
typename SIMP_RG::iterator findhash;
SIMP_RG* currg;
Simplex<C,PS,BT>* sloc; // face simplex possibly located in complex
// iterate over vertices of this simplex.
for (hat = simp->begin(); hat != simp->end(); ++hat)
{
verts.erase(*hat); // hat out this vertex
coeff = (facect % 2 == 0) ? 1 : -1; // and its incidence coefficient
// now check if current bdry simplex is in its anchor list
//cout<<"isin call: "; cin.get();
sloc = isIn(verts); // check if face is in corresponding list
//cout<<" back with "<<sloc; cin.get();
if (sloc == NULL) // no such face exists
{
// so add this new simplex to the map structure
sloc = new Simplex<C,PS,BT>(verts);
//cout<<"\n attempting insertion of: "<<*sloc; cin.get();
// it is possible that there tDim());
finddim = mymap.find(sloc->getDim());
if (finddim == mymap.end())
{
currg = new SIMP_RG;
mymap.insert(mymap.end(),make_pair(sloc->getDim(),currg));
//cout<<"inserted!"; cin.get();
}
else
{
currg = finddim->second;
}
//cout<<"range insert!"; cin.get();
currg->insert(make_pair(sloc->getHash(getHashMod()),sloc));
//cout<<"\n added: "<<*bdsimp<<" to "<<*firstbdvert<<" of dim "<<curd-1<<" at "<<bdsimp;
}
simp->addBDLink(sloc,coeff,true,inheritBirths);
facect++; // update number of faces handled
//cout<<"\n^^^^^^^^^^^^^^^^^added face: "<<*sloc; cin.get();
// restore boundary for next face, idiot:
verts.insert(*hat);
}
// // now make faces of faces etc...
// typename list<Simplex<C,PS,BT>*>::const_iterator face;
// for (face = facelist.begin(); face != facelist.end(); ++face)
// {
// makeFacesOf(*face); // recursive call
// }
return true;
}