Esempio n. 1
0
/**
 * \brief Perform data storage operation after selection
 * \param[in] operation is OPEN, SAVE or CLOSE
 * \req RS_06_03 - Perform data storage operation after selection
 *
 * Perform data storage operation after selection.
 * This is a data storage related function.
 */
USAGEMODE int DoDatastorageOperation(short operation)
{
    int nReturn = 0;

    if (sdataStorageInfo.m_Datastore == FILEMODE)
    {
        if (operation & SAVE)
        {
            nReturn = SaveDataFile(sdataStorageInfo.FSInfo->m_FilePath);
        }
        else if (operation & OPEN)
        {
            nReturn = LoadDataFile(sdataStorageInfo.FSInfo->m_FilePath);
        }
        else if (operation & CLOSE)
        {
            CloseDataFile();

            if (sdataStorageInfo.FSInfo != NULL)
            {
                delete sdataStorageInfo.FSInfo;
                sdataStorageInfo.FSInfo = NULL;
            }
        }
    }

    return nReturn;
}
void PrecalcIntro()
{
	//WriteDebug("Precalc Start.\n");
	glEnable(GL_NORMALIZE);

#ifdef INCLUDE_OBJ_BUTTERFLYSMOOTH
	initVertexBlend();
#endif
	InitTextureBuffer();
	InitIntroEditorEffects();
	
	unsigned char * data= raw_precalc;
	//DisplayPrecalcAnim=false;
	pEventList=0;
	pEventNum=0;
	pEventNum=LoadDataFile((void**)&data, &pMaterialList, &pPolySelectList, &pSceneList, &pWorldList, &pEventList, -1);
	//WriteDebug("Status bar project loaded.\n");

	if (setupcfg.music)
	{
#ifdef RELEASETYPE_DEMO
		if (!BASS_Init(1,44100,0,hWnd,NULL)) exit(0);
		str=BASS_StreamCreateFile(true,music,0,music_size,0);
#else
		if (!mvxSystem_Init(hWnd,music,music_size)) exit(0);
#endif
	}
	//WriteDebug("MVX init done.\n");

	data= raw_project;

	DisplayPrecalcAnim=true;
	EventNum=LoadDataFile((void**)&data, &MaterialList, &PolySelectList, &SceneList, &WorldList, &EventList, -1 /*setupcfg.texturedetail/**/);
	glScissor(0,(YRes-XRes/16*9)/2,XRes,XRes/16*9);
	//WriteDebug("Project loaded.\n");
}
Esempio n. 3
0
int main(int argc, char **argv)
{
    try {
        // parse command line
        if (argc != 3)
            throw CError(usage, argv[0]);
        int argn = 1;
        char *dataFileName = argv[argn++];
	char *outstem = argv[argn++];

	int writeParams = 1;
	int writeTimings = 1;

	FILE *debugfile = createDebugFile(writeParams, outstem, verbose, argc, argv);

	// Load datafile 
	int width, height, nLabels;
	std::vector<int> gt, data, lrPairwise, udPairwise;
	MRF::CostVal *dataCostArray, *hCue, *vCue;

	if (verbose)
	    fprintf(stderr, "Loading datafile...\n");
	
	LoadDataFile(dataFileName, width, height, nLabels, dataCostArray, hCue, vCue);

	DataCost *dcost = new DataCost(dataCostArray);
	SmoothnessCost *scost = new SmoothnessCost(1, 1, 1, hCue, vCue);
	EnergyFunction *energy = new EnergyFunction(dcost, scost);

	if (verbose)
	    fprintf(stderr, "Running optimization...\n");
	fflush(stderr);

	int MRFalg = aRunAll;

	int outerIter, innerIter;
	MRF *mrf = NULL;
	for (int numAlg = aICM; numAlg <= aBPM; numAlg++) {
	    outerIter = MAXITER;
	    innerIter = 1;
	    if (MRFalg < aRunAll && numAlg != MRFalg) continue;

	    startAlgInitTimer();

	    switch (numAlg) {
	    case aICM:       mrf = new ICM(width, height, nLabels, energy); innerIter = 5; break;
	    case aExpansion: mrf = new Expansion(width, height, nLabels, energy); break;
	    case aSwap:      mrf = new Swap(width, height, nLabels, energy); break;
	    case aTRWS:      mrf = new TRWS(width, height, nLabels, energy); break;
	    case aBPS:       mrf = new BPS(width, height, nLabels, energy);  
		//innerIter = 5; 
		break;
	    case aBPM:       mrf = new MaxProdBP(width, height, nLabels, energy);
		//innerIter = 2; 
		break;
	    default: throw new CError("unknown algorithm number");
	    }
	    if (debugfile)
		fprintf(debugfile, "******* Running %s for up to %d x %d iterations\n",
			algs[numAlg], outerIter, innerIter);

	    mrf->initialize();
	    mrf->clearAnswer();

	    bool initializeToWTA = false;
	    if (initializeToWTA) {
		if (debugfile)
		    fprintf(debugfile, "performing WTA\n");
		CByteImage disp;
		WTA(dataCostArray, width, height, nLabels, disp);
		writeDisparities(disp, 255, "WTA.png", debugfile);
		setDisparities(disp, mrf);
	    } else {
		mrf->clearAnswer();
	    }

	    float initTime = getAlgInitTime();
	    
	    FILE *timefile = createTimeFile(writeTimings, outstem, algs[numAlg], debugfile);

	    runAlg(mrf, numAlg, debugfile, timefile, outerIter, innerIter, initTime);

	    // save resulting labels as image
	    CShape sh(width, height, 1);
	    CByteImage outimg(sh);
	    int n = 0;
	    for (int y = 0; y < height; y++) {
		for (int x = 0; x < width; x++) {
		    outimg.Pixel(x, y, 0) = 255* mrf->getLabel(n);
		    n++;
		}
	    }

	    char fname[500];
	    sprintf(fname, "%s-%s.png", outstem, algs[numAlg]);
	    WriteImageVerb(outimg, fname, 1);
	    delete mrf;
	}

	if (writeParams)
	    fclose(debugfile);

	delete energy;
	delete scost;
	delete dcost;
	delete [] dataCostArray;
	delete [] hCue;
	delete [] vCue;
    }
    catch (CError &err) {
        fprintf(stderr, err.message);
        fprintf(stderr, "\n");
        return -1;
    }
    catch (bad_alloc) {
	fprintf(stderr, "*** Error: not enough memory\n");
	exit(1);
    }

    return 0;
}
BOOL dialogEditor_dataitem::OnInitDialog()
{
	CString sError;
	DWORD dwExtendedStyle = 0;

	pFont = new CFont;
	LOGFONT lf;

	memset(&lf, 0, sizeof(LOGFONT));
	lf.lfHeight = 0xfffffff5;
	lf.lfWeight = FW_REGULAR;
	lf.lfOutPrecision = OUT_STROKE_PRECIS;
	lf.lfClipPrecision = CLIP_STROKE_PRECIS;
	lf.lfQuality = DRAFT_QUALITY;
	lf.lfPitchAndFamily = 0x22;
	lf.lfCharSet = 0;
	strcpy(lf.lfFaceName,"Lucida Console");

	pFont->CreateFontIndirect(&lf);

	if((lpComboBox_type = (CComboBox*)GetDlgItem(IDC_EDITOR_DATAITEM_TYPE)) == NULL)
		return FALSE;

	lpComboBox_type->SetItemData(lpComboBox_type->AddString("Temperature"),0x1);
	lpComboBox_type->SetItemData(lpComboBox_type->AddString("Pressure"),0x2);
	lpComboBox_type->SetItemData(lpComboBox_type->AddString("Air/Fuel"),0x3);
	lpComboBox_type->SetItemData(lpComboBox_type->AddString("Speed"),0x4);
	lpComboBox_type->SetItemData(lpComboBox_type->AddString("Injector"),0x5);
	lpComboBox_type->SetItemData(lpComboBox_type->AddString("General"),0x6);
	lpComboBox_type->SetItemData(lpComboBox_type->AddString("Switch"),0x7);
	lpComboBox_type->SetItemData(lpComboBox_type->AddString("Boost (Corrected)"),0x9);

	CSpinButtonCtrl* pSpin = NULL;
	if((pSpin = (CSpinButtonCtrl*)GetDlgItem(IDC_EDITOR_DATAITEM_SPINBYTE)) == NULL)
		return FALSE;
	pSpin->SetRange(1,100);
	if((pSpin = (CSpinButtonCtrl*)GetDlgItem(IDC_EDITOR_DATAITEM_SPINBIT)) == NULL)
		return FALSE;
	pSpin->SetRange(1,8);
	if((pSpin = (CSpinButtonCtrl*)GetDlgItem(IDC_EDITOR_DATAITEM_ADDRESSHIGHSPIN)) == NULL)
		return FALSE;
	pSpin->SetRange32(0,0xFFFFFF);
	if((pSpin = (CSpinButtonCtrl*)GetDlgItem(IDC_EDITOR_DATAITEM_ADDRESSLOWSPIN)) == NULL)
		return FALSE;
	pSpin->SetRange32(0,0xFFFFFF);
	if((pSpin = (CSpinButtonCtrl*)GetDlgItem(IDC_EDITOR_DATAITEM_OPERANDADDITIONSPIN)) == NULL)
		return FALSE;
	pSpin->SetRange32(0,65536);
	if((pSpin = (CSpinButtonCtrl*)GetDlgItem(IDC_EDITOR_DATAITEM_OPERANDSUBTRACTSPIN)) == NULL)
		return FALSE;
	pSpin->SetRange32(0,65536);
	if((pSpin = (CSpinButtonCtrl*)GetDlgItem(IDC_EDITOR_DATAITEM_OPERANDMULTIPLIERSPIN)) == NULL)
		return FALSE;
	pSpin->SetRange32(0,65536);
	if((pSpin = (CSpinButtonCtrl*)GetDlgItem(IDC_EDITOR_DATAITEM_OPERANDDIVISORSPIN)) == NULL)
		return FALSE;
	pSpin->SetRange32(0,65536);
	if((pSpin = (CSpinButtonCtrl*)GetDlgItem(IDC_EDITOR_DATAITEM_DECIMALSSPIN)) == NULL)
		return FALSE;
	pSpin->SetRange(0,3);

	LoadDataFile();
	GetData();
	UpdateLabels(FALSE);

	listDataItem.GetCount() == 0 ? iIndex = 0 : iIndex = 1;
	sError.Format("Editor - Data Item Data File (%i of %i)",iIndex,listDataItem.GetCount());
	SetWindowText(sError);

	return CDialog::OnInitDialog();
}