⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 module.cpp

📁 test the resut l llke mjhue hbjhw hhww
💻 CPP
字号:
#include <stdio.h>#include "Floorplan.h"
Rect::Rect() {
	myNext = NULL;
}
Module::Module() {	myType = ModuleType;}Module::~Module() {}bool Module::M3OK(bool v_found,bool h_found) {	if(myNext==NULL) return v_found && h_found;	if(myNext->myType==OperatorType) {		return ((Operator *) myNext)->M3OK(v_found,h_found);	} else {		return ((Module *) myNext)->M3OK(v_found,h_found);	}}

Rect * Module::getRectangles() {
	Rect * myRect = new Rect();

	myRect->x = myWidth;
	myRect->y = myHeight;

	if(myWidth!=myHeight) {
		myRect->myNext = new Rect();
		myRect->myNext->x = myHeight;
		myRect->myNext->y = myWidth;
	}

	// dump rectangles
//	fprintf(stdout,"At node %i: ",myIndex);
//	for(int i=0;i<2;i++) {
//		if(myRects[2*i]==0) break;
//
//		fprintf(stdout,"(%i,%i) ",myRects[2*i],myRects[2*i+1]);
//	}
//	fprintf(stdout,"\n");

	return myRect;
}/*unsigned short Module::getHeight() {	return myHeight;}unsigned short Module::getWidth() {	return myWidth;}
*/Module * Module::GenerateListForward(Module * next) {	// modules are leaf nodes	myNext = next;	return this;}Module * Module::Clone() {	Module * retval;	retval = new Module();	retval->myHeight = myHeight;	retval->myWidth = myWidth;	retval->myIndex = myIndex;	return retval;}Module * Module::FindModuleWithIndex(unsigned int index) {	if(myType==ModuleType) {		if(myIndex==index) return this;		else if(myNext!=NULL) return myNext->FindModuleWithIndex(index);		else return NULL;	} else {		if(myNext!=NULL) return myNext->FindModuleWithIndex(index);		else return NULL;	}}Module * Module::FindParent() {	Module * myParent;	// my parent could be way down the list somewhere	// but I know my parent is an operator--but my parent	// could be NULL as well, if I am the root	myParent = myNext;		while(myParent!=NULL) {		// my parent is definately an operator,		// so skip all modules		if(myParent->myType==ModuleType) {			myParent = myParent->myNext;			continue;		}		// I've found an operator, so check to		// see if I am one of its children		if(((Operator *) myParent)->myRightChild==this) break;		if(((Operator *) myParent)->myLeftChild== this) break;		// that wasn't my parent, keep looking		myParent = myParent->myNext;	}	// if this is NULL, then I am the tree's root anyway,	// so I have no parent to return	return myParent;}Module * Module::FindNthModule(unsigned int index, unsigned int current) {//	fprintf(stdout,"c=%i,i=%i Visiting %s: %i--",current,index,(myType==ModuleType) ? "Module" : "Operator",myIndex);	if(current==index) {//		fprintf(stdout,"I match!\n");		return this;	}	else if(myNext!=NULL) {//		fprintf(stdout,"I don't match...checking my next...\n");		return myNext->FindNthModule(index,current+1);	}	else {//		fprintf(stdout,"I don't match, and I have no children!!\n");		return NULL;	}}void Module::dumpTree() {  fprintf(stdout,"<%i>",myIndex);}void Module::dumpList() {	fprintf(stdout,"<%i>",myIndex);	if(myNext!=NULL) {		if(myNext->myType==OperatorType) {			((Operator *) myNext)->dumpList();		} else {			((Module *) myNext)->dumpList();		}	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -