cachemodel_param_t * gene_cachemodel( cachemodellist_param_t *cachemodellist, target_param_t *target, OPJ_BOOL reqJPP)
{
  cachemodel_param_t *cachemodel;
  faixbox_param_t *tilepart;
  faixbox_param_t *precpacket;
  size_t numOfelem;
  Byte8_t numOftiles;
  int i;

  cachemodel = (cachemodel_param_t *)opj_malloc( sizeof(cachemodel_param_t));

  refer_target( target, &cachemodel->target);
  
  if( reqJPP){
    if( target->jppstream)
      cachemodel->jppstream = OPJ_TRUE;
    else
      cachemodel->jppstream = OPJ_FALSE;
  } else{ /* reqJPT */
    if( target->jptstream)
      cachemodel->jppstream = OPJ_FALSE;
    else
      cachemodel->jppstream = OPJ_TRUE;
  }

  cachemodel->mhead_model = OPJ_FALSE;
  
  tilepart = target->codeidx->tilepart;
  numOftiles = get_m( tilepart);
  numOfelem = get_nmax( tilepart)*numOftiles;
  cachemodel->tp_model = (OPJ_BOOL *)opj_calloc( 1, numOfelem*sizeof(OPJ_BOOL));
  cachemodel->th_model = (OPJ_BOOL *)opj_calloc( 1, numOftiles*sizeof(OPJ_BOOL));
  cachemodel->pp_model = (OPJ_BOOL **)opj_malloc( target->codeidx->SIZ.Csiz*sizeof(OPJ_BOOL *));
  for( i=0; i<target->codeidx->SIZ.Csiz; i++){
    precpacket = target->codeidx->precpacket[i];
    cachemodel->pp_model[i] = (OPJ_BOOL *)opj_calloc( 1, get_nmax(precpacket)*get_m(precpacket)*sizeof(OPJ_BOOL));
  }
  cachemodel->next = NULL;
  
  if( cachemodellist){
    if( cachemodellist->first) /* there are one or more entries */
      cachemodellist->last->next = cachemodel;
    else                   /* first entry */
      cachemodellist->first = cachemodel;
    cachemodellist->last = cachemodel;
  }

#ifndef SERVER
  fprintf( logstream, "local log: cachemodel generated\n");
#endif

  return cachemodel; 
}
示例#2
0
cachemodel_param_t * gene_cachemodel( cachemodellist_param_t *cachemodellist, target_param_t *target, bool reqJPP)
{
  cachemodel_param_t *cachemodel;
  faixbox_param_t *tilepart;
  faixbox_param_t *precpacket;
  size_t numOfelem;
  Byte8_t numOftiles;
  int i;

  cachemodel = (cachemodel_param_t *)malloc( sizeof(cachemodel_param_t));

  refer_target( target, &cachemodel->target);
  
  if( reqJPP){
    if( target->jppstream)
      cachemodel->jppstream = true;
    else
      cachemodel->jppstream = false;
  } else{ // reqJPT
    if( target->jptstream)
      cachemodel->jppstream = false;
    else
      cachemodel->jppstream = true;
  }

  cachemodel->mhead_model = false;
  
  tilepart = target->codeidx->tilepart;
  numOftiles = get_m( tilepart);
  numOfelem = get_nmax( tilepart)*numOftiles;
  cachemodel->tp_model = (bool *)calloc( 1, numOfelem*sizeof(bool));
  cachemodel->th_model = (bool *)calloc( 1, numOftiles*sizeof(bool));
  cachemodel->pp_model = (bool **)malloc( target->codeidx->SIZ.Csiz*sizeof(bool *));
  for( i=0; i<target->codeidx->SIZ.Csiz; i++){
    precpacket = target->codeidx->precpacket[i];
    cachemodel->pp_model[i] = (bool *)calloc( 1, get_nmax(precpacket)*get_m(precpacket)*sizeof(bool));
  }
  cachemodel->next = NULL;
  
  if( cachemodellist){
    if( cachemodellist->first) // there are one or more entries
      cachemodellist->last->next = cachemodel;
    else                   // first entry
      cachemodellist->first = cachemodel;
    cachemodellist->last = cachemodel;
  }

#ifndef SERVER
  fprintf( logstream, "local log: cachemodel generated\n");
#endif

  return cachemodel; 
}
示例#3
0
int main()
{
	int p, e, i, start, case_count = 0;
	int tmp;
	while(scanf("%d %d %d %d", &p, &e, &i, &start) != EOF){
		if(start == -1){
			break;
		}
		case_count++;
		tmp = (p*get_m(28, 33, 23) + e*get_m(23, 33, 28) + i*get_m(23, 28, 33))%21252;
		printf("Case %d: the next triple peak occurs in %d days.\n", case_count, (tmp > start) ? (tmp-start):(tmp+21252-start) );
	}
}
ostream& matrix_t::write(ostream& os)
{
	char aux[80];

	sprintf(aux, " %10d  %10d ",get_m(),get_n());
	os << aux<<endl;

	for(int i=1;i<=get_m();i++){
		for(int j=1;j<=get_n();j++){
			sprintf(aux," %10.6lf ",get_matrix_item(i,j));
			os << aux;
		}
		os << endl;
	}
}
void  sparse_matrix_t::mostrarMatrizDensa_1(void)
{
	char aux[80];

	for(int i=0;i<get_m();i++){

		for(int j=0;j<get_n();j++){

			bool encontrado=false;
			int l=matbeg_[j];

			for(;(l<matbeg_[j]+matcnt_[j]) && (!encontrado);l++)
				if (matind_[l]==i)
					encontrado=true;
			if (encontrado)
				sprintf(aux," %10.6lf ",matval_[l-1]);
			else
				sprintf(aux," %10.6lf ",0.0);

			cout << aux;							
		}

		std::cout << endl;
	}
}
//FUNCION DE LA FASE 3
void  sparse_matrix_t::mostrarMatrizDensa_2(void)
{
	char aux[80];

    /*Declaracion de los 3 vectores de punteros con el tamaño del numero de columnas de la matriz
    y asignación de memoria dinámica*/
	vector_inx_t**  matind_ptr = NULL;
	vector_inx_t**  matind_end_ptr = NULL;
	matrix_item_t** matval_ptr = NULL;

	matind_ptr = new vector_inx_t* [n_];
	matind_end_ptr = new vector_inx_t* [n_];
	matval_ptr     = new matrix_item_t*[n_];
	//
    
    //Inicializacion de valores de los vectores de punteros tal como en el PDF
	for(int j=0;j<get_n();j++){
		matind_ptr[j]     = matind_ + matbeg_[j];
		matval_ptr[j]     = matval_ + matbeg_[j];
		matind_end_ptr[j] = matind_ptr[j] + matcnt_[j];
	}
	//

	//Dos bucles para recorrer filas y columnas de la matriz
	for(int i=0;i<get_m();i++){//Recorrido filas

		for(int j=0;j<get_n();j++){//Recorrido columnas
             if (matind_ptr[j]==matind_end_ptr[j]) { //Primer condicional
                      sprintf(aux," %10.6lf ",0.0); 
                      cout << aux;
                   }
                   else {
                     if ((*matind_ptr[j])==i) { //Segundo condicional
                       
                       sprintf(aux," %10.6lf ",*matval_ptr[j]);
                       cout << aux;
                       matind_ptr[j] ++; //Ponemos el puntero en la siguiente direccion
                       matval_ptr[j] ++; //Ponemos el puntero en la siguiente direccion
                     }
                     else {
                       
                       sprintf(aux," %10.6lf ",0.0);
                       cout << aux;			
		     }
                   }
								
		}
		std::cout << endl;
	}
	
	//Borramos la memoria dinamica de los punteros y les quitamos la direccion (NULL)
	delete [] matind_ptr;
	delete [] matval_ptr;
	delete [] matind_end_ptr;

	matind_ptr=NULL;
	matval_ptr=NULL;
	matind_end_ptr=NULL;
	//
}
void GaussianProcessInterpolation::compute_OmiIm() {
  IMP_Eigen::VectorXd I(get_I());
  IMP_Eigen::VectorXd m(get_m());
  IMP_Eigen::MatrixXd Omi(get_Omi());
  IMP_LOG_TERSE("OmiIm ");
  OmiIm_ = ldlt_.solve(I - m);
  IMP_LOG_TERSE(std::endl);
}
示例#8
0
size_t HashBloom::get_k(size_t n, size_t h) {
    for(size_t k = TTHValue::BITS/h; k > 1; --k) {
        uint64_t m = get_m(n, k);
        if(m >> 24 == 0) {
            return k;
        }
    }
    return 1;
}
示例#9
0
文件: RAM.cpp 项目: alu4102/DAA_P01
void RAM::printDesc() {
	cout << "\t OPCODE \t OPERANDO/ETIQUETA \n";
	cout << "       *******************************\n";
	for (int i = 0; i < get_m(); i++)
		if ((get_item(i, 0) == "9") || (get_item(i, 0) == "10") || (get_item(i, 0) == "11"))
			cout << "L" << i+1 << "\t  " <<  desOpcode(get_item(i, 0)) << "\t\t\tL" << get_item(i, 1) << "\n";
		else
			cout << "L" << i + 1 << "\t  " << desOpcode(get_item(i, 0)) << "\t\t\t" << get_item(i, 1) << "\n";
}
示例#10
0
文件: RAM.cpp 项目: alu4102/DAA_P01
index RAM::position(index i, index j)
{
	if ((i<0) || (i>get_m()) || (j<0) || (j>get_n()))	// Verificamos que está dentro de los límites, para indexar en (1,1), i<1, j< 1, ....
	{
		cerr << "Error en los índices de la matriz." << endl;
		return 0;
	}

	return i*get_n() + j;			// (i - 1)*get_n() + (j - 1) si lo queremos indexar desde (1,1) en vez (0,0)
}
示例#11
0
void print_faixbox( faixbox_param_t *faix)
{
  Byte8_t i, j;

  fprintf( logstream, "faix box info\n");
  fprintf( logstream, "\tversion: %d\n", faix->version);
  
  fprintf( logstream, "\t nmax: %#" PRIx64 " = %" PRId64 "\n", get_nmax( faix), get_nmax( faix));
  fprintf( logstream, "\t m: %#" PRIx64 " = %" PRId64 "\n", get_m( faix), get_m( faix));

  for( i=0; i<get_m( faix); i++){
    for( j=0; j<get_nmax( faix); j++){
      fprintf( logstream, "\t off = %#" PRIx64 ", len = %#" PRIx64 "", get_elemOff( faix, j, i), get_elemLen( faix, j, i));
      if( 2 <= faix->version)
	fprintf( logstream, ", aux = %#x", get_elemAux( faix, j, i));
      fprintf( logstream, "\n");
    }
    fprintf( logstream, "\n");
  }
}
vector_inx_t matrix_t::pos(matrix_inx_t i,matrix_inx_t j)
{
	if ((i<1)||(i>get_m())||(j<1)||(j>get_n())){
		std::cerr << "Error accediendo a matriz"<< std::endl;
		return 0;
        }

	if (traspuesta_)
		return (j-1)*n_+i-1;
	else
		return (i-1)*n_+j-1;


}
示例#13
0
int main()
{
   get_m();
   for(int i = 3; i < 100; i++)
   {
       printf("%d ", f[i]);
   }
   printf("\n");
   int n, m;
   while(scanf("%d %d", &n, &m))
   {
       printf("%d\n", f[n]%m);
   }
   return 0;
}
void matrix_t::filtra(matrix_t& M, matrix_item_t it, double precision){
    matrix_inx_t m = get_m();
    matrix_inx_t n = get_n();
    M.redimensiona(m, n);
    for (int i = 1; i < m; i++) {
        for (int j = 1; j < n ; j++) {
            if (M.igual(get_matrix_item(i, j),it,precision) == true) {
                M.set_matrix_item(i, j, get_matrix_item(i, j));
            } else {
                matrix_item_t x = 0.00000;
                M.set_matrix_item(i, j, x);
            }
        }
    }
}
void  matrix_t::mostrarMatriz(void)
{

	char aux[80];

	for(int i=1;i<=get_m();i++){
		
		for(int j=1;j<=get_n();j++){
			sprintf(aux," %10.6lf ",get_matrix_item(i,j));
			cout << aux;
		}
		cout << endl;
	}

	cout << endl;	
}
void FemPoroelasticResidualLocalAssembler::assembleComponents
    (   const NumLib::TimeStep &timestep,
        const MeshLib::IElement &e, 
        const std::vector<size_t> &vec_order, 
        const std::vector<LocalVectorType> &vec_x0,
        const std::vector<LocalVectorType> &vec_x1,
        std::vector<LocalVectorType> &vec_r
        )
{
    assert(vec_order.size()==3);

    //TODO how do you know 1st is ux and 3rd is p? who decides it?
    const size_t id_ux = 0;
    const size_t id_uy = 1;
    const size_t id_p = 2;

    const size_t u_order = vec_order[id_ux];
    assert(u_order==vec_order[id_uy]);
    const size_t p_order = vec_order[id_p];
    const LocalVectorType &ux0 = vec_x0[id_ux];
    const LocalVectorType &uy0 = vec_x0[id_uy];
    const LocalVectorType &ux1 = vec_x1[id_ux];
    const LocalVectorType &uy1 = vec_x1[id_uy];
    // combine ux and uy
    LocalVectorType u0(ux0.rows()*2);
    LocalVectorType u1(ux0.rows()*2);
    for (int i=0; i<ux0.rows(); i++) {
        u0(i) = ux0(i);
        u0(i+ux0.rows()) = uy0(i);
        u1(i) = ux1(i);
        u1(i+ux0.rows()) = uy1(i);
    }
    const LocalVectorType &p0 = vec_x0[id_p];
    const LocalVectorType &p1 = vec_x1[id_p];
    // ------------------------------------------------------------------------
    // Element
    // ------------------------------------------------------------------------
    const size_t dim = e.getDimension();
    const size_t n_strain_components = getNumberOfStrainComponents(dim);
    const size_t nnodes_u = e.getNumberOfNodes(u_order);
    const size_t nnodes_p = e.getNumberOfNodes(p_order);
    const NumLib::TXPosition e_pos(NumLib::TXPosition::Element, e.getID());

    // ------------------------------------------------------------------------
    // Transient
    // ------------------------------------------------------------------------
    const double dt = timestep.getTimeStepSize();
    const double theta = 1.0;

    // ------------------------------------------------------------------------
    // Material (assuming element constant)
    // ------------------------------------------------------------------------
    size_t mat_id = e.getGroupID();
    size_t fluid_id = 0; //TODO
    Ogs6FemData* femData = Ogs6FemData::getInstance();
    MaterialLib::PorousMedia* pm = femData->list_pm[mat_id];
    MaterialLib::Solid *solidphase = femData->list_solid[mat_id];
    MaterialLib::Fluid *fluidphase = femData->list_fluid[fluid_id];

    // solid
    double rho_s = .0;
    if (solidphase->density!=NULL)
        solidphase->density->eval(e_pos, rho_s);
    LocalMatrixType De = LocalMatrixType::Zero(n_strain_components, n_strain_components);
    MathLib::LocalMatrix nv(1,1);
    MathLib::LocalMatrix E(1,1);
    solidphase->poisson_ratio->eval(e_pos, nv);
    solidphase->Youngs_modulus->eval(e_pos, E);
    double Lambda, G, K;
    MaterialLib::calculateLameConstant(nv(0,0), E(0,0), Lambda, G, K);
    MaterialLib::setElasticConsitutiveTensor(dim, Lambda, G, De);

    // fluid
    double mu = .0;
    fluidphase->dynamic_viscosity->eval(e_pos, mu);
    double rho_f = .0;
    fluidphase->density->eval(e_pos, rho_f);

    // media
    double k;
    pm->permeability->eval(e_pos, k);
    double n = .0;
    pm->porosity->eval(e_pos, n);
    double s = .0;
    pm->storage->eval(e_pos, s);
    double k_mu;
    k_mu = k / mu;


    // ------------------------------------------------------------------------
    // Body force
    // ------------------------------------------------------------------------
    LocalVectorType body_force = LocalVectorType::Zero(dim);
    bool hasGravity = false;
    if (hasGravity) {
        body_force[dim-1] = rho_s * 9.81;
    }

    // ------------------------------------------------------------------------
    // Local component assembly
    // ------------------------------------------------------------------------
    LocalMatrixType Kuu = LocalMatrixType::Zero(nnodes_u*dim, nnodes_u*dim);
    LocalMatrixType Cup = LocalMatrixType::Zero(nnodes_u*dim, nnodes_p);
    LocalMatrixType Kpp = LocalMatrixType::Zero(nnodes_p, nnodes_p);
    LocalMatrixType Mpp = LocalMatrixType::Zero(nnodes_p, nnodes_p);
    LocalMatrixType Cpu = LocalMatrixType::Zero(nnodes_p, nnodes_u*dim);
    LocalVectorType Fu = LocalVectorType::Zero(nnodes_u*dim);
    LocalVectorType Fp = LocalVectorType::Zero(nnodes_p);

    // temp matrix
    LocalMatrixType B = LocalMatrixType::Zero(n_strain_components, nnodes_u*dim);
    LocalMatrixType Nuvw = LocalMatrixType::Zero(dim, nnodes_u*dim);
    const LocalMatrixType m = get_m(dim);

    //
    FemLib::IFiniteElement* fe_u = _feObjects.getFeObject(e, u_order);
    FemLib::IFiniteElement* fe_p = _feObjects.getFeObject(e, p_order);
    FemLib::IFemNumericalIntegration *q_u = fe_u->getIntegrationMethod();
    double gp_x[3], real_x[3];
    for (size_t j=0; j<q_u->getNumberOfSamplingPoints(); j++) {
        q_u->getSamplingPoint(j, gp_x);
        fe_u->computeBasisFunctions(gp_x);
        fe_p->computeBasisFunctions(gp_x);
        fe_u->getRealCoordinates(real_x);
        double fac_u = fe_u->getDetJ() * q_u->getWeight(j);

        //--- local component ----
        // set N,B
        LocalMatrixType &Nu = *fe_u->getBasisFunction();
        LocalMatrixType &dNu = *fe_u->getGradBasisFunction();
        setNu_Matrix_byComponent(dim, nnodes_u, Nu, Nuvw);
        setB_Matrix_byComponent(dim, nnodes_u, dNu, B);
        LocalMatrixType &Np = *fe_p->getBasisFunction();

        // K_uu += B^T * D * B
        Kuu.noalias() += fac_u * B.transpose() * De * B;

        // C_up += B^T * m * Np
        Cup.noalias() += fac_u * B.transpose() * m * Np;

        // Fu += N^T * b
        if (hasGravity) {
            Fu.noalias() += fac_u * Nuvw.transpose() * body_force;
        }
    }
    Fu.noalias() += (theta - 1) * Kuu * u0 + (1-theta)* Cup * p0;

    FemLib::IFemNumericalIntegration *q_p = fe_p->getIntegrationMethod();
    for (size_t j=0; j<q_p->getNumberOfSamplingPoints(); j++) {
        q_p->getSamplingPoint(j, gp_x);
        fe_u->computeBasisFunctions(gp_x);
        fe_p->computeBasisFunctions(gp_x);
        fe_p->getRealCoordinates(real_x);
        double fac = fe_p->getDetJ() * q_p->getWeight(j);

        //--- local component ----
        // set N,B
        LocalMatrixType &dNu = *fe_u->getGradBasisFunction();
        setB_Matrix_byComponent(dim, nnodes_u, dNu, B);
        LocalMatrixType &Np = *fe_p->getBasisFunction();
        LocalMatrixType &dNp = *fe_p->getGradBasisFunction();

        // M_pp += Np^T * S * Np
        Mpp.noalias() += fac * Np.transpose() * s * Np;

        // K_pp += dNp^T * K * dNp
        Kpp.noalias() += fac * dNp.transpose() * k_mu * dNp;

        // C_pu += Np^T * m^T * B
        Cpu.noalias() += fac * Np.transpose() * m.transpose() * B;
    }

    // Backward euler
    Fp = (1.0/dt * Mpp - (1-theta)*Kpp)* p0 + 1.0/dt * Cpu * u0;

    // r = K*u - RHS
    LocalVectorType r_u = Kuu * u1 - Cup * p1 - Fu;
    LocalVectorType r_p = 1.0/dt * Cpu * u1 + (1.0/dt * Mpp + theta * Kpp) * p1 - Fp;
//    if (e.getID()==0) {
//        std::cout << "u1=" << std::endl << u1 << std::endl;
//        std::cout << "p1=" << std::endl << p1 << std::endl;
//        std::cout << "Fp=" << std::endl << Fp << std::endl;
//        std::cout << "r_p=" << std::endl << r_p << std::endl;
//    }

    //
    for (size_t i=0; i<dim; i++) {
        vec_r[i] = r_u.segment(i*nnodes_u, nnodes_u);
    }
    vec_r[id_p] = r_p;
}
示例#17
0
int main(void)
{
  //values
  double m_x_global,m_y_global,m_z_global;//,m_stdx_global,m_stdy_global,m_stdz_global;

  double d_begin = 3.0;
  double d_end   =30.0;
  double d_step  = 0.5;
  double d_i = d_begin;

  double m_begin,n_begin,m_end,n_end;

#if defined(_MSC_VER)
  char cam_left[]  = {"AVT_Stingray_right_left_cam1.inikalib.ini"};
  char cam_right[] = {"AVT_Stingray_right_right_cam2.inikalib.ini"};
#else
	char cam_left[]  = {"/home/steffen/projekte/Lehmann_und_Partner/photogrammetrie_dll/example_photogrammetrie/cam_calib/AVT_Stingray_right_left_cam1.inikalib.ini"};
	char cam_right[] = {"/home/steffen/projekte/Lehmann_und_Partner/photogrammetrie_dll/example_photogrammetrie/cam_calib/AVT_Stingray_right_right_cam2.inikalib.ini"};
#endif

//################################

#if defined(_MSC_VER)
  puts("access to the Photogrammetrie.dll\n");
#else
  puts("access to the Photogrammetrie.so\n");
#endif



//################################
  del_all();

  printf("\n##################################\n");
  printf("forwart intersection example 1:\n");

    //fill the camera list with one cam and on bpoint and than the next pair
    //create camera left with a bpoint
    addCam(1040,1392,0.00465,0.0,0.0,0.0,0.0,0.0,0.0,-8.3481198,0.00089,0.00472,-0.00284666,4.33195e-05,0,1.01299e-05,-2.01898e-05,-0.000134369,-4.26305e-05,2.427375,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0);
    addBPoint(272.0,325.0);

    //create camera right with a bpoint
    addCam(1040,1392,0.00465,-1114.242911,-2.313123752,-108.0708656,-0.006391017146,-0.1810263138,0.007287021954,-8.3789952,0.08349,0.00098,-0.00285721,4.69797e-05,0,8.79895e-05,6.01291e-05,3.13052e-05,-8.65479e-05,2.427375,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0);
    addBPoint(223.0,300.0);

    //calculate of the forward intersection
    calculate();

    //showVariablesAndInfos();

    printf("\nforwart intersection calc   :  x: %lf ,y: %lf z: %lf  std(%lf,%lf,%lf)",get_x_local(),get_y_local(),get_z_local(),get_stdx_local(),get_stdy_local(),get_stdz_local());
    printf("\nforwart intersection control: (-1741.225369 , 799.567923 , -7397.498111)  std(2.136106,1.646223,12.459384)\n");

    //delete all values (depends of the internal List of bpoints)
    del_all();


//################################

  printf("\n##################################\n");
  printf("forwart intersection example 2:\n");

                 //info -- calculation from the calibration --
				 /* calibration
				 ###### forward intersection ########
				  picture left:  RechtsVorn_13.BMP  picture right: RechtsHinten_13.BMP
				  BP_left :126 (  756.000,  345.000)   BP_right :126 (  401.000,  370.000)
				  ###### end forward intersection ########
				  ######  boreside transformation ########
				  car pos left  : (  641754.64076, 5638452.77658,     296.79691)  rot (0.67666,      -0.16642,     147.47308)   have pic's the same car pos :1
				  UTM global    : (  641748.32241, 5638451.20961,     299.20626)  0.00000 0.00000 0.00000
				  UTM soll P_ref: (  641748.32088, 5638451.20780,     299.20560)
				  soll - ist    : (      -0.0-1062.3945612937441,1587.5888858836174,-7728.733215755935)0153,      -0.00180,      -0.00066)
				 ###### end boreside transformation ########
				 */


  addCam2(cam_left);
  addBPoint(756.000,345.000);

  addCam2(cam_right);
  addBPoint(401.000,370.000);

  addGlobalCarReferencePoint(641754.64076,5638452.77658,296.79691,-0.2235410,-0.6600010,214.0967730,50.8803408,11.0150776);
  addGlobalCarReferencePoint_std( 1.0 , 1.0 , 2.0 , 0.1 , 0.1 , 0.2 );
  setGlobalReferenceFrame();//todo in process -> for EPS data

  //calculate of the forward intersection
  calculate();

  //showVariablesAndInfos();

  printf("\n");
  printf("\nforwart intersection calc   :  x: %lf ,y: %lf z: %lf  std(%lf,%lf,%lf)",get_x_local(),get_y_local(),get_z_local(),get_stdx_local(),get_stdy_local(),get_stdz_local());
  printf("\nforwart intersection control: ((       0.40655,       0.50524,      -3.78090))\n");


  printf("\nbore side calc   :  x: %lf ,y: %lf z: %lf  std(%lf,%lf,%lf)",get_x_global(),get_y_global(),get_z_global(),get_stdx_global(),get_stdy_global(),get_stdz_global());
  printf("\nbore side control: (641748.32241, 5638451.20961,     299.20626)");
  printf("\ntestfield control: (641748.32088, 5638451.20780,     299.20560)\n");

  //save the values for the next example
  m_x_global = get_x_global();//Easting
  m_y_global = get_y_global();//Northing
  m_z_global = get_z_global();//ell. Height


  //delete all values (depends of the internal List of bpoints)
  del_all();

//##################################

  printf("\n##################################\n");
  printf("forwart intersection example 2A:\n");

      //info -- calculation from the calibration --
      /* calibration
         ###### forward intersection ########
         picture left:  RechtsVorn_13.BMP  picture right: RechtsHinten_13.BMP
         BP_left :126 (  756.000,  345.000)   BP_right :126 (  401.000,  370.000)
         ###### end forward intersection ########
         ######  boreside transformation ########
         car pos left  : (  641754.64076, 5638452.77658,     296.79691)  rot (0.67666,      -0.16642,     147.47308)   have pic's the same car pos :1
         UTM global    : (  641748.32241, 5638451.20961,     299.20626)  0.00000 0.00000 0.00000
         UTM soll P_ref: (  641748.32088, 5638451.20780,     299.20560)
         soll - ist    : (      -0.0-1062.3945612937441,1587.5888858836174,-7728.733215755935)0153,      -0.00180,      -0.00066)
         ###### end boreside transformation ########
      */

  addCam( 960, 1280,
          0.00645,                            
          0, 0, 0,                              
          0, 0, 0,                              
          -5.96131, 0.09154, 0.05499,           
          -0.00392312, 5.3042e-05, 0,           
          3.41561e-05, 1.66584e-05,            
          0.000115336, 3.44961e-05,            
          3.1,
          1.810038117, 1.997471691, 2.954505537,
          0, 0, 0,                              
          1.236546986, -0.6468711578, -0.222276496,
          0, 0, 0);
  addBPoint(756.000,345.000);

  addCam( 960, 1280, 
          0.00645,                                   
          1.694736602, -0.5066248238, 1.913592406,     
          0.06547699024, -0.02425883623, 0.01597899627,
          -5.96062, -0.02699, 0.00748,                 
          -0.00392089, 5.0132e-05, 0,                  
          -2.96244e-05, -0.000116111,                 
          -8.63535e-05, -7.70085e-05,                 
          3.1,                                       
          1.886692106, -0.6072478387, 2.940466502,     
          0, 0, 0,                                     
          1.312015813, -0.6836290131, -0.1604868833,   
          0, 0, 0 );
  addBPoint(401.000,370.000);

  addGlobalCarReferencePoint(641754.64076,5638452.77658,296.79691,-0.2235410,-0.6600010,214.0967730,50.8803408,11.0150776);
  setGlobalReferenceFrame();//todo in process -> for EPS data

  //calculate of the forward intersection
  calculate();

  //showVariablesAndInfos();

  printf("\n");
  printf("\nforwart intersection calc   :  x: %lf ,y: %lf z: %lf  std(%lf,%lf,%lf)",get_x_local(),get_y_local(),get_z_local(),get_stdx_local(),get_stdy_local(),get_stdz_local());
  printf("\nforwart intersection control: ((       0.40655,       0.50524,      -3.78090))\n");


  printf("\nbore side calc   :  x: %lf ,y: %lf z: %lf  std(%lf,%lf,%lf)",get_x_global(),get_y_global(),get_z_global(),get_stdx_global(),get_stdy_global(),get_stdz_global());
  printf("\nbore side control: (641748.32241, 5638451.20961,     299.20626)");
  printf("\ntestfield control: (641748.32088, 5638451.20780,     299.20560)\n");

  //save the values for the next example
  m_x_global = get_x_global();//Easting
  m_y_global = get_y_global();//Northing
  m_z_global = get_z_global();//ell. Height


  //delete all values (depends of the internal List of bpoints)
  del_all();




//##################################

  printf("\n#########################################\n");
  printf("calc back from a global point to left cam :\n");


  addCam2(cam_left);
  addGlobalMeasurementPoint(m_x_global,m_y_global,m_z_global);

  addGlobalCarReferencePoint(641754.64076,5638452.77658,296.79691,-0.2235410,-0.6600010,214.0967730,50.8803408,11.0150776);
  setGlobalReferenceFrame();//todo in process -> for EPS data

  calculate();

  //showVariablesAndInfos();

  printf("\n");
  printf("\npicture point cam left calc   :  m: %lf , n: %lf ",get_m(),get_n());
  printf("\npicture point cam left control: ( 756.000 , 345.000 )\n");

  //delete all values (depends of the internal List of bpoints) is extreme important!!
  del_all();


//##################################

  printf("\n############################################\n");
  printf("calc back from a global point to right cam :\n");


  addCam2(cam_right);
  addGlobalMeasurementPoint(m_x_global,m_y_global,m_z_global);

  addGlobalCarReferencePoint(641754.64076,5638452.77658,296.79691,-0.2235410,-0.6600010,214.0967730,50.8803408,11.0150776);
  setGlobalReferenceFrame();//todo in process -> for EPS data

  calculate();

  //showVariablesAndInfos();

  printf("\n");
  printf("\npicture point cam left calc   :  m: %lf , n: %lf ",get_m(),get_n());
  printf("\npicture point cam left control: ( 401.000,370.000 )\n");

  //delete all values (depends of the internal List of bpoints) is extreme important!!
  del_all();

//##################################

		printf("\n############################################\n");
		printf("Epipolargeomerie:\n");

		//double d_begin = 3.0;
		//double d_end   =30.0;
		//double d_step  = 0.5;
		//double d_i = d_begin;

		addCam2(cam_left);
		addBPoint(756.0,345.0);
		addGlobalCarReferencePoint_CamSetGlobal(641754.64076,5638452.77658,296.79691,-0.2235410,-0.6600010,214.0967730,50.8803408,11.0150776);

		addCam2(cam_right);
		addGlobalCarReferencePoint_CamSetGlobal(641754.64076,5638452.77658,296.79691,-0.2235410,-0.6600010,214.0967730,50.8803408,11.0150776);

		printf("\n");
		//double m_begin,n_begin,m_end,n_end;

		while( d_i <= d_end )
		{
		 setDistanceForEpipolarLine(d_i);
		 calculate();

		 if(d_i==d_begin)
		 {
		     m_begin=get_m();
		     n_begin=get_n();
		 }
		 if(d_i==d_end)
		 {
             m_end=get_m();
             n_end=get_n();
		 }

		 printf("\none point in %lf m distance on the epipolar line:   m: %lf , n: %lf ",d_i,get_m(),get_n());

		 d_i+=d_step;
		}



		printf("\ndistance of %lf m in pixel of the epipolar line:  dm: %lf , dn: %lf ",d_i,(m_begin-m_end),(n_begin-n_end));

		//delete all values (depends of the internal List of bpoints)
		del_all();


  //##################################

  printf("\n############################################\n");
  printf("Mono Photogrammetrie only for testing!!!:\n");

  //E ground car: ( n:  (      -0.00278,       0.02638,      -0.99965) , p:       0.20855) (test ground plane from UNO (TUD))

  addCam2(cam_left);
  addBPoint(756.000,345.000);
  addRefGroundSurface(0.0,0.0,1.0,2.44); //plane only for Point 126 picture 13!!

  addGlobalCarReferencePoint(641754.64076,5638452.77658,296.79691,-0.2235410,-0.6600010,214.0967730,50.8803408,11.0150776);
  setGlobalReferenceFrame();//todo in process -> for EPS data

  //showVariablesAndInfos();

  //calculate of the forward intersection
  calculate();


  printf("\nmono measurenment calc   :  x: %lf ,y: %lf z: %lf  std(%lf,%lf,%lf)",get_x_local(),get_y_local(),get_z_local(),get_stdx_local(),get_stdy_local(),get_stdz_local());
  printf("\nmono measurenment control: (not available -> this function only for testing)\n");
  printf("\nmono measurenment control: ( 0.410760 , 0.509896 , -3.820846 )\n");

  printf("\nbore side calc   :  x: %lf ,y: %lf z: %lf  std(%lf,%lf,%lf)",get_x_global(),get_y_global(),get_z_global(),get_stdx_global(),get_stdy_global(),get_stdz_global());
  printf("\nbore side control: (not available -> this function only for testing)");
  printf("\nbore side control: (641748.283425 , 5638451.200895 , 299.200014)");

  //delete all values (depends of the internal List of bpoints)
  del_all();

//##################################

		printf("\n############################################\n");
		printf("multi car position photogrammetrie:\n");

		setGlobalReferenceFrame();//todo in process -> for EPS data

		//picture 13
		addCam2(cam_left);
		addBPoint(756.000,345.000);
		addGlobalCarReferencePoint_CamSetGlobal(641754.64076,5638452.77658,296.79691,-0.2235410,-0.6600010,214.0967730,50.8803408,11.0150776);

		//picture 13
		addCam2(cam_right);
		addBPoint(401.000,370.000);
		addGlobalCarReferencePoint_CamSetGlobal(641754.64076,5638452.77658,296.79691,-0.2235410,-0.6600010,214.0967730,50.8803408,11.0150776);

		//picture 12
		addCam2(cam_left);
		addBPoint( 715.0 , 325.0 );
		addGlobalCarReferencePoint_CamSetGlobal(641754.9447785,5638453.2901614,296.8227930,0.0109420,-0.9424530,212.0283640,50.8803453,11.0150821);

		//picture 12
		addCam2(cam_right);
		addBPoint( 395.0, 360.0 );
		addGlobalCarReferencePoint_CamSetGlobal(641754.9447785,5638453.2901614,296.8227930,0.0109420,-0.9424530,212.0283640,50.8803453,11.0150821);

		//picture 10
		addCam2(cam_left);
		addBPoint( 985.0 , 369.0);
		addGlobalCarReferencePoint_CamSetGlobal(641753.5016304,5638454.2034647,296.7935520,-0.1139750,-0.5450980,190.7414720,50.8803539,11.0150620);

		//picture 10
		addCam2(cam_right);
		addBPoint( 506.0 , 381.0 );
		addGlobalCarReferencePoint_CamSetGlobal(641753.5016304,5638454.2034647,296.7935520,-0.1139750,-0.5450980,190.7414720,50.8803539,11.0150620);

		//picture 1
		addCam2(cam_left);
		addBPoint( 65.0 , 305.0);
		//1001;50.8803713;11.0150901;296.8429180;-0.2612280;-1.5055340;219.9422050;15:47:18;1;641755.4308509;5638456.1936776
		addGlobalCarReferencePoint_CamSetGlobal(641755.4308509,5638456.1936776,296.8429180,-0.2612280,-1.5055340,219.9422050,50.8803713,11.0150901);


		//calculate of the forward intersection
		calculate();

		//showVariablesAndInfos();

		printf("\n");
		printf("\nforwart intersection calc   :  x: %lf ,y: %lf z: %lf  std(%lf,%lf,%lf)",get_x_local(),get_y_local(),get_z_local(),get_stdx_local(),get_stdy_local(),get_stdz_local());
		printf("\nforwart intersection control: (641748.309525 , 5638451.210544 , 299.207956  std(0.023276,0.012765,0.006509))\n");


		printf("\nbore side calc   :  x: %lf ,y: %lf z: %lf  std(%lf,%lf,%lf)",get_x_global(),get_y_global(),get_z_global(),get_stdx_global(),get_stdy_global(),get_stdz_global());
		printf("\nbore side control: (641748.309525 , 5638451.210544 , 299.207956)");
		printf("\ntestfield control: (641748.32088  , 5638451.20780  , 299.20560)\n");


		//delete all values (depends of the internal List of bpoints)
		del_all();



//##################################

        printf("\n############################################\n");
        printf("foot print:\n");

        setGlobalReferenceFrame();//todo in process -> for EPS data

        //picture 13
        addCam2(cam_left);
        addGlobalCarReferencePoint_CamSetGlobal(641754.64076,5638452.77658,296.79691,-0.2235410,-0.6600010,214.0967730,50.8803408,11.0150776);
        addRefGroundSurface(0.0,0.0,1.0,0.30); //test plane
        setDistanceForEpipolarLine(20.0); //max 20m in front of the picture

        //calculate of the forward intersection
        calculate();

        printf("\n Point left  up [x,y,z] : [%lf,%lf,%lf] ",get_FP_Easting(0),get_FP_Northing(0),get_FP_eHeight(0));
        printf("\n Point right up [x,y,z] : [%lf,%lf,%lf] ",get_FP_Easting(1),get_FP_Northing(1),get_FP_eHeight(1));
        printf("\n Point left  dw [x,y,z] : [%lf,%lf,%lf] ",get_FP_Easting(2),get_FP_Northing(2),get_FP_eHeight(2));
        printf("\n Point right dw [x,y,z] : [%lf,%lf,%lf] ",get_FP_Easting(3),get_FP_Northing(3),get_FP_eHeight(3));


        //delete all values (depends of the internal List of bpoints)
        del_all();

printf("\n\nend\n");

#if defined(_MSC_VER)
  getchar();
#endif

  return EXIT_SUCCESS;
}
示例#18
0
文件: RAM.cpp 项目: alu4102/DAA_P01
istream& RAM::readFile(istream& file)
{
	vector<string> vTag;
	I_.clear();
	set_n(2);									// En esta opción sólo se almacena el opcode y su operando

	string line, tag, comm, instruc, oper;		// Cada línea, etiqueta, comentario, opcode, operando/etiqueta
	size_t indexC, indexT;						// Índice de Comentario, Etiqueta y Et Fin
	int nLine = 1;								// Nº de líneas con código sin comentario. Útil para saber donde van las etiquetas

	while (getline(file, line)) {
		// ****** ETIQUETA
		indexT = line.find(":");				// Índice que guarda el lugar donde termina la etiqueta
		if (indexT < 1000) {					// Si existe etiqueta (el índice no puede ser el npos).
			tag = line.substr(0, indexT);		// Substring que contiene desde el inicio hasta el :, almacena el nombre de la etiqueta
			tag = Trim(tag.begin(), tag.end());	// Eliminamos los espacios en blanco
			vTag.push_back(to_string(nLine));	// Se añade a un vector el nº de línea donde aparece
			vTag.push_back(tag);				// Se añade el nombre de la etiqueta
			indexT++;							// Se añade uno al índice de la etiqueta para no coger el caracter : en las instrucciones
		}
		else {
			indexT = 0;							// Sino se encuentra etiqueta coloco el índice en 0, para iniciar desde ahí la búsqueda de la instrucción
			tag = "";							// Si me hiciera almacenar más adelante el nombre de la etiqueta, saber que aquí no tenía
		}
		// ****** COMENTARIO
		indexC = line.find(";");				// Almacena el índice donde empieza el comentario
		if (indexC < 1000) {					// Si existe comentario su índice es distinto del npos (un nº muy grande)
			comm = line.substr(indexC + 1);		// Almacena el comentario, es un substring desde ; hasta el final (se le añade +1 para eliminar ;
		}
		else {
			indexC = line.size();				// Sino se encuentra comentario es hasta el final de la línea la instrucción
			comm = "";							// Sino existe comentario es ""
		}
		// ****** INSTRUCCIONES = OPCODE + OPERANDO/ETIQUETA/NADA
		if (indexT != indexC) {										// Cuando existe código 
			instruc = line.substr(indexT, indexC - indexT);			// Substring que contiene la instrucción y el operando/tag juntos
			instruc.append(" ");									// Añado un espacio al final para no exista fallo con el último comando
			instruc = TrimFirst(instruc.begin(), instruc.end());	// Captura la primera palabra
			instruc = codOpcode(instruc);							// Codifico el opcode
			if (instruc != "12") {									// 12 = HALT, entra salvo que sea 12, que no tiene ni tag ni operando
				oper = line.substr(indexT, indexC - indexT);		// Substring que contiene la instrucción y el operando/tag juntos
				//oper.append(" ");									
				oper = TrimSecond(oper.begin(), oper.end());		// Se toma la segunda palabra que corresponde con el operando/etiqueta
			}
			else
				oper = "";											// Halt no tiene nada
			I_.push_back(instruc);									// Se añade el opcode a la estructura
			I_.push_back(oper);										// Se añade el operando/etiqueta a la estructura
			nLine++;												// Se incrementa el nº de líneas con código, para identificar la etiqueta
		}
	}

	set_m(nLine - 1);												// Al querer sólo contar las líneas con código, y estar el tag primero que instrucc
																	// se me hace necesario incrementarlo dentro de éste, por lo que, al final me sobra uno

	for (int i = 0; i < vTag.size() / 2; i++) {						// Se recorre el vector que almacena las etiquetas y su posición
		for (int j = 0; j < get_m(); j++) {							// Se recorre el vector que almacena el opcode y su operando/etiqueta
			if (vTag[2 * i + 1] == get_item(j, 1))					// Si coincide el nombre de la etiqueta con el etiqueta del opcode
				set_item(j, 1, vTag[2 * i]);						// Se cambia por el nº de línea
		}
	}

	return file;
}
示例#19
0
void
QtUtil :: Grid3DView :: draw_cursor (QPainter & p, int, int)
const
{
	int c_i = get_i (m_cursor) - get_i (m_position);
	int c_k = get_k (m_cursor) - get_k (m_position);

	if (get_m (m_cursor) > get_m (m_position))
		p .setPen (CURSOR_ABOVE);
	else if (get_m (m_cursor) < get_m (m_position))
		p .setPen (CURSOR_BELOW);
	else
		p .setPen (CURSOR_LEVEL);

	auto arrow = [&] (int x, int y, int dir)
	{
		p .save ();

		p .translate (m_width + x + 0.5, m_width + y + 0.5);
		
		p .rotate (dir * 360 / 8);

		p .scale (0.15, 0.15);

		p .drawLine (0,  0, 3, 0);
		p .drawLine (2,  1, 3, 0);
		p .drawLine (2, -1, 3, 0);

		p .restore ();
	};

	const int W = m_width;

	if (c_i < -W)
	{
		if (c_k < -W)
			arrow (-W, -W, 5);
		else if (c_k > W)
			arrow (-W, W, 3);
		else
			arrow (-W, c_k, 4);
	}
	else if (c_i > W)
	{
		if (c_k < -W)
			arrow (W, -W, 7);
		else if (c_k > W)
			arrow (W, W, 1);
		else
			arrow (W, c_k, 0);
	}
	else if (c_k < -W)
	{
		assert (-W <= c_i && c_i <= W);

		arrow (c_i, -W, 6);
	}
	else if (c_k > W)
	{
		assert (-W <= c_i && c_i <= W);

		arrow (c_i, W, 2);
	}
	else
	{
		assert (-W <= c_i && c_i <= W);
		assert (-W <= c_k && c_k <= W);

		p .drawRect (c_i + W, c_k + W, 1, 1);

		const int di = m_drag_info .di;
		const int dk = m_drag_info .dk;

		if (m_drag_info .dragging && (di || dk))
		{
			int angle = 0;

			if (dk == 0)
			{
				angle = (di > 0) ? 0 : 4;
			}
			else
			{
				if (di > 0)
					angle = 1;
				else if (0 == di)
					angle = 2;
				else
					angle = 3;

				if (dk < 0)
					angle = -angle;
			}

			arrow (c_i + di, c_k + dk, angle);
		}
	}
}
示例#20
0
文件: RAM.cpp 项目: alu4102/DAA_P01
void RAM::printCod() {
	cout << "\t OPCODE \t OPERANDO/ETIQUETA \n";
	cout << "       *******************************\n";
	for (int i = 0; i < get_m(); i++) 
		cout << "L" << i + 1 << "\t  " << get_item(i, 0) << "\t\t" << get_item(i, 1) << "\n";
}