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


C++ Map::GetMap方法代码示例

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


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

示例1: main

int main () {
	srand(time(NULL));
	
	for(int i=0;i<POINTS;++i)
	{
		polars[i]=float(rand())*M_PI*2.0f/float(RAND_MAX);
	}
	sort(polars, polars+POINTS);
	
	for(int i=0;i<POINTS;++i)
	{
		pps1[i].polar=polars[i];
		pps1[i].radial=float(rand())*300.0f/float(RAND_MAX);
		pps2[i].polar=polars[i];
		pps2[i].radial=float(rand())*300.0f/float(RAND_MAX);
	}
	
	Polygon p1(POINTS, new Point[POINTS]);
	Polygon p2(POINTS, new Point[POINTS]);
	
	for(int i=0;i<POINTS;++i)
	{
		p1.points[i]=pps1[i].to_cartesian();
		p2.points[i]=pps2[i].to_cartesian();
		p2.points[i].x+=200.0f;
	}
	
	SectionPolygon sp1=*p1.to_sectionpolygon();
	SectionPolygon sp2=*p2.to_sectionpolygon();
	
	Map map;
	
	map.AddPart(sp1);
	map.AddPart(sp2);
	
	SectionPolygonWithHoles* rp=map.GetMap();
	
	printf("%d\n%d 1 0 0 0\n", rp->size+2, POINTS);
	for(int i=0;i<POINTS;++i)
	{
		printf("%lf %lf\n", p1.points[i].x, p1.points[i].y);
	}
	printf("%d 0 1 0 0\n", POINTS);
	for(int i=0;i<POINTS;++i)
	{
		printf("%lf %lf\n", p2.points[i].x, p2.points[i].y);
	}
	
	for(int i=0;i<rp->size;++i)
	{
		printf("%d 0 0 1 0\n", rp->polygons[i]->size);
		for(int j=0;j<rp->polygons[i]->size;++j)
		{
			printf("%lf %lf\n", rp->polygons[i]->sections[j].f.x, rp->polygons[i]->sections[j].f.y);
		}
	}
	
	
}
开发者ID:r3pack,项目名称:robocik,代码行数:59,代码来源:maptest.cpp

示例2: RandomNumber

/*FUNCTIONS OF CLASS HOST
 *Constructs a host for the initialization of the population: it fills the MHC genes with a randomly picked allele from the population
 * and creates KIRs that match their own MHC according to the specificity*/
Host::Host(int loci_kir, int loci_mhc, double _mutationRate, bool _tuning, int numberOfExtraKirs,Map& kirMap, MHCGenePool& mhcPool, bool hla) {

	InitializeHostParameters(_mutationRate,_tuning, loci_kir, loci_mhc);
	//fill the mhc Genes
	for(int i = 0; i <lociMHC*TWO; i++)
	{
		Gene firstGene;
		int mhc1 = mhcPool.RandomlyPickGene(hla);
		firstGene.SetGeneID(mhc1);
		mhcGenes.push_back(firstGene);
	}

/*
	Gene secondGene;
	secondGene.SetGeneID(mhc2);
	mhcGenes.push_back(secondGene);*/

	//create random KIRs with random specificity for ONE haplotype
	// (at the beginning of the simulation, the size of the map should equal the LOCI_NUMBER)
	map< pair<int,int>, pair <int, int> > ::iterator it;
	for(it = kirMap.GetMap().begin(); it != kirMap.GetMap().end(); it ++)
	{
		int id = it->first.first;
		int geneType = it->first.second;
		int L = it->second.first;
		int pseudo = it->second.second;
		KIRGene kir;
		kir.SetGeneSpecificity(L);
		kir.SetGeneID(id);
		kir.SetPseudogene(pseudo);
		kir.SetGeneType(geneType);
		kir.SetGeneFunctionality(false);
		kir.SetGeneExpression(false);
		kirGenes.push_back(kir);
		//cout << "printing genes in host first constructor" <<endl;
		//kir.PrintGenes();
	}

	int size = kirGenes.size();
	//make sure that the first haplotype has number lociKIR (regardless of the Map size!)
	while(size < lociKIR)
	{
		KIRGene bla = kirGenes.at(size-1);
		kirGenes.push_back(bla);
		size ++;
	}

	//copy the first kirs into the other haplotype (all individuals are homozygous!)
	for(int i=0; i<lociKIR; i++)
	{
		KIRGene kir = kirGenes.at(i);
		kirGenes.push_back(kir);

	}

	if(tuning == true)
		EducateKIRs();
	ExpressKIRs(numberOfExtraKirs);
	//CountFunctionalKIRs();
	age = RandomNumber(1,70); //population initialized with a random age between 1 and 70
	//cout <<inhibitoryKIRs << "|" <<activatingKIRs <<"|"<<CountExpressedKIRs() <<endl;
}
开发者ID:paolacarrillob,项目名称:NKRs_viruses_coevolution,代码行数:65,代码来源:Host.cpp


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