Example #1
0
void MCC::loadCylinder(ifstream &reader){

    int nCylinders;
    float * bufferF  =  new float [Ns*Ns*Nd];
    int auxI;
    float auxF;
    bool * bufferB1 = new bool[Ns*Ns*Nd];
    bool * bufferB2 = new bool[Ns*Ns*Nd];

//cylinders.clear();
        reader.read ((char *) (&nCylinders), sizeof (int));


	//cout << "Tenemos cilindros = " << nCylinders << endl;

		Cylinder cmVectorAUX;
	for(int i=0; i<nCylinders; ++i){

            //read index
            reader.read ((char *) (&auxI), sizeof (int));
            cmVectorAUX.setIndex(auxI);

            //read X Y T variables
            reader.read ((char *) (&auxI), sizeof (int));
            cmVectorAUX.setX(auxI);

            reader.read ((char *) (&auxI), sizeof (int));
            cmVectorAUX.setY(auxI);

            reader.read ((char *) (&auxF), sizeof (float));
            cmVectorAUX.setT(auxF);




	    if(bit){
	        reader.read ((char *) bufferB1, sizeof (bool)*Ns*Ns*Nd);
	        reader.read ((char *) bufferB2, sizeof (bool)*Ns*Ns*Nd);

		for(unsigned int j=0; j< Ns*Ns*Nd;++j){
			cmVectorAUX.setB1(j, bufferB1[j]);
			cmVectorAUX.setB2(j, bufferB2[j]);
		}

	    }else{

	        //bufferF
	        reader.read ((char *) bufferF, sizeof (float)*Ns*Ns*Nd);

		//cmVectorAUX.reserve(Ns*Ns*Nd);

		for(unsigned int j=0; j< Ns*Ns*Nd;++j){
		//	cout << bufferF[j] << "  ";
			cmVectorAUX.setCM(j, bufferF[j]);
			cmVectorAUX.setValidity(true);
		}


		//	delete [] bufferF;

	    }

		//cout << endl;
		cylinders.push_back(cmVectorAUX);
	}

		//cout << cylinders[22];
	//cout << "Fin lectura = " << (int)cylinders.size() << endl;


}
Example #2
0
void MCC::loadCylinder(string name){
    ifstream reader;
    int nCylinders;
    float * bufferF  =  new float [Ns*Ns*Nd];
    bool * bufferB1 = new bool[Ns*Ns*Nd];
    bool * bufferB2 = new bool[Ns*Ns*Nd];
    int auxI;
    float auxF;


	cerr << "Leyendo cilindro" << endl;

    reader.open(name.c_str(), fstream::binary);
    if (!reader.is_open())
    {
       cerr << "Error opening file" << endl;
       return;
    }



        reader.read ((char *) (&nCylinders), sizeof (int));


	//cout << "Tenemos cilindros = " << nCylinders << endl;

	Cylinder cmVectorAUX;
	for(int i=0; i<nCylinders; ++i){

            //read index
            reader.read ((char *) (&auxI), sizeof (int));
            cmVectorAUX.setIndex(auxI);

            //read X Y T variables
            reader.read ((char *) (&auxI), sizeof (int));
            cmVectorAUX.setX(auxI);

            reader.read ((char *) (&auxI), sizeof (int));
            cmVectorAUX.setY(auxI);

            reader.read ((char *) (&auxF), sizeof (float));
            cmVectorAUX.setT(auxF);



	    if(bit){
	        reader.read ((char *) bufferB1, sizeof (bool)*Ns*Ns*Nd);
	        reader.read ((char *) bufferB2, sizeof (bool)*Ns*Ns*Nd);

		for(unsigned int j=0; j< Ns*Ns*Nd;++j){
			cmVectorAUX.setB1(j, bufferB1[j]);
			cmVectorAUX.setB2(j, bufferB2[j]);
		}

	    }else{

	        //bufferF
	        reader.read ((char *) bufferF, sizeof (float)*Ns*Ns*Nd);

		//cmVectorAUX.reserve(Ns*Ns*Nd);

		for(unsigned int j=0; j< Ns*Ns*Nd;++j){
		//	cout << bufferF[j] << "  ";
			cmVectorAUX.setCM(j, bufferF[j]);
			cmVectorAUX.setValidity(true);
		}


		//	delete [] bufferF;

	    }

		//cout << endl;
		cylinders.push_back(cmVectorAUX);

	}  // endfor

		//cout << cylinders[22];
	cout << "Fin lectura = " << (int)cylinders.size() << endl;

    reader.close();
}