Example #1
0
 static void PrintSimplex(std::ostream &str, const Simplex &simplex)
 {
     for (typename Simplex::const_iterator i = simplex.begin(); i != simplex.end(); i++)
     {
         str<<(*i)<<" ";
     }
     str<<std::endl;
 }
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;
}