コード例 #1
0
ファイル: MappingRequest.cpp プロジェクト: ThomasPasieka/hifi
void RenameMappingRequest::doStart() {

    // short circuit the request if either of the paths are invalid
    if (!isValidPath(_oldPath) || !isValidPath(_newPath)) {
        _error = InvalidPath;
        emit finished(this);
        return;
    }

    auto assetClient = DependencyManager::get<AssetClient>();

    assetClient->renameAssetMapping(_oldPath, _newPath, [this, assetClient](bool responseReceived,
                                                                            AssetServerError error,
                                                                            QSharedPointer<ReceivedMessage> message) {
        if (!responseReceived) {
            _error = NetworkError;
        } else {
            switch (error) {
                case AssetServerError::NoError:
                    _error = NoError;
                    break;
                case AssetServerError::PermissionDenied:
                    _error = PermissionDenied;
                    break;
                default:
                    _error = UnknownError;
                    break;
            }
        }

        emit finished(this);
    });
}
コード例 #2
0
ファイル: engine.cpp プロジェクト: fr33mind/Belle
bool Engine::loadPath()
{
    bool defaultLoaded = loadDefaultPath();

    if (isValidPath(mPath))
        return true;

    if (defaultLoaded) {
        mPath = mDefaultPath;
        return isValidPath(mPath);
    }

    return false;
}
コード例 #3
0
ファイル: MappingRequest.cpp プロジェクト: ThomasPasieka/hifi
void SetMappingRequest::doStart() {

    // short circuit the request if the hash or path are invalid
    auto validPath = isValidPath(_path);
    auto validHash = isValidHash(_hash);
    if (!validPath || !validHash) {
        _error = !validPath ? MappingRequest::InvalidPath : MappingRequest::InvalidHash;
        emit finished(this);
        return;
    }

    auto assetClient = DependencyManager::get<AssetClient>();

    assetClient->setAssetMapping(_path, _hash, [this, assetClient](bool responseReceived, AssetServerError error, QSharedPointer<ReceivedMessage> message) {
        if (!responseReceived) {
            _error = NetworkError;
        } else {
            switch (error) {
                case AssetServerError::NoError:
                    _error = NoError;
                    break;
                case AssetServerError::PermissionDenied:
                    _error = PermissionDenied;
                    break;
                default:
                    _error = UnknownError;
                    break;
            }
        }

        emit finished(this);
    });
};
コード例 #4
0
ファイル: utils.c プロジェクト: shyrfxl/A-simple-HTTP-in-C
/* 
 * check validity of url by checking validity of each part of it
 */
