Combinatorial Solid Geometry example.
void csgdemo ()
{
bar->
AddButton(
"How to run ",
"help()",
"Instructions ");
bar->
AddButton(
"Union ",
"s_union()",
"A + B ");
bar->
AddButton(
"Intersection ",
"s_intersection()",
"A * B ");
bar->
AddButton(
"Difference ",
"s_difference()",
"A - B ");
bar->
AddButton(
"Complex composite",
"complex_1()",
"(A * B) + (C - D)");
}
void MakePicture()
{
}
void s_union()
{
gROOT->GetListOfCanvases()->Delete();
TCanvas *c =
new TCanvas(
"composite shape",
"Union boolean operation", 700, 1000);
MakePicture();
TText *text = pt->
AddText(
"TGeoCompositeShape - composite shape class");
pt->
AddText(
"----- It's an example of boolean union operation : A + B");
pt->
AddText(
"----- A == part of sphere (5-175, 0-340), B == pgon");
}
void s_intersection()
{
gROOT->GetListOfCanvases()->Delete();
TCanvas *c =
new TCanvas(
"composite shape",
"Intersection boolean operation", 700, 1000);
MakePicture();
TText *text = pt->
AddText(
"TGeoCompositeShape - composite shape class");
pt->
AddText(
"----- Here is an example of boolean intersection operation : A * B");
pt->
AddText(
"----- A == sphere (with inner radius non-zero), B == box");
}
void s_difference()
{
gROOT->GetListOfCanvases()->Delete();
TCanvas *c =
new TCanvas(
"composite shape",
"Difference boolean operation", 700, 1000);
MakePicture();
TText *text = pt->
AddText(
"TGeoCompositeShape - composite shape class");
pt->
AddText(
"----- It's an example of boolean difference: A - B");
pt->
AddText(
"----- A == part of sphere (0-180, 0-270), B == partial torus (45-145)");
}
void complex_1()
{
gROOT->GetListOfCanvases()->Delete();
MakePicture();
TText *text = pt->
AddText(
"TGeoCompositeShape - composite shape class");
pt->
AddText(
"----- (sphere * box) + (sphere - box) ");
}
void AddText(
TPaveText *pave,
const char *datamember,
Double_t value,
const char *comment)
{
char line[128];
for (
Int_t i=0; i<128; i++) line[i] =
' ';
memcpy(&line[0], datamember, strlen(datamember));
line[10] = '=';
char number[20];
sprintf(number, "%5.2f", value);
memcpy(&line[12], number, strlen(number));
line[26] = '=';
line[27] = '>';
sprintf(&line[30], "%s",comment);
}
void AddText(
TPaveText *pave,
const char *datamember,
Int_t value,
const char *comment)
{
char line[128];
for (
Int_t i=0; i<128; i++) line[i] =
' ';
memcpy(&line[0], datamember, strlen(datamember));
line[10] = '=';
char number[20];
sprintf(number, "%5i", value);
memcpy(&line[12], number, strlen(number));
line[26] = '=';
line[27] = '>';
sprintf(&line[30], "%s",comment);
}
{
char line[128];
if (!pave || !pf) return;
for (
Int_t i=0; i<128; i++) line[i] =
' ';
sprintf(line,
"Division of %s on axis %d (%s)", volume->
GetName(), iaxis,sh->
GetAxisName(iaxis));
text->SetTextAlign(12);
AddText(pave,
"fNdiv",finder->
GetNdiv(),
"number of divisions");
AddText(pave,
"fStart",finder->
GetStart(),
"start divisioning position");
AddText(pave,
"fStep",finder->
GetStep(),
"division step");
}
void raytrace() {
if (!painter) return;
}
void help() {
new TCanvas(
"chelp",
"Help to run demos",200,10,700,600);
welcome->
AddText(
"Welcome to the new geometry package");
hdemo->
AddText(
"- Demo for building TGeo composite shapes");
}