예제 #1
0
void Hd(pilha *P, No **raiz)
{
    No *pai_a = (No*) malloc(sizeof(No));
    No *pai_resto = (No*) malloc(sizeof(No));
    pilha Pilha[10000];
    if(tamPilha > 1)
    {
        pai_a = pop(P);
        pai_resto = pop(P);
        if(pai_a->dir->c == '@')
        {
            DecodificaOperacao(pai_a->dir, Pilha);
            OP = pop(Pilha);
            if(OP->c == 'T')
                Tl(Pilha, &pai_a->dir);
            else if(OP->c == 'H')
                Hd(Pilha, &pai_a->dir);
            else
                printf("\n--ERRO!!--\n");
        }
        pai_resto->esq = pai_a->dir->esq;

        DecodificaOperacao(pai_resto, P);
    }
    else if(tamPilha == 1)
    {
        pai_a = pop(P);

        if(pai_a->dir->c == '@')
        {
            DecodificaOperacao(pai_a->dir, Pilha);
            OP = pop(Pilha);
            if(OP->c == 'T')
                Tl(Pilha, &pai_a->dir);
            else if(OP->c == 'H')
                Hd(Pilha, &pai_a->dir);
            else
                printf("\n--ERRO!!--\n");
        }
        (*raiz) = pai_a->dir->esq;

        DecodificaOperacao(*raiz, P);
    }
    else
    {
        Fim=1;
    }
}
void FsGuiColorDialog::UpdateHSVSliderFromCurrentColor(void)
{
	auto col=GetCurrentColor();
	hueSlider->SetPosition(col.Hd());
	saturationSlider->SetPosition(col.Sd());
	valueSlider->SetPosition(col.Vd());
}
예제 #3
0
int check_h()
{
    int i,flg=0;
    for(i=0; i<E; i++)
    {
        h(i)=H3(en(i,0)-1,0)-H3(en(i,1)-1,0);
        qc(i)=c(i)*(h(i)+Hd(i));
        if(ch(i)==1)
        {
            Re=ro*qc(i)*D(i)/(A(i)*mu);
            f(i)=.094*pow(K(i),0.225)+0.53*K(i)+88*pow(K(i),0.44)*pow(fabs(Re),(-1.62*pow(K(i),0.134)));
            hc(i)=f(i)*L(i)*pow(qc(i),2)/(2*g*D(i)*pow(A(i),2))+k(i)*pow(qc(i),2)/(2*g*pow(A(i),2));
        }
        else if (ch(i)==2 && qc(i)>0)
        {
            hc(i)=pow((qc(i)/A(i)),2)/(2*g)-Hd(i);
        }
        else if(ch(i)==2 && qc(i)<0)
        {
            hc(i)=-pow((qc(i)/A(i)),2)/(2*g)-Hd(i);
        }
        else if(ch(i)==3)
        {
            hc(i)=k(i)*pow((qc(i)/A(i)),2)/(2*g)*pow((100.0/o(i)),(2*n(i)));
        }
        cc(i)=fabs(qc(i)/(hc(i)+Hd(i)));
        err(i)=fabs(fabs(hc(i))-fabs(h(i)))/fabs(h(i))*100;
        qDebug()<<"hc "<<hc(i)<<"h "<<h(i)<<"D "<<D(i)<<"f "<<f(i)<<"L "<<L(i)<<"A "<<A(i);
        if(err(i)<rangep)
        {
            flg++;
        }
        if(hc(i)!=hc(i))
        {
            qDebug()<<"Inside break for NaN";
            stop=1;
        }
    }
    qDebug()<<"flg "<< flg;
return flg;
}
void Booster_Details::on_bstr_pb_clicked()
{
    q(elc)=qa;
    D(elc)=ui->D_le->text().toDouble();
    Hd(elc)=ui->Hd_le->text().toDouble();
    L(elc)=0;
    e(elc)=0;
    k(elc)=0;
    o(elc)=0;
    n(elc)=0;
    //calculate_h();
    this->close();
    //qDebug()<<"Area "<<A(elc)<<"\nHead Loss "<<h0(elc);
}
void Flow_Control_Valve_Details::on_ok_fvc_pb_clicked()
{

    D(elc)=ui->D_le->text().toDouble();
    o(elc)=ui->o_le->text().toDouble();
    k(elc)=ui->k_le->text().toDouble();
    n(elc)=ui->n_le->text().toDouble();
    L(elc)=0;
    e(elc)=0;
    Hd(elc)=0;
    q(elc)=qa;
    //calculate_h(); Moved to thread.cpp with necessary
    this->close();
    //qDebug()<<"Area "<<A(elc)<<"\nHead Loss "<<h0(elc);
}
예제 #6
0
int main()
{
    int i;
    char strEntrada[200000];
    No *Raiz;
    pilha Pilha[10000];
    OP = (No*) malloc(sizeof(No));
    FILE *arq = fopen("string.in", "r");
    fscanf(arq,"%s",strEntrada);

    criaNo('@', &Raiz);
    Raiz = criaGrafo(strEntrada, Raiz);
    DecodificaOperacao(Raiz, Pilha);

    //for(i = 0; i<1; i++)
    while(Fim == 0 && Raiz->c != ':' && Raiz->c != '$')
    {
        OP = pop(Pilha);
        switch (OP->c)
        {
        case 'S':
            if(Verifica(3,Pilha, &Raiz))
            {
                S(Pilha, &Raiz);
                #ifdef CONT_FLAG
                    cont_S++;
                #endif
            }
            break;
        case 'K':
            K(Pilha, &Raiz);
            #ifdef CONT_FLAG
                cont_K++;
            #endif
            break;
        case 'B':
            if(Verifica(3,Pilha, &Raiz))
            {
                B(Pilha, &Raiz);
                #ifdef CONT_FLAG
                    cont_B++;
                #endif
            }
            break;
        case 'b':
            if(Verifica(3,Pilha, &Raiz))
            {
                BL(Pilha, &Raiz);
                #ifdef CONT_FLAG
                    cont_BL++;
                #endif
            }
            break;
        case 'P':
            if(Verifica(3,Pilha, &Raiz))
            {
                CL(Pilha, &Raiz);
                #ifdef CONT_FLAG
                    cont_CL++;
                #endif
            }
            break;
        case 'I':
            I(Pilha, &Raiz);
            #ifdef CONT_FLAG
                cont_I++;
            #endif
            break;
        case 'W':
            if(Verifica(3,Pilha, &Raiz))
            {
                SL(Pilha, &Raiz);
                #ifdef CONT_FLAG
                    cont_SL++;
                #endif
            }
            break;
        case 'C':
            if(Verifica(3,Pilha, &Raiz))
            {
                C(Pilha, &Raiz);
                #ifdef CONT_FLAG
                    cont_C++;
                #endif
            }
            break;
        case 'H': //Hd
            Hd(Pilha, &Raiz);
            break;
        case 'T': //Tl
            Tl(Pilha, &Raiz);
            break;
        case '*':
            MULT(Pilha, &Raiz);
            break;
        case '/':
            DIV(Pilha, &Raiz);
            break;
        case '-':
            SUB(Pilha, &Raiz);
            break;
        case '+':
            ADD(Pilha, &Raiz);
            break;
        case '^':
            POT(Pilha, &Raiz);
            break;
        default:
            Fim = 1;
            break;
        }
    }
    printf("Saida: ");
    printaGrafo(Raiz);
    printf("\n");
    printf("\nChamadas ao GC:%d\n", garbage);

#ifdef CONT_FLAG
    printf("S: %d\n",cont_S);
    printf("K: %d\n",cont_K);
    printf("I: %d\n",cont_I);
    printf("C: %d\n",cont_C);
    printf("B: %d\n",cont_B);
    printf("S': %d\n",cont_SL);
    printf("C': %d\n",cont_CL);
    printf("B': %d\n",cont_BL);
#endif

    return 0;
}
예제 #7
0
//
//
//
////s = regionprops(bw,accumMatrix,'weightedcentroid'); % in opencv, it is the centers of the contours. 
//
//void regionprops(int bw,Mat & accumMatrix,vector<Point> & centers){
//	vector<vector<Point>> contours;
//
//	findContours(accumMatrix,contours,CV_RETR_EXTERNAL,CV_CHAIN_APPROX_NONE);
//	for (int i=0;i<contours.size();i++)
//	{
//		Rect r0 = boundingRect(Mat(contours[i]));
//		centers.push_back(Point(((r0.X + r0.width)/2),((r0.Y + r0.height)/2)));
//	}
//	
//
//}
//
//
void myChcenters(Mat & accumMatrix, double suppThreshold,vector<Point> & centers,vector<float> & metric){

	int medFiltSize = 5;

	//cout<<accumMatrix<<endl;
	Mat Hd(accumMatrix.rows,accumMatrix.cols,CV_32FC1);
	//abs(accumMatrix)
	for (int i=0;i<accumMatrix.rows;i++)
	{
		for (int j=0;j<accumMatrix.cols;j++)
		{
			Hd.at<float>(i,j) = sqrt(pow(accumMatrix.at<cv::Vec2f>(i,j)[0],2) + pow(accumMatrix.at<cv::Vec2f>(i,j)[1],2));
		}
	}
	
	
	imshow("Hd0",Hd);
	waitKey(1);
	//cout<<Hd<<endl;
	//pre-process the accumulator array
	if(Hd.rows > medFiltSize&&Hd.cols>medFiltSize){
		 medianBlur(Hd,Hd,3);
	}
	imshow("Hd1",Hd);
	//Hd = morphReconstruct(Hd-suppThreshold,Hd);
	
	Hd = imReconstr(Hd-suppThreshold,Hd);
	//Hd = Hd.mul(255);
	imshow("Hd2",Hd);
	Mat bw  = Hd - imReconstr(Hd-1,Hd);
	bw =  bw.mul(255);
	//cout<<bw<<endl;
	imshow("bww",bw);
	waitKey(0);
	//Mat location
	//int bw = imregionalmax(Hd,Hd.rows * Hd.cols,0.001,10,);

	////regionprops
	//vector<Point> centers;
	//regionprops(bw,accumMatrix,centers);

	//vector<int> Centers_y,Centers_x;
	//for (int i=0;i<centers.size();i++)
	//{
	//	Centers_x.push_back(centers.at(i).X);
	//	Centers_y.push_back(centers.at(i).Y);
	//}

	//vector<int> Hd_idx;
	//mysub2ind(cv::Size(Hd.cols,Hd.rows),Centers_y,Centers_x,Hd_idx);

	//vector<double> metric;
	//for(int i=0;i<Hd_idx.size();i++){
	//	int y = Hd_idx.at(i)/(Hd.cols -1);
	//	int x = Hd_idx.at(i)%(Hd.cols -1);

	//	metric.push_back(Hd.at<double>(y,x));
	//}


	//double tmp;
	//Point p_tmp;
	//for (int j=0;j<metric.size()-1;j++)
	//{
	//	for (int i=0;i<metric.size()-1-j;i++)
	//	{
	//		if (metric.at(i)<metric.at(i+1))
	//		{
	//			tmp = metric.at(i);
	//			metric.at(i) = metric.at(i+1);
	//			metric.at(i+1) = tmp;

	//			p_tmp = centers.at(i);
	//			centers.at(i) = centers.at(i+1);
	//			centers.at(i+1) = p_tmp;
	//		}
	//	}
	//}
	//metric.sort();
	//centers.sort();

}
void Booster_Details::first_show()
{
    ui->D_le->setText(QString::number(D(elc)));
    ui->Hd_le->setText(QString::number(Hd(elc)));
}