示例#1
0
QString Project::save_Cloud(QString name, pcl::PointCloud<pcl::PointXYZI>::Ptr c)
{
    QString path_out = QString ("%1\\%2.pcd").arg(get_Path()).arg(name);

    pcl::io::savePCDFileBinaryCompressed(path_out.toUtf8().constData(), *c);
    return path_out;
}
示例#2
0
void Project::save_newCloud(QString type, QString name, pcl::PointCloud<pcl::PointXYZI>::Ptr c )
{
    QString path = save_Cloud(name,c);
    //otevrit Proj.3df file pro pripsani
    QString projfile = QString("%1\\%2.3df").arg(get_Path()).arg(get_ProjName());

    QFile file (projfile);
    if(!file.exists())
    {
        projfile = QString("%1\\proj.3df").arg(get_Path()).arg(get_ProjName());
        QFile file (projfile);
    }
    file.open(QIODevice::Append | QIODevice::Text);
    QTextStream out(&file);
    out  << type << " " << path<<"\n";
    file.close();
}
示例#3
0
void Project::save_newCloud(QString type, QString path)
{
    //save cloud
    QString path1 = save_Cloud(path);
    //otevrit Proj.3df file pro pripsani
    QString projfile = QString("%1/%2.3df").arg(get_Path()).arg(get_ProjName());
    QFile file (projfile);
    if(!file.exists())
    {
        projfile = QString("%1\\proj.3df").arg(get_Path()).arg(get_ProjName());
        QFile file (projfile);
    }

    file.open(QIODevice::Append | QIODevice::Text);
    QTextStream out(&file);
    out  << type << " " << path1<<"\n";
    file.close();
}
示例#4
0
void FileWin::DoCreate( void )
{
	mNeedFlush = true;
	
	SECURITY_ATTRIBUTES sa;
	sa.nLength = sizeof(sa);
	sa.lpSecurityDescriptor = NULL;
	sa.bInheritHandle = TRUE;

	// IS: 24.04.2008
	// Use FILE_SHARE_READ shared access instead of 0.
	// It would be very helpful for Warnings and so on.
	// In other words - this process have RW access and allows RO for another processes.
	//

	HANDLE hFile;
	if( IsWindowsNTFamilyOS() )
	{
		const UChar* pathU = get_Path().c_str();
		hFile = ::CreateFileW( pathU, 
					GENERIC_READ | GENERIC_WRITE, 					
					FILE_SHARE_READ,
					&sa, 
					CREATE_ALWAYS, 
					FILE_ATTRIBUTE_NORMAL, 
					NULL);
	}
	else
	{
		const char* pathA = get_Path().getBufferA();
		hFile = ::CreateFileA( pathA, 
					GENERIC_READ | GENERIC_WRITE, 					
					FILE_SHARE_READ,
					&sa, 
					CREATE_ALWAYS, 
					FILE_ATTRIBUTE_NORMAL, 
					NULL);
	}
	
	if( hFile == INVALID_HANDLE_VALUE )
		throw xOSFileError( (ERROR_TYPE)::GetLastError() );

	mHandle = hFile;
}
示例#5
0
flength	FileWin::DoGetLengthOfClosed( void ) const
{
	WIN32_FIND_DATAA findFileDataA = {0};
	WIN32_FIND_DATAW findFileDataW = {0};

	HANDLE hFind;
	if( IsWindowsNTFamilyOS() )
		hFind = ::FindFirstFileW( (LPWSTR) get_Path().c_str(), &findFileDataW );
	else
		hFind = ::FindFirstFileA( (LPSTR) get_Path().getBufferA(), &findFileDataA );

	if( hFind == INVALID_HANDLE_VALUE )
		return 0;

	::FindClose(hFind);
	//FBL_CHECK(findFileData.nFileSizeHigh == 0);

#if FBL_LENGTH <= 32	
	if( IsWindowsNTFamilyOS() )
		return (flength)findFileDataW.nFileSizeLow;
	else
		return (flength)findFileDataA.nFileSizeLow;
#else	
	LARGE_INTEGER li;
	if( IsWindowsNTFamilyOS() )
	{
		li.LowPart 	= findFileDataW.nFileSizeLow;
		li.HighPart = (vint32) findFileDataW.nFileSizeHigh;
	}
	else
	{
		li.LowPart 	= findFileDataA.nFileSizeLow;
		li.HighPart = (vint32) findFileDataA.nFileSizeHigh;
	}

	return (flength) li.QuadPart;
#endif	
}
示例#6
0
// find_path(pos1, pos2, searchdistance,
//     max_jump, max_drop, algorithm) -> table containing path
int ModApiEnvMod::l_find_path(lua_State *L)
{
	GET_ENV_PTR;

	v3s16 pos1                  = read_v3s16(L, 1);
	v3s16 pos2                  = read_v3s16(L, 2);
	unsigned int searchdistance = luaL_checkint(L, 3);
	unsigned int max_jump       = luaL_checkint(L, 4);
	unsigned int max_drop       = luaL_checkint(L, 5);
	algorithm algo              = A_PLAIN_NP;
	if (!lua_isnil(L, 6)) {
		std::string algorithm = luaL_checkstring(L,6);

		if (algorithm == "A*")
			algo = A_PLAIN;

		if (algorithm == "Dijkstra")
			algo = DIJKSTRA;
	}

	std::vector<v3s16> path =
			get_Path(env,pos1,pos2,searchdistance,max_jump,max_drop,algo);

	if (path.size() > 0)
	{
		lua_newtable(L);
		int top = lua_gettop(L);
		unsigned int index = 1;
		for (std::vector<v3s16>::iterator i = path.begin(); i != path.end();i++)
		{
			lua_pushnumber(L,index);
			push_v3s16(L, *i);
			lua_settable(L, top);
			index++;
		}
		return 1;
	}

	return 0;
}
示例#7
0
void FileWin::DoThrowOut( void )
{
	const String& s = get_Path();
	if( !::DeleteFileA( s.getBufferA() ) )
		throw xOSFileError( (ERROR_TYPE) ::GetLastError() );	
}
示例#8
0
void FileWin::DoOpen( void )
{
	const char*  fileNameA = get_Path().getBufferA();
	const UChar* fileNameU = get_Path().c_str();

	// map modeNoInherit flag
	SECURITY_ATTRIBUTES sa;
	sa.nLength 				= sizeof(sa);
	sa.lpSecurityDescriptor = NULL;
	sa.bInheritHandle 		= TRUE;
	
	// If we want to open file for writing we have to check it is possible.
	// And open for reading in case of such check fails.
	//	
	if( (mReadOnly & fExternalRO) == false )
	{
		// define attributes of file:
		DWORD attr;
		if( IsWindowsNTFamilyOS() )
			attr = GetFileAttributesW( fileNameU );
		else
			attr = GetFileAttributesA( fileNameA );

		if( attr & FILE_ATTRIBUTE_READONLY )
			mReadOnly |= fExternalRO;
	}
	
	//
	// mReadOnly == false	- this process have RW access and allows RO for another processes.
	// mReadOnly == true	- this process have RO access and allows RW for another processes.
	//
	DWORD mode 		= (mReadOnly & fExternalRO) ? GENERIC_READ : (GENERIC_READ | GENERIC_WRITE);
	DWORD shared	= (mReadOnly & fExternalRO) ? (FILE_SHARE_READ | FILE_SHARE_WRITE) : FILE_SHARE_READ;

	HANDLE hFile;
	if( IsWindowsNTFamilyOS() )
		hFile = ::CreateFileW( fileNameU, mode, shared, &sa, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
	else
		hFile = ::CreateFileA( fileNameA, mode, shared, &sa, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);

	if( hFile == INVALID_HANDLE_VALUE )
	{
		// IS: 03.03.2008
		// http://www.valentina-db.com/bt/view.php?id=3063
		//throw xOSFileError( ERR_OS_FILE_NOT_FOUND, fileNameU );
		ERROR_TYPE err = ::GetLastError();
		// If "The system cannot find the file specified. " we throw xOSFileError
		// we need it because of another files like posix which throws this error.
		if( err == ERROR_FILE_NOT_FOUND ||
			err == ERROR_PATH_NOT_FOUND )
		{
			throw xOSFileError( ERR_OS_FILE_NOT_FOUND, fileNameU );
		}
		else
		{
			// IS: 07.04.2010
			// If we are not able to open file for writing because of access denied
			// Probably we can open it for reading
			if( ((mReadOnly & fExternalRO) == false) && (
						err == ERROR_ACCESS_DENIED 
					||	err == ERROR_WRITE_PROTECT 
					||	err == ERROR_SHARING_VIOLATION ) )
			{
				mReadOnly |= fExternalRO;
				DWORD mode2 	= GENERIC_READ;
				DWORD shared2 = FILE_SHARE_READ | FILE_SHARE_WRITE;

				if( IsWindowsNTFamilyOS() )
					hFile = ::CreateFileW( fileNameU, mode2, shared2, &sa, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
				else
					hFile = ::CreateFileA( fileNameA, mode2, shared2, &sa, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);

				err =  (hFile == INVALID_HANDLE_VALUE) ? ::GetLastError() : 0;
			}

			if( err )
				throw xOSFileError( err );
		}
	}

	mHandle = hFile;
}
示例#9
0
void Project::delete_Cloud(QString name)
{
    //otevrit soubor proj.3df vymazat radek vyhledany podle zadaneho textu
    QString filepath = QString ("%1/%2.3df").arg(m_path).arg(m_projectName);
    QString fileout = QString ("%1/%2_t.3df").arg(m_path).arg(m_projectName);

    QFile file(filepath);
    if(!file.exists())
    {
        filepath = QString("%1\\proj.3df").arg(get_Path());
        fileout = QString("%1\\proj_t.3df").arg(get_Path());
        QFile file (filepath);
    }
    QFile fileU(fileout);
    file.open(QIODevice::ReadWrite| QIODevice::Text);
    fileU.open(QIODevice::ReadWrite| QIODevice::Text);
    QTextStream in(&file);
    QTextStream out(&fileU);

    while(!in.atEnd())
    {
        QString line = in.readLine();
        if(!line.contains(name))
            out << line<<"\n";
    }
    //smazat proj a prejmenovat proj_t
    file.close();
    fileU.close();
    QFile::remove(filepath);
    QFile::rename(fileout,filepath);

    remove_file(name);

    std::vector<Cloud> baseCloud;
    for (int i = 0; i < m_baseCloud.size(); i++)
    {
        if(m_baseCloud.at(i).get_name() != name)
        {
            baseCloud.push_back(m_baseCloud.at(i));
        }
    }
    m_baseCloud.swap(baseCloud);

    std::vector<Cloud> terrainCloud;
    for (int i = 0; i < m_terrainCloud.size(); i++)
    {
        if(m_terrainCloud.at(i).get_name() != name)
        {
            terrainCloud.push_back(m_terrainCloud.at(i));
        }
    }
    m_terrainCloud.swap(terrainCloud);

    std::vector<Cloud> vegeCloud;
    for (int i = 0; i < m_vegeCloud.size(); i++)
    {
        if(m_vegeCloud.at(i).get_name() != name)
        {
            vegeCloud.push_back(m_vegeCloud.at(i));
        }
    }
    m_vegeCloud.swap(vegeCloud);

    std::vector<Cloud> ostCloud;
    for (int i = 0; i < m_ostCloud.size(); i++)
    {
        if(m_ostCloud.at(i).get_name() != name)
        {
            ostCloud.push_back(m_ostCloud.at(i));
        }
    }
    m_ostCloud.swap(ostCloud);

    std::vector<Tree> stromy;
    for (int i = 0; i < m_stromy.size(); i++)
    {
        if(m_stromy.at(i).get_name() != name)
        {
            stromy.push_back(m_stromy.at(i));
        }
    }
    m_stromy.swap(stromy);
}