Exemple #1
0
 // Demonstrate bounding polygonal contours with circles and rectangles.
 //
 DemoDisplay(const cv::Mat &s):
     source(s), bounds(s.size(), CV_8UC3),
     bar(100), maxBar(std::numeric_limits<uchar>::max())
 {
     makeWindow("Original", source, 2);
     makeWindow("Bounds",   bounds);
     makeTrackbar("Threshold:", "Original", &bar, maxBar);
     makeTrackbar("Threshold:", "Bounds",   &bar, maxBar);
     cv::imshow("Original", source);
 }
Exemple #2
0
// Return src after applying a default Gaussian blur with a kernel of size
// (kernelSize x kernelSize) and converting to grayscale and showing the
// results.
//
static cv::Mat showOriginalBlurGray(const cv::Mat &src, int kernelSize)
{
    static const double sigmaX = 0.0;
    static const double sigmaY = 0.0;
    static const int borderKind = cv::BORDER_DEFAULT;
    const cv::Size kernel(kernelSize, kernelSize);
    makeWindow("Original", src, 2);
    cv::Mat blur;
    cv::GaussianBlur(src, blur, kernel, sigmaX, sigmaY, borderKind);
    makeWindow("Original Blur", blur);
    cv::Mat result;
    cv::cvtColor(blur, result, cv::COLOR_RGB2GRAY);
    makeWindow("Original Blurred Grayscale", result);
    return result;
}
Exemple #3
0
/*
   ** makeVisible().
   **        We can't really make windows visible, or invisible.  So we
   **        have to delete the entire window when making it visible,
   **        and create it again when making it visible.
 */
void
makeVisible (TuiGenWinInfoPtr winInfo, int visible)
{
  /* Don't tear down/recreate command window */
  if (winInfo->type == CMD_WIN)
    return;

  if (visible)
    {
      if (!winInfo->isVisible)
	{
	  makeWindow (
		       winInfo,
	   (winInfo->type != CMD_WIN && !m_winIsAuxillary (winInfo->type)));
	  winInfo->isVisible = TRUE;
	}
      tuiRefreshWin (winInfo);
    }
  else if (!visible &&
	   winInfo->isVisible && winInfo->handle != (WINDOW *) NULL)
    {
      winInfo->isVisible = FALSE;
      tuiClearWin (winInfo);
      tuiDelwin (winInfo->handle);
      winInfo->handle = (WINDOW *) NULL;
    }

  return;
}				/* makeVisible */
 // Find and display contours in image s.
 //
 DemoDisplay(const cv::Mat &s):
     sourceImage(s), grayImage(grayScale(s)), bar(23), maxBar(100)
 {
     sourceImage.copyTo(cornersImage);
     makeWindow("Corners", cornersImage);
     makeTrackbar("Max Corners:", "Corners", &bar, maxBar);
 }