int 
isValidURL(Request *req)
{
	if (req == NULL) {
		return 0;
	}

	if (req->queryString != NULL) {
		if (!isValidQueryOrFrag(req->queryString)) {	
			return 0;
		}
	}

	if (req->fragment != NULL) {
		if (!isValidQueryOrFrag(req->fragment)) {	
			return 0;
		}
	}

	if (req->path != NULL) {
		if (!isValidPath(req->path)) {
			return 0;
		}
	}

	return 1;
}
コード例 #5
0
ファイル: MappingRequest.cpp プロジェクト: ThomasPasieka/hifi
void DeleteMappingsRequest::doStart() {

    // short circuit the request if any of the paths are invalid
    for (auto& path : _paths) {
        if (!isValidPath(path)) {
            _error = MappingRequest::InvalidPath;
            emit finished(this);
            return;
        }
    }

    auto assetClient = DependencyManager::get<AssetClient>();

    assetClient->deleteAssetMappings(_paths, [this, assetClient](bool responseReceived, AssetServerError error, QSharedPointer<ReceivedMessage> message) {
        if (!responseReceived) {
            _error = NetworkError;
        } else {
            switch (error) {
                case AssetServerError::NoError:
                    _error = NoError;
                    break;
                case AssetServerError::PermissionDenied:
                    _error = PermissionDenied;
                    break;
                default:
                    _error = UnknownError;
                    break;
            }
        }

        emit finished(this);
    });
};
コード例 #6
0
ファイル: MappingRequest.cpp プロジェクト: ThomasPasieka/hifi
void GetMappingRequest::doStart() {

    // short circuit the request if the path is invalid
    if (!isValidPath(_path)) {
        _error = MappingRequest::InvalidPath;
        emit finished(this);
        return;
    }

    auto assetClient = DependencyManager::get<AssetClient>();

    assetClient->getAssetMapping(_path, [this, assetClient](bool responseReceived, AssetServerError error, QSharedPointer<ReceivedMessage> message) {
        if (!responseReceived) {
            _error = NetworkError;
        } else {
            switch (error) {
                case AssetServerError::NoError:
                    _error = NoError;
                    break;
                case AssetServerError::AssetNotFound:
                    _error = NotFound;
                    break;
                default:
                    _error = UnknownError;
                    break;
            }
        }

        if (!_error) {
            _hash = message->read(SHA256_HASH_LENGTH).toHex();
        }
        emit finished(this);
    });
};
コード例 #7
0
ファイル: DOMFilePath.cpp プロジェクト: mirror/chromium
bool DOMFilePath::isValidName(const String& name) {
  if (name.isEmpty())
    return true;
  // '/' is not allowed in name.
  if (name.contains('/'))
    return false;
  return isValidPath(name);
}
コード例 #8
0
void SvCreator::open(void)
{
  QString path;
  path = QFileDialog::getOpenFileName(this,
                                      tr("%1 | Select target file").arg(APP_NAME),
                                      ".",
                                      FILE_FILTER);
  if (isValidPath(path)) loadFile(path);
}
コード例 #9
0
ファイル: fileop.cpp プロジェクト: Gamer125/wiibrowser
bool AutoDownloader(char *path)
{
    int AbsolutePath = CheckFolder(Settings.DownloadFolder);

    if(AbsolutePath == RELATIVE)
        sprintf(path, "%s%s", Settings.BootDevice, Settings.DownloadFolder);
    else if(AbsolutePath == ABSOLUTE)
        sprintf(path, Settings.DownloadFolder);

    if (isValidPath(path))
        return true;
    return false;
}
コード例 #10
0
ファイル: engine.cpp プロジェクト: daodaoliang/moonriver
void Engine::guessPath()
{
    QString enginePath("Engine");
    QDir currDir = QDir::current();

    if (currDir.cd(enginePath) || currDir.cd(enginePath.toLower()))
        mPath = currDir.absolutePath();

    if (! isValidPath(mPath)) {
        currDir.cdUp();
        if (currDir.cd(enginePath) || currDir.cd(enginePath.toLower()))
            mPath = currDir.absolutePath();
    }
}
コード例 #11
0
ファイル: StageSelect.cpp プロジェクト: gab0626/blackwhite
void StageSelect::Setup_map_Data_()
{
    draw_Map_Size_ = Vec2i(500, 300);

    draw_Select_Box_Size_ = Vec2i(100, 100);

    stage_No_ = 1;
    for (
        std::string _file_name = "res/map/stage" + std::to_string(stage_No_) + ".txt";
        isValidPath(_file_name);
        _file_name = "res/map/stage" + std::to_string(++stage_No_) + ".txt"
        )
    {
        std::ifstream* _ifstream_ptr = new std::ifstream(_file_name);

        Vec2i _map_Size;
        *_ifstream_ptr >> _map_Size.y();
        *_ifstream_ptr >> _map_Size.x();

        std::vector<std::vector<int>> _buf_2D_Map_Chip_Data;
        for (int y = 0; y < _map_Size.y(); ++y)
        {
            std::vector<int> _chip_1D = std::vector<int>(_map_Size.x());
            for (int x = 0; x < _map_Size.x(); ++x)
            {
                *_ifstream_ptr >> _chip_1D[x];
            }
            _buf_2D_Map_Chip_Data.push_back(_chip_1D);
        }
        delete _ifstream_ptr;

        std::vector<std::vector<int>> _chip_2D;
        for (int y = _map_Size.y() - 1; y != -1; --y)
        {
            std::vector<int> _chip_1D;
            for (int x = 0; x < _map_Size.x(); ++x)
            {
                _chip_1D.push_back(_buf_2D_Map_Chip_Data[y][x]);
            }
            _chip_2D.push_back(_chip_1D);
        }
        map_Chip_Data_.push_back(_chip_2D);

        block_Window_Size_.push_back(Vec2f(draw_Map_Size_.x() / _map_Size.x(), draw_Map_Size_.y() / _map_Size.y()));
    }

    stage_Max_No_ = stage_No_ - 1;
    stage_No_ = 0;
}
コード例 #12
0
ファイル: engine.cpp プロジェクト: fr33mind/Belle
bool Engine::loadDefaultPath()
{
    #if defined(Q_OS_UNIX)
        if (mDefaultPath == ENGINE_DEFAULT_PATH) {
            mDefaultPath = QCoreApplication::applicationDirPath() +
                           QDir::separator() + ENGINE_DEFAULT_PATH;
        }
    #endif

    if (isValidPath(mDefaultPath))
        return true;

    QStringList paths;
    paths << "engine";

    foreach(const QString& path, paths) {
        if (isValidPath(path)) {
            mDefaultPath = path;
            return true;
        }
    }

    return false;
}
コード例 #13
0
ファイル: AssetUtils.cpp プロジェクト: howard-stearns/hifi
// Get the normalized ATP URL for a raw hash, /path or "atp:" input string.
QUrl getATPUrl(const QString& input) {
    QUrl url = input;
    if (!url.scheme().isEmpty() && url.scheme() != URL_SCHEME_ATP) {
        return QUrl();
    }
    // this strips extraneous info from the URL (while preserving fragment/querystring)
    QString path = url.toEncoded(
        QUrl::RemoveAuthority | QUrl::RemoveScheme |
        QUrl::StripTrailingSlash | QUrl::NormalizePathSegments
    );
    QString baseName = QFileInfo(url.path()).baseName();
    if (isValidPath(path) || isValidHash(baseName)) {
        return QUrl(QString("%1:%2").arg(URL_SCHEME_ATP).arg(path));
    }
    return QUrl();
}
コード例 #14
0
void SvCreator::importNagiosChecks(void)
{
  QMap<QString, SourceT> sourceInfos;
  fetchSourceList(MonitorT::Nagios, sourceInfos);
  CheckImportationSettingsForm importationSettingForm(sourceInfos.keys(), true);
  if (importationSettingForm.exec() == QDialog::Accepted) {
    QString srcId = importationSettingForm.selectedSource();
    QString path = importationSettingForm.selectedFile();
    SourceT srcInfo = sourceInfos[srcId];

    if (! isValidPath(path) ) {
      showStatusMsg(tr("Loading checks from %1:%2...").arg(srcId, path), false);
      ChecksT checks;
      int retcode = parseStatusFile(path, checks);
      processCheckLoadResults(retcode, srcInfo.id, checks, tr("Error while parsing the file"));
    } else {
      showStatusMsg(tr("No file selected"), true);
    }
  }
}
コード例 #15
0
ファイル: nAryTree.c プロジェクト: RahulSinghDhek/vfsgrp30
struct dirNode* insertNAry(FileDescriptor *fd,struct dirNode* root,int *flag)
{
	struct dirNode *p;
	struct dirNode *parent;
	char *ref;
	int exitStatus=FALSE;
	p=getNode();
	if(p==NULL)
	{
		printf("Sorry NO SUFFICIENT MEMORY");
		//*flag=NOT_ENOUGH_MEMORY;
		exit(0);
	}
	//printf("before");
	root=isValidPath(fd,root,flag);
	//printf("after");
	if(*flag==101){
		printf(ERR_VFS_MAKEDIR_03);
		*flag=401;
		//printf("\nwrong path entered\n");		
	}
	if(*flag==100)
	{
		p->fileDesc=fd;
		if(root==NULL)
		{	
			root=p;
			exitStatus=TRUE;
		}
		else
		{
			parent=root;
			while(exitStatus==FALSE)
			{
					//printf("%s\n",p->fileDesc->fullPath);
				if(strstr(p->fileDesc->fullPath,parent->fileDesc->fullPath)==NULL)
				{
					if(parent->rightSibling==NULL)
					{
						parent->rightSibling=p;
						exitStatus=TRUE;
					}
					else
						parent=parent->rightSibling;
				}
				else
				{
					if(parent->firstChild==NULL)
					{
						parent->firstChild=p;
						exitStatus=TRUE;
					}	
					else
					{
						parent=parent->firstChild;
					}	
				}
			}
		}
	  }
      return root;
}
コード例 #16
0
ファイル: fileop.cpp プロジェクト: Gamer125/wiibrowser
bool GuiBrowser(GuiWindow *mainWindow, GuiWindow *parentWindow, char *path, const char *label)
{
    char temp[256];
    char title[100];
	int i;

	ShutoffRumble();

	// populate initial directory listing
	if(BrowseDevice() <= 0)
	{
		WindowPrompt(
		"Error",
		"Unable to display files on selected load device",
		"Ok",
		NULL);

        return false;
	}

	int menu = MENU_NONE;
	int dev = 0;
	char mount[2][5] = {"SD", "USB"};

    GuiTrigger trigA;
	trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);

    if(OpenDefaultFolder() <= 0)
    {
        BrowseDevice();
        bzero(temp, sizeof(temp));
    }
    else sprintf(temp, "%s/", Settings.UserFolder);

	sprintf(title, "Browse files");
	bzero(path, sizeof(path));

    GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM);
    GuiImageData Textbox(textbox_end_png);
    GuiImage TextboxImg(&Textbox);
    GuiButton InsertURL(TextboxImg.GetWidth(), TextboxImg.GetHeight());

    GuiImageData Device(textbox_begin_png);
    GuiImage DeviceImg(&Device);
    GuiButton InsertDEV(DeviceImg.GetWidth(), DeviceImg.GetHeight());

    GuiText URL(strchr(temp, '/'), 20, (GXColor){0, 0, 0, 255});
    GuiText DEV("SD", 20, (GXColor){0, 0, 0, 255});

    URL.SetMaxWidth(TextboxImg.GetWidth()-20);
    URL.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
    URL.SetPosition(5,0);
    URL.SetScroll(SCROLL_HORIZONTAL);

    InsertURL.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
    InsertURL.SetPosition(InsertDEV.GetWidth()/2,30);
    InsertURL.SetLabel(&URL);
    InsertURL.SetImage(&TextboxImg);
    InsertURL.SetSoundOver(&btnSoundOver);
    InsertURL.SetTrigger(&trigA);

    InsertDEV.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
    InsertDEV.SetPosition(InsertURL.GetLeft()-InsertDEV.GetWidth()/2,30);
    InsertDEV.SetLabel(&DEV);
    InsertDEV.SetImage(&DeviceImg);
    InsertDEV.SetSoundOver(&btnSoundOver);
    InsertDEV.SetTrigger(&trigA);
    InsertDEV.SetEffectGrow();

    GuiText titleTxt(title, 28, (GXColor){0, 0, 0, 255});
    titleTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
	titleTxt.SetPosition(50,50);

	GuiFileBrowser fileBrowser(552, 248);
	fileBrowser.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
	fileBrowser.SetPosition(0, 108);
	fileBrowser.SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_IN, 30);

	GuiImageData btnOutline(button_png);
	GuiImageData btnOutlineOver(button_over_png);

	GuiText okBtnTxt(label, 24, (GXColor){0, 0, 0, 255});
	GuiImage okBtnImg(&btnOutline);
	GuiImage okBtnImgOver(&btnOutlineOver);
	GuiButton okBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
	okBtn.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM);
	okBtn.SetPosition(50, -35);
	okBtn.SetLabel(&okBtnTxt);
	okBtn.SetImage(&okBtnImg);
	okBtn.SetImageOver(&okBtnImgOver);
	okBtn.SetTrigger(&trigA);
	okBtn.SetEffectGrow();

    GuiText cancelBtnTxt("Cancel", 24, (GXColor){0, 0, 0, 255});
	GuiImage cancelBtnImg(&btnOutline);
	GuiImage cancelBtnImgOver(&btnOutlineOver);
	GuiButton cancelBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
	cancelBtn.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM);
	cancelBtn.SetPosition(-50, -35);
	cancelBtn.SetLabel(&cancelBtnTxt);
	cancelBtn.SetImage(&cancelBtnImg);
	cancelBtn.SetImageOver(&cancelBtnImgOver);
	cancelBtn.SetTrigger(&trigA);
	cancelBtn.SetEffectGrow();

	GuiWindow buttonWindow(screenwidth, screenheight);
	buttonWindow.Append(&okBtn);
	buttonWindow.Append(&cancelBtn);
	buttonWindow.Append(&InsertURL);
	buttonWindow.Append(&InsertDEV);
    buttonWindow.SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_IN, 30);

    if (mainWindow)
    {
        mainWindow->SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50);
        while(mainWindow->GetEffect() > 0)
            usleep(100);
    }

    HaltGui();
    if (mainWindow)
        parentWindow->Remove(mainWindow);
    parentWindow->Append(&buttonWindow);
    parentWindow->Append(&fileBrowser);
    ResumeGui();

	while(menu == MENU_NONE)
	{
		usleep(100);
		if(!strlen(URL.GetText()) || URL.GetText()[0] != '/')
        {
            sprintf(temp, "%s", rootdir);
            URL.SetText(strchr(temp, '/'));
        }

        if(InsertURL.GetState() == STATE_CLICKED)
        {
            URL.SetScroll(SCROLL_NONE);
            OnScreenKeyboard(parentWindow, strchr(temp, '/'), 256);
            URL.SetText(strchr(temp, '/'));
            URL.SetScroll(SCROLL_HORIZONTAL);

            InsertURL.ResetState();
        }

        if(InsertDEV.GetState() == STATE_CLICKED)
        {
            InsertDEV.ResetState();
            dev ^= 1;

            if(BrowseDevice(dev) <= 0)
            {
                BrowseDevice();
                dev = 0;
            }

            DEV.SetText(mount[dev]);
            URL.SetText("");
        }

		// update file browser based on arrow buttons
		// set MENU_EXIT if A button pressed on a file
		for(i=0; i < FILE_PAGESIZE; i++)
		{
			if(fileBrowser.fileList[i]->GetState() == STATE_CLICKED)
			{
				fileBrowser.fileList[i]->ResetState();
				// check corresponding browser entry
				if(browserList[browser.selIndex].isdir)
				{
					if(BrowserChangeFolder())
					{
						fileBrowser.ResetState();
						fileBrowser.fileList[0]->SetState(STATE_SELECTED);
						fileBrowser.TriggerUpdate();

                        if(strlen(browser.dir) > 1)
                            sprintf(fullpath, "%s%s/", rootdir, browser.dir+1); // print current path
                        else sprintf(fullpath, "%s", rootdir); // print current path

                        sprintf(temp, fullpath);
                        URL.SetText(strchr(temp, '/'));
					}
					else
					{
						menu = MENU_HOME;
						break;
					}
				}
				else
				{
					ShutoffRumble();
					// load file
					if(strlen(browser.dir) > 1)
                        sprintf(fullpath, "%s%s/%s", rootdir, browser.dir+1, browserList[browser.selIndex].filename); // print current path
                    else sprintf(fullpath, "%s%s", rootdir, browserList[browser.selIndex].filename); // print current path

                    sprintf(temp, fullpath);
                    URL.SetText(strchr(temp, '/'));
				}
			}
		}

		if(okBtn.GetState() == STATE_CLICKED)
		{
		    sprintf(path, temp);
		    menu = MENU_HOME;
		}
        if(cancelBtn.GetState() == STATE_CLICKED)
		    menu = MENU_HOME;
	}

    fileBrowser.SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 50);
    buttonWindow.SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 50);
    while(buttonWindow.GetEffect() > 0)
        usleep(100);

    fileBrowser.SetVisible(false);
    buttonWindow.SetVisible(false);

    if(mainWindow)
    {
        mainWindow->SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 30);
        parentWindow->Append(mainWindow);
        while(mainWindow->GetEffect() > 0)
            usleep(100);
    }

    HaltGui();
    parentWindow->Remove(&buttonWindow);
    parentWindow->Remove(&fileBrowser);
    ResumeGui();

    if (isValidPath(path))
        return true;
    return false;
}
コード例 #17
0
ファイル: engine.cpp プロジェクト: fr33mind/Belle
bool Engine::isValid()
{
    return isValidPath(mPath);
}
コード例 #18
0
ファイル: main.cpp プロジェクト: UIKit0/OpenSynther
int main(int argc, char*argv[])
{	
	if (argc < 1)
	{
		std::cout << "Usage: " << argv[0] << " <inputPath>" <<std::endl;
		std::cout << "<inputPath> : PhotoSynth project folder" <<std::endl;

		return -1;
	}

	std::string projectPath = std::string(argv[1]);	

	if (!isValidPath(projectPath))
	{
		std::cout << "You need to use a valid folder created by PhotoSynthToolkit" << std::endl;
		std::cout << projectPath << "guid.txt doesn't exist" << std::endl;
		return -1;
	}

	initializeProject(projectPath);

	Synther::ManagerOption options;
	options.verbose             = true;
	options.matchingMode        = Synther::MATCHINGMODE_UNSTRUCTURED_QUADRATIC;
	options.maxPictureDimension = 2500;
	options.matchingThreshold   = 0.3f;
	
	Synther::LinearMatcherOption linearOptions;
	linearOptions.nbFeaturesUsedPerPicture         = 300;
	linearOptions.nbNearestNeighborsInFeatureSpace = 6;
	linearOptions.nbClosestPicturesUsed            = 8;
	
	clock_t start = clock();
	Synther::Manager manager(options, linearOptions);
	{
		std::stringstream path;
		path << projectPath << "distort";
		const std::vector<std::string>& pictureList = manager.getPictureList(path.str());
		savePictureList(pictureList, projectPath);

		std::cout<< "[Extracting features...]";
		clock_t startFeatureExtraction = clock();
		manager.extractFeatures(pictureList);
		manager.clearScreen();
		std::cout<< "[Features extracted in " << floor(float(clock() - startFeatureExtraction) / CLOCKS_PER_SEC)  << "s]" << std::endl;

		path.str("");
		path << projectPath << "bundler_tmp\\vector.txt";
		manager.exportVector(path.str());

		std::cout<< "[Matching features...]";
		clock_t startFeatureMatching = clock();
		manager.matchFeatures();
		manager.clearScreen();
		std::cout<< "[Features matched in " << floor(float(clock() - startFeatureMatching) / CLOCKS_PER_SEC)  << "s]" << std::endl;

		path.str("");
		path << projectPath << "bundler_tmp\\matrix.txt";
		manager.exportMatrix(path.str());

		std::cout<< "[Pruning matches...]";
		clock_t startMatchPruning = clock();
		manager.pruneMatches();
		manager.clearScreen();
		std::cout<< "[Matches pruned in " << floor(float(clock() - startMatchPruning) / CLOCKS_PER_SEC)  << "s]" << std::endl;

		path.str("");
		path << projectPath << "bundler_tmp\\matrix.pruned.txt";	
		manager.exportMatrix(path.str());

		std::cout<< "[Estimating Fundamental matrices...]";
		clock_t startFundamentalMatrixEstimation = clock();
		manager.estimateFundamentalMatrix();
		manager.clearScreen();
		std::cout<< "[Fundamental matrices estimated in " << floor(float(clock() - startMatchPruning) / CLOCKS_PER_SEC)  << "s]" << std::endl;
		
		path.str("");
		path << projectPath << "bundler_tmp\\matrix.ransac.txt";		
		manager.exportMatrix(path.str());

		std::cout << "[Building Tracks]";
		clock_t startTrackBuilding = clock();
		int nbTracks = manager.buildTracks();
		manager.clearScreen();
		std::cout<< "[" << nbTracks << " tracks built in " << floor(float(clock() - startTrackBuilding) / CLOCKS_PER_SEC)  << "s]" << std::endl;
				
		PhotoSynth::Parser parser;
		std::string guid = parser.getGuid(PhotoSynth::Parser::createFilePath(argv[1], PhotoSynth::Parser::guidFilename));
		parser.parseSoap(PhotoSynth::Parser::createFilePath(argv[1], PhotoSynth::Parser::soapFilename));
		parser.parseJson(PhotoSynth::Parser::createFilePath(argv[1], PhotoSynth::Parser::jsonFilename), guid);
		manager.loadPhotoSynthJson(&parser);

		std::cout<< "[Triangulating tracks...]";
		clock_t startTriangulatingTracks = clock();
		manager.triangulateTracks();
		manager.clearScreen();
		std::cout<< "[Tracks triangulated in " << floor(float(clock() - startTriangulatingTracks) / CLOCKS_PER_SEC)  << "s]" << std::endl;

		std::cout<< "[Colorizing tracks...]";
		clock_t startColorizingTracks = clock();
		manager.colorizeTracks();
		manager.clearScreen();
		std::cout<< "[Tracks colorized in " << floor(float(clock() - startColorizingTracks) / CLOCKS_PER_SEC)  << "s]" << std::endl;

		path.str("");
		path << projectPath << "bundler_tmp\\tracks.histogram.txt";	
		manager.exportTracksLengthHistogram(path.str());

		path.str("");
		path << projectPath << "bundler_tmp\\pointCloud.ply";	
		manager.exportTracksAsPointCloud(path.str());

		path.str("");
		path << projectPath << "bundler_tmp\\tracks.xml";	
		manager.exportTracks(path.str());

		path.str("");
		path << projectPath << "bundler_output\\bundle.out";	
		manager.exportBundlerOutput(path.str());

		path.str("");
		path << projectPath << "pmvs\\bundle.rd.out";
		manager.exportBundlerOutput(path.str(), true);

		path << projectPath << "pmvs\\vis.dat";
		manager.exportVisibility(path.str());

		manager.exportDataForTracking(projectPath);
	}

	std::cout << "Time elapsed: " << floor(float(clock() - start) / CLOCKS_PER_SEC) << "s" << std::endl;

	return 0;
}
コード例 #19
0
/*!
 * \brief Validate this configuration..
 * \return Return true if all configuration is valid.
 */
