예제 #1
0
Highscore::Highscore(GameType type) : type_(type), blink_(nullptr) {
	if(type == NORMAL)
	{
		filename_ = getPaths().getConfig() + "normal.txt";
	}
	else if(type == FIFTYLINES)
	{
		filename_ = (getPaths().getConfig() + "fiftylines.txt");
	}
	else
	{
		throw std::runtime_error("Unknown GameType");
	}
	std::ifstream fin(filename_);
	if(fin)
	{
		for(int i = 0; i < 5; ++i)
		{
			Data temp;
			std::getline(fin, temp.name);
			fin >> (temp.score) >> (temp.time);
			highscores_.push_back(temp);
			fin.ignore(3, '\n'); // Read till next \n
		}
	}
	else
	{
		for(int i = 0; i < 5; ++i)
예제 #2
0
파일: 257.cpp 프로젝트: nurnoch/leetcode
    void getPaths(TreeNode* root, vector<string>& result, string str) {
        if(root->left == NULL && root->right == NULL) {
            result.push_back(str);
            return;
        }

        if(root->left)
            getPaths(root->left, result, str + "->" + to_string(root->left->val));
        if(root->right)
            getPaths(root->right, result, str + "->" + to_string(root->right->val));
    }
예제 #3
0
Chooser::Chooser(int x, int y)
	: previous_(""),
	  next_(""), sprite_("chooser"), x_(x), y_(y)
{
	previous_.Connect(boost::bind(&Chooser::Previous, this));
	previous_.SetSprites("chooser_left", "chooser_left_over", "chooser_left_over");
	previous_.CenterAt(x - jngl::getWidth(getPaths().getGraphics() + sprite_) / 2 - previous_.GetWidth() / 2, y);
	next_.Connect(boost::bind(&Chooser::Next, this));
	next_.SetSprites("chooser_right", "chooser_right_over", "chooser_right_over");
	next_.CenterAt(x + jngl::getWidth(getPaths().getGraphics() + sprite_) / 2 + next_.GetWidth() / 2, y);
}
예제 #4
0
    void getPaths(TreeNode * root, vector<string> &ans, string path) {
        if (! root) return;

        path = (path == "") ? to_string(root->val) : (path + "->" + to_string(root->val));
        if (! root->left && ! root->right) {
            ans.push_back(path);
            return;
        }
        if (root->left) getPaths(root->left, ans, path);
        if (root->right) getPaths(root->right, ans, path);
    }
 void getPaths(TreeNode* root, vector<int> path, vector<string> &ret) {
     path.push_back(root->val);
     if (root->left == NULL && root->right == NULL) {
         // new path
         ret.push_back(formatPath(path));
     } else {
         if (root->left) {
             getPaths(root->left, path, ret);
         }
         if (root->right) {
             getPaths(root->right, path, ret);
         }
     }
 }
 void getPaths(TreeNode* root, vector<string>& res, string path){
     if (root == NULL) {
         return ;
     }
     else{
         string tmp = path + "->" + std::to_string(root->val);
         if(root->left == NULL && root->right == NULL){
             res.push_back(tmp);
         }
         else {
             getPaths(root->left, res, tmp);
             getPaths(root->right, res, tmp);
         }
     }
 }
    vector<string> binaryTreePaths(TreeNode* root) {
        vector<string> res;
        if (root == NULL) {
            return res;
        }
        string path = std::to_string(root->val);
        if (root->left || root->right) {
            getPaths(root->left, res, path);
            getPaths(root->right, res, path);
        }
        else{
            res.push_back(path);
        }

        return res;
    }
예제 #8
0
bool TypeLoader::findCSL( const std::string& typeName, std::string& fullPath, std::string& relativePath )
{
	std::string names[2];
	int n = 0;

	// if the current namespace is not the root, first try a relative path
	if( _namespace && _namespace->getParentNamespace() )
	{
		const std::string& fullNS = _namespace->getFullName();
		names[n].reserve( fullNS.size() + typeName.size() + 5 );
		names[n] = fullNS;
		names[n].push_back( '.' );
		names[n].append( typeName );
		OS::convertDotsToDirSeps( names[n] );
		names[n].append( ".csl" );
		++n;
	}

	names[n].reserve( typeName.size() + 4 );
	names[n] = typeName;
	OS::convertDotsToDirSeps( names[n] );
	names[n].append( ".csl" );
	++n;

	bool succeeded = OS::searchFile2( getPaths(), Slice<std::string>( names, n ),
										fullPath, NULL, &relativePath );
	if( !succeeded )
		CORAL_THROW( co::Exception, "type '" << typeName << "' was not found in the path" );

	return succeeded;
}
예제 #9
0
/* Get the absolute path of a file. Searches first in PATH.
 * If not found in PATH, will check if fileName is already 
 * an absolute OR relative path.
 * Accepts absolute paths with '~' representing HOME
 * @param: string of the name or path of a file
 * @return: string of absolute path of the file if found. NULL otherwise.
 */
char* getFilePath(char* fileName){
   char** paths = getPaths();
   char* filePath = NULL;
   int i = 0;
   filePath = malloc(PATH_MAX*sizeof(char));

   while( paths[i] != NULL){
       strcpy(filePath, paths[i]);
       strcat(filePath, "/");
       strcat(filePath, fileName);

       if(doesFileExist(filePath)){
	   return filePath;
	}
 
 	i++;
   }
   
   //File was not found in PATH
   strcpy(filePath, fileName);
   filePath = tildaToHome(filePath);
   filePath = realpath(filePath, NULL);

   if( filePath != NULL ){
       return filePath;
   }

	return NULL;
}
예제 #10
0
int executeWhere(Cmd c){
	int i =0;
	char *path = getenv("PATH");
	int noOfPaths=0;
	char **paths = getPaths(path,&noOfPaths);
	int count =0;
	struct stat    statbuf;
	char *tmpChar;

	printWhereBuiltIns(c->args[1]);
	while(i<noOfPaths){
		count =strlen(paths[i])+strlen(c->args[1])+2;
		tmpChar = paths[i];
		paths[i]=malloc(count*sizeof(char));
		strcat(paths[i],tmpChar);
		strcat(paths[i],"/");
		strcat(paths[i],c->args[1]);
		if(paths[i],stat(paths[i],&statbuf)==0){
	//		if(statbuf.st_mode & 0111){
				printf("%s\n",paths[i]);
	//		}
		}
		i++;
	}
	return 0;
}
예제 #11
0
/*
* Изтрива всички директории в параметрите.
* Root директорият не може да се изтрие.
*/
void CommandPrompt::deleteDirectory(string parameters){
	/*
	* Извличаме адресите от параметрите.
	*/
	queue<string> dirPaths = getPaths(parameters);

	/*
	* Намираме директория по дадения път и викаме deleteFile().
	* Ако е NULL извеждаме грешка. 
	* Ако текущата директория се съдържа в директорията която трием, я применяме на root.
	* Root директорията не може да се изтрие.
	*/
	Directory* dir;
	while (!dirPaths.empty()) {
		dir = this->determinePathAndGetDir(dirPaths.front());
		if (dir != NULL) {
			if(currentDir->getFSysPath().find(dir->getFSysPath()) != string::npos){
				currentDir = fs.getRoot();
				cout << "Current directory now root!" << endl;
			}
			if (dir == fs.getRoot())
				cerr << "Cannot delete root directory!" << endl;
			else
				dir->deleteFile();
		}
		else
			cerr << "Directory not found!" << endl;
		dirPaths.pop();
	}
}
예제 #12
0
bool CBC::download(QString filename)
{
    if(!compile(filename))
        return false;
    
    qWarning("Calling gcc...");
    m_gcc.reset();
    
    m_gcc.start(m_gccPath, QStringList() << "-E" << "-Wp,-MM" << filename);
    m_gcc.waitForFinished();
    
    qWarning("Gcc finished...");
    
    QString depString = QString::fromLocal8Bit(m_gcc.readAllStandardOutput());
    
    QStringList deps = getPaths(depString);
    
    deps.removeFirst();
    qWarning("deps.size()=%d", deps.size());
    
    qWarning("deps=\"%s\"", qPrintable(deps.join(",")));
    
    qWarning("Calling sendFile");
    
    if(!QSerialPort(m_defaultPort).open(QIODevice::ReadWrite)) {
        emit requestPort();
        if(!QSerialPort(m_defaultPort).open(QIODevice::ReadWrite))
            return false;
    }
    
    m_serial.setPort(m_defaultPort);
    return m_serial.sendFile(filename, deps);
}
예제 #13
0
파일: 257.cpp 프로젝트: nurnoch/leetcode
 vector<string> binaryTreePaths(TreeNode* root) {
     vector<string> result;
     if(root == NULL)
         return result;
     getPaths(root, result, to_string(root->val));
     return result;
 }
예제 #14
0
    vector<vector<string>> findLadders(string beginWord, string endWord, vector<string>& wordList) {
        unordered_set<string> dict(wordList.begin(), wordList.end());//list to set for quick membership check     
        if (!dict.count(endWord)) return {};//problem statement

        dict.erase(beginWord); //why?
        dict.erase(endWord); //why??
        
        //steps store word -> steps from beginWord
        unordered_map<string, int> steps{{beginWord, 1}}; //double }}
        unordered_map<string, vector<string>> parents;
        queue<string> q{{beginWord}};
        //q.push(beginWord);
        
        int step = 0;        
        bool found = false;
        //found endWord at shortest level/step
        while (!q.empty() && !found) {
            ++step;
            //remove all elements from queue at this step/level
            for (int size = q.size(); size > 0; size--) {
                const string p = q.front(); q.pop();
                string w = p; //copy p to w, w to change, p will be parent
                for (int i = 0; i < w.size(); i++) { //for each letter position
                    const char ch = w[i];
                    for (char j = 'a'; j <= 'z'; j++) {
                        if (j == ch) continue;
                        w[i] = j;
                        //new word w is one letter diff
                        if (w == endWord) {
                            parents[w].push_back(p);
                            found = true;
                        } else {
                            // new word w != eneWord, but another transform
                            // with the same number of steps
                            //if (steps.count(w) && step < steps.at(w))
                            //why this? 
                            if (steps.count(w) && step < steps[w])
                                parents[w].push_back(p);
                        }
                        
                        if (dict.count(w) == 0) continue; // can not go to w 
                        dict.erase(w); //to visit w, won't visit it again
                        q.push(w);
                        steps[w] = steps[p] + 1;
                        parents[w].push_back(p);
                    }
                    w[i] = ch; //restore w
                }
            }
        }
        
        vector<vector<string>> res;
        if (found) {
            vector<string> curr{endWord};
            getPaths(endWord, beginWord, parents, curr, res);
        }
        return res;
    }
예제 #15
0
bool findFile( const std::string& moduleName, const std::string& fileName, std::string& filePath )
{
	std::string modulePath( moduleName );
	OS::convertDotsToDirSeps( modulePath );
	return OS::searchFile3( getPaths(),
				Range<const std::string>( &modulePath, 1 ),
				Range<const std::string>( &fileName, 1 ),
				filePath );
}
 vector<string> binaryTreePaths(TreeNode* root) {
     vector<string> ret;
     if (root == NULL)
         return ret;
     
     vector<int> path;
     getPaths(root, path, ret);
     return ret;
 }
예제 #17
0
/*
* Създава всички директории подадени в параметрите. 
*/
void CommandPrompt::makeDirectory(string parameters){
	/*
	* Извличаме адресите и извикваме createNestedDirectories за всеки.
	*/
	queue<string> filePaths = getPaths(parameters);
	while (!filePaths.empty()) {
		createNestedDirectories(filePaths.front());
		filePaths.pop();
	}
}
예제 #18
0
CWiiSaveCrypted::CWiiSaveCrypted(const char* FileName, u64 TitleID)
 : m_TitleID(TitleID)
{
	Common::ReadReplacements(replacements);
	strcpy(pathData_bin, FileName);
	memcpy(SD_IV, "\x21\x67\x12\xE6\xAA\x1F\x68\x9F\x95\xC5\xA2\x23\x24\xDC\x6A\x98", 0x10);

	if (!TitleID) // Import
	{
		AES_set_decrypt_key(SDKey, 128, &m_AES_KEY);
		do
		{
			b_valid = true;
			ReadHDR();
			ReadBKHDR();
			ImportWiiSaveFiles();
			// TODO: check_sig()
			if (b_valid)
			{
				SuccessAlertT("Successfully imported save files");
				b_tryAgain = false;
			}
			else
			{
				b_tryAgain = AskYesNoT("Import failed, try again?");
			}
		} while(b_tryAgain);
	}
	else
	{
		AES_set_encrypt_key(SDKey, 128, &m_AES_KEY);
		
		if (getPaths(true))
		{
			do
			{
				b_valid = true;
				WriteHDR();
				WriteBKHDR();
				ExportWiiSaveFiles();
				do_sig();
				if (b_valid)
				{
					SuccessAlertT("Successfully exported file to %s", pathData_bin);
					b_tryAgain = false;
				}
				else
				{
					b_tryAgain = AskYesNoT("Export failed, try again?");
				}
			} while(b_tryAgain);
		}
	}
}
예제 #19
0
void CWiiSaveCrypted::ReadHDR()
{
	File::IOFile fpData_bin(encryptedSavePath, "rb");
	if (!fpData_bin)
	{
		PanicAlertT("Cannot open %s", encryptedSavePath.c_str());
		b_valid = false;
		return;
	}
	if (!fpData_bin.ReadBytes(&_encryptedHeader, HEADER_SZ))
	{
		PanicAlertT("Failed to read header");
		b_valid = false;
		return;
	}
	fpData_bin.Close();

	aes_crypt_cbc(&m_AES_ctx, AES_DECRYPT, HEADER_SZ, SD_IV, (const u8*)&_encryptedHeader, (u8*)&_header);
	u32 bannerSize = Common::swap32(_header.hdr.BannerSize);
	if ((bannerSize < FULL_BNR_MIN) || (bannerSize > FULL_BNR_MAX) ||
		(((bannerSize - BNR_SZ) % ICON_SZ) != 0))
	{
		PanicAlertT("Not a Wii save or read failure for file header size %x", bannerSize);
		b_valid = false;
		return;
	}
	m_TitleID = Common::swap64(_header.hdr.SaveGameTitle);


	u8 md5_file[16];
	u8 md5_calc[16];
	memcpy(md5_file, _header.hdr.Md5, 0x10);
	memcpy(_header.hdr.Md5, MD5_BLANKER, 0x10);
	md5((u8*)&_header, HEADER_SZ, md5_calc);
	if (memcmp(md5_file, md5_calc, 0x10))
	{
		PanicAlertT("MD5 mismatch\n %016" PRIx64 "%016" PRIx64 " != %016" PRIx64 "%016" PRIx64, Common::swap64(md5_file),Common::swap64(md5_file+8), Common::swap64(md5_calc), Common::swap64(md5_calc+8));
		b_valid= false;
	}

	if (!getPaths())
	{
		b_valid = false;
		return;
	}
	std::string BannerFilePath = WiiTitlePath + "banner.bin";
	if (!File::Exists(BannerFilePath) || AskYesNoT("%s already exists, overwrite?", BannerFilePath.c_str()))
	{
		INFO_LOG(CONSOLE, "Creating file %s", BannerFilePath.c_str());
		File::IOFile fpBanner_bin(BannerFilePath, "wb");
		fpBanner_bin.WriteBytes(_header.BNR, bannerSize);
	}
}
예제 #20
0
void Circuit::getPaths(gate* g)//gets all paths in the circuit and prints them
{
    Paths.push_back(g); // push this gate into the vector
    if (Paths.size() > 1) PathDelay+=Paths[Paths.size()-2]->getDelay(); //add delay of previous gate
    for(std::map<std::string, wire*>::iterator i = wireMap.begin(); i != wireMap.end(); i++)
        if (i->second->getWSource()->getName() == g->getName())
            for (int j = 0; j < i->second->getWDestionations().size(); j++)
                getPaths(i->second->getWDestionations()[j]);
    if ((g->getIsFlip() && !g->getFlipIn()) || g->getType() == "output") //if the gate is an output flipflop or normal output
        printPaths(calcReqTime(g));
    Paths.pop_back();
    PathDelay-= g->getDelay();
}
예제 #21
0
파일: getopt.c 프로젝트: andy2m11/CS-0x19A
//---------------------------------------------------------------------
myftw(char *pathname, Myfunc *func)
{
 	fprintf(stderr, "Searching for %s in: %s\n",ar.sval, pathname);
	ar.pval = (char*)path_alloc(&pathlen);
	/* malloc PATH_MAX+1 bytes */
	if (pathlen <= strlen(pathname)) {
		pathlen = strlen(pathname) * 2;
		if ((ar.pval = realloc(ar.pval, pathlen)) == NULL)
			 fprintf(stderr, "%s\n", "Alloc failed");
	}
	strcpy(ar.pval, pathname);
	return(getPaths(func));
}
/*		START_OF_MAIN		*/
int main(int argc, char const *argv[]){
	/*degiskenler*/
	struct 	sigaction act;
	char 	sPath[PATH_MAX];
	FILE 	*fLogFilePtr;
	DIR 	*dRootDirPtr;
	int 	fd[2],
			iPipeFirstValue = 0,
			iResult = 0;
	
	/* signal handler olustur*/
	act.sa_handler = setdoneflag; 	
	act.sa_flags = 0;
	if ((sigemptyset(&act.sa_mask) == -1) || sigaction(SIGINT, &act, NULL) == -1) {
		err_sys("Failed to set CTRL-C handler\n");
	}
	mainpid=getpid();
	strcpy(sPath,argv[1]);

	if(argc!=3)
        usage("Please enter 3 command line arguments: <executable_file> <text_file> <target_word>");

    if(isDirectory(sPath)==false || strlen(argv[1])>PATH_MAX)
    	usage("Please enter a correct path.");
    if((dRootDirPtr = opendir(sPath)) == NULL)
		usage("Can't open directory.");
	closedir(dRootDirPtr);
    /* log dosyasini ac */
	fLogFilePtr=fopen(LOG_FILE, "a");
	if(fLogFilePtr==NULL)
		err_sys("opendir");
	/*pipe olustur*/
	if(pipe(fd)==-1)
		err_sys("Failed to create the pipe.\n");
	/*pipe'a ilk deger olarak 0 yaz ve pipe'i kapat*/
	write(fd[1], &iPipeFirstValue, sizeof(int));

	/*recursive fonksiyonu cagir*/
   	getPaths(sPath, argv[2], fd, fLogFilePtr);
   	/*toplam kelime sayisini pipe'tan oku ve pipe'i kapat*/
	read(fd[0], &iResult, sizeof(int));
	close(fd[0]);
	close(fd[1]);
	/*prompt*/
	printf("\n'%s' iterates %d times in '%s'.\n", argv[2], iResult, sPath);
	/*dosyayi kapat*/
	fclose(fLogFilePtr);
	return 0;
}
예제 #23
0
 bool	CubeAnim::initFmod()
 {
   FMOD_System_Create(&system);
   FMOD_System_Init(system, 1, FMOD_INIT_NORMAL, NULL);
   getPaths(MUSIC_PATH);
   if (_paths.size() == 0)
     std::cout << "Error on loading" << std::endl;
   else
   {
     _itp = _paths.begin();
     if (loadSound(*_itp) == false)
       return (false);
   }
   return (true);
 }
예제 #24
0
Highscore::Highscore(GameType type) : type_(type), blink_(nullptr) {
	switch (type) {
		case GameType::NORMAL:
			filename_ = getPaths().getConfig() + "normal.txt";
			break;
		case GameType::FIFTYLINES:
			filename_ = getPaths().getConfig() + "fiftylines.txt";
			break;
	}
	std::ifstream fin(filename_);
	if(fin)
	{
		for(int i = 0; i < 5; ++i)
		{
			Data temp;
			std::getline(fin, temp.name);
			fin >> (temp.score) >> (temp.time);
			highscores_.push_back(temp);
			fin.ignore(3, '\n'); // Read till next \n
		}
	}
	else
	{
		for(int i = 0; i < 5; ++i)
예제 #25
0
CWiiSaveCrypted::CWiiSaveCrypted(const char* FileName, u64 TitleID)
 : m_TitleID(TitleID)
{
	Common::ReadReplacements(replacements);
	encryptedSavePath = std::string(FileName);
	memcpy(SD_IV, "\x21\x67\x12\xE6\xAA\x1F\x68\x9F\x95\xC5\xA2\x23\x24\xDC\x6A\x98", 0x10);

	if (!TitleID) // Import
	{
		aes_setkey_dec(&m_AES_ctx, SDKey, 128);
			b_valid = true;
			ReadHDR();
			ReadBKHDR();
			ImportWiiSaveFiles();
			// TODO: check_sig()
			if (b_valid)
			{
				SuccessAlertT("Successfully imported save files");
			}
			else
			{
				PanicAlertT("Import failed");
			}
	}
	else
	{
		aes_setkey_enc(&m_AES_ctx, SDKey, 128);

		if (getPaths(true))
		{
			b_valid = true;
			WriteHDR();
			WriteBKHDR();
			ExportWiiSaveFiles();
			do_sig();
			if (b_valid)
			{
				SuccessAlertT("Successfully exported file to %s", encryptedSavePath.c_str());
			}
			else
			{
				 PanicAlertT("Export failed");
			}
		}
	}
}
예제 #26
0
 //find paths from word to beginWord with parents
 //grow path curr
 void getPaths(const string& word, 
               const string& beginWord, 
               const unordered_map<string, vector<string>>& parents,
               vector<string>& curr,
               vector<vector<string>>& ans) {        
     
     if (word == beginWord) { //curr path reaches beginWord, curr: end -> beginWord
         //use curr to create new path, copy/clone, since curr will continue change
         ans.push_back(vector<string>(curr.rbegin(), curr.rend()));
         return;
     }
     
     for (const string& p : parents.at(word)) { //accepted
     //for (const string& p: parents[word]) { //error
         curr.push_back(p);// try each parent
         //recur with p, curr
         getPaths(p, beginWord, parents, curr, ans);
         curr.pop_back(); //backtracking
     }        
 }
예제 #27
0
   void RoadNavigation::planRoadDetection(const nav_msgs::Path::ConstPtr& lane_traj, const geometry_msgs::PoseWithCovarianceStamped::ConstPtr& pose) {
        nav_msgs::Path target_traj = decideTargetTrajectory(lane_traj);
        geometry_msgs::Pose current_pose = pose->pose.pose;

        std::vector<geometry_msgs::Pose> targets = getTargets(current_pose, target_traj);
        std::vector<std::vector<PathSegment*> > paths = getPaths(current_pose, targets);

        if (paths.size() == 0) {
            ROS_WARN("[local_planner]: No path found");
            return;
        }

//        nav_msgs::Path best_path;
//        for (int i = 0; i < paths.size(); i++) {
//            // TODO: Choose the best path
//            best_path = paths[0];
//        }
//
//        best_path.header.stamp = ros::Time::now();
//        return best_path;
    }
예제 #28
0
/*
* Извежда метаданните на всички файлове в параметрите.
*/
void CommandPrompt::getFileMetadata(string parameters){
	/*
	* Ако няма параметри извежда метаданните на текущата директория.
	*/
	if (parameters.empty()) {
		currentDir->printMeta();
		return;
	}

	/*
	* Извлича адресите от параметрите и за всеки намира директорията или файла 
	*/
	queue<string> dirPaths = getPaths(parameters);
	TextFile* file;
	while (!dirPaths.empty()) {
		file = this->determinePathAndGetFile(dirPaths.front());
		if (file != NULL)
			file->printMeta();
		dirPaths.pop();
	}
}
void BinaryPLYArchiLidarFileIO::loadData(LidarDataContainer& lidarContainer, std::string filename)
{
    getPaths(lidarContainer,filename);
    // BV: very subtle problem: windows endlines are counted double in ascii (\R\N), but not in binary (0a)
    // so under windows there will be a shift between ascii and binary positions
    // My solution: we get the data size from the lidarContainer and get the end header position from end of file based on it
    std::ifstream ply_ifs(m_data_path.c_str(), std::ios::binary);
    if(!ply_ifs.good()) throw std::logic_error(std::string(__FUNCTION__) + ": Failed to open " + m_data_path +"\n");
    ply_ifs.seekg(0, std::ios::end);
    const int dataSize = lidarContainer.size()*lidarContainer.pointSize();
    if(ply_ifs.tellg() < dataSize)
    {
        std::ostringstream oss;
        oss << "BinaryPLYArchiLidarFileIO::loadData: binary file size " << ply_ifs.tellg() << "< what xml expects: " << dataSize << std::endl;
        oss <<  "lidarContainer.size()=" << lidarContainer.size() << ", lidarContainer.pointSize()=" << lidarContainer.pointSize() << std:: endl;
        throw std::logic_error(oss.str());
    }
    ply_ifs.seekg(-dataSize, std::ios::end);
    //std::cout << "Binary part starts at " << fileInBin.tellg() << std::endl;
    // lidarContainer.allocate(lidarMetaData.nbPoints_); // BV: do we need that ? works well without
    ply_ifs.read(lidarContainer.rawData(), dataSize);
}
예제 #30
0
static void runClassifier(const std::string& outputFilename,
	const std::string& inputFileNames, const std::string& modelFileName,
	bool shouldClassify, bool shouldTrain, bool shouldLearnFeatures, bool shouldExtractFeatures)
{
	util::log("minerva-classifier") << "Loading classifier.\n";

	classifiers::ClassifierEngine* engine = nullptr;

	try
	{
		checkInputs(inputFileNames, modelFileName, shouldClassify,
			shouldTrain, shouldLearnFeatures, shouldExtractFeatures);
	
		engine = createEngine(outputFilename, shouldClassify, shouldTrain,
			shouldLearnFeatures, shouldExtractFeatures);
		
		if(engine == nullptr)
		{
			throw std::runtime_error("Failed to create classifier engine.");
		}

		engine->loadModel(modelFileName);

		engine->runOnPaths(getPaths(inputFileNames));
		
		engine->reportStatistics(std::cout);
	
		delete engine;
	}
	catch(const std::exception& e)
	{
		std::cout << "Minerva Classifier Failed:\n";
		std::cout << "Message: " << e.what() << "\n\n";
		
		delete engine;
	}
	
}