Hello Rooters again,
I try to use compositeshape with different dimensions. The goal is to create a volume wich is not referenced in the primitive shapes : a sort of triangle based on a circular arc. It is something like this: http://www.intellego.fr/bibliotheque/390_bissectrice%20instruction%202.png
I do not have problem to create this.
I have to create a certain number of these geometries with different dimensions. To do that i make intersection between a TGeoPara and a TGeoTube in a loop. The probleme is that each Triangle i create in my loop have the same dimensions whereas i want to change the dimensions. All happen as if the first volume created was defined in all the loop.
Here is my code:
for(int lll=0;lll<TableauPasAxial.size();lll++){
ParaTriangle=geom->MakePara("ParaTriangle",Box[k],CoteTriangle/2*BetaK,CoteTriangle*cos((AngleTriangle-90)*2*PI/360)/2*BetaK,TableauPasAxial[lll]/2-TableauPasAxial[lll-1]/2,90-AngleTriangle,0,0);
ParaTriangle->SetLineColor(kBlack);
TubeTriangle=geom->MakeTube("TubeTriangle",Boitier[k] ,0, DBarresBoitierSodiumTriangle/2*BetaK, TableauPasAxial[lll]/2-TableauPasAxial[lll-1]/2);
TubeTriangle->SetLineColor(kRed);
tr = new TGeoTranslation(DBarresBoitierSodiumTriangle/2*(cos((AngleTriangle-90)*2*PI/360))*BetaK-EcartTriangleTube*BetaK,0, 0);
tr->SetName("tr");
tr->RegisterYourself();
ro = new TGeoRotation();
ro->SetAngles(-AngleTriangle/2,0,0);
ro->SetName("ro");
ro->RegisterYourself();
cs = new TGeoCompositeShape("mir", "ParaTriangle:ro * TubeTriangle:tr");
vol = new TGeoVolume("COMP2",cs);
int kkk0=-1;
for (int tnr0=0; tnr0<6; tnr0++){
kkk0++;
rot1= new TGeoRotation();
rot1->SetAngles(30+tnr0*60,0,0);
tubBarreSCP->AddNode(vol,kkk0,new TGeoCombiTrans("rottrans",(-DBarresBoitierSodiumTriangle/2*(cos((AngleTriangle-90)*2*PI/360))*BetaK+EcartTriangleTube*BetaK)*cos(PI/6+tnr0*PI/3),(-DBarresBoitierSodiumTriangle/2*(cos((AngleTriangle-90)*2*PI/360))*BetaK+EcartTriangleTube*BetaK)*sin(PI/6+tnr0*PI/3),0,rot1));
}}
you see that, in my loop, the value of “lll” changes. But when i print it, all the volume have the same size in z axis. I am sorry, i do not give you all the parameters because my code is really long…
Thank you
If you need further information, do not hesitate to ask.
I am a beginner.
Please help me.
Cher Thomas,
You will have also to change the names of the shapes and transformation matrices in the same loop. This is because the constructor TGeoCompositeShape(“mir”, “ParaTriangle:ro * TubeTriangle:tr”) will just pick-up the first occurrence of the shapes/matrices with the names provided in the expression.
Salutations,
Dear Agheata,
Thank you for your answer.
I tried to follow your advice but i am certainly not doing it correctly:
TGeoCompositeShape *cs[NbAssemblages*NombreElementsAx];
TGeoTranslation *tr[NbAssemblages*NombreElementsAx];
TGeoRotation *ro[NbAssemblages*NombreElementsAx];
for(int lll=0;lll<TableauPasAxial.size();lll++){
ParaTriangle=geom->MakePara("ParaTriangle",Box[k],CoteTriangle/2*BetaK,CoteTriangle*cos((AngleTriangle-90)*2*PI/360)/2*BetaK,TableauPasAxial[lll]/2-TableauPasAxial[lll-1]/2,90-AngleTriangle,0,0);
ParaTriangle->SetLineColor(kBlack);
TubeTriangle=geom->MakeTube("TubeTriangle",Boitier[k] ,0, DBarresBoitierSodiumTriangle/2*BetaK, TableauPasAxial[lll]/2-TableauPasAxial[lll-1]/2);
TubeTriangle->SetLineColor(kRed);
tr[lll] = new TGeoTranslation(DBarresBoitierSodiumTriangle/2*(cos((AngleTriangle-90)*2*PI/360))*BetaK-EcartTriangleTube*BetaK,0, 0);
tr[lll]->SetName("tr");
tr[lll]->RegisterYourself();
ro[lll] = new TGeoRotation();
ro[lll]->SetAngles(-AngleTriangle/2,0,0);
ro[lll]->SetName("ro");
ro[lll]->RegisterYourself();
cs[lll] = new TGeoCompositeShape("mir", ("ParaTriangle:ro[%d] * TubeTriangle:tr[%d]",lll ,lll));
vol = new TGeoVolume("COMP2",cs[lll]);
int kkk0=-1;
for (int tnr0=0; tnr0<6; tnr0++){
kkk0++;
rot1= new TGeoRotation();
rot1->SetAngles(30+tnr0*60,0,0);
tubBarreSCP->AddNode(vol,kkk0,new TGeoCombiTrans("rottrans",(-DBarresBoitierSodiumTriangle/2*(cos((AngleTriangle-90)*2*PI/360))*BetaK+EcartTriangleTube*BetaK)*cos(PI/6+tnr0*PI/3),(-DBarresBoitierSodiumTriangle/2*(cos((AngleTriangle-90)*2*PI/360))*BetaK+EcartTriangleTube*BetaK)*sin(PI/6+tnr0*PI/3),0,rot1));
}}
I added indices (lll) to my transformations and TGeoCompositeShape. I still have a problem. Root does not understand the line cs[lll] = new TGeoCompositeShape(“mir”, (“ParaTriangle:ro[%d] * TubeTriangle:tr[%d]”,lll ,ll));
Could you please help me to understand what is wrong ?
Hi,
The %d cannot be interpreted like that. Everywhere where you use strings, you can use for example::
TString myName1 = Form(“ParaTriangle:ro[%d] * TubeTriangle:tr[%d]”,lll);
… new TGeoCompositeShape(“mir”, myName1);
Make sure to be consistent between the name used to create the shape or transformation and the ones used to create the composite.
Cheers,
Hello,
Is there another way to do this ?
Because that still does not work. The definition of geometry is 100 times longer and i have an error message about tr[lll] (transformation not found)
I think i do not understand how works TGeoCompositeShape …
You maybe have an exemple ?
An example can be found in: $ROOTSYS/tutorials/geom/csgdemo.C
You get the error because you use inconsistently the names. There is another composite shape constructor allowing to start from a boolean node (i.e. provide directly the pointers to 2 shapes and 2 transformations to create a union, subtraction or intersection). The thing gets slow only if you create a composite with too many components (note that the composite shape is not necessary the best choice for what you need to do) or if you do a logical mistake.
Good luck,
So, what is the best choice ? What is the other shape constructor ?
I already used csgdemo to create my compositeshape.
Hi,
Check the attached example.
Cheers,
Reflexao.C (17.4 KB)
Dear Agheata,
Thank you very much for your help.
I suceeded with your example.
Thank you again,
Thomas