Exemple #5
0
RuskWindow* makeRusk()
{
	RuskWindow *rusk;
	
	if((rusk = malloc(sizeof(RuskWindow))) == NULL)
	{
		return NULL;
	}

	if(makeWindow(rusk) != 0)
	{
		return NULL;
	}

	if(setupWebView(rusk) != 0)
	{
		return NULL;
	}

	if(connectDataBase(rusk) != 0)
	{
		return NULL;
	}

	g_ruskCounter++;

	return rusk;
}
Exemple #6
0
// Show application of Laplacian() to src.
//
static void showLaplacian(const cv::Mat &src, int kernelSize)
{
    static const int borderKind = cv::BORDER_DEFAULT;
    static const int depth = CV_16S;
    static const double scale = 1.0;
    static const double delta = 0.0;
    static const double alpha = 0.5;
    static const double beta  = 0.5;
    static const double gamma = 0.0;
    cv::Mat dst, absDst;
    cv::Laplacian(src, dst, depth, kernelSize, scale, delta, borderKind);
    cv::convertScaleAbs(dst, absDst);
    makeWindow("Laplacian", absDst);
}
Exemple #7
0
ButtonRefWindow::ButtonRefWindow(QWidget *parent, QString const &typeName
		, qReal::models::LogicalModelAssistApi const &logicalModelAssistApi
		, int role, const QModelIndex &index
		, qReal::MainWindow *mainWindow)
	: QPushButton(parent)
	, mName(typeName)
	, mApi(logicalModelAssistApi.logicalRepoApi())
	, mRole(role)
	, mIndex(index)
	, mMainWindow(mainWindow)
{
	setText("Reference button");
	connect(this, SIGNAL(clicked()), this, SLOT(makeWindow()));
	show();
}
// Display the count images in bgr and compute their HSV histograms.
// Then compare each histogram to the first one and report results.
//
static void showHistogramComparisons(int count,
                                     const char *name[],
                                     const cv::Mat bgr[])
{
    std::vector<cv::Mat> hsv(count);
    std::vector<cv::Mat> histogram(count);
    for (int i = 0; i < count; ++i) {
        makeWindow(name[i], bgr[i]);
        cv::cvtColor(bgr[i], hsv[i], cv::COLOR_BGR2HSV);
    }
    for (int i = 0; i < histogram.size(); ++i) {
        histogram[i] = calculateHistogram(hsv[i]);
    }
    compareHistograms(histogram, name);
    std::cout << "Press a key to quit." << std::endl;
    cv::waitKey(0);
}
Exemple #9
0
// Set things up and run
int main(int argc, char** argv) {
	makeWindow(argc, argv);
	acquireSharedOpenCLContext();
	initObjects();
	initPrograms();
	initFramebuffers();
	initShaders();
	setupGlutCallbacks();

	camera.pos = MakeVector(0, 0, -12);
	camera.up = MakeVector(0, 1, 0);
	camera.front = MakeVector(0, 0, 1);
	
	glutSetCursor(GLUT_CURSOR_NONE);
	glutMainLoop();

	releaseSharedOpenCLContext();
}
void initializeGame(){
	upperStateWindow = makeWindow(7, 100, 2, 5);

	myPlayGround = makeWindow(PLAY_WIDTH_SIZE, PLAY_HEIGHT_SIZE, PG_LINE_X, 51);
	settingMyPlayGround(myPlayGround);
	myScoreWindow = makeWindow(4, 24 + 12 + 2 + 2, 34, 51);
	myTempBlock = makeWindow(PLAY_WIDTH_SIZE, 12, PG_LINE_X, 53 + PLAY_WIDTH_SIZE + 2);

	otherPlayGround = makeWindow(PLAY_WIDTH_SIZE, PLAY_HEIGHT_SIZE, PG_LINE_X, 5);
	settingOtherPlayGround(otherPlayGround);
	otherScoreWIndow = makeWindow(4, 24 + 12 + 2 + 2, 34, 5);
	otherTempBlock = makeWindow(PLAY_WIDTH_SIZE, 12, PG_LINE_X, 7 + PLAY_WIDTH_SIZE + 2);

	chatWindow = makeWindow(28, 30, PG_LINE_X, 95);
	
	settingMyTemp(myTempBlock);
	settingChat(chatWindow);
	
	//otherPlayGround = makeWindow(40, 20, 25, 50);

}
Exemple #11
0
void Spectrum::initialize(sampleSizes s, PaSampleFormat b, int nr, QString dir)
{
    nrig          = nr;
    userDirectory = dir;
    sizes         = s;
    sizeIQ        = sizes.sample_length / 8; // 512 IQ phase/gain bins
    // initialize FFTW
#ifdef Q_OS_WIN
    if (!fftwWinInit()) {
        return;
    }
    if (in) (fftw_freep) (in);
    if (out) (fftw_freep) (out);
    if (errfunc) (fftw_freep) (errfunc);
    if (plan) (fftw_destroy_planp) (plan);

    in      = (fftw_complex *) (fftw_mallocp) (sizeof(fftw_complex) * sizes.sample_length);
    out     = (fftw_complex *) (fftw_mallocp) (sizeof(fftw_complex) * sizes.sample_length);
    errfunc = (fftw_complex *) (fftw_mallocp) (sizeof(fftw_complex) * sizes.sample_length);
    plan    = (fftw_plan_dft_1dp) (sizes.sample_length, in, out, FFTW_FORWARD, FFTW_MEASURE);
#else
    if (in) fftw_free(in);
    if (out) fftw_free(out);
    if (errfunc) fftw_free(errfunc);
    if (plan) fftw_destroy_plan(plan);

    in      = (fftw_complex *) fftw_malloc(sizeof(fftw_complex) * sizes.sample_length);
    out     = (fftw_complex *) fftw_malloc(sizeof(fftw_complex) * sizes.sample_length);
    errfunc = (fftw_complex *) fftw_malloc(sizeof(fftw_complex) * sizes.sample_length);
    plan    = fftw_plan_dft_1d(sizes.sample_length, in, out, FFTW_FORWARD, FFTW_MEASURE);
#endif
    switch (b) {
    case paInt16:
        bits = 16;
        break;
    case paInt24:
        bits = 24;
        break;
    case paInt32:
        bits = 32;
        break;
    default:
        bits = 16;
    }

    if (output) delete [] output;
    output = new unsigned char[sizes.display_length];

    for (int i = 0; i < SIG_N_AVG; i++) {
        if (peakAvg[i]) delete [] peakAvg[i];
        peakAvg[i] = new double[sizes.spec_length];
    }
    if (spec_smooth) delete [] spec_smooth;
    spec_smooth = new double[sizes.sample_length];
    if (spec_tmp) delete [] spec_tmp;
    spec_tmp = new double[sizes.sample_length];

    if (spec_tmp2) delete [] spec_tmp2;
    spec_tmp2 = new double[sizes.sample_length];

    for (int i = 0; i < sizes.sample_length; i++) {
        spec_tmp[i]    = 0.;
        spec_smooth[i] = 0.;
        spec_tmp2[i]   = 0.;
    }

    if (tmp4) delete [] tmp4;
    tmp4 = new double[sizes.spec_length];
    if (window) delete [] window;
    window = new double[sizes.sample_length];

    makeWindow();

    for (int i = 0; i < sizes.spec_length; i++) {
        tmp4[i] = 0.;
    }
    if (sigOnCnt) delete [] sigOnCnt;
    sigOnCnt = new int[sizes.sample_length];

    if (sigOn) delete [] sigOn;
    sigOn = new bool[sizes.sample_length];

    for (int i = 0; i < sizes.sample_length; i++) {
        sigOnCnt[i] = 2;
        sigOn[i]    = false;
    }
    if (calibSigList) delete [] calibSigList;
    calibSigList = new CalibSignal[sizeIQ];
    for (int i = 0; i < FIT_ORDER; i++) {
        aGain[i]  = 0.;
        aPhase[i] = 0.;
    }
    addOffset=0;

    // intialize to unit gain and zero phase
    aGain[0] = 1.0;
    makeGainPhase();

    readError();
    calcError(true);
}
int main (int argc, char **argv)
{
    FILE    *fp_out, *fp_f1plus, *fp_f1min;
    FILE    *fp_gmin, *fp_gplus, *fp_f2, *fp_pmin;
    int     i, j, l, ret, nshots, Nsyn, nt, nx, nts, nxs, ngath;
    int     size, n1, n2, ntap, tap, di, ntraces, nb, ib;
    int     nw, nw_low, nw_high, nfreq, *xnx, *xnxsyn, *synpos;
    int     reci, mode, ixa, ixb, n2out, verbose, ntfft;
    int     iter, niter, niterh, tracf, *muteW, pad, nt0, ampest, *hmuteW, *hxnxsyn;
    int     hw, smooth, above, shift, *ixpossyn, npossyn, ix, first=1;
    float   fmin, fmax, *tapersh, *tapersy, fxf, dxf, fxs2, *xsrc, *xrcv, *zsyn, *zsrc, *xrcvsyn;
	float	*hzsyn, *hxsyn, *hxrcvsyn, *hG_d, xloc, zloc, *HomG;
    double  t0, t1, t2, t3, tsyn, tread, tfft, tcopy, energyNi, *J;
    float   d1, d2, f1, f2, fxs, ft, fx, *xsyn, dxsrc, Q, f0, *Costdet;
    float   *green, *f2p, *pmin, *G_d, dt, dx, dxs, scl, mem, *Image, *Image2;
    float   *f1plus, *f1min, *iRN, *Ni, *trace, *Gmin, *Gplus, *Gm0;
    float   xmin, xmax, weight, tsq, *Gd, *amp, bstart, bend, db, *bdet, bp, b, bmin;
    complex *Refl, *Fop, *cshot;
    char    *file_tinv, *file_shot, *file_green, *file_iter, *file_wav, *file_ray, *file_amp, *file_img, *file_cp, *file_rays, *file_amps;
    char    *file_f1plus, *file_f1min, *file_gmin, *file_gplus, *file_f2, *file_pmin, *wavtype, *wavtype2, *file_homg, *file_tinvs;
    segy    *hdrs_im, *hdrs_homg;
	WavePar WP,WPs;
	modPar mod;
    recPar rec;
    srcPar src;
    shotPar shot;
    rayPar ray;

    initargs(argc, argv);
    requestdoc(1);

    tsyn = tread = tfft = tcopy = 0.0;
    t0   = wallclock_time();

	if (!getparstring("file_img", &file_img)) file_img = "img.su";
	if (!getparstring("file_homg", &file_homg)) file_homg = NULL;
    if (!getparstring("file_shot", &file_shot)) file_shot = NULL;
    if (!getparstring("file_tinv", &file_tinv)) file_tinv = NULL;
	if (!getparstring("file_tinvs", &file_tinvs)) file_tinvs = NULL;
    if (!getparstring("file_f1plus", &file_f1plus)) file_f1plus = NULL;
    if (!getparstring("file_f1min", &file_f1min)) file_f1min = NULL;
    if (!getparstring("file_gplus", &file_gplus)) file_gplus = NULL;
    if (!getparstring("file_gmin", &file_gmin)) file_gmin = NULL;
    if (!getparstring("file_pplus", &file_f2)) file_f2 = NULL;
    if (!getparstring("file_f2", &file_f2)) file_f2 = NULL;
    if (!getparstring("file_pmin", &file_pmin)) file_pmin = NULL;
    if (!getparstring("file_iter", &file_iter)) file_iter = NULL;
	if (!getparstring("file_wav", &file_wav)) file_wav=NULL;
	if (!getparstring("file_ray", &file_ray)) file_ray=NULL;
	if (!getparstring("file_amp", &file_amp)) file_amp=NULL;
	if (!getparstring("file_rays", &file_rays)) file_rays=NULL;
    if (!getparstring("file_amps", &file_amps)) file_amps=NULL;
	if (!getparstring("file_cp", &file_cp)) file_cp = NULL;
    if (!getparint("verbose", &verbose)) verbose = 0;
    if (file_tinv == NULL && file_shot == NULL) 
        verr("file_tinv and file_shot cannot be both input pipe");
    if (!getparstring("file_green", &file_green)) {
        if (verbose) vwarn("parameter file_green not found, assume pipe");
        file_green = NULL;
    }
    if (!getparfloat("fmin", &fmin)) fmin = 0.0;
    if (!getparfloat("fmax", &fmax)) fmax = 70.0;
    if (!getparint("ixa", &ixa)) ixa = 0;
    if (!getparint("ixb", &ixb)) ixb = ixa;
//    if (!getparint("reci", &reci)) reci = 0;
	reci=0; // source-receiver reciprocity is not yet fully build into the code
    if (!getparfloat("weight", &weight)) weight = 1.0;
	if (!getparfloat("tsq", &tsq)) tsq = 0.0;
	if (!getparfloat("Q", &Q)) Q = 0.0;
	if (!getparfloat("f0", &f0)) f0 = 0.0;
    if (!getparint("tap", &tap)) tap = 0;
    if (!getparint("ntap", &ntap)) ntap = 0;
	if (!getparint("pad", &pad)) pad = 0;

    if(!getparint("hw", &hw)) hw = 15;
    if(!getparint("smooth", &smooth)) smooth = 5;
    if(!getparint("above", &above)) above = 0;
    if(!getparint("shift", &shift)) shift=12;
	if(!getparint("ampest", &ampest)) ampest=0;
	if(!getparint("nb", &nb)) nb=0;
	if (!getparfloat("bstart", &bstart)) bstart = 1.0;
    if (!getparfloat("bend", &bend)) bend = 1.0;

    if (reci && ntap) vwarn("tapering influences the reciprocal result");

	/* Reading in wavelet parameters */
    if(!getparfloat("fpw", &WP.fp)) WP.fp = -1.0;
    if(!getparfloat("fminw", &WP.fmin)) WP.fmin = 10.0;
    if(!getparfloat("flefw", &WP.flef)) WP.flef = 20.0;
    if(!getparfloat("frigw", &WP.frig)) WP.frig = 50.0;
    if(!getparfloat("fmaxw", &WP.fmax)) WP.fmax = 60.0;
    else WP.fp = -1;
    if(!getparfloat("dbw", &WP.db)) WP.db = -20.0;
    if(!getparfloat("t0w", &WP.t0)) WP.t0 = 0.0;
    if(!getparint("shiftw", &WP.shift)) WP.shift = 0;
    if(!getparint("invw", &WP.inv)) WP.inv = 0;
    if(!getparfloat("epsw", &WP.eps)) WP.eps = 1.0;
    if(!getparfloat("scalew", &WP.scale)) WP.scale = 1.0;
    if(!getparint("scfftw", &WP.scfft)) WP.scfft = 1;
    if(!getparint("cmw", &WP.cm)) WP.cm = 10;
    if(!getparint("cnw", &WP.cn)) WP.cn = 1;
	if(!getparint("wav", &WP.wav)) WP.wav = 0;
	if(!getparstring("file_wav", &WP.file_wav)) WP.file_wav=NULL;
    if(!getparstring("w", &wavtype)) strcpy(WP.w, "g2");
    else strcpy(WP.w, wavtype);

	if(!getparfloat("fpws", &WPs.fp)) WPs.fp = -1.0;
    if(!getparfloat("fminws", &WPs.fmin)) WPs.fmin = 10.0;
    if(!getparfloat("flefws", &WPs.flef)) WPs.flef = 20.0;
    if(!getparfloat("frigws", &WPs.frig)) WPs.frig = 50.0;
    if(!getparfloat("fmaxws", &WPs.fmax)) WPs.fmax = 60.0;
    else WPs.fp = -1;
    if(!getparfloat("dbw", &WPs.db)) WPs.db = -20.0;
    if(!getparfloat("t0ws", &WPs.t0)) WPs.t0 = 0.0;
    if(!getparint("shiftws", &WPs.shift)) WPs.shift = 0;
    if(!getparint("invws", &WPs.inv)) WPs.inv = 0;
    if(!getparfloat("epsws", &WPs.eps)) WPs.eps = 1.0;
    if(!getparfloat("scalews", &WPs.scale)) WPs.scale = 1.0;
    if(!getparint("scfftws", &WPs.scfft)) WPs.scfft = 1;
    if(!getparint("cmws", &WPs.cm)) WPs.cm = 10;
    if(!getparint("cnws", &WPs.cn)) WPs.cn = 1;
    if(!getparint("wavs", &WPs.wav)) WPs.wav = 0;
    if(!getparstring("file_wavs", &WPs.file_wav)) WPs.file_wav=NULL;
    if(!getparstring("ws", &wavtype2)) strcpy(WPs.w, "g2");
    else strcpy(WPs.w, wavtype2);
	if(!getparint("niter", &niter)) niter = 10;
	if(!getparint("niterh", &niterh)) niterh = niter;

/*================ Reading info about shot and initial operator sizes ================*/

    ngath = 0; /* setting ngath=0 scans all traces; n2 contains maximum traces/gather */
	if (file_ray!=NULL && file_tinv==NULL) {
		ret = getFileInfo(file_ray, &n2, &n1, &ngath, &d1, &d2, &f2, &f1, &xmin, &xmax, &scl, &ntraces);
		n1 = 1;
		ntraces = n2*ngath;
		scl = 0.0010;
		d1 = -1.0*xmin;
		xmin = -1.0*xmax;
		xmax = d1;
		WP.wav = 1;
        WP.xloc = -123456.0;
        WP.zloc = -123456.0;
		synpos = (int *)calloc(ngath,sizeof(int));
		shot.nz = 1;
		shot.nx = ngath;
		shot.n = shot.nx*shot.nz;
		for (l=0; l<shot.nz; l++) {
            for (j=0; j<shot.nx; j++) {
                synpos[l*shot.nx+j] = j*shot.nz+l;
            }
        }
	}
	else if (file_ray==NULL && file_tinv==NULL) {
		getParameters(&mod, &rec, &src, &shot, &ray, verbose);
		n1 = 1;
		n2 = rec.n;
		ngath = shot.n;
		d1 = mod.dt;
		d2 = (rec.x[1]-rec.x[0])*mod.dx;
		f1 = 0.0;
		f2 = mod.x0+rec.x[0]*mod.dx;
		xmin = mod.x0+rec.x[0]*mod.dx;
		xmax = mod.x0+rec.x[rec.n-1]*mod.dx;
		scl = 0.0010;
		ntraces = n2*ngath;
		WP.wav = 1;
		WP.xloc = -123456.0;
		WP.zloc = -123456.0;
		synpos = (int *)calloc(ngath,sizeof(int));
		for (l=0; l<shot.nz; l++) {
			for (j=0; j<shot.nx; j++) {
				synpos[l*shot.nx+j] = j*shot.nz+l;
			}
		}
	}
	else {
    	ret = getFileInfo(file_tinv, &n1, &n2, &ngath, &d1, &d2, &f1, &f2, &xmin, &xmax, &scl, &ntraces);
	}

    Nsyn = ngath;
    nxs = n2; 
    nts = n1;
	nt0 = n1;
    dxs = d2; 
    fxs = f2;

    ngath = 0; /* setting ngath=0 scans all traces; nx contains maximum traces/gather */
    ret = getFileInfo(file_shot, &nt, &nx, &ngath, &d1, &dx, &ft, &fx, &xmin, &xmax, &scl, &ntraces);
    nshots = ngath;
	assert (nxs >= nshots);

    if (!getparfloat("dt", &dt)) dt = d1;

    ntfft = optncr(MAX(nt+pad, nts+pad)); 
    nfreq = ntfft/2+1;
    nw_low = (int)MIN((fmin*ntfft*dt), nfreq-1);
    nw_low = MAX(nw_low, 1);
    nw_high = MIN((int)(fmax*ntfft*dt), nfreq-1);
    nw  = nw_high - nw_low + 1;
    scl   = 1.0/((float)ntfft);

	if (nb > 1) {
		db	= (bend-bstart)/((float)(nb-1));
	}
	else if (nb == 1) {
		db = 0;
		bend = bstart;
	}
    
/*================ Allocating all data arrays ================*/

    green   = (float *)calloc(Nsyn*nxs*ntfft,sizeof(float));
    f2p     = (float *)calloc(Nsyn*nxs*ntfft,sizeof(float));
    pmin    = (float *)calloc(Nsyn*nxs*ntfft,sizeof(float));
    f1plus  = (float *)calloc(Nsyn*nxs*ntfft,sizeof(float));
    f1min   = (float *)calloc(Nsyn*nxs*ntfft,sizeof(float));
    G_d     = (float *)calloc(Nsyn*nxs*ntfft,sizeof(float));
    muteW   = (int *)calloc(Nsyn*nxs,sizeof(int));
    trace   = (float *)malloc(ntfft*sizeof(float));
    ixpossyn = (int *)malloc(nxs*sizeof(int));
    xrcvsyn = (float *)calloc(Nsyn*nxs,sizeof(float));
    xsyn    = (float *)malloc(Nsyn*sizeof(float));
    zsyn    = (float *)malloc(Nsyn*sizeof(float));
    xnxsyn  = (int *)calloc(Nsyn,sizeof(int));
    tapersy = (float *)malloc(nxs*sizeof(float));

    Refl    = (complex *)malloc(nw*nx*nshots*sizeof(complex));
    tapersh = (float *)malloc(nx*sizeof(float));
    xsrc    = (float *)calloc(nshots,sizeof(float));
    zsrc    = (float *)calloc(nshots,sizeof(float));
    xrcv    = (float *)calloc(nshots*nx,sizeof(float));
    xnx     = (int *)calloc(nshots,sizeof(int));

/*================ Read and define mute window based on focusing operator(s) ================*/
/* G_d = p_0^+ = G_d (-t) ~ Tinv */

	WPs.nt = ntfft;
	WPs.dt = dt;
	WP.nt = ntfft;
	WP.dt = dt;

	if (file_ray!=NULL || file_cp!=NULL) {
		makeWindow(WP, file_ray, file_amp, dt, xrcvsyn, xsyn, zsyn, xnxsyn,
             Nsyn, nxs, ntfft, mode, muteW, G_d, hw, verbose);
	}
	else {
    	mode=-1; /* apply complex conjugate to read in data */
    	readTinvData(file_tinv, dt, xrcvsyn, xsyn, zsyn, xnxsyn, 
			 Nsyn, nxs, ntfft, mode, muteW, G_d, hw, verbose);
	}
	/* reading data added zero's to the number of time samples to be the same as ntfft */
    nts   = ntfft;
                         
	/* define tapers to taper edges of acquisition */
    if (tap == 1 || tap == 3) {
        for (j = 0; j < ntap; j++)
            tapersy[j] = (cos(PI*(j-ntap)/ntap)+1)/2.0;
        for (j = ntap; j < nxs-ntap; j++)
            tapersy[j] = 1.0;
        for (j = nxs-ntap; j < nxs; j++)
            tapersy[j] =(cos(PI*(j-(nxs-ntap))/ntap)+1)/2.0;
    }
    else {
        for (j = 0; j < nxs; j++) tapersy[j] = 1.0;
    }
    if (tap == 1 || tap == 3) {
        if (verbose) vmess("Taper for operator applied ntap=%d", ntap);
        for (l = 0; l < Nsyn; l++) {
            for (i = 0; i < nxs; i++) {
                for (j = 0; j < nts; j++) {
                    G_d[l*nxs*nts+i*nts+j] *= tapersy[i];
                }   
            }   
        }   
    }

	/* check consistency of header values */
    dxf = (xrcvsyn[nxs-1] - xrcvsyn[0])/(float)(nxs-1);
    if (NINT(dxs*1e3) != NINT(fabs(dxf)*1e3)) {
        vmess("dx in hdr.d1 (%.3f) and hdr.gx (%.3f) not equal",d2, dxf);
        if (dxf != 0) dxs = fabs(dxf);
        vmess("dx in operator => %f", dxs);
    }
    if (xrcvsyn[0] != 0 || xrcvsyn[1] != 0 ) fxs = xrcvsyn[0];
    fxs2 = fxs + (float)(nxs-1)*dxs;

/*================ Reading shot records ================*/

    mode=1;
    readShotData(file_shot, xrcv, xsrc, zsrc, xnx, Refl, nw, nw_low, ngath, nx, nx, ntfft, 
         mode, weight, tsq, Q, f0, verbose);

    tapersh = (float *)malloc(nx*sizeof(float));
    if (tap == 2 || tap == 3) {
        for (j = 0; j < ntap; j++)
            tapersh[j] = (cos(PI*(j-ntap)/ntap)+1)/2.0;
        for (j = ntap; j < nx-ntap; j++)
            tapersh[j] = 1.0;
        for (j = nx-ntap; j < nx; j++)
            tapersh[j] =(cos(PI*(j-(nx-ntap))/ntap)+1)/2.0;
    }
    else {
        for (j = 0; j < nx; j++) tapersh[j] = 1.0;
    }
    if (tap == 2 || tap == 3) {
        if (verbose) vmess("Taper for shots applied ntap=%d", ntap);
        for (l = 0; l < nshots; l++) {
            for (j = 1; j < nw; j++) {
                for (i = 0; i < nx; i++) {
                    Refl[l*nx*nw+j*nx+i].r *= tapersh[i];
                    Refl[l*nx*nw+j*nx+i].i *= tapersh[i];
                }   
            }   
        }
    }
    free(tapersh);

	/* check consistency of header values */
    fxf = xsrc[0];
    if (nx > 1) dxf = (xrcv[0] - xrcv[nx-1])/(float)(nx-1);
    else dxf = d2;
    if (NINT(dx*1e3) != NINT(fabs(dxf)*1e3)) {
        vmess("dx in hdr.d1 (%.3f) and hdr.gx (%.3f) not equal",dx, dxf);
        if (dxf != 0) dx = fabs(dxf);
        else verr("gx hdrs not set");
        vmess("dx used => %f", dx);
    }
    
    dxsrc = (float)xsrc[1] - xsrc[0];
    if (dxsrc == 0) {
        vwarn("sx hdrs are not filled in!!");
        dxsrc = dx;
    }

/*================ Check the size of the files ================*/

    if (NINT(dxsrc/dx)*dx != NINT(dxsrc)) {
        vwarn("source (%.2f) and receiver step (%.2f) don't match",dxsrc,dx);
        if (reci == 2) vwarn("step used from operator (%.2f) ",dxs);
    }
    di = NINT(dxf/dxs);
    if ((NINT(di*dxs) != NINT(dxf)) && verbose) 
        vwarn("dx in receiver (%.2f) and operator (%.2f) don't match",dx,dxs);
    if (nt != nts) 
        vmess("Time samples in shot (%d) and focusing operator (%d) are not equal",nt, nts);
    if (verbose) {
        vmess("Number of focusing operators   = %d", Nsyn);
        vmess("Number of receivers in focusop = %d", nxs);
        vmess("number of shots                = %d", nshots);
        vmess("number of receiver/shot        = %d", nx);
        vmess("first model position           = %.2f", fxs);
        vmess("last model position            = %.2f", fxs2);
        vmess("first source position fxf      = %.2f", fxf);
        vmess("source distance dxsrc          = %.2f", dxsrc);
        vmess("last source position           = %.2f", fxf+(nshots-1)*dxsrc);
        vmess("receiver distance     dxf      = %.2f", dxf);
        vmess("direction of increasing traces = %d", di);
        vmess("number of time samples (nt,nts) = %d (%d,%d)", ntfft, nt, nts);
        vmess("time sampling                  = %e ", dt);
		if (ampest > 0) 		vmess("Amplitude correction estimation is switched on");
		if (nb > 0)				vmess("Scaling estimation in %d step(s) from %.3f to %.3f (db=%.3f)",nb,bstart,bend,db);
        if (file_green != NULL) vmess("Green output file              = %s ", file_green);
        if (file_gmin != NULL)  vmess("Gmin output file               = %s ", file_gmin);
        if (file_gplus != NULL) vmess("Gplus output file              = %s ", file_gplus);
        if (file_pmin != NULL)  vmess("Pmin output file               = %s ", file_pmin);
        if (file_f2 != NULL)    vmess("f2 (=pplus) output file        = %s ", file_f2);
        if (file_f1min != NULL) vmess("f1min output file              = %s ", file_f1min);
        if (file_f1plus != NULL)vmess("f1plus output file             = %s ", file_f1plus);
        if (file_iter != NULL)  vmess("Iterations output file         = %s ", file_iter);
    }

/*================ initializations ================*/

    if (ixa || ixb) n2out = ixa + ixb + 1;
    else if (reci) n2out = nxs;
    else n2out = nshots;
    mem = Nsyn*n2out*ntfft*sizeof(float)/1048576.0;
    if (verbose) {
        vmess("number of output traces        = %d", n2out);
        vmess("number of output samples       = %d", ntfft);
        vmess("Size of output data/file       = %.1f MB", mem);
    }

    //memcpy(Ni, G_d, Nsyn*nxs*ntfft*sizeof(float));
    
	if (file_homg!=NULL) {
		hG_d     = (float *)calloc(nxs*ntfft,sizeof(float));
    	hmuteW   = (int *)calloc(nxs,sizeof(int));
		hxrcvsyn = (float *)calloc(nxs,sizeof(float));
		hxsyn 	 = (float *)calloc(1,sizeof(float));
		hzsyn    = (float *)calloc(1,sizeof(float));
		hxnxsyn  = (int *)calloc(1,sizeof(int));
		cshot 	 = (complex *)calloc(nxs*nfreq,sizeof(complex));

		if(!getparfloat("xloc", &WPs.xloc)) WPs.xloc = -123456.0;
    	if(!getparfloat("zloc", &WPs.zloc)) WPs.zloc = -123456.0;
		if (WPs.xloc == -123456.0 && WPs.zloc == -123456.0) file_cp = NULL;
		if (WPs.xloc == -123456.0) WPs.xloc = 0.0;
		if (WPs.zloc == -123456.0) WPs.zloc = 0.0;
		xloc = WPs.xloc;
		zloc = WPs.zloc;
		ngath = 1;

		if (file_rays!=NULL || file_cp!=NULL) {
			WPs.wav=1;
			makeWindow(WPs, file_rays, file_amps, dt, hxrcvsyn, hxsyn, hzsyn, hxnxsyn, ngath, nxs, ntfft, mode, hmuteW, hG_d, hw, verbose);
    	}
    	else {
        	mode=-1; /* apply complex conjugate to read in data */
        	readTinvData(file_tinvs, dt, hxrcvsyn, hxsyn, hzsyn, hxnxsyn,
            	ngath, nxs, ntfft, mode, hmuteW, hG_d, hw, verbose);
    	}

		WPs.xloc = -123456.0;
		WPs.zloc = -123456.0;

		if (tap == 1 || tap == 3) {
        	if (verbose) vmess("Taper for operator applied ntap=%d", ntap);
            for (i = 0; i < nxs; i++) {
                for (j = 0; j < nts; j++) {
                    hG_d[i*nts+j] *= tapersy[i];
                }
            }
        }

		ngath   = omp_get_max_threads();
		
		synthesisPosistions(nx, nt, nxs, nts, dt, hxsyn, 1, xrcv, xsrc, fxs2, fxs,
        	dxs, dxsrc, dx, ixa, ixb, reci, nshots, ixpossyn, &npossyn, verbose);

		iterations(Refl,nx,nt,nxs,nts,dt,hxsyn,1,xrcv,xsrc,fxs2,fxs,dxs,dxsrc,dx,ixa,ixb,
        	ntfft,nw,nw_low,nw_high,mode,reci,nshots,ixpossyn,npossyn,pmin,f1min,f1plus,
        	f2p,hG_d,hmuteW,smooth,shift,above,pad,nt0,&first,niterh,verbose);

		/* compute full Green's function G = int R * f2(t) + f2(-t) = Pplus + Pmin */
        for (i = 0; i < npossyn; i++) {
            j = 0;
            /* set green to zero if mute-window exceeds nt/2 */
            if (hmuteW[ixpossyn[i]] >= nts/2) {
                memset(&green[i*nts],0, sizeof(float)*nt);
                continue;
            }
            green[i*nts+j] = f2p[i*nts+j] + pmin[i*nts+j];
            for (j = 1; j < nts; j++) {
                green[i*nts+j] = f2p[i*nts+nts-j] + pmin[i*nts+j];
            }
        }

		applyMute(green, hmuteW, smooth, 4, 1, nxs, nts, ixpossyn, npossyn, shift, pad, nt0);

        omp_set_num_threads(ngath);

        /* Transform the green position to the frequency domain */
        /*for (i = 0; i < npossyn; i++) {
        	rc1fft(&green[i*nts],&cshot[i*nfreq],ntfft,-1);
    	}*/
		//free(hG_d);free(hmuteW);free(hxrcvsyn);
		free(hmuteW);free(hxrcvsyn);
		free(hxsyn);free(hzsyn);free(hxnxsyn);free(cshot);
	}

    /* dry-run of synthesis to get all x-positions calcalated by the integration */
    synthesisPosistions(nx, nt, nxs, nts, dt, xsyn, Nsyn, xrcv, xsrc, fxs2, fxs, 
        dxs, dxsrc, dx, ixa, ixb,  reci, nshots, ixpossyn, &npossyn, verbose);
    if (verbose) {
        vmess("synthesisPosistions: nshots=%d npossyn=%d", nshots, npossyn);
    }


    t1    = wallclock_time();
    tread = t1-t0;

	iterations(Refl,nx,nt,nxs,nts,dt,xsyn,Nsyn,xrcv,xsrc,fxs2,fxs,dxs,dxsrc,dx,ixa,ixb,
		ntfft,nw,nw_low,nw_high,mode,reci,nshots,ixpossyn,npossyn,pmin,f1min,f1plus,
		f2p,G_d,muteW,smooth,shift,above,pad,nt0,&first,niter,verbose);

	/*if (niter==0) {
		for (l = 0; l < Nsyn; l++) {
        	for (i = 0; i < npossyn; i++) {
            	j = 0;
                ix = ixpossyn[i];
                f2p[l*nxs*nts+i*nts+j] = G_d[l*nxs*nts+ix*nts+j];
				f1plus[l*nxs*nts+i*nts+j] = G_d[l*nxs*nts+ix*nts+j];
                for (j = 1; j < nts; j++) {
                	f2p[l*nxs*nts+i*nts+j] = G_d[l*nxs*nts+ix*nts+j];
					f1plus[l*nxs*nts+i*nts+j] = G_d[l*nxs*nts+ix*nts+j];
                }
            }
    	}
	}*/

	

	if (niterh==0) {
        for (l = 0; l < Nsyn; l++) {
            for (i = 0; i < npossyn; i++) {
                j = 0;
                ix = ixpossyn[i];
                green[i*nts+j] = hG_d[ix*nts+j];
                for (j = 1; j < nts; j++) {
                    green[i*nts+j] = hG_d[ix*nts+nts-j];
                }
            }
        }
    }

	if (file_img!=NULL) {
	
		/*================ set variables for output data ================*/

    	hdrs_im = (segy *) calloc(shot.nx,sizeof(segy));
    	if (hdrs_im == NULL) verr("allocation for hdrs_out");
		Image   = (float *)calloc(Nsyn,sizeof(float));

		first=0;
		imaging(Image,WPs,Refl,nx,nt,nxs,nts,dt,xsyn,Nsyn,xrcv,xsrc,fxs2,fxs,dxs,dxsrc,dx,ixa,ixb,
       		ntfft,nw,nw_low,nw_high,mode,reci,nshots,ixpossyn,npossyn,pmin,f1min,f1plus,
       		f2p,G_d,muteW,smooth,shift,above,pad,nt0,synpos,verbose);

		/*============= write output files ================*/

		fp_out = fopen(file_img, "w+");

    	for (i = 0; i < shot.nx; i++) {
            hdrs_im[i].fldr    = 1;
            hdrs_im[i].tracl   = 1;
            hdrs_im[i].tracf   = i+1;
            hdrs_im[i].scalco  = -1000;
            hdrs_im[i].scalel  = -1000;
            hdrs_im[i].sdepth  = 0;
            hdrs_im[i].trid    = 1;
            hdrs_im[i].ns      = shot.nz;
            hdrs_im[i].trwf    = shot.nx;
            hdrs_im[i].ntr     = hdrs_im[i].fldr*hdrs_im[i].trwf;
            hdrs_im[i].f1      = zsyn[0];
            hdrs_im[i].f2      = xsyn[0];
            hdrs_im[i].dt      = dt*(1E6);
            hdrs_im[i].d1      = (float)zsyn[shot.nx]-zsyn[0];
            hdrs_im[i].d2      = (float)xsyn[1]-xsyn[0];
            hdrs_im[i].sx      = (int)roundf(xsyn[0] + (i*hdrs_im[i].d2));
            hdrs_im[i].gx      = (int)roundf(xsyn[0] + (i*hdrs_im[i].d2));
            hdrs_im[i].offset  = (hdrs_im[i].gx - hdrs_im[i].sx)/1000.0;
    	}
    	ret = writeData(fp_out, &Image[0], hdrs_im, shot.nz, shot.nx);
    	if (ret < 0 ) verr("error on writing output file.");

    	fclose(fp_out);
	}

	if (file_homg!=NULL) {

		/*================ set variables for output data ================*/

        hdrs_homg = (segy *) calloc(shot.nx,sizeof(segy));
        if (hdrs_homg == NULL) verr("allocation for hdrs_out");
        HomG	= (float *)calloc(Nsyn*ntfft,sizeof(float));

        homogeneousg(HomG,green,Refl,nx,nt,nxs,nts,dt,xsyn,Nsyn,xrcv,xsrc,fxs2,fxs,dxs,dxsrc,dx,ixa,ixb,
           	ntfft,nw,nw_low,nw_high,mode,reci,nshots,ixpossyn,npossyn,pmin,f1min,f1plus,
           	f2p,G_d,muteW,smooth,shift,above,pad,nt0,synpos,verbose);

        /*============= write output files ================*/

		 fp_out = fopen(file_homg, "w+");

		for (j = 0; j < ntfft; j++) {
        	for (i = 0; i < shot.nx; i++) {
            	hdrs_homg[i].fldr    = j+1;
            	hdrs_homg[i].tracl   = j*shot.nx+i+1;
            	hdrs_homg[i].tracf   = i+1;
            	hdrs_homg[i].scalco  = -1000;
            	hdrs_homg[i].scalel  = -1000;
            	hdrs_homg[i].sdepth  = (int)(zloc*1000.0);
            	hdrs_homg[i].trid    = 1;
            	hdrs_homg[i].ns      = shot.nz;
            	hdrs_homg[i].trwf    = shot.nx;
            	hdrs_homg[i].ntr     = hdrs_homg[i].fldr*hdrs_homg[i].trwf;
            	hdrs_homg[i].f1      = zsyn[0];
            	hdrs_homg[i].f2      = xsyn[0];
            	hdrs_homg[i].dt      = dt*(1E6);
            	hdrs_homg[i].d1      = (float)zsyn[shot.nx]-zsyn[0];
            	hdrs_homg[i].d2      = (float)xsyn[1]-xsyn[0];
            	hdrs_homg[i].sx      = (int)roundf(xsyn[0] + (i*hdrs_homg[i].d2));
            	hdrs_homg[i].gx      = (int)roundf(xsyn[0] + (i*hdrs_homg[i].d2));
            	hdrs_homg[i].offset  = (hdrs_homg[i].gx - hdrs_homg[i].sx)/1000.0;
        	}
        	ret = writeData(fp_out, &HomG[j*shot.n], hdrs_homg, shot.nz, shot.nx);
        	if (ret < 0 ) verr("error on writing output file.");
		}

        fclose(fp_out);
    }

    if (verbose) {
        t1 = wallclock_time();
        vmess("and CPU-time write data  = %.3f", t1-t2);
    }


    free(tapersy);

    exit(0);
}
Exemple #13
0
int main(int argc, char *argv[])
{
    signal(SIGALRM, timeOutHandler); // bind the timeOutHandler with the timer object.
   // int sockfd, newsockfd, cwnd_length, portno, pid;
	int newsockfd, cwnd_length, portno, pid;
    //float ploss, pcorr;
    char* tail;
    char* hi = "Received your message";

   // socklen_t clilen;
   //struct sockaddr_in serv_addr, cli_addr;


    if (argc < 5 && argc!=2) {
        fprintf(stderr,"ERROR, proper use: ./sender <port number> <cwnd> <p_loss> <p_corrupt>\n");
        exit(1);
    }
    if (argc==2){
	test=true;
    }

  if(test==false){
    sockfd = socket(AF_INET, SOCK_DGRAM, 0);

    if (sockfd < 0)
        error("ERROR opening socket");

    bzero((char *) &serv_addr, sizeof(serv_addr));

    portno = atoi(argv[1]);
    cwnd_length = atoi(argv[2]);

    ploss = strtof(argv[3], &tail);
    pcorr = strtof(argv[4], &tail);

    printf( "Probability of Loss: %f\n",ploss);
    printf( "Probability of Corruption: %f\n\n", pcorr);

	

    serv_addr.sin_family = AF_INET;
    serv_addr.sin_addr.s_addr = INADDR_ANY;
    serv_addr.sin_port = htons(portno);

    if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) //ANDREW CHANGE #2: casted &serv_addr to (struct sockaddr *) instead of (struct sockaddr_in*)
        error("ERROR on binding");

    clilen = sizeof(cli_addr);
  }

    FILE* requestFile; // FIXME: Read the document about allocate a new file in ram


   char* testInput;

   if (test==false){		//if not a test, read socket input into buffer
	while (1) {
		int n;
        	char buffer[256];

       	 	bzero(buffer, 256);
       		 n = recvfrom(sockfd, buffer, sizeof(buffer), 0, (struct sockaddr*) &cli_addr, (socklen_t *) &clilen); //ANDREW CHANGE #3: casted &cli_addr to (struct sockaddr *)
        	if (n < 0)
            		error("ERROR reading from socket");
       		 else {
            		// fprintf(stdout, buffer);
           		 requestFile = findFile(buffer);
           		 break;
           		 // break out the initial round of request
            		// FIXME: if the file is not found, send something to client
       		 }
   	 } /* end of while */
   }
   else{		//if a test, read "test" into buffer
	 testInput = argv[1];
   	 printf( "\n\n\nmain()\n----------\nRequested Filename: %s\n\n\n",testInput);
	 requestFile = findFile(testInput);
   }

    /* init window */

    //FIRST BURST OF COMMANDS
	makeWindow(requestFile);		//allocate and construct window
	//if(test==true){
	if(1){
	  printWindow();
	}

    //FIXME: Not sure if anything missing
	
	
    int commandLength;	//single pointer to a single integer that saves the length of lastCommand()
    int* lastCommand = prepareToSend(&commandLength);
	printf( "Preparing to send\n{ ");
	 int p=0;
	for (p=0; p < commandLength; p++){
		if (p == commandLength - 1)
			printf( "%d }\n",lastCommand[p]);
		else
			printf( "%d, ",lastCommand[p]);
	}
	sendPacket(lastCommand, commandLength, sockfd, (struct sockaddr*)&cli_addr, clilen); // first send
        // TODO: free the lastCommand;

        free(lastCommand);
	commandLength=0;
	printWindow();
		
    alarm(1); // start timming cycle.
	
    while(1){
      //if timeout, resend
	if(resend == true){
		printf( "About to resend\n");
		lastCommand = prepareToSend(&commandLength);
		if(commandLength>0){
			printf( "Preparing to resend:\n{ ");
			printf( "%d }\n",lastCommand[0]);
			sendPacket(lastCommand, commandLength, sockfd, (struct sockaddr*)&cli_addr, clilen); 
		}
		free(lastCommand);
		resend=false;
	}
      // receving acks from recever:
      int n;
      char buffer[256]; // buffer for acks
      bzero(buffer, 256);
	
      n = recvfrom(sockfd, buffer, sizeof(buffer), 0, (struct sockaddr*)&cli_addr, (socklen_t *) &clilen);
      if (n < 0)
          error("ERROR reading from socket");
      else {
        int ack = 0;

        // check if done
        if(strncmp("done", buffer, 4) == 0) {
          printf("Receiver signaled final fully sent! Terminating...\n");
          exit(0);
        }
        // TODO: parse the acks from buffer:
	ack = atoi(buffer);
        updateOnAcked(ack);

	 printWindow();
	if (isFinished()){
		printf( "Send complete! \n\n");
		break;
	}
	 
        lastCommand = prepareToSend(&commandLength);
	if(commandLength>0){
		printf( "Preparing to send:\n{ ");
		 int p=0;
		for (p=0; p < commandLength; p++){
			if (p == commandLength - 1)
				printf( "%d }\n",lastCommand[p]);
			else
				printf( "%d, ",lastCommand[p]);
		}
		sendPacket(lastCommand, commandLength, sockfd, (struct sockaddr*)&cli_addr, clilen); // first send
        	// TODO: free the lastCommand;
        	
   	}
	 else
		printf( "Nothing to Send \n\n");
	 printWindow();
	free(lastCommand);
	 commandLength=0;
        //TODO: free the lastCommand
        // free(lastCommand);
      }
    }
    return 0; /* we never get here */
}
Exemple #14
0
int CAppBase::InitWindow(HINSTANCE hInstance)
{
	return makeWindow(hInstance);
}
Exemple #15
0
int main() {
    auto window = makeWindow();

    // Asset loader setup
    auto assets = std::make_shared<sfr::AssetTable>();
    auto assetLoader = std::make_shared<sfr::AssetLoader>(assets);

    // Renderer setup
    auto deferredRenderer = std::make_shared<sfr::DeferredRenderer>(assets);
    auto transformUpdater = std::make_shared<sfr::TransformUpdater>();

    // Scene setup
    auto scene = std::make_shared<sfr::Scene>();

    // Set up a camera positioned at (1, 0, 1) and looking at (0, 0, 0). The
    // camera's up vector is the y-axis.
    auto up = sfr::Vector(0, 1.f, 0);
    auto origin = sfr::Vector(1.f, 0, 1.f);
    auto target = sfr::Vector(0, 0, 0);
    auto cameraNode = scene->root()->childIs<sfr::Transform>("camera");
    cameraNode->transformIs(sfr::Matrix::look(origin, target, up));

    auto camera = cameraNode->childIs<sfr::Camera>();
    camera->viewportWidthIs(window->getSize().x);
    camera->viewportWidthIs(window->getSize().y);
    scene->cameraIs(camera); // set this camera to the active camera

    // Place the car mesh (loaded from the asset loader) at (0, 0, 0)
    auto car = assets->assetIs<sfr::Transform>("meshes/Lexus.obj");
    scene->root()->childIs(car);

    // Place a spotlight at (0, 16, 0) and point it down towards the car.  The
    // spotlight's position is determined from the parent transform.
    auto lightNode = scene->root()->childIs<sfr::Transform>("light");
    lightNode->positionIs(sfr::Vector(0, 16.f, 0));
    
    auto light = lightNode->childIs<sfr::SpotLight>();
    light->spotCutoffIs(20.f); // set spot light to spread by 20 degrees
    light->spotPowerIs(40.f); // larger spotPower results in sharper beam edges
    light->constantAttenuationIs(1.f);
    light->linearAttenuationIs(0);
    light->quadraticAttenuationIs(0);
    light->specularColorIs(sfr::Color(1.f, 1.f, 1.f, 1.f));
    light->diffuseColorIs(sfr::Color(3.f, 3.f, 3.f, 3.f)); // really bright light
    light->directionIs(sfr::Vector(0, -1.f, 0)); // point the light down the y-axis

    // Enable shadows for the light
    light->shadowMapIs(std::make_shared<sfr::DepthRenderTarget>(1024, 1024));


    // Run the render loop. This code differs depending on what windowing
    // library you use. The parts that will always remain the same are:
    // 1. glClear
    // 2. transformUpdater->operator(): Updates the scene graph world transforms
    // 3. deferredRenderer->operator()): Renders the scene
    while (window->isOpen()) {
        sf::Event evt;
        while (window->pollEvent(evt)) {
            switch (evt.type) {
            case sf::Event::Closed:
                exit(0);
                break;
            default:
                break;
            }
        }

        glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
        transformUpdater->operator()(scene);
        deferredRenderer->operator()(scene);
        
        window->display();
    }

    return 0;
}
void Draft::makeBoard(Team *arr, vector<NodeData*>& a, int teams) {
	int sY = 8, sX = 0, w = 14, h = 4, ch, j = 0, z = 0;
	string tName;			
	WINDOW *board[BOARD_SIZE]; //timer + players + menu  + roster + titles +    title +    teams(2)
					   //ar[34]  arr[33]   ar[32]  ar[31]   arr[20-29]    ar[30]  ar[0-19]

	initscr();											//start curses
	cbreak();											//line buffer off
	keypad(stdscr, TRUE);								//to use f1
	printw("Press cntr+c to exit");						//print 
	refresh();											//output

	board[TITLE] = createWin(4, 100, 1, 0);				//title
	wattron(board[TITLE], A_BOLD);
	mvwprintw(board[TITLE], 1, 10, "John Zoeller Draft");	//print T
	wrefresh(board[TITLE]);								//output

	board[34] = createWin(4, 40, 1, 101);				//timer
	wattron(board[34], A_BOLD);
	mvwprintw(board[34], 1, 1, "ROUND");				//print time
	wrefresh(board[34]);								//output

	for(int k = 0; k < 10; k++){						//team names
		board[k + 20] = createWin(3, 14, 5, (sX + (w * k)));
		wattron(board[k + 20], A_BOLD);	

		if(arr[k].getUser()){
			tName = to_string(arr[k].getPosition()) + " " + arr[k].getName();
			wattron(board[k + 20], A_UNDERLINE);
		} else
			tName = to_string(k + 1) + " Auto";

		mvwprintw(board[k + 20], 1, 1, tName.c_str());
		wrefresh(board[k + 20]);
	} 

	for(int i = 0; i < 10; i++)
		board[i] = createWin(h, w, (sY + (h * j)), (sX + (w * i)));

	j++;

	for(int a = 19; a >= 10; a--){
		board[a] = createWin(h, w, (sY + (h * j)), (sX + (w * z)));
		z++;
	}

	int dims[] = { 22, 45, 16, 0 };
	makeWindow("PLAYERS", dims, PLAYERS_AVAILABLE);


	board[33] = createWin(22, 45, 16, 0);				//players
	wattron(board[33], A_BOLD);
	mvwprintw(board[33], 1, 1, "PLAYERS");				//print title
	wattroff(board[33], A_BOLD);
	wrefresh(board[33]);								//output

	board[32] = createWin(10, 45, 16, 46);				//menu
	wattron(board[32], A_BOLD);
	mvwprintw(board[32], 1, 1, "MENU");					//print title
	wattroff(board[32], A_BOLD);
	wrefresh(board[32]);								//output

	board[31] = createWin(22, 45, 16, 92);				//roster
	wattron(board[31], A_BOLD);
	mvwprintw(board[31], 1, 1, "MY ROSTER");				//print title
	wattroff(board[31], A_BOLD);
	wrefresh(board[31]);								//output

	while((ch = getch()) != KEY_F(1)){					//drafting
		startDraft(arr, a, teams, board);
	}

	for(int i = 0; i < 35; i++){						//delete windows
		if(board[i] != NULL)
			destroy_win(board[i]);
	}

	endwin();
}