예제 #1
0
	//--------------------------------------------------
	// As of writing this, you can use:
	// FAST, STAR, SIFT, SURF, MSER, GFTT, HARRIS, L
	vector<KeyPoint> MatchableImage::findFeatures(string alg_name)
	{
		log(LOG_LEVEL_DEBUG, "finding features using %s", alg_name.c_str());
		
		
		if(featuresCurrent && featureAlgUsed.compare(alg_name)==0) return features;
		
		if(empty())
		{
			log(LOG_LEVEL_ERROR, "in findFeatures(), image is empty");
		}
		
		
		// "L" isn't in the "createDetector" thingie.
		// TO DO:  Figure out what these vars do & how to pass them in!
		// For that matter, how to pass in parameters to any of the other feature detectors?
		if(alg_name.compare("L")==0)
		{
			Size patchSize(32, 32);
			int radius = 7;
			int threshold = 20;
			int nOctaves=2;
			int nViews=2000;
			int clusteringDistance = 2;
			ldetector = LDetector(radius, threshold, nOctaves, nViews, patchSize.width, clusteringDistance);
			ldetector.setVerbose(true);
			
			double backgroundMin=0;
			double backgroundMax=256;
			double noiseRange=5;
			bool randomBlur=true;
			double lambdaMin=0.8;
			double lambdaMax=1.2;
			double thetaMin=-CV_PI/2;
			double thetaMax=CV_PI/2;
			double phiMin=-CV_PI/2;
			double phiMax=CV_PI/2;
			gen = PatchGenerator(backgroundMin, backgroundMax, noiseRange, randomBlur, 
								 lambdaMin, lambdaMax, thetaMin, thetaMax, phiMin, phiMax);
			int maxPoints=100;
			ldetector.getMostStable2D(bw(), features, maxPoints, gen);
		}
		else 
		{
			Ptr<FeatureDetector> detector = createFeatureDetector( alg_name );
			if(detector==0)
			{
				log(LOG_LEVEL_ERROR, "Feature detector %s not found!", alg_name.c_str());
			}
			
			detector->detect( bw(), features );
		}
		
		log(LOG_LEVEL_DEBUG, "in findFeatures(), %d features", features.size());
		featuresCurrent = true;
		descriptorsCurrent = false;
		matcherTrained=false;
		featureAlgUsed=alg_name;
		return features;
	}
