Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
visualizeWavefrontObj.C File Reference

Detailed Description

Macro allowing to vizualize tessellations from Wavefront's .obj format.

#include <TROOT.h>
#include <TColor.h>
#include <TDatime.h>
#include <TRandom3.h>
#include <TGeoManager.h>
//______________________________________________________________________________
{
gRandom = new TRandom3();
gRandom->SetSeed(dt.GetTime());
TColor *color = new TColor(ci, gRandom->Rndm(), gRandom->Rndm(), gRandom->Rndm());
return ci;
}
//______________________________________________________________________________
void visualizeWavefrontObj(const char *dot_obj_file = "", bool check = false)
{
// Input a file in .obj format (https://en.wikipedia.org/wiki/Wavefront_.obj_file)
// The file should have a single object inside, only vertex and faces information is used
if (sfile.IsNull()) {
sfile = gROOT->GetTutorialsDir();
sfile += "/visualisation/geom/teddy.obj";
}
name.ReplaceAll(".obj", "");
gROOT->GetListOfCanvases()->Delete();
delete gGeoManager;
new TGeoManager(name, "Imported from .obj file");
TGeoMaterial *mat = new TGeoMaterial("Al", 26.98, 13, 2.7);
TGeoMedium *med = new TGeoMedium("MED", 1, mat);
TGeoVolume *top = gGeoManager->MakeBox("TOP", med, 10, 10, 10);
if (!tsl)
return;
tsl->ResizeCenter(5.);
TGeoVolume *vol = new TGeoVolume(name, tsl, med);
vol->SetLineWidth(2);
top->AddNode(vol, 1);
if (!gROOT->IsBatch())
top->Draw("ogl");
}
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
char name[80]
Definition TGX11.cxx:110
R__EXTERN TGeoManager * gGeoManager
#define gROOT
Definition TROOT.h:406
R__EXTERN TRandom * gRandom
Definition TRandom.h:62
The color creation and management class.
Definition TColor.h:22
static Int_t GetFreeColorIndex()
Static function: Returns the free color index greater than the highest defined color index.
Definition TColor.cxx:2368
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
Definition TDatime.h:37
The manager class for any TGeo geometry.
Definition TGeoManager.h:44
void CloseGeometry(Option_t *option="d")
Closing geometry implies checking the geometry validity, fixing shapes with negative parameters (run-...
TGeoVolume * MakeBox(const char *name, TGeoMedium *medium, Double_t dx, Double_t dy, Double_t dz)
Make in one step a volume pointing to a box shape with given medium.
void SetTopVolume(TGeoVolume *vol)
Set the top volume and corresponding node as starting point of the geometry.
Base class describing materials.
Media are used to store properties related to tracking and which are useful only when using geometry ...
Definition TGeoMedium.h:23
static TGeoTessellated * ImportFromObjFormat(const char *objfile, bool check=false, bool verbose=false)
Reader from .obj format.
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition TGeoVolume.h:43
void SetLineWidth(Width_t lwidth) override
Set the line width.
virtual TGeoNode * AddNode(TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat=nullptr, Option_t *option="")
Add a TGeoNode to the list of nodes.
void Draw(Option_t *option="") override
draw top volume according to option
void SetLineColor(Color_t lcolor) override
Set the line color.
Random number generator class based on M.
Definition TRandom3.h:27
virtual void SetSeed(ULong_t seed=0)
Set the random generator seed.
Definition TRandom.cxx:615
Double_t Rndm() override
Machine independent random number generator.
Definition TRandom.cxx:559
Basic string class.
Definition TString.h:139
Author
Andrei Gheata

Definition in file visualizeWavefrontObj.C.