void BuildGear(TGeometry & tGeometry, const TGearInfo & tInfo)
{
	//tInfo.m_fTeethDepth;
	//tInfo.m_iTeethCount;

	const float fDepth = 1 - tInfo.m_fTeethDepth;

	float fX = 0;
	float fY = 0;
	float fOldX = 1.0f;
	float fOldY = 0;
	

	for (int i = 0; i < 19; i++)
	{
		float fTemp = GfxMathDegToRad((float(i * 20)));
		fX = cos(fTemp);
		fY = sin(fTemp);
		tGeometry.AddLine(TGfxVec3(fOldX/3, fOldY/3, 0), TGfxVec3(fX/3, fY/3, 0));
		fOldX = fX;
		fOldY = fY;
	}
	
	bool bIsTeeth = true;
	int iTeethNbr = 0;

	for (int i = 0; i < ((tInfo.m_iTeethCount*4)+1); i++)
	{
		if (iTeethNbr>1)
		{
			if (bIsTeeth == true)
			{
				bIsTeeth = false;
			}
			else if(bIsTeeth == false)
			{
				bIsTeeth = true;
			}
			iTeethNbr = 0;
		}

		float fTemp = GfxMathDegToRad(i * (360.0f / (tInfo.m_iTeethCount * 4)));
		fX = cos(fTemp);
		fY = sin(fTemp);
		if (bIsTeeth == true)
		{
			tGeometry.AddLine(TGfxVec3(fOldX, fOldY, 0), TGfxVec3(fX, fY, 0));
			fOldX = fX;
			fOldY = fY;
		}
		else
		{
			tGeometry.AddLine(TGfxVec3(fOldX, fOldY, 0), TGfxVec3(fX * fDepth, fY * fDepth, 0));
			fOldX = fX*fDepth;
			fOldY = fY*fDepth;
		}

		iTeethNbr++;
	}
}
Example #2
0
//_____________________________________________________________________________
Int_t AliTRDdisplayDigits3D(Int_t event = 0, Int_t thresh = 4
                          , Bool_t sdigits = kFALSE) 
{
  //  
  //  TRD digits display
  //
  //  Input parameter:
  //    <event>   : Event number 
  //    <thresh>  : Threshold to suppress the noise
  //    <sdigits> : If kTRUE it will display summable digits, normal digits otherwise.
  //                The signal event is displayed in yellow.
  //

  Char_t *inputFile = "galice.root";

  // Define the objects
  AliTRDv1       *trd;
  AliTRDgeometry *geo;

  TString       evfoldname = AliConfig::GetDefaultEventFolderName();
  AliRunLoader *runLoader  = AliRunLoader::GetRunLoader(evfoldname);
  if (!runLoader) {
    runLoader = AliRunLoader::Open(inputFile
                                  ,AliConfig::GetDefaultEventFolderName()
                                  ,"UPDATE");
  }
  if (!runLoader) {
    printf("Can not open session for file %s.",inputFile);
    return kFALSE;
  }
   
  if (!runLoader->GetAliRun()) {
    runLoader->LoadgAlice();
  }
  gAlice = runLoader->GetAliRun();  
  if (!gAlice) {
    printf("Could not find AliRun object.\n");
    return kFALSE;
  }

  runLoader->GetEvent(event);
  
  AliLoader *loader = runLoader->GetLoader("TRDLoader");
  if (!loader) {
    printf("Can not get TRD loader from Run Loader");
  }
  loader->LoadDigits();
  
  // Get the pointer to the detector object
  trd = (AliTRDv1*) gAlice->GetDetector("TRD");

  // Get the pointer to the geometry object
  if (trd) {
    geo = trd->GetGeometry();
  }
  else {
    printf("Cannot find the geometry\n");
    return 1;
  }

  AliCDBManager *cdbManager  = AliCDBManager::Instance();
  cdbManager->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
  AliTRDcalibDB *calibration = AliTRDcalibDB::Instance();
  calibration->SetRun(0);

  TCanvas *c1 = new TCanvas("digits","TRD digits display",0,0,700,730);
  TView   *v  = new TView(1);
  v->SetRange(-430,-560,-430,430,560,1710);
  v->SetParallel();
  c1->Clear();
  c1->SetFillColor(1);
  c1->SetTheta(90.0);
  c1->SetPhi(0.0);

  Int_t markerColorSignal = 2;
  Int_t markerColorBgnd   = 7;
  Int_t markerColorMerged = 5;
  Int_t mask              = 10000000;

  // Create the digits manager
  AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager();
  digitsManager->SetSDigits(sdigits);

  // Read the digits from the file
  if (sdigits) {
    digitsManager->ReadDigits(loader->TreeS());
  }
  else {
    if (!loader->TreeD()) {
      printf("mist\n");
      return kFALSE;
    }
    digitsManager->ReadDigits(loader->TreeD());
  }

  Int_t totalsignal = 0;
  Int_t totalbgnd   = 0;
  Int_t totalmerged = 0;
  Int_t timeMax     = calibration->GetNumberOfTimeBins();

  // Loop through all detectors
  for (Int_t idet = 0; idet < geo->Ndet(); idet++) {

    printf("<AliTRDdisplayDigits3D> Loading detector %d\n",idet);
    AliTRDdataArrayI *digits  = digitsManager->GetDigits(idet);
    digits->Expand();

    Int_t isec    = geo->GetSector(idet);
    Int_t icha    = geo->GetChamber(idet);
    Int_t ipla    = geo->GetPlane(idet);
    AliTRDpadPlane *padPlane = new AliTRDpadPlane(ipla,icha);
    Int_t  rowMax = padPlane->GetNrows();
    Int_t  colMax = padPlane->GetNcols();

    Int_t ndigits = digits->GetOverThreshold(thresh);

    if (ndigits > 0) {

      TPolyMarker3D *pmSignal = new TPolyMarker3D(ndigits);
      Int_t isignal = 0;

      for (Int_t time = 0; time < timeMax; time++) {
        for (Int_t  col = 0;  col <  colMax;  col++) {
          for (Int_t  row = 0;  row <  rowMax;  row++) {

            Int_t amp = digits->GetDataUnchecked(row,col,time);

            if (amp > thresh) {
          
              Double_t glb[3];
              Double_t loc[3];

              loc[0] = row;
              loc[1] = col;
              loc[2] = time;
              geo->Local2Global(idet,loc,glb);
              Double_t x = glb[0];
              Double_t y = glb[1];
              Double_t z = glb[2];

              pmSignal->SetPoint(isignal,x,y,z);
              isignal++;
              totalsignal++;

	    }

	  }
        }
      }

      digits->Compress(1,0);

      pmSignal->SetMarkerSize(1); 
      pmSignal->SetMarkerColor(markerColorSignal);
      pmSignal->SetMarkerStyle(1);
      pmSignal->Draw();
   
    }

  }

  delete padPlane;

  TGeometry *geoAlice = gAlice->GetGeometry();
  TNode     *main     = (TNode *) ((geoAlice->GetListOfNodes())->First());
  TIter      next(main->GetListOfNodes());
  TNode     *module   = 0;
  while ((module = (TNode *) next())) {
    Char_t ch[100];
    sprintf(ch,"%s\n",module->GetTitle());
    if ((ch[0] == 'T') && ((ch[1] == 'R') || (ch[1] == 'P'))) {
      module->SetVisibility( 3);
    }
    else {
      module->SetVisibility(-1);
    }
  }
      
  geoAlice->Draw("same");

  c1->Modified(); 
  c1->Update(); 

  return 0;

}
void BuildClock(TGeometry & tGeometry, const TClockInfo & tInfo)
{
	float fX = 0;
	float fY = 0;
	float fOldX = 1.0f;
	float fOldY = 0;

	int iCpt = 0;

	for (int i = 0; i < 61; i++)
	{
		float fTemp = GfxMathDegToRad(float(i * 6));
		fX = cos(fTemp);
		fY = sin(fTemp);
		tGeometry.AddLine(TGfxVec3(fOldX, fOldY, 0), TGfxVec3(fX, fY, 0));
		if (iCpt == 0)
		{
			tGeometry.AddLine(TGfxVec3(fX, fY, 0), TGfxVec3(fX*0.8f, fY*0.8f, 0));
			iCpt++;
		}
		else
		{
			if (iCpt == 5 || iCpt == 10)
			{
				tGeometry.AddLine(TGfxVec3(fX, fY, 0), TGfxVec3(fX*0.9f, fY*0.9f, 0));
			}
			else
			{
				tGeometry.AddLine(TGfxVec3(fX, fY, 0), TGfxVec3(fX*0.95f, fY*0.95f, 0));
			}

			iCpt++;

			if (iCpt == 15)
			{
				iCpt = 0;
			}
		}
		fOldX = fX;
		fOldY = fY;
	}

	const int iHours = tInfo.m_iHours;

	const int iMinutes = tInfo.m_iMinutes;

	const int iAngle = -90 + (iHours * 30);

	const int iAngleMinutes = 90 - (iMinutes * 6);

	const float fTemp = GfxMathDegToRad(float(iAngle));
	const float fTempLeft = GfxMathDegToRad(float(iAngle - 60));
	const float fTempRight = GfxMathDegToRad(float(iAngle + 60));

	const float fTempMin = GfxMathDegToRad(float(iAngleMinutes));
	const float fTempLeftMin = GfxMathDegToRad(float(iAngleMinutes - 60));
	const float fTempRightMin = GfxMathDegToRad(float(iAngleMinutes + 60));

	fX = cos(fTemp);
	fY = sin(fTemp);
	const float fXLeft = cos(fTempLeft);
	const float fYLeft = sin(fTempLeft);
	const float fXRight = cos(fTempRight);
	const float fYRight = sin(fTempRight);

	const float fXMin = cos(fTempMin);
	const float fYMin = sin(fTempMin);
	const float fXLeftMin = cos(fTempLeftMin);
	const float fYLeftMin = sin(fTempLeftMin);
	const float fXRightMin = cos(fTempRightMin);
	const float fYRightMin = sin(fTempRightMin);

	tGeometry.AddLine(TGfxVec3(0, 0, 0), TGfxVec3(fXLeft / 10, -fYLeft / 10, 0));
	tGeometry.AddLine(TGfxVec3(0, 0, 0), TGfxVec3(fXRight / 10, -fYRight / 10, 0));
	tGeometry.AddLine(TGfxVec3(fXRight / 10, -fYRight / 10, 0), TGfxVec3(fX / 3, -fY / 3, 0));
	tGeometry.AddLine(TGfxVec3(fXLeft / 10, -fYLeft / 10, 0), TGfxVec3(fX / 3, -fY / 3, 0));

	tGeometry.AddLine(TGfxVec3(0, 0, 0), TGfxVec3(fXLeftMin / 10, fYLeftMin / 10, 0));
	tGeometry.AddLine(TGfxVec3(0, 0, 0), TGfxVec3(fXRightMin / 10, fYRightMin / 10, 0));
	tGeometry.AddLine(TGfxVec3(fXRightMin / 10, fYRightMin / 10, 0), TGfxVec3(fXMin / 2, fYMin / 2, 0));
	tGeometry.AddLine(TGfxVec3(fXLeftMin / 10, fYLeftMin / 10, 0), TGfxVec3(fXMin / 2, fYMin / 2, 0));
}
void BuildBox(TGeometry & tGeometry)
{
	tGeometry.AddLine(TGfxVec3(-1, -1, -1), TGfxVec3(1, 1, -1), GfxColor(63, 63, 63, 255));
	tGeometry.AddLine(TGfxVec3(-1, 1, -1), TGfxVec3(1, -1, -1), GfxColor(63, 63, 63, 255));

	tGeometry.AddLine(TGfxVec3(1, 1, 1), TGfxVec3(-1, 1, 1));
	tGeometry.AddLine(TGfxVec3(-1, 1, 1), TGfxVec3(-1, -1, 1));
	tGeometry.AddLine(TGfxVec3(-1, -1, 1), TGfxVec3(1, -1, 1));
	tGeometry.AddLine(TGfxVec3(1, -1, 1), TGfxVec3(1, 1, 1));

	tGeometry.AddLine(TGfxVec3(1, 1, -1), TGfxVec3(-1, 1, -1));
	tGeometry.AddLine(TGfxVec3(-1, 1, -1), TGfxVec3(-1, -1, -1));
	tGeometry.AddLine(TGfxVec3(-1, -1, -1), TGfxVec3(1, -1, -1));
	tGeometry.AddLine(TGfxVec3(1, -1, -1), TGfxVec3(1, 1, -1));

	tGeometry.AddLine(TGfxVec3(1, 1, 1), TGfxVec3(1, 1, -1));
	tGeometry.AddLine(TGfxVec3(-1, 1, 1), TGfxVec3(-1, 1, -1));
	tGeometry.AddLine(TGfxVec3(-1, -1, 1), TGfxVec3(-1, -1, -1));
	tGeometry.AddLine(TGfxVec3(1, -1, 1), TGfxVec3(1, -1, -1));
}
void BuildChessTower(TGeometry & tGeometry, const TChessTowerInfo & tInfo)
{	
	TGfxVec3 tLevelZeroPosition[36];
	TGfxVec3 tLevelOnePosition[36];
	TGfxVec3 tLevelTwoPosition[36];
	TGfxVec3 tLevelThreePosition[36];
	TGfxVec3 tLevelFourPosition[36];
	TGfxVec3 tLevelFivePosition[36];
	TGfxVec3 tLevelSixPosition[36];
	TGfxVec3 tLevelSevenPosition[36];
	TGfxVec3 tLevelHeightPosition[36];
	TGfxVec3 tLevelNinePosition[36];
	TGfxVec3 tLevelTenPosition[36];
	TGfxVec3 tLevelElevenPosition[36];

	float fHeightFromBottomTableau[12]; // Tableau de nombres magiques suivant approximativement les hauteurs de l'exercice
	fHeightFromBottomTableau[0] = 0.0f;
	fHeightFromBottomTableau[1] = 0.0f;
	fHeightFromBottomTableau[2] = 0.2f;
	fHeightFromBottomTableau[3] = 0.2f;
	fHeightFromBottomTableau[4] = 0.4f;
	fHeightFromBottomTableau[5] = 0.6f;
	fHeightFromBottomTableau[6] = 1.4f;
	fHeightFromBottomTableau[7] = 1.6f;
	fHeightFromBottomTableau[8] = 2.0f;
	fHeightFromBottomTableau[9] = 2.0f;
	fHeightFromBottomTableau[10] = 1.6f;
	fHeightFromBottomTableau[11] = 1.6f;

	float fWidthTableau[12]; // Tableau de nombres magiques suivant approximativement les largeurs de l'exercice
	fWidthTableau[0] = 0.0f;
	fWidthTableau[1] = 1.0f;
	fWidthTableau[2] = 1.0f;
	fWidthTableau[3] = 0.8f;
	fWidthTableau[4] = 0.8f;
	fWidthTableau[5] = 0.6f;
	fWidthTableau[6] = 0.6f;
	fWidthTableau[7] = 0.8f;
	fWidthTableau[8] = 0.8f;
	fWidthTableau[9] = 0.6f;
	fWidthTableau[10] = 0.6f;
	fWidthTableau[11] = 0.0f;

	float fX = 0;
	float fY = 0;

	for (int i = 0; i < tInfo.m_iSegments; i++)
	{
		tLevelZeroPosition[i] = TGfxVec3(0.0f,-1.0f,0.0f);
	}

	for (int i = 0; i < tInfo.m_iSegments; i++)
	{
		float fTemp = GfxMathDegToRad(i * (360.0f / (tInfo.m_iSegments)));
		fX = cos(fTemp);
		fY = sin(fTemp);

		tLevelOnePosition[i] = TGfxVec3((fX*fWidthTableau[1])*tInfo.m_fRadius, -1.0f + (fHeightFromBottomTableau[1] * tInfo.m_fHeight), (fY*fWidthTableau[1])* tInfo.m_fRadius);
		tLevelTwoPosition[i] = TGfxVec3((fX*fWidthTableau[2])*tInfo.m_fRadius, -1.0f + (fHeightFromBottomTableau[2] * tInfo.m_fHeight), (fY*fWidthTableau[2])* tInfo.m_fRadius);
		tLevelThreePosition[i] = TGfxVec3((fX*fWidthTableau[3])*tInfo.m_fRadius, -1.0f + (fHeightFromBottomTableau[3] * tInfo.m_fHeight), (fY*fWidthTableau[3])* tInfo.m_fRadius);
		tLevelFourPosition[i] = TGfxVec3((fX*fWidthTableau[4])*tInfo.m_fRadius, -1.0f + (fHeightFromBottomTableau[4] * tInfo.m_fHeight), (fY*fWidthTableau[4])* tInfo.m_fRadius);
		tLevelFivePosition[i] = TGfxVec3((fX*fWidthTableau[5])*tInfo.m_fRadius, -1.0f + (fHeightFromBottomTableau[5] * tInfo.m_fHeight), (fY*fWidthTableau[5])* tInfo.m_fRadius);
		tLevelSixPosition[i] = TGfxVec3((fX*fWidthTableau[6])*tInfo.m_fRadius, -1.0f + (fHeightFromBottomTableau[6] * tInfo.m_fHeight), (fY*fWidthTableau[6])* tInfo.m_fRadius);
		tLevelSevenPosition[i] = TGfxVec3((fX*fWidthTableau[7])*tInfo.m_fRadius, -1.0f + (fHeightFromBottomTableau[7] * tInfo.m_fHeight), (fY*fWidthTableau[7])* tInfo.m_fRadius);
		tLevelHeightPosition[i] = TGfxVec3((fX*fWidthTableau[8])*tInfo.m_fRadius, -1.0f + (fHeightFromBottomTableau[8] * tInfo.m_fHeight), (fY*fWidthTableau[8])* tInfo.m_fRadius);
		tLevelNinePosition[i] = TGfxVec3((fX*fWidthTableau[9])*tInfo.m_fRadius, -1.0f + (fHeightFromBottomTableau[9] * tInfo.m_fHeight), (fY*fWidthTableau[9])* tInfo.m_fRadius);
		tLevelTenPosition[i] = TGfxVec3((fX*fWidthTableau[10])*tInfo.m_fRadius, -1.0f + (fHeightFromBottomTableau[10] * tInfo.m_fHeight), (fY*fWidthTableau[10])* tInfo.m_fRadius);
		tLevelElevenPosition[i] = TGfxVec3((fX*fWidthTableau[11])*tInfo.m_fRadius, -1.0f + (fHeightFromBottomTableau[11] * tInfo.m_fHeight), (fY*fWidthTableau[11])* tInfo.m_fRadius);
	}
	
	for (int i = 0; i < tInfo.m_iSegments; i++)
	{
		tGeometry.AddLine(tLevelZeroPosition[i], tLevelOnePosition[i]);
		tGeometry.AddLine(tLevelOnePosition[i], tLevelTwoPosition[i]);
		tGeometry.AddLine(tLevelTwoPosition[i], tLevelThreePosition[i]);
		tGeometry.AddLine(tLevelThreePosition[i], tLevelFourPosition[i]);
		tGeometry.AddLine(tLevelFourPosition[i], tLevelFivePosition[i]);
		tGeometry.AddLine(tLevelFivePosition[i], tLevelSixPosition[i]);
		tGeometry.AddLine(tLevelSixPosition[i], tLevelSevenPosition[i]);
		tGeometry.AddLine(tLevelSevenPosition[i], tLevelHeightPosition[i]);
		tGeometry.AddLine(tLevelHeightPosition[i], tLevelNinePosition[i]);
		tGeometry.AddLine(tLevelNinePosition[i], tLevelTenPosition[i]);
		tGeometry.AddLine(tLevelTenPosition[i], tLevelElevenPosition[i]);
	}


	for (int i = 0; i < tInfo.m_iSegments; i++)
	{
		if (i == tInfo.m_iSegments - 1)
		{
			tGeometry.AddLine(tLevelOnePosition[i], tLevelOnePosition[0]);
			tGeometry.AddLine(tLevelTwoPosition[i], tLevelTwoPosition[0]);
			tGeometry.AddLine(tLevelThreePosition[i], tLevelThreePosition[0]);
			tGeometry.AddLine(tLevelFourPosition[i], tLevelFourPosition[0]);
			tGeometry.AddLine(tLevelFivePosition[i], tLevelFivePosition[0]);
			tGeometry.AddLine(tLevelSixPosition[i], tLevelSixPosition[0]);
			tGeometry.AddLine(tLevelSevenPosition[i], tLevelSevenPosition[0]);
			tGeometry.AddLine(tLevelHeightPosition[i], tLevelHeightPosition[0]);
			tGeometry.AddLine(tLevelNinePosition[i], tLevelNinePosition[0]);
			tGeometry.AddLine(tLevelTenPosition[i], tLevelTenPosition[0]);
		}
		else
		{
			tGeometry.AddLine(tLevelOnePosition[i], tLevelOnePosition[i + 1]);
			tGeometry.AddLine(tLevelTwoPosition[i], tLevelTwoPosition[i + 1]);
			tGeometry.AddLine(tLevelThreePosition[i], tLevelThreePosition[i + 1]);
			tGeometry.AddLine(tLevelFourPosition[i], tLevelFourPosition[i + 1]);
			tGeometry.AddLine(tLevelFivePosition[i], tLevelFivePosition[i + 1]);
			tGeometry.AddLine(tLevelSixPosition[i], tLevelSixPosition[i + 1]);
			tGeometry.AddLine(tLevelSevenPosition[i], tLevelSevenPosition[i + 1]);
			tGeometry.AddLine(tLevelHeightPosition[i], tLevelHeightPosition[i + 1]);
			tGeometry.AddLine(tLevelNinePosition[i], tLevelNinePosition[i + 1]);
			tGeometry.AddLine(tLevelTenPosition[i], tLevelTenPosition[i + 1]);
		}
	}
}
Example #6
0
void xtruSamples()
{
// Draw a sample of TXTRU shapes some convex, concave (and possibly malformed)
// Change Bool_t's to test alternative specifications
// Author: Robert Hatcher ([email protected]) 2000.09.06

// One normally specifies the x-y points in counter-clockwise order;
// flip this to TRUE to test that it doesn't matter.
  Bool_t makecw      = kFALSE;

// One normally specifies the z points in increasing z order;
// flip this to TRUE to test that it doesn't matter.
  Bool_t reversez    = kFALSE;

// One shouldn't be creating malformed polygons
// but to test what happens when one does here's a flag.
// The effect will be only apparent in solid rendering mode
  Bool_t domalformed = kFALSE;
//  domalformed = kTRUE;

  c1 = new TCanvas("c1","sample TXTRU Shapes",200,10,640,640);

// Create a new geometry
  TGeometry* geom = new TGeometry("sample","sample");
  geom->cd();

// Define the complexity of the drawing
  Float_t zseg   = 6;  // either 2 or 6
  Int_t extravis = 0;  // make extra z "arrow" visible

  Float_t unit = 1;

// Create a large BRIK to embed things into
  Float_t bigdim = 12.5*unit;
  TBRIK* world = new TBRIK("world","world","void",bigdim,bigdim,bigdim);

  // Create the main node, make it invisible
  TNode* worldnode = new TNode("worldnode","world node",world);
  worldnode->SetVisibility(0);
  worldnode->cd();

// Canonical shape ... gets further modified by scale factors
// to create convex (and malformed) versions
  Float_t x[] = { -0.50, -1.20,  1.20,  0.50,  0.50,  1.20, -1.20, -0.50 };
  Float_t y[] = { -0.75, -2.00, -2.00, -0.75,  0.75,  2.00,  2.00,  0.75 };
  Float_t z[] = { -0.50, -1.50, -1.50,  1.50,  1.50,  0.50 };
  Float_t s[] = {  0.50,  1.00,  1.50,  1.50,  1.00,  0.50 };
  Int_t   nxy = sizeof(x)/sizeof(Float_t);
  Float_t convexscale[] = { 7.0, -1.0, 1.5 };

  Int_t icolor[] = { 1, 2, 3, 2, 2, 2, 4, 2, 6 };

// xycase and zcase:  0=convex, 1=malformed, 2=concave
// this will either create a 2x2 matrix of shapes
// or a 3x3 array (if displaying malformed versions)
  for (Int_t zcase = 0; zcase<3; zcase++) {
     if (zcase == 1 && !domalformed) continue;
     for (Int_t xycase = 0; xycase<3; xycase++) {
        if (xycase == 1 && !domalformed) continue;

        Char_t *name = "txtruXYZ";
        sprintf(name,"txtru%1d%1d%1d",xycase,zcase,zseg);
        TXTRU* mytxtru = new TXTRU(name,name,"void",8,2);

        Int_t i, j;
        Float_t xsign = (makecw) ? -1 : 1;
        Float_t zsign = (reversez) ? -1 : 1;

        // set the vertex points
        for (i=0; i<nxy; i++) {
           Float_t xtmp = x[i]*xsign;
           Float_t ytmp = y[i];
           if (i==0||i==3||i==4||i==7) xtmp *= convexscale[xycase];
           if (xycase==2) xtmp *=2;
           mytxtru->DefineVertex(i,xtmp,ytmp);
        }
        // set the z segment positions and scales
        for (i=0, j=0; i<zseg; i++) {
           Float_t ztmp = z[i]*zsign;
           if (i==0||i==5) ztmp *= convexscale[zcase];
           if (zcase==2) ztmp *= 2.5;
           if (zseg>2 && zcase!=2 && (i==1||i==4)) continue;
           mytxtru->DefineSection(j,ztmp,s[i]);
           j++;
        }

        TNode* txtrunode = new TNode(name,name,mytxtru);
        txtrunode->SetLineColor(icolor[3*zcase+xycase]);
        Float_t pos_scale = (domalformed) ? 10 : 6;
        Float_t xpos = (xycase-1)*pos_scale*unit;
        Float_t ypos = (zcase-1)*pos_scale*unit;
        txtrunode->SetPosition(xpos,ypos,0.);
     }
  }


// Some extra shapes to show the direction of "z"
  Float_t zhalf = 0.5*bigdim;
  Float_t rmax = 0.03*bigdim;
  TCONE* zcone = new TCONE("zcone","zcone","void",zhalf,0.,rmax,0.,0.);
  zcone->SetVisibility(extravis);
  TNode* zconenode = new TNode("zconenode","zconenode",zcone);
  zconenode->SetLineColor(3);

  Float_t dzstub = 2*rmax; 
  TBRIK* zbrik = new TBRIK("zbrik","zbrik","void",rmax,rmax,dzstub);
  zbrik->SetVisibility(extravis);
  TNode* zbriknode = new TNode("zbriknode","zbriknode",zbrik);
  zbriknode->SetPosition(0.,0.,zhalf+dzstub);
  zbriknode->SetLineColor(3);

//  geom->ls();

  geom->Draw();

// Tweak the pad so that it displays the entire geometry undistorted
  TVirtualPad *thisPad = gPad;
  if (thisPad) {
    TView *view = thisPad->GetView(); 
    if (!view) return;
    Double_t min[3],max[3],center[3];
    view->GetRange(min,max);
    int i;
    // Find the boxed center
    for (i=0;i<3; i++) center[i] = 0.5*(max[i]+min[i]);
    Double_t maxSide = 0;
    // Find the largest side
    for (i=0;i<3; i++) maxSide = TMath::Max(maxSide,max[i]-center[i]);
    file://Adjust scales:
    for (i=0;i<3; i++) {
       max[i] = center[i] + maxSide;
       min[i] = center[i] - maxSide;
    }
    view->SetRange(min,max);
    thisPad->Modified();
    thisPad->Update();
  }

}