예제 #2
0
void scroller::dragger_area(int &x1, int &y1, int &x2, int &y2) {
	if (vert) {
		x1 = x + l;
		y1 = y + bh();
		x2 = x + l + bw() - 1;
		y2 = y + h - bh() - 1;
	} else {
		x1 = x + bw();
		y1 = y + h;
		x2 = x + l - bw();
		y2 = y + h + bh() - 1;
	}
}
예제 #3
0
HRESULT DispReel::SaveData(IStream *pstm, HCRYPTHASH hcrypthash, HCRYPTKEY hcryptkey)
{
   BiffWriter bw(pstm, hcrypthash, hcryptkey);

   bw.WriteStruct(FID(VER1), &m_d.m_v1, sizeof(Vertex2D));
   bw.WriteStruct(FID(VER2), &m_d.m_v2, sizeof(Vertex2D));
   bw.WriteInt(FID(CLRB), m_d.m_backcolor);
   bw.WriteBool(FID(TMON), m_d.m_tdr.m_fTimerEnabled);
   bw.WriteInt(FID(TMIN), m_d.m_tdr.m_TimerInterval);
   bw.WriteBool(FID(TRNS), m_d.m_fTransparent);
   bw.WriteString(FID(IMAG), m_d.m_szImage);
   bw.WriteString(FID(SOUN), m_d.m_szSound);
   bw.WriteWideString(FID(NAME), (WCHAR *)m_wzName);
   bw.WriteFloat(FID(WDTH), m_d.m_width);
   bw.WriteFloat(FID(HIGH), m_d.m_height);
   const float reel = (float)m_d.m_reelcount;
   bw.WriteFloat(FID(RCNT), reel);
   bw.WriteFloat(FID(RSPC), m_d.m_reelspacing);
   bw.WriteFloat(FID(MSTP), m_d.m_motorsteps);
   const float dig = (float)m_d.m_digitrange;
   bw.WriteFloat(FID(RANG), dig);
   bw.WriteInt(FID(UPTM), m_d.m_updateinterval);
   bw.WriteBool(FID(UGRD), m_d.m_fUseImageGrid);
   bw.WriteBool(FID(VISI), m_d.m_fVisible);
   bw.WriteInt(FID(GIPR), m_d.m_imagesPerGridRow);

   ISelect::SaveData(pstm, hcrypthash, hcryptkey); //add BDS2

   bw.WriteTag(FID(ENDB));

   return S_OK;
}
예제 #4
0
bool MeasuresExporter::MeasuresExporterAV::save(FieldDescribedPoints meas, std::string filename, const double quota_slm, const bool saveFieldValues) {
	const auto field_values = meas.getField_values();
	const auto values = meas.getValues();

	try {
		FileWriter bw(filename);

		for (unsigned i = 0; i<values.size(); i++) {
			if (i > 0)			// vai a capo (quindi l'ultima riga non avrà il '\n')
				bw.write('\n');

			for (unsigned k = 0; k<values[i].size(); k++) {
				if (k > 0)
					bw.write(DEFAULT_SEPARATOR);

				std::string vf = values[i][k];

				if (i == 0 && !Utils::startsWith(values[i][k], "\"") && !Utils::endsWith(values[i][k], "\""))	// sulla prima riga, se i campi non sono "-escapati, escape
					vf = "\"" + vf + "\"";

				bw.write(vf);
			}

			if (saveFieldValues)
				bw.write(DEFAULT_SEPARATOR + (i == 0 ? "\"FieldValue\"" : Utils::formatDouble(field_values[i - 1], 2)));
		}

		return true;
	}
	catch (const std::exception& e) {
		Utils::MessageBox("Error writing AV measure file:\n" + std::string(e.what()), "ERRORE");
		return false;
	}
}
예제 #5
0
HRESULT Bumper::SaveData(IStream *pstm, HCRYPTHASH hcrypthash, HCRYPTKEY hcryptkey)
{
   BiffWriter bw(pstm, hcrypthash, hcryptkey);

   bw.WriteStruct(FID(VCEN), &m_d.m_vCenter, sizeof(Vertex2D));
   bw.WriteFloat(FID(RADI), m_d.m_radius);
   bw.WriteBool(FID(TMON), m_d.m_tdr.m_fTimerEnabled);
   bw.WriteInt(FID(TMIN), m_d.m_tdr.m_TimerInterval);
   bw.WriteFloat(FID(THRS), m_d.m_threshold);
   bw.WriteFloat(FID(FORC), m_d.m_force);
   bw.WriteFloat(FID(HISC), m_d.m_heightScale);
   bw.WriteFloat(FID(RISP), m_d.m_ringSpeed);
   bw.WriteFloat(FID(ORIN), m_d.m_orientation);
   bw.WriteString(FID(MATR), m_d.m_szCapMaterial);
   bw.WriteString(FID(BAMA), m_d.m_szBaseMaterial);
   bw.WriteString(FID(SKMA), m_d.m_szSkirtMaterial);
   bw.WriteString(FID(RIMA), m_d.m_szRingMaterial);
   bw.WriteString(FID(SURF), m_d.m_szSurface);
   bw.WriteWideString(FID(NAME), (WCHAR *)m_wzName);

   bw.WriteBool(FID(CAVI), m_d.m_fCapVisible);
   bw.WriteBool(FID(BSVS), m_d.m_fBaseVisible);
   bw.WriteBool(FID(RIVS), m_d.m_fRingVisible);
   bw.WriteBool(FID(SKVS), m_d.m_fSkirtVisible);
   bw.WriteBool(FID(HAHE), m_d.m_fHitEvent);
   bw.WriteBool(FID(COLI), m_d.m_fCollidable);
   bw.WriteBool(FID(REEN), m_d.m_fReflectionEnabled);

   ISelect::SaveData(pstm, hcrypthash, hcryptkey);

   bw.WriteTag(FID(ENDB));

   return S_OK;
}
예제 #6
0
bool AntennaExporter::AntennaExporterANT::save(Antenna antenna, std::string filename) const {

	try {
		FileWriter bw(filename);

		{	// horizontal plane
			const AntennaPattern h = antenna.getPlaneH();

			for (int i = 0; i<360; i++) {
				const AntennaPattern::AntennaPatternValue res = h.getResult(i);
				bw.write(Utils::formatDoubleAsNeeded(res.value0) + "\n");
			}
		}

		{	// vertical plane
			const AntennaPattern v = antenna.getPlaneV();

			for (int i = 0; i<360; i++) {
				const AntennaPattern::AntennaPatternValue res = v.getResult(i);
				bw.write(Utils::formatDoubleAsNeeded(res.value0) + (i<360 - 1 ? "\n" : ""));
			}
		}

		return true;
	}
	catch (...) { return false; }
}
예제 #7
0
파일: bumper.cpp 프로젝트: c-f-h/vpinball
HRESULT Bumper::SaveData(IStream *pstm, HCRYPTHASH hcrypthash, HCRYPTKEY hcryptkey)
{
   BiffWriter bw(pstm, hcrypthash, hcryptkey);

   bw.WriteStruct(FID(VCEN), &m_d.m_vCenter, sizeof(Vertex2D));
   bw.WriteFloat(FID(RADI), m_d.m_radius);
   bw.WriteBool(FID(TMON), m_d.m_tdr.m_fTimerEnabled);
   bw.WriteInt(FID(TMIN), m_d.m_tdr.m_TimerInterval);
   bw.WriteFloat(FID(THRS), m_d.m_threshold);
   bw.WriteFloat(FID(FORC), m_d.m_force);
   bw.WriteFloat(FID(HOFF), m_d.m_heightoffset);
   bw.WriteFloat(FID(OVRH), m_d.m_overhang);
   bw.WriteInt(FID(COLR), m_d.m_color);
   bw.WriteInt(FID(SCLR), m_d.m_sidecolor);
   bw.WriteString(FID(IMAG), m_d.m_szImage);
   bw.WriteString(FID(SURF), m_d.m_szSurface);
   bw.WriteWideString(FID(NAME), (WCHAR *)m_wzName);
   bw.WriteInt(FID(STAT), m_d.m_state);
   bw.WriteString(FID(BPAT), m_rgblinkpattern);
   bw.WriteInt(FID(BINT), m_blinkinterval);

   bw.WriteBool(FID(TRNS), m_d.m_fFlashWhenHit);

   bw.WriteBool(FID(CSHD), m_d.m_fCastsShadow);
   bw.WriteBool(FID(BVIS), m_d.m_fVisible);
   bw.WriteBool(FID(BSVS), m_d.m_fSideVisible);

   ISelect::SaveData(pstm, hcrypthash, hcryptkey);

   bw.WriteTag(FID(ENDB));

   return S_OK;
}
예제 #8
0
void Movi::automov(uint8_t pck1,uint8_t pck2,uint8_t pck3,uint8_t pck4){
	if(pck1 == MOVSIMPLE){
		if(pck2==MOVFW) fw(pck4);
		if(pck2==MOVBW) bw(pck4);
		if(pck2==MOVLE){ 
			if(pck3==TURNSHORT) left(pck4,1);
			if(pck3==TURNLONG) left(pck4,0);
		}
		if(pck2==MOVRI){ 
			if(pck3==TURNSHORT) right(pck4,1);
			if(pck3==TURNLONG) right(pck4,0);
		}
		if(pck2==MOVST){
			if(pck4==MOTOR1) stop(1);
			if(pck4==MOTOR2) stop(2);
			if(pck4==MOTORALL) stop(3);
		}
	}
	else if(pck1 == MOVRAW){
		if(pck2==BWBW)	raw(pck3,0,pck4,1);
		if(pck2==FWBW)	raw(pck3,0,pck4,0);
		if(pck2==BWFW)	raw(pck3,1,pck4,1);
		if(pck2==FWFW)	raw(pck3,1,pck4,0);
	}





}
예제 #9
0
파일: bwconvert.cpp 프로젝트: KDE/digikam
bool BWConvert::toolOperations()
{
    if (!loadToDImg())
    {
        return false;
    }

    BWSepiaContainer prm;

    prm.filmType                     = settings()[QLatin1String("filmType")].toInt();
    prm.filterType                   = settings()[QLatin1String("filterType")].toInt();
    prm.toneType                     = settings()[QLatin1String("toneType")].toInt();
    prm.bcgPrm.contrast              = settings()[QLatin1String("contrast")].toDouble();
    prm.strength                     = settings()[QLatin1String("strength")].toDouble();

    CurvesContainer curves((ImageCurves::CurveType)settings()[QLatin1String("curvesType")].toInt(), true);
    curves.initialize();
    curves.values[LuminosityChannel] = settings()[QLatin1String("curves")].value<QPolygon>();
    prm.curvesPrm                    = curves;

    BWSepiaFilter bw(&image(), 0L, prm);
    applyFilter(&bw);

    return (savefromDImg());
}
예제 #10
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent), ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    QPixmap pix(":/data/monkey_on_64x64.png");

    QImage mask(16, 16, QImage::Format_MonoLSB);
    QImage bw(16, 16, QImage::Format_MonoLSB);
    mask.fill(0);
    bw.fill(0);
    for (int x = 0; x < 16; x++) {
        bw.setPixel(x, x, 1);
        bw.setPixel(x, 15 - x, 1);
        mask.setPixel(x, x, 1);
        mask.setPixel(x, 15 - x, 1);
        if (x > 0 && x < 15) {
            mask.setPixel(x - 1, x, 1);
            mask.setPixel(x + 1, x, 1);
            mask.setPixel(x - 1, 15 - x, 1);
            mask.setPixel(x + 1, 15 - x, 1);
        }
    }

    ccurs = QCursor(pix);
    bcurs = QCursor(QBitmap::fromImage(bw), QBitmap::fromImage(mask));
    ui->label->setCursor(ccurs);

    timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()), this, SLOT(toggleOverrideCursor()));
    timer->start(2000);

    override = 0;