bool TConfiguration::validate(void) {
  bool result = true;

  /* File check */
  TStringConfig *filenames[] = {fileName, heapLogFile, archiveFile,
                                logFile,  logDir,      NULL};
  for (TStringConfig **elmt = filenames; *elmt != NULL; elmt++) {
    if (strlen((*elmt)->get()) == 0) {
      // "" means "disable", not a file path like "./".
      continue;
    }
    try {
      if (!isValidPath((*elmt)->get())) {
        throw "Permission denied";
      }
    } catch (const char *message) {
      logger->printWarnMsg("%s: %s = %s", message, (*elmt)->getConfigName(),
                           (*elmt)->get());
      result = false;
    } catch (int errnum) {
      logger->printWarnMsgWithErrno("Configuration error: %s = %s",
                                    (*elmt)->getConfigName(), (*elmt)->get());
      result = false;
    }
  }

  /* Range check */
  TIntConfig *percentages[] = {alertPercentage, heapAlertPercentage, NULL};
  for (TIntConfig **percentage = percentages; *percentage != NULL;
       percentage++) {
    if (((*percentage)->get() < 0) || ((*percentage)->get() > 100)) {
      logger->printWarnMsg("Out of range: %s = %d",
                           (*percentage)->getConfigName(),
                           (*percentage)->get());
      result = false;
    }
  }

  /* Set alert threshold. */
  jlong maxMem = this->jvmInfo->getMaxMemory();
  alertThreshold =
      (maxMem == -1) ? -1 : (maxMem * alertPercentage->get() / 100);
  heapAlertThreshold =
      (maxMem == -1) ? -1 : (maxMem * heapAlertPercentage->get() / 100);

  /* Signal check */
  char *reloadSig = reloadSignal->get();
  char *normalSig = logSignalNormal->get();
  char *allSig = logSignalAll->get();
  if (reloadSig != NULL) {
    if ((normalSig != NULL) && (strcmp(normalSig, reloadSig) == 0)) {
      logger->printWarnMsg(
          "Cannot set same signal: logsignal_normal & signal_reload");
      result = false;
    }

    if ((allSig != NULL) && (strcmp(allSig, reloadSig) == 0)) {
      logger->printWarnMsg(
          "Cannot set same signal: logsignal_all & signal_reload");
      result = false;
    }
  }

  if ((normalSig != NULL) && (allSig != NULL) &&
      (strcmp(normalSig, allSig) == 0)) {
    logger->printWarnMsg(
        "Cannot set same signal: logsignal_normal & logsignal_all");
    result = false;
  }

  /* Thread recorder check */
  if (threadRecordEnable->get()) {
    if (threadRecordBufferSize <= 0) {
      logger->printWarnMsg("Invalid value: thread_record_buffer_size = %ld",
                           threadRecordBufferSize->get());
      result = false;
    } else if (!isValidPath(threadRecordFileName->get())) {
      logger->printWarnMsg("Permission denied: thread_record_filename = %s",
                           threadRecordFileName->get());
      result = false;
    }
  }

  /* SNMP check */
  if (snmpSend->get()) {
    if ((snmpTarget->get() == NULL) || (strlen(snmpTarget->get()) == 0)) {
      logger->printWarnMsg("snmp_target have to be set when snmp_send is set");
      result = false;
    }

    if ((snmpComName->get() == NULL) || (strlen(snmpComName->get()) == 0)) {
      logger->printWarnMsg("snmp_comname have to be set when snmp_send is set");
      result = false;
    }
  }

  return result;
}