//================================================================
// Function : DrawSurface                           
// Purpose  : displays a given geometric surface in 3d viewer
//            (creates a finite face and displays it)
//================================================================
Handle_AIS_InteractiveObject OCCDemo_Presentation::drawSurface
                                  (const Handle_Geom_Surface& theSurface,
                                   const Quantity_Color& theColor,
                                   const Standard_Boolean toDisplay)
{
  Standard_Real u1, u2, v1, v2;
  theSurface->Bounds(u1,u2,v1,v2);
  fixParam(u1);
  fixParam(u2);
  fixParam(v1);
  fixParam(v2);

  Handle_AIS_Shape aGraphicSurface = 
    new AIS_Shape(BRepBuilderAPI_MakeFace (theSurface, u1, u2, v1, v2));

  getAISContext()->SetMaterial(aGraphicSurface, Graphic3d_NOM_PLASTIC, toDisplay);
  getAISContext()->SetColor(aGraphicSurface, theColor, toDisplay);
  if (toDisplay) {
    if (FitMode){
		getAISContext()->Display (aGraphicSurface, Standard_False);
		COCCDemoDoc::Fit();
	}
	else
		getAISContext()->Display (aGraphicSurface);
  }
  
  return aGraphicSurface;
}
//
// When it's time to get new variables for quadfunc. Randomize the correct ones
//
void switchRandVar()
{
	// Different sorts of path
	//-1 = left turn
	// 1 = right turn
	if(counter == 0); // if not zero a turn is in progress
	static int decideAction = randfunc(-5,5,1);
	
	
	if(decideAction == 1 || decideAction == -1)
		counter = 2;
	

    if (test == 1.0)
    {
        randTerrain(&a_next,&b_next,&c_next,&d_next);
        fixParam(&a_next,&b_next,&c_next,&d_next,decideAction, counter);
    }
    else
    {
        randTerrain(&a_curr,&b_curr,&c_curr,&d_curr);
        fixParam(&a_next,&b_next,&c_next,&d_next,decideAction, counter);
    }
    
    if(counter > 0)
    	counter -= 1;
}
Exemple #3
0
RooFitResult * scan(RooAbsPdf * pdf, RooDataSet * data, RooAbsReal * nll, Str2VarMap p, int nfree, string opt, RooArgSet * cons, 
		unsigned np, double * a, double * f, double * ab, double *c, double *r, RooArgSet * nuisances)
{
	RooFitResult * res = NULL;
	double minLL = 1.e6, minLL2 = 1.e6;
	double mina2=0,minab2=0,minf2=0;

	bool afb_iscost  = p["afb"]->getAttribute("Constant");
	bool fL_iscost   = p["fL"]->getAttribute("Constant");
	bool afbB_iscost = p["afbB"]->getAttribute("Constant");
	((RooRealVar*)p["afb"])->setConstant();
	((RooRealVar*)p["fL"])->setConstant();
	((RooRealVar*)p["afbB"])->setConstant();

	for( unsigned i = 0; i < np; i++ )
	{
		if(!afb_iscost) ((RooRealVar*)p["afb"])->setVal(a[i]);
		if(!fL_iscost) ((RooRealVar*)p["fL"])->setVal(f[i]);
		if(!afbB_iscost) ((RooRealVar*)p["afbB"])->setVal(ab[i]);

		double tmp = nll->getVal();
		if(tmp < minLL)	{ minLL = tmp; c[0] = p["afb"]->getVal(); c[1] = p["fL"]->getVal(); c[2] = p["afbB"]->getVal(); }
		else if(tmp < minLL2) { minLL2 = tmp; mina2 = p["afb"]->getVal(); minf2 = p["fL"]->getVal(); minab2 = p["afbB"]->getVal(); }
	}

	if(!afb_iscost) ((RooRealVar*)p["afb"])->setVal(c[0]);
	if(!fL_iscost) ((RooRealVar*)p["fL"])->setVal(c[1]);
	if(!afbB_iscost) ((RooRealVar*)p["afbB"])->setVal(c[2]);
	if(nfree>3){ fixParam(pdf,new RooArgSet(),nuisances); res = fitTo(pdf,data,cons,opt); }
	((RooRealVar*)p["afb"])->setConstant(afb_iscost);
	((RooRealVar*)p["fL"])->setConstant(fL_iscost);
	((RooRealVar*)p["afbB"])->setConstant(afbB_iscost);

	c[0] = p["afb"]->getVal();
	c[1] = p["fL"]->getVal();
	c[2] = p["afbB"]->getVal();
	r[0] = TMath::Sqrt( TMath::Power(c[0]-mina2,2) + TMath::Power(c[1]-minf2,2) + TMath::Power(c[2]-minab2,2) );

	return res;
}