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


C++ Prefix::simplify方法代码示例

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


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

示例1: checkNewEP

int SymmetryObject::checkNewEP()
{
	int siz = newEP.size();	// antal vertices i kedja
	cout << "siz = " << siz << endl;
	vector<VEC> wc;

	cout << "skriver ut ala newEP: " << endl;
	for (int i=0; i<siz; i++) {
		wc.push_back(getWcFromPoint(newEP[i]));
		cout << i << ":\t" << wc[i] << "\t" << newEP[i].toString() << endl;
	}


	if (siz <= 1) {
		cout << "return 1: siz = " << siz << "<= 1 " << endl;
		return 1;
	}


		// gå genom alla och se om någon om två vertices sträcker sig för långt
	Prefix pfxDiff;
	for (int i=siz-2; i>=0; i--)
	{
		//pfxDiff = (newEP[siz-1].Pfx / newEP[i].Pfx);
		pfxDiff = (newEP[i].Pfx.getInverse() * newEP[siz-1].Pfx);
		pfxDiff.simplify();

		switch(pfxDiff.size())
		{
		case 0:
		case 1:
			break;
		case 2:
			if ((pfxDiff[0]^pfxDiff[1]) != 6) {
				cout << "return 0: pfxDiff[0]^pfxDiff[1] = " << (pfxDiff[0]^pfxDiff[1]) << " != 6" << endl;
				cout << "PfxDiff = ";
				pfxDiff.print();
				return 0;
			}
			break;
		default:
			cout << "return 0: pfxDiff[0].size() > 2" << endl;
			return 0;
		}
	}


	cout << "pfxDiff: " << pfxDiff.toString() << endl;
	int pfxDiffSiz = pfxDiff.size();


		// kontrollera att den inte är bend åt fel håll
	if (siz > 2) {
		if (~(wc[siz-1]-wc[siz-2]) * (wc[siz-3]-wc[siz-2]) < 0)
		{
			cout << "Bend towards vrong hool" << endl;
			return 0;
		}
	}

		//kontrollera så ingen är ansluten A -> B

		//kontrollera att inga korsningar existerar


		// finns det enclosed Points:
	VEC A[3];
	list<Point> enclosedPoints;
	if (siz >= 3) {
		A[0] = wc[0];
		A[1] = wc[siz-2];
		A[2] = wc[siz-1];
		int extraPoints = getEnclosedPoints(A, enclosedPoints);

		cout << "enclosed Points: " << extraPoints << endl;
		for (list<Point>::iterator itP = enclosedPoints.begin(); itP != enclosedPoints.end(); itP++)
			cout << "\t" << itP->toString() << endl;

		if (extraPoints > 0) {
			cout << "det fanns enclosed punkter" << endl;
			return 0;
		}
	}

		// kontrollera om den inte återvänder till samma index
	if (newEP[siz-1].index != newEP[0].index) {
		cout << "index[siz-1] != index[0] so returna 1" << endl;
		return 1;
	}


		// bestäm vad det är för typ av face
	switch(pfxDiffSiz) {
	case 0:
		cout << "Not centered" << endl;
		if (siz == 2) {
			cout << "siz = 2 och returnar till samma punkt" << endl;
			return 0;
		}
		return NOT_CENTERED;
//.........这里部分代码省略.........
开发者ID:gralm,项目名称:symmetry,代码行数:101,代码来源:symmetryObject.cpp

示例2: addNewEP

bool SymmetryObject::addNewEP(int sluten)
{
	//cout << "i addfacetobe so is sluten = " << sluten << endl;
			//vector<edge>::iterator ite = E_ToBe.end();
	int sizE = E.size();

	//		Fixa:
	// Rootera tillbaka ytan så att början
	//och slutet alltid rör  en rootPoint.
	Prefix draBortPfxInv = E_ToBe[0].fr.Pfx;//.getSize();
	cout << "The following prefix ska dras away" << endl;
	draBortPfxInv.print();
	draBortPfxInv = draBortPfxInv.getInverse();

	for (unsigned int i=0; i<E_ToBe.size()-1; i++)
	{
		edge edgeToPushBack;

		Prefix enAnnanPrefixIgen = draBortPfxInv;
		enAnnanPrefixIgen.rotate(E_ToBe[i].fr.Pfx);
		enAnnanPrefixIgen.simplify();
		edgeToPushBack.fr.Pfx = enAnnanPrefixIgen;
		edgeToPushBack.fr.index = E_ToBe[i].fr.index;

		enAnnanPrefixIgen = draBortPfxInv;
		enAnnanPrefixIgen.rotate(E_ToBe[i].to.Pfx);
		enAnnanPrefixIgen.simplify();
		edgeToPushBack.to.Pfx = enAnnanPrefixIgen;
		edgeToPushBack.to.index = E_ToBe[i].to.index;

		Prefix PfxNext;
		Prefix PfxPrev;

		switch (sluten) {
			case NOT_CENTERED: {
				edgeToPushBack.next = Edge(PfxNext, (i==E_ToBe.size()-2? sizE: sizE + i + 1));
				edgeToPushBack.prev = Edge(PfxPrev, (i==0? sizE + E_ToBe.size() - 2: sizE + i - 1));
				break;
			}
			case VERTEX_CENTERED: {

				if (i==0)
					PfxPrev.rotate(VN);
				if (i==E_ToBe.size()-2)
					PfxNext.rotate(VP);
				edgeToPushBack.next = Edge(PfxNext, (i==E_ToBe.size()-2? sizE: sizE + i + 1));
				edgeToPushBack.prev = Edge(PfxPrev, i==0? sizE + E_ToBe.size() - 2: sizE + i - 1);
				//edgeToPushBack.next = (i==E_ToBe.size()-2? Edge(Pfx, sizE): Edge(Prefix(), sizE + i + 1));
				break;
			}
			case EDGE_CENTERED: {
				Prefix cpPrefixHelvete;

				cpPrefixHelvete = E_ToBe[E_ToBe.size()-1].fr.Pfx;
				cpPrefixHelvete.rotate(draBortPfxInv);

				cout << "when it is done, it becomasar: ";
				cpPrefixHelvete.print();
				cout << endl;

				if (i==0) {
					PfxPrev = cpPrefixHelvete;
				}


				if (i==E_ToBe.size()-2) {
					PfxNext = cpPrefixHelvete;
				}

				edgeToPushBack.next = Edge(PfxNext, (i==E_ToBe.size()-2? sizE: sizE + i + 1));
				edgeToPushBack.prev = Edge(PfxPrev, (i==0? sizE + E_ToBe.size() - 2: sizE + i - 1));
				break;
			}
			case FACE_CENTERED: {
				Prefix PfxNext;
				Prefix PfxPrev;

				if (i==0)
					PfxPrev.rotate(FN);
				if (i==E_ToBe.size()-2)
					PfxNext.rotate(FP);
				edgeToPushBack.next = Edge(PfxNext, (i==E_ToBe.size()-2? sizE: sizE + i + 1));
				edgeToPushBack.prev = Edge(PfxPrev, (i==0? sizE + E_ToBe.size() - 2: sizE + i - 1));
				break;
			}
			default:
				cout << "symmetryObject.cpp\tHIT SKA DEN INTE KOMMA!!!!!!!!!!!" << endl;
				break;
		}

			// kolla genom om man kan hitta någon opposite
		cout << endl;
		//int kortastePrefix = 10000000;
		edgeToPushBack.oppo.index = -1;
		//edgeToPushBack.





//.........这里部分代码省略.........
开发者ID:gralm,项目名称:symmetry,代码行数:101,代码来源:symmetryObject.cpp

示例3: equalTo

bool Point::equalTo(Point &A) {
	Prefix subPfx = Pfx.difference(A.Pfx);
	bool keepTrying = (index<-1);
	subPfx.simplify();

	//cout << endl << "subPfx before: ";
	//subPfx.print();
	//cout << endl;


	//for (list<TYP>::reverse_iterator rit = R.rbegin(); rit != R.rend(); rit++)
		//toReturn.R.push_back(INV_ROTATION(*rit));

	int previousEcTYP = 0;
	int k = 0;

	keepTrying = true;
	for (list<TYP>::reverse_iterator ritR = subPfx.R.rbegin(); keepTrying && ritR != subPfx.R.rend();)
	{
		k++;
		//cout << "now is ritR = ";
		//rotationPrint(*ritR);
		//cout << endl;

		if (index == VERTEX_CENTERED && (*ritR == VN || *ritR == VP)) {
			//cout << "VC" << endl;
			/*subPfx.R.erase(--(ritR.base()));
			ritR = subPfx.R.rbegin();*/
			ritR = list<TYP>::reverse_iterator(subPfx.R.erase(--(ritR.base())));
			//cout << "ritR efter erase: ";
			//rotationPrint(*ritR);
			//cout << endl;
		} else if (index == FACE_CENTERED && (*ritR == FN || *ritR == FP)) {
			//cout << "FC" << endl;
			ritR = list<TYP>::reverse_iterator(subPfx.R.erase(--(ritR.base())));
			//cout << "ritR efter erase: ";
			//rotationPrint(*ritR);
		} else if (index == EDGE_CENTERED) {
			//TYP ritRold = *ritR;
			if ((previousEcTYP == FP && *ritR == VP) || (previousEcTYP == VN && *ritR == FN)) {
				//cout << "ECa" << endl;
				subPfx.R.pop_back();
				subPfx.R.pop_back();
				ritR = subPfx.R.rbegin();
				//ritR = list<TYP>::reverse_iterator(subPfx.R.erase(--(ritR.base())));
				//ritR = list<TYP>::reverse_iterator(subPfx.R.erase(--(ritR.base())));
				previousEcTYP = 0;
			} else if ((previousEcTYP == VN && *ritR == FP) || (previousEcTYP == VN && *ritR == FP)){
				//cout << "ECd" << endl;
				subPfx.R.pop_back();
				subPfx.R.pop_back();
				subPfx.R.push_back(FN);
				ritR = subPfx.R.rbegin();
				subPfx.print();
				//cout << endl;
				subPfx.simplify();
				subPfx.print();
				//cout << endl;
				previousEcTYP = 0;
				//cout << endl;
			} else if (previousEcTYP == 0 && (*ritR == FP || *ritR == VN)) {
				//cout << "ECb" << endl;
				previousEcTYP = *ritR;
				ritR++;
			} else {
				//cout << "ECc" << endl;
				keepTrying = false;
			}
		} else {

			//cout << "0" << endl;
			keepTrying = false;
		}
		if (k > 10)
			break; 
	}


	//cout << endl << "subPfx efter: ";
	//subPfx.print();
	//cout << endl;

	return (subPfx.size() == 0);
}
开发者ID:gralm,项目名称:symmetry,代码行数:84,代码来源:point.cpp


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