//---------------------------------------------------------------------------
const std::vector<double> Data::GetFractions() const
{
  std::lock_guard<std::recursive_mutex> lock(m_mutex);
  std::vector<double> v = GetTimes(); //Recursion: need std::recursive_mutex
  const double sum_time = std::accumulate(v.begin(),v.end(),0.0);

  if (sum_time != 0.0)
  {
    std::for_each(v.begin(),v.end(),
      [sum_time](double& d) { d/= sum_time; } );

  }
  return v;
}
/******************************Public*Routine******************************\
* Run
\**************************************************************************/
HRESULT CVMR9Subgraph::Run()
{
    HRESULT hr = S_OK;

    if( !m_pMc )
    {
        return E_UNEXPECTED;
    }
	LONGLONG  llCur= 0; LONGLONG  llDur = 0;
	hr = GetTimes(llCur,  llDur);
	if(llCur == llDur)
		SetTime(0);
    hr = m_pMc->Run();

    return hr;
}
Example #3
0
void ExecAgDual(MPI_Comm communicator)
{
  char      stop        = FALSE,
            sleep_ag    = FALSE,
            new_problem = FALSE;
  int       i           = 0,
            nb_cuts     = 0;
  CutType  *cut         = NULL;
  DualType  DualSol;

  DualSol.var_u    = (double *) malloc(max_lin * sizeof(double));
  DualSol.red_cost = (double *) malloc(nb_col * sizeof(double));
  DualSol.cut      = (int *) malloc(CutsofSol * sizeof(int));
  delta_u          = (double *) malloc(max_lin * sizeof(double));
  I_u              = (int *) malloc((max_lin + 1) * sizeof(int));
  inact            = (int *) malloc(max_lin * sizeof(int));
  cut              = (CutType *) malloc(CutsofSol * sizeof(CutType));
  
  int * bufferInterface;
  MPI_Request request;
  MPI_Status status;
  int count = 0;
  char change[1];
  int flag = 0, position = 0;
  int aux = -1;

  for (i = 0; i < CutsofSol; i++)
    cut[i].coef = (short *) malloc(nb_col * sizeof(short));

  GetTimes(FALSE);
  do
   {
     MPI_Iprobe(MPI_ANY_SOURCE, MPI_ANY_TAG, interfaceComm, &flag, &status);
     MPI_Get_count(&status, MPI_PACKED, &count);

     if(flag){
      
      bufferInterface = malloc(count);
      MPI_Recv(bufferInterface, count, MPI_PACKED, MPI_ANY_SOURCE, MPI_ANY_TAG, interfaceComm, &status);
      MPI_Unpack(bufferInterface, count, &position, &change[0], 1, MPI_CHAR, interfaceComm);
      
      if(change[0] == 'S'){
        return;
      }
      
      else if(change[0] == 'P'){
   
	    MPI_Unpack(bufferInterface, count, &position, &aux, 1, MPI_INT, interfaceComm);
	    if(aux != -1)
	      TimeSleeping = aux;
	    
	    aux = -1;
	    MPI_Unpack(bufferInterface, count, &position, &aux, 1, MPI_INT, interfaceComm);  
        if(aux != -1)
           MaxLenDualMem = aux;

      aux = -1;
	    MPI_Unpack(bufferInterface, count, &position, &aux, 1, MPI_INT, interfaceComm);  
        if(aux != -1)
          CutsofSol    = aux;
        
      aux = -1;
	    MPI_Unpack(bufferInterface, count, &position, &aux, 1, MPI_INT, interfaceComm);  
        if(aux != -1)
          MaxExeTime   = aux;
      
      aux = -1;
	    MPI_Unpack(bufferInterface, count, &position, &aux, 1, MPI_INT, interfaceComm);  
        if(aux != -1)
          ReducPerc = aux;

      aux = -1;
	    MPI_Unpack(bufferInterface, count, &position, &aux, 1, MPI_INT, interfaceComm);  
        if(aux != -1)
          RandomDual = (char) aux;
      
	   }
	  
      position = 0;
      flag = 0;
      free(bufferInterface);
     } 
     /* if (sleep_ag)
       sleep(TimeSleeping); */
     RequestNCutstoServer(&stop,&nb_cuts,cut,communicator);
     if (!stop)
     { if (nb_cuts > 0)
	     AddCutstoProblem(nb_cuts,cut,&DualSol);
       else
	     DualSol.nb_cuts = 0;
	   DualGreedy(RandomDual,((float) ReducPerc / 100.0),&DualSol);
	   GetTimes(TRUE);

	   DualSol.proc_time = total_time_cpu - lost_time_cpu;
	   //printf("droga");
	   SendDualSolutiontoServer(&stop,&sleep_ag,&new_problem,
				                &DualSol,communicator);
	   if (nb_cuts > 0)
	     ExcludeCutsofProblem(nb_cuts);
     }
     //printf("\n* Dual *");
   } while((!stop) && (MaxExeTimeCron()));

  //if (!stop)
    //StopAteam(communicator,NULL);
  
  free(DualSol.var_u);
  free(DualSol.red_cost);
  free(DualSol.cut);
  free(delta_u);
  free(I_u);
  free(inact);
  for (i = 0; i < CutsofSol; i++)
    free(cut[i].coef);
  free(cut);
}
Example #4
0
void DoExactCorrectness(FBLatInfo *fbInfo, Lattice *lat){
  if(!PhoneMEE){ 
    /* Minimum Word Error (exact).  Get the "sausage" of correct words (this is a linear sausage, no alternatives) and call DoCorrectness. */

    LNode *node; LArc *larc;  int a,n,p;
    int i,nWords=0,w; int **iwords;
    short int *niwords; /* just 1's. */
    short int *minn_of_t, *maxn_of_t;
    unsigned char *nonempty;
	 
    if(!lat){ HError(-1, "No extraNumLat for MPE! "); }
	 
    /* Count words. */
    for(node=lat->lnodes+0; node->foll; node=node->foll->end) /*This code appears to rely on first node being silence. */
      if(node->foll->nAlign > 1 ||  (node->foll->nAlign==1 && ! IsSilence(node->foll->lAlign[0].label->name))) /* a word [ not sil. ]...*/
	nWords++; 

    /* for each word arc, number it in list of words. */
    for(larc=lat->larcs,a=0;a<lat->na;larc++,a++){  
      if(larc->start->pred){ n=(int)larc->start->pred->score; }
      else n=0;
      if(larc->start->pred && IsNonSilArc(larc->start->pred))
	n++; /* prev is non-silence so increment.. */
      larc->score = (float) n;
      if((n>=nWords&&IsNonSilArc(larc)) || n<0) HError(1, "n out of range [0...nWords-1], PhoneMEE.");
    }
	 
    niwords = (short int*)New(&fbInfo->tempStack, sizeof(short int) * (nWords+1));	   
    iwords = (int**)New(&fbInfo->tempStack, sizeof(int*) * (nWords+1));
    for(w=0;w<=nWords;w++) niwords[w] = 1;
	 
    nonempty = (unsigned char*)New(&fbInfo->tempStack, sizeof(char) * (nWords+1));
    minn_of_t = (short int*)New(&fbInfo->tempStack, sizeof(short int) * fbInfo->T); minn_of_t--;
    maxn_of_t = (short int*)New(&fbInfo->tempStack, sizeof(short int) * fbInfo->T); maxn_of_t--;
    for(i=1;i<=fbInfo->T;i++){
      minn_of_t[i] = nWords;
      maxn_of_t[i] = 0;
    }
    for(p=0;p<nWords;p++){
      niwords[p] = 1; /*all 1 & will stay that way, for MWE case */
      nonempty[p] = 1;  /*all 1 & will stay that way, for MWE case */
      iwords[p] = (int*)New(&fbInfo->tempStack, sizeof(int) * 1);
    }
	 
    /* Get word list. */
    w=0;
    for(node=lat->lnodes+0; node->foll; node=node->foll->end)
      if(node->foll->nAlign > 1 ||  (node->foll->nAlign==1 && ! IsSilence(node->foll->lAlign[0].label->name))) /* a word [ not sil. ]...*/
	iwords[w++][0] = (int)node->foll->end->word->wordName; /* word is at the node at the end of the arc. */
	 
    for(larc=lat->larcs,a=0;a<lat->na;larc++,a++){   
      if(IsNonSilArc(larc)){  /* Is a word [not sil]*/
	int startT, endT;
	int w = (int) larc->score;
	if(w<0 || w>=nWords) HError(-1, "Problem with word numbering [2] (%d,%d)...",w,nWords);
	GetTimes(larc, 0, &startT, &endT); /* get times [of first phone]... */
	if(startT<1){ HError(-1, "Invalid start time..."); startT=1;}
	if(endT>fbInfo->T){ HError(-1, "Invalid end time..."); endT=fbInfo->T; }
	if(startT>fbInfo->T){ HError(-1, "Invalid start time..."); startT=fbInfo->T;}
	if(endT<1){ HError(-1, "Invalid end time..."); endT=1; }
	minn_of_t[endT] = MIN(minn_of_t[endT], w);
	maxn_of_t[startT] = MAX(maxn_of_t[startT], w);
      }
    }
	 
    /* set {min,max}n_of_t */
    { int min=nWords-1; for(i=fbInfo->T;i>=1;i--) if(minn_of_t[i]>min) minn_of_t[i]=min; else min=minn_of_t[i]; } /*make sure increasing.*/
    { int max=0; for(i=1;i<=fbInfo->T;i++) if(maxn_of_t[i]<max) maxn_of_t[i]=max; else max=maxn_of_t[i]; } /*make sure increasing.*/
    if(maxn_of_t[1]<0 || maxn_of_t[fbInfo->T]>=nWords || minn_of_t[1]<0 || minn_of_t[fbInfo->T]>=nWords)
      HError(1, "Problem with minn_of_t or maxn_of_t...");
	 
    for(i=1;i<=fbInfo->Q;i++) fbInfo->aInfo->ac[i].mpe_occscale = 0; 
    fbInfo->AvgCorr = fbInfo->MPEFileLength + 
      DoCorrectness(fbInfo, &fbInfo->tempStack, fbInfo->aInfo, EXACTCORR_PRUNE/*prune*/, PHONE_BEAM, 
		    minn_of_t, maxn_of_t, niwords, iwords, nonempty, fbInfo->T, nWords, InsCorrectness, FALSE/*Quinphone*/, fbInfo->pr);
	 
	 
  } else { 
    /* Minimum Phone Error (Exact).  Get the "sausage" of correct phones and call DoCorrectness. */
    LNode *node; LArc *larc; 
	 
    int nWords=0; short int *maxNPhones, *nArcs, *phoneStart;
    int maxNArcs=0,n,a,w,p,i;
    int **iphone;
    short int *niphones, nPhones; unsigned char *nonempty; /*doesnt contain empty phone...*/
    short int *minn_of_t, *maxn_of_t;
	 
    if(!lat){ HError(-1, "No extraNumLat for MPE! "); }

    for(node=lat->lnodes+0; node->foll; node=node->foll->end){
      if(node->foll->nAlign > 1 ||  (node->foll->nAlign==1 && ! IsSilence(node->foll->lAlign[0].label->name))){ /* a word [ not sil. ]...*/
	nWords++; 
      }
    }
    maxNPhones = (short int*)New(&fbInfo->tempStack, sizeof(short int) * (nWords+1));
    for(w=0;w<=nWords;w++) maxNPhones[w]=0;
    nArcs = (short int*)New(&fbInfo->tempStack, sizeof(short int) * (nWords+1));
    for(w=0;w<=nWords;w++) nArcs[w]=0;
    phoneStart = (short int*)New(&fbInfo->tempStack, sizeof(short int) * (nWords+1)); /* phone no. at which word starts.. */
	   
    for(larc=lat->larcs,a=0;a<lat->na;larc++,a++){  /* for each word arc, number it in list of words, & get maxNPhones[ ].....*/
      int np;
      if(larc->start->pred){ n=(int)larc->start->pred->score; } 
      else n=0;
      if(larc->start->pred && IsNonSilArc(larc->start->pred))
	n++; /* prev is non-silence so increment.. */
      larc->score = (float) n;
      if(IsNonSilArc(larc)){
	np = GetNumPhones(larc); /*works for quinphones too...*/
	if(np > maxNPhones[n]){
	  maxNPhones[n] = np;
	}
	nArcs[n]++;
	if(nArcs[n]>maxNArcs) maxNArcs=nArcs[n];
	if(n >= nWords) HError(-1, "Problem with word numbering...");
      }
    }
    nPhones=0;
    for(w=0;w<nWords;w++){
      phoneStart[w] = nPhones;
      nPhones += maxNPhones[w];
    }
	   
    iphone = (int**)New(&fbInfo->tempStack, sizeof(int*) * (nPhones+1));
    niphones = (short int*)New(&fbInfo->tempStack, sizeof(short int) * (nPhones+1));
    nonempty = (unsigned char*)New(&fbInfo->tempStack, sizeof(char) * (nPhones+1));
    minn_of_t = (short int*)New(&fbInfo->tempStack, sizeof(short int) * fbInfo->T); minn_of_t--;
    maxn_of_t = (short int*)New(&fbInfo->tempStack, sizeof(short int) * fbInfo->T); maxn_of_t--;
    for(i=1;i<=fbInfo->T;i++){
      minn_of_t[i] = nPhones;
      maxn_of_t[i] = 0;
    }

    for(p=0;p<nPhones;p++){
      niphones[p] = 0;
      nonempty[p] = 1;
      iphone[p] = (int*)New(&fbInfo->tempStack, sizeof(int) * maxNArcs);
    }


    for(larc=lat->larcs,a=0;a<lat->na;larc++,a++){   /* set up the 'iphone[..]' and 'niphones' and 'nonempty' arrays.*/
      if(IsNonSilArc(larc)){  /* Is a word [not sil]*/
	int startPos,j;
	int w = (int) larc->score;
	if(w<0 || w>=nWords) HError(-1, "Problem with word numbering [2] (%d,%d)...",w,nWords);
	startPos = phoneStart[w];
	       
	p=0; /* indx of "real" phone [start of quinphone]. */
	for(j=0;j<larc->nAlign;j++){ 
	  if(NonSil_and_Quinphone_IsStartPhone(larc,j)){ /* Is a starting phone... ( x_nnn_2 or some such, I think...), and is not silence. */
	    int startT, endT;
	    int nStates_quinphone, state_quinphone=0,x; Boolean Found=FALSE;
	    int local_iphone = GetNoContextPhone(larc->lAlign[j].label,&nStates_quinphone, &state_quinphone,NULL,NULL); 
	    if(Quinphone && state_quinphone != 2) HError(1, "Quinphone problem... check code, may not be compat with this quinphone set.");
	    for(x=0;x<niphones[startPos+p];x++)if(local_iphone==iphone[startPos+p][x]){ Found=TRUE; break; } 
	    if(!Found){ iphone[startPos+p][niphones[startPos+p]++] = local_iphone; }
	    GetTimes(larc, j, &startT, &endT); /* set times... */
	    if(startT<1){ HError(-1, "Invalid start time..."); startT=1;}
	    if(endT>fbInfo->T){ HError(-1, "Invalid end time..."); endT=fbInfo->T; }
	    if(startT>fbInfo->T){ HError(-1, "Invalid start time..."); startT=fbInfo->T;}
	    if(endT<1){ HError(-1, "Invalid end time..."); endT=1; }

	    minn_of_t[endT] = MIN(minn_of_t[endT], startPos+p);
	    maxn_of_t[startT] = MAX(maxn_of_t[startT], startPos+p);
	    p++;
	  }
	}
	for(;p<maxNPhones[w];p++){
	  nonempty[startPos+p] = 0; /* contains an empty phone. */
	}
      }
    }
    for(n=0;n<nPhones;n++){ if(niphones[n]==0 || niphones[n]>maxNArcs) HError(1, "niphones > maxNArcs...."); }
	   
    { int min=nPhones-1; for(i=fbInfo->T;i>=1;i--) if(minn_of_t[i]>min) minn_of_t[i]=min; else min=minn_of_t[i]; } /*make sure increasing.*/
    { int max=0; for(i=1;i<=fbInfo->T;i++) if(maxn_of_t[i]<max) maxn_of_t[i]=max; else max=maxn_of_t[i]; } /*make sure increasing.*/
    if(maxn_of_t[1]<0 || maxn_of_t[fbInfo->T]>=nPhones || minn_of_t[1]<0 || minn_of_t[fbInfo->T]>=nPhones)
      HError(1, "Problem with minn_of_t or maxn_of_t...");
	   
#ifdef DEBUG_MEE
    for(i=0;i<nPhones;i++){ 
      int j; printf(" %d(", i);for(j=0;j<niphones[i];j++){ int phone=iphone[i][j];char *cphone=(char*)(&phone);while(!(*cphone))cphone++; printf("%s:",cphone); }
      printf("%d) ", nonempty[i]);
    } 
    printf("\n");
#endif	   
	   
    for(i=1;i<=fbInfo->Q;i++) fbInfo->aInfo->ac[i].mpe_occscale = 0; 
    fbInfo->AvgCorr = fbInfo->MPEFileLength + 
      DoCorrectness(fbInfo, &fbInfo->tempStack, fbInfo->aInfo, EXACTCORR_PRUNE/*prune*/, PHONE_BEAM, 
		    minn_of_t, maxn_of_t, niphones, iphone, nonempty, fbInfo->T, nPhones, InsCorrectness, Quinphone, fbInfo->pr);
	   
  }
}
BallMovement BallMovementCalculator::CalculateBallMovement(TimedDetectedBall timedDetectedBall)
{
	Mat image(480,640, CV_8UC3, Scalar(0,0,0));

	if (!timedDetectedBall.IsDetected)
	{
		return BallMovement::BallNotDetected();
	}

	if(timedDetectedBall.DetectionTime - m_SamplesArray[0].DetectionTime > 2)
	{
		ResetSamples();
	}

	if (IsNewSampleRelevant(timedDetectedBall))
	{
		PushDetectedBallToQueue(timedDetectedBall);
	}

//	if (!IsEnoughSamples())
//	{
//		return BallMovement::NotEnoughSamples();
//	}

	vector<TimedDetectedBall> relevantSamples = GetRelevantSamples();

	if(relevantSamples.size() < MIN_NUM_OF_SAMPLES_TO_APPROX)
	{
		return BallMovement::NotEnoughSamples();
	}

//	if (!IsTimeDiffValid())
//	{
//		return BallMovement::InvalidTimeDiff();
//	}
//
//	if (!IsLocationDiffValid())
//	{
//		return BallMovement::InvalidLocationDiff();
//	}

	LeastSquareApprox* ballMovementApprox = LineApprox::Approx(GetYValues(relevantSamples), GetXValues(relevantSamples));
	JumpDirection jumpDirection = CalculateDirection(ballMovementApprox);

	LeastSquareApprox* timingApprox = ParabolaApprox::Approx(GetYValues(relevantSamples), GetTimes(relevantSamples));
	float msToJump = CalculateJumpingTime(timingApprox);

	BallMovement ballMovement(jumpDirection, msToJump);

	if(DEBUG_MODE)
	{
		PrintCalculationData(image, relevantSamples);
		ballMovement.PrintDetailsOnImage(image, Point(0, (NUM_OF_SAMPLES + 1)*20));
	}
	imshow("Ball movement calc", image);

	return ballMovement;
}
Example #6
0
WORD CGameLogic::GetWinScore( BYTE cbPlayStatus[GAME_PLAYER] ,BYTE cbHandCardData[GAME_PLAYER][MAX_COUNT] , LONGLONG lTableScore , LONGLONG *lWinScore , WORD wRevenue , LONGLONG *lUserRevenue/*=NULL*/ )
{
    WORD wWinTimes=0;
    /*ZeroMemory(wWinCount,sizeof(wWinCount));*/

    //保存扑克
    BYTE cbUserCardData[GAME_PLAYER][MAX_COUNT];
    CopyMemory(cbUserCardData,cbHandCardData,sizeof(cbUserCardData));

    WORD wWinPlayer = 0;
    for (WORD i=0; i<GAME_PLAYER; i++)
    {
        if(cbPlayStatus[i] == FALSE)continue;
        wWinPlayer = i;
        break;
    }
    //对比玩家
    for (WORD i=0; i<GAME_PLAYER; i++)
    {
        if(cbPlayStatus[i] == FALSE)continue;

        //对比扑克
        if (RatioCompareCard(cbUserCardData[i],cbUserCardData[wWinPlayer],MAX_COUNT,TRUE,TRUE) )
        {
            wWinPlayer = i;
        }
    }
    //获得倍数
    wWinTimes = GetTimes(cbUserCardData[wWinPlayer], MAX_COUNT);


    //统计得分
    for (WORD i=0; i<GAME_PLAYER; i++)
    {
        if(cbPlayStatus[i] == FALSE)continue;
        if(i==wWinPlayer)
        {
            continue;/*lWinScore[i]=lTableScore*wWinTimes;*/
        }
        else
        {
            lWinScore[i]= -lTableScore*wWinTimes;
        }
    }
    LONGLONG lWinerScore =0;;
    for (int i=0; i<GAME_PLAYER; i++)
    {
        if(cbPlayStatus[i] == FALSE || i==wWinPlayer)continue;
        lWinerScore+= (-lWinScore[i]);
    }

    lWinScore[wWinPlayer]=lWinerScore;

    //扣税
    for (WORD i=0; i<GAME_PLAYER; i++)
    {
        if(lWinScore[i] > 0)
        {
            if(lUserRevenue != NULL)
            {
                lUserRevenue[i] = lWinScore[i]*wRevenue/100;
            }
            lWinScore[i] -= lWinScore[i]*wRevenue/100;
        }
    }

    return wWinPlayer;
}
void
My_TestGLDrawing::DrawTest(bool offscreen)
{
    std::cout << "My_TestGLDrawing::DrawTest()\n";

    HdPerfLog& perfLog = HdPerfLog::GetInstance();
    perfLog.Enable();
    
    // Reset all counters we care about.
    perfLog.ResetCache(HdTokens->extent);
    perfLog.ResetCache(HdTokens->points);
    perfLog.ResetCache(HdTokens->topology);
    perfLog.ResetCache(HdTokens->transform);
    perfLog.SetCounter(UsdImagingTokens->usdVaryingExtent, 0);
    perfLog.SetCounter(UsdImagingTokens->usdVaryingPrimvar, 0);
    perfLog.SetCounter(UsdImagingTokens->usdVaryingTopology, 0);
    perfLog.SetCounter(UsdImagingTokens->usdVaryingVisibility, 0);
    perfLog.SetCounter(UsdImagingTokens->usdVaryingXform, 0);

    int width = GetWidth(), height = GetHeight();

    double aspectRatio = double(width)/height;
    GfFrustum frustum;
    frustum.SetPerspective(60.0, aspectRatio, 1, 100000.0);

    GfMatrix4d viewMatrix;
    viewMatrix.SetIdentity();
    viewMatrix *= GfMatrix4d().SetRotate(GfRotation(GfVec3d(0, 1, 0), _rotate[0]));
    viewMatrix *= GfMatrix4d().SetRotate(GfRotation(GfVec3d(1, 0, 0), _rotate[1]));
    viewMatrix *= GfMatrix4d().SetTranslate(GfVec3d(_translate[0], _translate[1], _translate[2]));

    GfMatrix4d projMatrix = frustum.ComputeProjectionMatrix();

    GfMatrix4d modelViewMatrix = viewMatrix; 
    if (UsdGeomGetStageUpAxis(_stage) == UsdGeomTokens->z) {
        // rotate from z-up to y-up
        modelViewMatrix = 
            GfMatrix4d().SetRotate(GfRotation(GfVec3d(1.0,0.0,0.0), -90.0)) *
            modelViewMatrix;
    }

    GfVec4d viewport(0, 0, width, height);
    _engine->SetCameraState(modelViewMatrix, projMatrix, viewport);

    size_t i = 0;
    TF_FOR_ALL(timeIt, GetTimes()) {
        UsdTimeCode time = *timeIt;
        if (*timeIt == -999) {
            time = UsdTimeCode::Default();
        }
        UsdImagingGLRenderParams params;
        params.drawMode = GetDrawMode();
        params.enableLighting = IsEnabledTestLighting();
        params.enableIdRender = IsEnabledIdRender();
        params.frame = time;
        params.complexity = _GetComplexity();
        params.cullStyle = IsEnabledCullBackfaces() ?
                            UsdImagingGLCullStyle::CULL_STYLE_BACK :
                            UsdImagingGLCullStyle::CULL_STYLE_NOTHING;

        glViewport(0, 0, width, height);

        glEnable(GL_DEPTH_TEST);

        if(IsEnabledTestLighting()) {
            if(UsdImagingGLEngine::IsHydraEnabled()) {
                _engine->SetLightingState(_lightingContext);
            } else {
                _engine->SetLightingStateFromOpenGL();
            }
        }

        if (!GetClipPlanes().empty()) {
            params.clipPlanes = GetClipPlanes();
            for (size_t i=0; i<GetClipPlanes().size(); ++i) {
                glEnable(GL_CLIP_PLANE0 + i);
            }
        }

        GfVec4f const &clearColor = GetClearColor();
        GLfloat clearDepth[1] = { 1.0f };

        // Make sure we render to convergence.
        TfErrorMark mark;
        do {
            glClearBufferfv(GL_COLOR, 0, clearColor.data());
            glClearBufferfv(GL_DEPTH, 0, clearDepth);
            _engine->Render(_stage->GetPseudoRoot(), params);
        } while (!_engine->IsConverged());
        TF_VERIFY(mark.IsClean(), "Errors occurred while rendering!");

        std::cout << "itemsDrawn " << perfLog.GetCounter(HdTokens->itemsDrawn) << std::endl;
        std::cout << "totalItemCount " << perfLog.GetCounter(HdTokens->totalItemCount) << std::endl;

        std::string imageFilePath = GetOutputFilePath();
        if (!imageFilePath.empty()) {
            if (time != UsdTimeCode::Default()) {
                std::stringstream suffix;
                suffix << "_" << std::setw(3) << std::setfill('0') << params.frame << ".png";
                imageFilePath = TfStringReplace(imageFilePath, ".png", suffix.str());
            }
            std::cout << imageFilePath << "\n";
            WriteToFile("color", imageFilePath);
        }
        i++;
    }