//-------------------------------------------------------------------------------------------------------- // // Private: ReadExperimentalData // //-------------------------------------------------------------------------------------------------------- Bool ReconstructionSetup::ReadExperimentalData( CSimulationData & oExpData, bool bServerMode ) { const vector< SIntRange > & vFileRangeList = oExpSetup.GetFileRangeList(); const vector< SRange > & vOmegaRangeList = oExpSetup.GetOmegaRangeList(); const vector< CDetector > & vDetectorList = oExpSetup.GetDetectorList(); RUNTIME_ASSERT( vFileRangeList.size() == vDetectorList.size() && vDetectorList.size() > 0, "ERROR: File range not specified for some detector(s) \n" ); // // TODO: This needs to be more robust // oExpData.Initialize( vOmegaRangeList.size(), vDetectorList.size(), vDetectorList[0].GetNumCols(), vDetectorList[0].GetNumRows() ); for ( Size_Type nDetector = 0; nDetector < vFileRangeList.size(); nDetector ++ ) { Size_Type nNumFile = vFileRangeList[ nDetector ].nHigh - vFileRangeList[ nDetector ].nLow + 1; RUNTIME_ASSERT( nNumFile == vOmegaRangeList.size(), "ERROR: Number of files does not match specified number of omega inteval\n"); // Using -- openmp -- TODO - limit number of threads? #pragma omp parallel for for ( Int nFileNum = vFileRangeList[nDetector].nLow; nFileNum <= vFileRangeList[nDetector].nHigh; nFileNum ++ ) { Int nCurrentFileIndex = nFileNum - vFileRangeList[nDetector].nLow; stringstream ssFilename; ssFilename << InputParameters().InFileBasename << InitFileIO::NumToSuffix( nFileNum, InputParameters().InFileSerialLength ) << "." << InputParameters().InFileExt << nDetector + oExpSetup.GetBCDetectorOffset(); Bool bSuccess = false; switch( InputParameters().InFileType ) { case eASCII: bSuccess= oExpData.mImageMap[ nCurrentFileIndex ][ nDetector ].ReadCXDMSimulationDataFile( ssFilename.str() ); break; case eBin: bSuccess= oExpData.mImageMap[ nCurrentFileIndex ][ nDetector ].ReadCXDMSimulationUFFFile( ssFilename.str(), bServerMode ); break; case eTif: RUNTIME_ASSERT( 0, "Error: Tif input format not yet supported\n" ); break; default: RUNTIME_ASSERT( 0, "Error: Input File Type Not Recognized" ); } DEBUG_ALERT( 0, ssFilename.str() + "\n" ); RUNTIME_ASSERT( bSuccess, "Error! Input data files cannot be read, please check file format and location\n" + ssFilename.str() ); } } return true; }
//--------------------------------------------------------- // // Public: // Read // // //--------------------------------------------------------- // MIC file format // // line 1: a0, the fundamental lattice constant for the triangular mesh // // others: // // columns 1 -3: xyz location of left vertex of a triangle // column 4: 1/2 for triangle type -- 1 for upward pointing or 2 for downward // pointing // column 5: generation number -- triangle side length = a0/(2^generation), // generation = 0,1,2,... // column 6: 0/1 for phase -- 0 mean it wasn't (or hasn't yet) fitted to an // orientation, 1 means it was // columns 7 -9: Eulers in degrees // column 10: confidence parameter: fraction of simulated Bragg peaks that hit // experimental peaks //--------------------------------------------------------- bool CMic::ReadEffient( const string &filename ) { vector< vector<string> > vsTokens; if( !ReadFileToBuf(filename)) { return false; } std::ifstream InputStream; if( !InputStream.open( filename ) ) return false; std::string Tokens = " \t\n"; // GeneralLib::Tokenize( vsTokens, string( pBuffer, nBufferSize ), " \t\n"); // we expect side length for the first line if(vsTokens[0].size() > 1){ cerr << "[CMic::ReadMicFile] Incorrect Mic File Format " << filename << endl; exit(0); } // fInitialSideLength = atof(vsTokens[0][0].c_str()); // for( Size_Type i = 1; i < vsTokens.size(); i ++){ while() { if(vsTokens[i].size() < 9 ) { cerr << "[CMic::ReadMicFile] Error: Incorrect number of columns, line: " << i << filename << endl; } else { DEBUG_ALERT( vsTokens[i].size() >= 10, "CMic::Read: Warning! Old format MIC file with only 9 columns\n" ); SVoxel v; v.nGeneration = atoi( vsTokens[i][4].c_str() ); v.fSideLength = fInitialSideLength / pow( 2, v.nGeneration ) ; v.nPhase = atoi( vsTokens[i][5].c_str() ); Float fX, fY, fZ; fX = atof( vsTokens[i][0].c_str() ); fY = atof( vsTokens[i][1].c_str() ); fZ = atof( vsTokens[i][2].c_str() ); if ( atoi( vsTokens[i][3].c_str() ) == UP ) { // Winding order, counter clockwise v.pVertex[0].Set( fX, fY, fZ ); v.pVertex[1].Set( fX + v.fSideLength, fY, fZ ); v.pVertex[2].Set( fX + v.fSideLength / (Float) 2.0 , fY + v.fSideLength / (Float) 2.0 * sqrt( (Float) 3.0 ) , fZ); v.bVoxelPointsUp = true; } else { // Winding order, counter clockwise v.pVertex[0].Set( fX, fY, fZ ); v.pVertex[1].Set( fX + v.fSideLength / (Float) 2.0 , fY - v.fSideLength / (Float) 2.0 * sqrt( (Float) 3.0 ) , fZ); v.pVertex[2].Set( fX + v.fSideLength, fY, fZ ); v.bVoxelPointsUp = false; } SVector3 oOrientation; oOrientation.Set( DEGREE_TO_RADIAN( atof(vsTokens[i][6].c_str()) ), DEGREE_TO_RADIAN( atof(vsTokens[i][7].c_str()) ), DEGREE_TO_RADIAN( atof(vsTokens[i][8].c_str()) ) ); // note that orientation matrix assigned here - the choice of active vs. passive // transform is made by the file format v.oOrientMatrix.BuildActiveEulerMatrix( oOrientation.m_fX, oOrientation.m_fY, oOrientation.m_fZ ); if( vsTokens[i].size() > 9 ) v.fConfidence = atof( vsTokens[i][9].c_str() ); else v.fConfidence = 0; if( vsTokens[i].size() == 19 ) // Defining our strain tensor to be ( I) { v.fCost = atof( vsTokens[i][10].c_str() ); v.fPixelOverlapRatio = atof( vsTokens[i][11].c_str() ); v.oDeformation.m[0][0] = atof( vsTokens[i][13].c_str() ); v.oDeformation.m[1][1] = atof( vsTokens[i][14].c_str() ); v.oDeformation.m[2][2] = atof( vsTokens[i][15].c_str() ); v.oDeformation.m[0][1] = v.oDeformation.m[1][0] = atof( vsTokens[i][16].c_str() ); v.oDeformation.m[1][2] = v.oDeformation.m[2][1] = atof( vsTokens[i][17].c_str() ); v.oDeformation.m[0][2] = v.oDeformation.m[2][0] = atof( vsTokens[i][18].c_str() ); } else { v.oDeformation.SetIdentity(); } oVoxelList.push_back(v); } } ClearBuffer(); // clear buffer after use return true; }