当前位置: 首页>>代码示例>>C++>>正文


C++ VertexElement::getNCon方法代码示例

本文整理汇总了C++中VertexElement::getNCon方法的典型用法代码示例。如果您正苦于以下问题:C++ VertexElement::getNCon方法的具体用法?C++ VertexElement::getNCon怎么用?C++ VertexElement::getNCon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在VertexElement的用法示例。


在下文中一共展示了VertexElement::getNCon方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

void sefield::TetMesh::fill_ve_vec(set<VertexElement*> & veset, vector<VertexElement*> & vevec, queue<VertexElement*> & vequeue, uint ncons, VertexElement ** nbrs)
{

    //cout << "Veset size: " << veset.size();

    vector<uint>newindcs=std::vector<uint>();
    for (uint i=0; i < ncons; ++i)
    {
        bool inserted = veset.insert(nbrs[i]).second;
        if (inserted)
        {
            newindcs.push_back(i);
            // This is the important one- in a vector to keep the ordering
            vevec.push_back(nbrs[i]);
            // And add to the queue too, to find their neighbours:
            vequeue.push(nbrs[i]);
        }
    }


    // Go to the next element in the queue
    if (vequeue.empty() == true) return;
    else
    {
        VertexElement * nextve = vequeue.front();
        vequeue.pop();
        VertexElement ** newneighbs = nextve->getNeighbours();
        uint nextcons = nextve->getNCon();
        fill_ve_vec(veset, vevec, vequeue, nextcons, newneighbs);
    }

    /*
    for (uint i=0; i < newindcs.size(); ++i)
    {
        VertexElement ** newneighbs = nbrs[newindcs[i]]->getNeighbours();
        uint newcons = nbrs[newindcs[i]]->getNCon();
        fill_ve_vec(veset, vevec, newcons, newneighbs, false);
    }
     */
}
开发者ID:delalond,项目名称:STEPS,代码行数:40,代码来源:tetmesh.cpp

示例2: ArgErr

void sefield::TetMesh::axisOrderElements(uint opt_method, std::string const & opt_file_name)
{

	// Now this method provides a choice between Stefan and Robert's method
	// and the new method by Iain. The original method is fast and suffices for
	// simple geometries, Iain's method is superior and important for complex
	// geometries, but slow.

	if (opt_file_name != "")
	{
		std::fstream opt_file;

	    opt_file.open(opt_file_name.c_str(),
	                std::fstream::in | std::fstream::binary);
	    opt_file.seekg(0);

	    uint nelems = 0;
	    opt_file.read((char*)&nelems, sizeof(uint));
	    if (pElements.size() != nelems) {
	        std::ostringstream os;
	        os << "optimal data mismatch with simulator parameters: sefield::Tetmesh::nelems, ";
	        os << nelems << ":" << pElements.size();
	        throw steps::ArgErr(os.str());
	    }
	    opt_file.read((char*)pVertexPerm, sizeof(uint) * nelems);

	    VertexElementPVec elements_temp = pElements;

	    for (uint vidx = 0; vidx < nelems; ++vidx)
	    {
	    	VertexElementP vep = elements_temp[vidx];
	    	// sanity check
	    	assert(vep->getIDX() == vidx);
	    	uint new_idx = pVertexPerm[vidx];
	    	pElements[new_idx] = vep;
	    }

	    reindexElements();
	    reordered();
	    opt_file.close();
	    return;

	}


	if (opt_method == 2)
	{
		// / / / / / / / / / / / /  / / NEW / / / / / / / / / / / / / / / / / / //

		// LOOPING OVER ALL VERTICES, APPLYING THE WALK METHOD AND FINDING WHICH
		// STARTING VERTEX GIVES THE LOWEST MATRIX WIDTH.

		uint pNVerts = pElements.size();

		// the best vertex(narrowest width)
		uint bestone = 0;
		uint bestwidth = pNVerts;

		std::vector<VertexElement*> orig_indices = pElements;

        stringstream ss;
        ss << "\nFinding optimal vertex indexing. This can take some time...";
        cout << ss.str() << endl;
		for (uint vidx = 0; vidx < pNVerts; ++vidx)
		{
			set<VertexElement*> verteleset = set<VertexElement*>();
			vector<VertexElement*> vertelevec = vector<VertexElement*>();
			queue<VertexElement*> vertelqueue = queue<VertexElement*>();

			verteleset.insert(orig_indices[vidx]);
			vertelevec.push_back(orig_indices[vidx]);
			uint ve0ncons = orig_indices[vidx]->getNCon();
			VertexElement ** ve0neighbs = orig_indices[vidx]->getNeighbours();

			fill_ve_vec(verteleset, vertelevec, vertelqueue, ve0ncons, ve0neighbs);
			pElements.clear();

			vector<VertexElement*>::iterator vertele_end = vertelevec.end();
			uint ielt = 0;

			for (vector<VertexElement*>::iterator vertele = vertelevec.begin(); vertele != vertele_end; ++vertele)
			{
				pElements.push_back(*vertele);
				pVertexPerm[(*vertele)->getIDX()]=ielt;
				ielt++;
			}

			// Note: this will reorder the vertex indices as we go- not a problem in this loop
			// but they must be reset for the final index setting to work
			reindexElements();

			uint maxdi = 0;
			for (int iv = 0; iv < pNVerts; ++iv)
			{
				VertexElement* ve = getVertex(iv);
				int ind = ve->getIDX();

				for (int i = 0; i < ve->getNCon(); ++i)
				{
					int inbr = ve->nbrIdx(i);
//.........这里部分代码省略.........
开发者ID:delalond,项目名称:STEPS,代码行数:101,代码来源:tetmesh.cpp


注:本文中的VertexElement::getNCon方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。