예제 #11
0
bool FieldExporter::FieldExporterCSV::save(const FieldVerticalPlane* plane, std::string filename, double min_value, int numdec)
{
	if (Config::getInstance().isWarnOverwriteSimulations() && Utils::abortOnExistingAndDontOverwrite(filename))
		return false;

	try {
		FileWriter bw(filename);
		bw.write("X\tY\tZ\tCE(V/m)\n");

		const yMatrix<glm::vec3> pts = plane->getPoints();
		const yMatrix<double> values = plane->get();
		for (unsigned y = 0; y<pts.getSizeY(); y++)
			for (unsigned x = 0; x<pts.getSizeX(); x++)
				if (values.get(x, y) >= min_value) {
					const glm::vec3 p = pts.get(x, y);
					bw.write("" + std::to_string(p.x) + "\t" + std::to_string(p.y) + "\t" + std::to_string(p.z) + "\t" + Utils::formatDouble(values.get(x, y), numdec) + "\n");
				}

		bw.close();
		return true;
	}
	catch (const std::exception& e) {
		Utils::MessageBox("Error saving Vertical Field:\n" + std::string(e.what()), "ERROR");
		return false;
	}
}
예제 #12
0
bool AntennaExporter::AntennaExporterMSI::save(Antenna antenna, std::string filename) const {

	try {
		FileWriter bw(filename);

		bw.write("NAME " + antenna.getName() + "\n");
		bw.write("FREQUENCY " + Utils::formatDoubleAsNeeded(antenna.getFrequency()) + "\n");
		bw.write("GAIN " + Utils::formatDoubleAsNeeded(antenna.getGain()) + "\n");
		bw.write("TILT " + antenna.getTilt() + "\n");
		bw.write("COMMENT " + antenna.getComment() + "\n");

		{	// horizontal plane
			const AntennaPattern h = antenna.getPlaneH();
			const std::vector<double> hvalues = h.getValues();
			const double hdetail = h.getDetail();
			bw.write("HORIZONTAL " + std::to_string(hvalues.size()) + "\n");
			for (unsigned i = 0; i<hvalues.size(); i++)
				bw.write(Utils::formatDoubleAsNeeded(i*hdetail) + " " + Utils::formatDoubleAsNeeded(hvalues[i]) + "\n");
		}

		{	// vertical plane
			const AntennaPattern v = antenna.getPlaneV();
			const std::vector<double> vvalues = v.getValues();
			const double vdetail = v.getDetail();
			bw.write("VERTICAL " + std::to_string(vvalues.size()) + "\n");
			for (unsigned i = 0; i<vvalues.size(); i++)
				bw.write(Utils::formatDoubleAsNeeded(i*vdetail) + " " + Utils::formatDoubleAsNeeded(vvalues[i]) + "\n");
		}

		return true;
	}
	catch (...) { return false; }
}
예제 #13
0
HRESULT Flasher::SaveData(IStream *pstm, HCRYPTHASH hcrypthash, HCRYPTKEY hcryptkey)
{
   BiffWriter bw(pstm, hcrypthash, hcryptkey);

   bw.WriteFloat(FID(FHEI), m_d.m_height);
   bw.WriteFloat(FID(FLAX), m_d.m_vCenter.x);
   bw.WriteFloat(FID(FLAY), m_d.m_vCenter.y);
   bw.WriteFloat(FID(FROX), m_d.m_rotX);
   bw.WriteFloat(FID(FROY), m_d.m_rotY);
   bw.WriteFloat(FID(FROZ), m_d.m_rotZ);
   bw.WriteInt(FID(COLR), m_d.m_color);
   bw.WriteBool(FID(TMON), m_d.m_tdr.m_fTimerEnabled);
   bw.WriteInt(FID(TMIN), m_d.m_tdr.m_TimerInterval);
   bw.WriteWideString(FID(NAME), (WCHAR *)m_wzName);
   bw.WriteString(FID(IMAG), m_d.m_szImageA);
   bw.WriteString(FID(IMAB), m_d.m_szImageB);
   bw.WriteInt(FID(FALP), m_d.m_fAlpha);
   bw.WriteFloat(FID(MOVA), m_d.m_modulate_vs_add);
   bw.WriteBool(FID(FVIS), m_d.m_IsVisible);
   bw.WriteBool(FID(DSPT), m_d.m_fDisplayTexture);
   bw.WriteBool(FID(ADDB), m_d.m_fAddBlend);
   bw.WriteBool(FID(IDMD), m_d.m_IsDMD);
   bw.WriteFloat(FID(FLDB), m_d.m_depthBias);
   bw.WriteInt(FID(ALGN), m_d.m_imagealignment);
   bw.WriteInt(FID(FILT), m_d.m_filter);
   bw.WriteInt(FID(FIAM), m_d.m_fFilterAmount);
   ISelect::SaveData(pstm, hcrypthash, hcryptkey);
   HRESULT hr;
   if (FAILED(hr = SavePointData(pstm, hcrypthash, hcryptkey)))
      return hr;

   bw.WriteTag(FID(ENDB));

   return S_OK;
}
예제 #14
0
파일: spinner.cpp 프로젝트: jsm174/vpinball
HRESULT Spinner::SaveData(IStream *pstm, HCRYPTHASH hcrypthash)
{
   BiffWriter bw(pstm, hcrypthash);

   bw.WriteStruct(FID(VCEN), &m_d.m_vCenter, sizeof(Vertex2D));
   bw.WriteFloat(FID(ROTA), m_d.m_rotation);
   bw.WriteBool(FID(TMON), m_d.m_tdr.m_fTimerEnabled);
   bw.WriteInt(FID(TMIN), m_d.m_tdr.m_TimerInterval);
   bw.WriteFloat(FID(HIGH), m_d.m_height);
   bw.WriteFloat(FID(LGTH), m_d.m_length);
   bw.WriteFloat(FID(AFRC), m_d.m_damping);

   bw.WriteFloat(FID(SMAX), m_d.m_angleMax);
   bw.WriteFloat(FID(SMIN), m_d.m_angleMin);
   bw.WriteFloat(FID(SELA), m_d.m_elasticity);
   bw.WriteBool(FID(SVIS), m_d.m_fVisible);
   bw.WriteBool(FID(SSUPT), m_d.m_fShowBracket);
   bw.WriteString(FID(MATR), m_d.m_szMaterial);
   bw.WriteString(FID(IMGF), m_d.m_szImage);
   bw.WriteString(FID(SURF), m_d.m_szSurface);
   bw.WriteWideString(FID(NAME), (WCHAR *)m_wzName);

   ISelect::SaveData(pstm, hcrypthash);

   bw.WriteTag(FID(ENDB));

   return S_OK;
}
예제 #15
0
파일: algorithms.cpp 프로젝트: ydxt25/IM-2
int HoughTester::DoYourJob(Magick::Image& image)
{
    std::cout<<"\"noise\";\"R\";\"FI\";\"value\""<<std::endl;

    for(int level=0; level<NumberOfNoiseLevels+2; level++)
    {
        noise.Percent=level*100/(NumberOfNoiseLevels+1);

        for(int pass=0; pass<NumberOfTriesPerLevel; pass++)
        {
            Magick::Image copy=image;
            noise(copy);
            bw(copy);
            accumulator(copy);
            blur(accumulator.Accumulator);

            HoughResult max=accumulator.Maximum();

            std::cout<<noise.Percent<<";"<<max.R<<";"<<max.Fi<<";"<<max.Value<<std::endl;

            if(level==0)
                break;
        }
    }
}
예제 #16
0
int main() { 
  typedef funct::Product<funct::Parameter, funct::BreitWigner>::type FitFunction;
  typedef fit::HistoChiSquare<FitFunction> ChiSquared;
  try {
    funct::Parameter yield("Yield", 1000);
    funct::Parameter mass("Mass", 91.2);
    funct::Parameter gamma("Gamma", 2.50);
    funct::BreitWigner bw(mass, gamma);
    
    FitFunction f = yield * bw;
    TF1 startFun = root::tf1("startFun", f, 0, 200, yield, mass, gamma);
    TH1D histo("histo", "Z mass (GeV/c)", 200, 0, 200);
    histo.FillRandom("startFun", yield);
    ChiSquared chi2(f, &histo, 80, 120);
    fit::RootMinuit<ChiSquared> minuit(chi2, true);
    minuit.addParameter(yield, 100, 0, 10000);
    minuit.addParameter(mass, 2, 70, 120);
    minuit.addParameter(gamma, 1, 0, 5);
    minuit.minimize();
    minuit.migrad();
  } catch(std::exception & err){
    std::cerr << "Exception caught:\n" << err.what() << std::endl;
    return 1;
  }
  
  return 0;
}
예제 #17
0
bool FieldExporter::FieldExporterCSV::save(const FieldHorizontalPlane* plane, std::string filename, double min_value, bool save3d, int numdec)
{
	if (Config::getInstance().isWarnOverwriteSimulations() && Utils::abortOnExistingAndDontOverwrite(filename))
		return false;

	try {
		const auto values = plane->get();

		FileWriter bw(filename);
		bw.write("X\tY\t" + (save3d ? "Z\t" : std::string("")) + "CE(V/m)\n");
		const double Z = plane->getZ();

		for (unsigned yi = 0; yi<values.getSizeY(); yi++) {
			const double realy = plane->getCoordY(yi);

			for (unsigned xi = 0; xi<values.getSizeX(); xi++) {
				const double realx = plane->getCoordX(xi);;

				const double value = values.get(xi, yi);
				if (min_value <= 0 || value>min_value)
					bw.write("" + std::to_string(realx) + "\t" + std::to_string(realy) + "\t" + (save3d ? std::to_string(Z) + "\t" : "") + Utils::formatDouble(value, numdec) + "\n");
			}
		}

		bw.close();
		return true;
	}
	catch (const std::exception& e) {
		Utils::MessageBox("Error saving Field:\n" + std::string(e.what()), "ERROR");
		return false;
	}
}
예제 #18
0
BinaryData DBUtils::getBlkDataKey(uint32_t height,
   uint8_t  dup)
{
   BinaryWriter bw(5);
   bw.put_uint8_t(DB_PREFIX_TXDATA);
   bw.put_BinaryData(heightAndDupToHgtx(height, dup));
   return bw.getData();
}
예제 #19
0
HRESULT ISelect::SaveData(IStream *pstm, HCRYPTHASH hcrypthash, HCRYPTKEY hcryptkey)
{
   BiffWriter bw(pstm, hcrypthash, hcryptkey);

   bw.WriteBool(FID(LOCK), m_fLocked);
   bw.WriteInt(FID(LAYR), layerIndex);
   return S_OK;
}
예제 #20
0
파일: GeoSaver.cpp 프로젝트: asmCode/ssg02
void GeoSaver::SaveMeshes(std::vector<Scene3DMesh*> &meshes, std::ostream &os)
{
	BinaryWriter bw(&os);

	bw.Write((int)meshes.size());

	for (int i = 0; i < (int)meshes.size(); i++)
		SaveMesh(meshes[i], bw);
}
예제 #21
0
void scroller::draw_first(image *screen) {
	if (sx >= t)
		sx = t - 1;
	draw(0, screen);
	screen->widget_bar(b1x(), b1y(), b1x() + bw() - 1, b1y() + bh() - 1,
			wm->bright_color(), wm->medium_color(), wm->dark_color());
	screen->widget_bar(b2x(), b2y(), b2x() + bw() - 1, b2y() + bh() - 1,
			wm->bright_color(), wm->medium_color(), wm->dark_color());
	show_icon(screen, b1x() + 2, b1y() + 2, bw() - 4, bh() - 4, b1());
	show_icon(screen, b2x() + 2, b2y() + 2, bw() - 4, bh() - 4, b2());

	int x1, y1, x2, y2;
	dragger_area(x1, y1, x2, y2);
	screen->bar(x1, y1, x2, y2, wm->black());
	screen->bar(x1 + 1, y1 + 1, x2 - 1, y2 - 1, wm->medium_color());
	draw_widget(screen, 0);
	scroll_event(sx, screen);
}
예제 #22
0
void scroller::area(int &x1, int &y1, int &x2, int &y2)
{
  area_config();
  x1=m_pos.x-1; y1=m_pos.y-1;
  if (vert)
  { x2=m_pos.x+l+bw();  y2=m_pos.y+h; }
  else
  { x2=m_pos.x+l;  y2=m_pos.y+h+bh(); }
}
예제 #23
0
int OdroidSmartPowerSource::sendCommand(Command cmd) {
	lastCmd = cmd;
	QByteArray bw(65,'\0');
	bw[1] = static_cast<unsigned char>(cmd);
	bw[2] = 0x0; //param;
	int ret = write(bw);
	assert(ret != -1);
	return ret;
}
예제 #24
0
int scroller::mouse_to_drag(int mx, int my) {
	int x1, y1, x2, y2;
	dragger_area(x1, y1, x2, y2);

	if (vert) {
		int h = (y2 - y1 + 1 - bh());
		if (h)
			return (my - y - bh() - bh() / 2) * (t - 1) / h;
		else
			return 0;
	} else {
		int w = (x2 - x1 + 1 - bw());
		if (w)
			return (mx - x - bw() - bw() / 2) * (t - 1) / w;
		else
			return 0;
	}
}
예제 #25
0
BinaryData DBUtils::getBlkDataKeyNoPrefix(uint32_t height,
   uint8_t  dup,
   uint16_t txIdx)
{
   BinaryWriter bw(6);
   bw.put_BinaryData(heightAndDupToHgtx(height, dup));
   bw.put_uint16_t(txIdx, BE);
   return bw.getData();
}
예제 #26
0
void scroller::wig_area(int &x1, int &y1, int &x2, int &y2) {
	int sx1, sy1, sx2, sy2;
	dragger_area(sx1, sy1, sx2, sy2);
	if (vert) {
		x1 = x + l + 1;
		if (t < 2)
			y1 = y + bh() + 1;
		else
			y1 = y + bh() + 1 + sx * (sy2 - sy1 + 1 - bh()) / (t - 1);
	} else {
		if (t < 2)
			x1 = x + bw() + 1;
		else
			x1 = x + bw() + 1 + sx * (sx2 - sx1 + 1 - bw()) / (t - 1);
		y1 = y + h + 1;
	}
	x2 = x1 + bw() - 3;
	y2 = y1 + bh() - 3;

}
예제 #27
0
void ActiveContourSeed::getSparseCoordinates_full(Array1D<int> *xS,
		Array1D<int> *yS, Array1D<int> *zS) {

	// get binary segmentation
	Image3D<float> bw(*phi_);
	for (int x = 0; x < _dimx_Rel; x++) {
		for (int y = 0; y < _dimy_Rel; y++) {
			for (int z = 0; z < _dimz_Rel; z++) {
				if (bw(x, y, z) <= 0) {
					bw(x, y, z) = 1;
				} else {
					bw(x, y, z) = 0;
				}
			}
		}
	}

	// get sparse coordinates
	getSparseCoordinates(xS, yS, zS, &bw);
}
예제 #28
0
BinaryData DBUtils::getBlkDataKey(uint32_t height,
   uint8_t  dup,
   uint16_t txIdx,
   uint16_t txOutIdx)
{
   BinaryWriter bw(9);
   bw.put_uint8_t(DB_PREFIX_TXDATA);
   bw.put_BinaryData(heightAndDupToHgtx(height, dup));
   bw.put_uint16_t(txIdx, BE);
   bw.put_uint16_t(txOutIdx, BE);
   return bw.getData();
}
예제 #29
0
bool SGMExporter::DoExport(const TCHAR *name, ExpInterface *ei, Interface *max_interface)
{
	scene = GetIGameInterface();
	assert(scene != NULL);

	std::string sceneName = StringUtils::ToNarrow(scene->GetSceneFileName());
	sceneName.replace(sceneName.find(".max"), 4, "");
	fileName = StringUtils::ToNarrow(name) + sceneName + ".skm";

	Log::StartLog(true, false, false);
	Log::LogT("=== exporting skinned mesh to file '%s'", fileName.c_str());

	scene->SetStaticFrame(0);

	IGameConversionManager *cm = GetConversionManager();
	assert(cm != NULL);

	cm->SetCoordSystem(IGameConversionManager::IGAME_OGL);

	if (!scene->InitialiseIGame(false))
	{
		Log::LogT("error: couldnt initialize scene");
		return false;
	}

	meshesCount = 0;

	std::ofstream fileStream(fileName.c_str(), std::ios::binary);
	BinaryWriter bw(&fileStream);

	/*

	1.2
		- vertex channels in mesh part

	*/

	bw.Write("FTSMDL", 6);
	bw.Write((unsigned short)((1 << 8) | 2)); // version 1.2

	bw.Write((int)0);

	std::vector<Scene3DMesh*> meshes;
	if (!GetMeshes(meshes, &bw))
		return false;

	fileStream.seekp(8, std::ios::beg);
	//fileStream.seekp(0, std::ios::beg);
	bw.Write((int)meshesCount);
	fileStream.close();

	return true;
}
예제 #30
0
EvtComplex EvtMassAmp::amplitude(const EvtPoint1D& p) const 
{
  // Modified vertex

  double m = p.value();
  // keep things from crashing..

  if ( m< (_vd.mA()+_vd.mB()) ) return EvtComplex(0.,0.);

  EvtTwoBodyKine vd(_vd.mA(),_vd.mB(),m);
  
  // Compute mass-dependent width for relativistic propagator

  EvtPropBreitWignerRel bw(_prop.m0(),_prop.g0()*_vd.widthFactor(vd)); 
  EvtComplex amp = bw.evaluate(m);


  // Birth vertex factors

  if(_useBirthFact) {

    assert(_vb);
    if ( (m+_vb->mB()) < _vb->mAB() ) {  
      EvtTwoBodyKine vb(m,_vb->mB(),_vb->mAB());
      amp *= _vb->phaseSpaceFactor(vb,EvtTwoBodyKine::AB);
      amp *= sqrt((vb.p() / _vb->pD()));

      if(_useBirthFactFF) {
	
	assert(_vb);
	amp *= _vb->formFactor(vb);
      }
    }
    else{
      if ( _vb->L() != 0 ) amp=0.;
    }
  }


  // Decay vertex factors

  if(_useDeathFact) {
    amp *= _vd.phaseSpaceFactor(vd,EvtTwoBodyKine::AB);
    amp *= sqrt((vd.p() / _vd.pD()));
  }
  if(_useDeathFactFF) amp *= _vd.formFactor(vd);

  return amp;
}