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


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

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


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

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