void lsFunction(int fd, char * dirName){ printf("LS -> LOG Header %s \n", dirName); static char buffer[BUFSIZE + 1]; sprintf(buffer, "%s", listFilesDir(dirName)); write(fd,buffer,BUFSIZE); }
void mgetFunction(int fd, char *dirName) { FILE *fp; char path[255]; static char buffer[BUFSIZE + 1]; printf("MGET COUNT -> LOG Header %s \n", dirName); sprintf(buffer, "%s", listFilesDir(dirName)); write(fd,buffer,BUFSIZE); }
int main(int argc, char *argv[]) { //Check for minimum number of required arguments if(argc < 2) { std::cerr << "Usage: Executable Input-File Optional-Command" << std::endl; return -1; } //If command argument is given, set it std::string argCommand; if(argc == 3) { argCommand = argv[2]; } int counter = 0; std::vector<vtkSmartPointer<vtkPolyData> > polyVect; float scale[3]; std::vector<std::string> fileNames; std::vector<std::string> plyFiles; std::string fileName; std::string colorFile; std::string outputFile; std::string fileExt; std::string plyFile; //Open parameters file ifstream segParam(argv[1]); if(!segParam) { std::cerr << "Error opening segmentation parameter file" << std::endl; return -1; } //Read in image scale segParam >> scale[0] >> scale[1] >> scale[2]; //Read in label image file name segParam >> fileName; segParam.close(); //Check the image file extension if(fileName != " " && fileName != "") { //Get file extension and output file base (file name without extension) fileExt = getFileExt(fileName); outputFile = getOrigFileName(fileName); //If tif, process if(fileExt == "tif" || fileExt == "tiff" || fileExt == "TIF" || fileExt == "TIFF") { //If running from cache if(argCommand == "-c") { std::cout << "Running from cache..." << std::endl; std::vector<std::string> *dirFiles = listFilesDir("cache"); if(dirFiles->size() <= 2) { std::cout << "Cache doesn't exist/nothing in cache" << std::endl; return -1; } std::string cacheFileExt; //Iterate through vector of strings containing file names in the cache directory for(std::vector<std::string>::iterator it = dirFiles->begin(); it != dirFiles->end(); ++it) { //If the proper file name base is found if((*it).find(outputFile) == 0) { //Get cache file extension cacheFileExt = getFileExt((*it)); //If the file is a poly data file if (cacheFileExt == "ply") { //Add it to the poly data file list std::string output = "cache/"; counter++; output.append((*it)); plyFiles.push_back(output); } } } //Render poly data if(counter == 0) { std::cout << "No cached files for this image" << std::endl; return -1; } renderPolyData(counter, scale, plyFiles); } else { //Make a cache directory if one isn't already there MKDIR("cache"); //Append ouput string to original file name for colored images outputFile.append("_out.tif"); //Create relative address string for the colored images to be cached std::string output = "cache/"; output.append(outputFile); std::cout << "here" << std::endl; //Run graph coloring on the original image, to divide it into colored images ftk::NuclearSegmentation *segmentation = new ftk::NuclearSegmentation(); std::vector<std::string> colorFiles = segmentation->RunGraphColoring(fileName, output); //Set counter variable to number of outputted color images counter = (int)colorFiles.size(); //Cycle through the colored images for(int i = 0; i < counter; i++) { //Create string for .ply file name colorFile = colorFiles[i]; plyFile = colorFiles[i].append(".ply"); //Add this .ply file to the vector of poly data files to be rendered later plyFiles.push_back(plyFile); //If this .ply file doesn't already exist, generate the poly data and write the //.ply file from the colored image files generatePolyData(colorFile, plyFiles[i], polyVect); } delete segmentation; renderPolyData(counter, scale, plyFiles); //renderPolyData(counter, scale, polyVect, plyFiles); } } //If file not of the proper type, print error else { std::cerr << "Invalid file type for segmentation output" << std::endl; return -1; } } //If parameter file can't be opened, print error else { std::cerr << "Invalid filename in parameters, load valid parameter file" << std::endl; return -1; } return 0; }