Geant4-11
Public Member Functions | Private Attributes
G4VisCommandSceneAddLogo::G4Logo Struct Reference

Public Member Functions

 G4Logo (G4double height, const G4VisAttributes &, const G4Transform3D &)
 
void operator() (G4VGraphicsScene &, const G4ModelingParameters *)
 
 ~G4Logo ()
 

Private Attributes

G4Polyhedronfp4
 
G4PolyhedronfpG
 

Detailed Description

Definition at line 322 of file G4VisCommandsSceneAdd.hh.

Constructor & Destructor Documentation

◆ G4Logo()

G4VisCommandSceneAddLogo::G4Logo::G4Logo ( G4double  height,
const G4VisAttributes visAtts,
const G4Transform3D transform 
)

Definition at line 1837 of file G4VisCommandsSceneAdd.cc.

1839{
1840 const G4double& h = height;
1841 const G4double h2 = 0.5 * h; // Half height.
1842 const G4double ri = 0.25 * h; // Inner radius.
1843 const G4double ro = 0.5 * h; // Outer radius.
1844 const G4double ro2 = 0.5 * ro; // Half outer radius.
1845 const G4double w = ro - ri; // Width.
1846 const G4double w2 = 0.5 * w; // Half width.
1847 const G4double d2 = 0.2 * h; // Half depth.
1848 const G4double f1 = 0.05 * h; // left edge of stem of "4".
1849 const G4double f2 = -0.3 * h; // bottom edge of cross of "4".
1850 const G4double e = 1.e-4 * h; // epsilon.
1851 const G4double xt = f1, yt = h2; // Top of slope.
1852 const G4double xb = -h2, yb = f2 + w; // Bottom of slope.
1853 const G4double dx = xt - xb, dy = yt - yb;
1854 const G4double angle = std::atan2(dy,dx);
1856 rm.rotateZ(angle*rad);
1857 const G4double d = std::sqrt(dx * dx + dy * dy);
1858 const G4double ss = h; // Half height of square subtractor
1859 const G4double y8 = ss; // Choose y of subtractor for outer slope.
1860 const G4double x8 = ((-ss * d - dx * (yt - y8)) / dy) + xt;
1861 G4double y9 = ss; // Choose y of subtractor for inner slope.
1862 G4double x9 = ((-(ss - w) * d - dx * (yt - y8)) / dy) + xt;
1863 // But to get inner, we make a triangle translated by...
1864 const G4double xtr = ss - f1, ytr = -ss - f2 -w;
1865 x9 += xtr; y9 += ytr;
1866
1867 // The idea here is to create a polyhedron for the G and the 4. To do
1868 // this we use Geant4 geometry solids and make boolean operations.
1869 // Note that we do not need to keep the solids. We use local objects,
1870 // which, of course, are deleted on leaving this function. This
1871 // is contrary to the usual requirement for solids that are part of the
1872 // detector for which solids MUST be created on the heap (with "new").
1873 // Finally we invoke CreatePolyhedron, which creates a polyhedron on the heap
1874 // and returns a pointer. It is the user's responsibility to delete,
1875 // which is done in the destructor of this class. Thus the polyhedra,
1876 // created here, remain on the heap for the lifetime of the job.
1877
1878 // G...
1879 G4Tubs tG("tG",ri,ro,d2,0.15*pi,1.85*pi);
1880 G4Box bG("bG",w2,ro2,d2);
1881 G4UnionSolid logoG("logoG",&tG,&bG,G4Translate3D(ri+w2,-ro2,0.));
1882 fpG = logoG.CreatePolyhedron();
1883 fpG->SetVisAttributes(visAtts);
1884 fpG->Transform(G4Translate3D(-0.55*h,0.,0.));
1886
1887 // 4...
1888 G4Box b1("b1",h2,h2,d2);
1889 G4Box bS("bS",ss,ss,d2+e); // Subtractor.
1890 G4Box bS2("bS2",ss,ss,d2+2.*e); // 2nd Subtractor.
1891 G4SubtractionSolid s1("s1",&b1,&bS,G4Translate3D(f1-ss,f2-ss,0.));
1892 G4SubtractionSolid s2("s2",&s1,&bS,G4Translate3D(f1+ss+w,f2-ss,0.));
1893 G4SubtractionSolid s3("s3",&s2,&bS,G4Translate3D(f1+ss+w,f2+ss+w,0.));
1895 ("s4",&s3,&bS,G4Transform3D(rm,G4ThreeVector(x8,y8,0.)));
1896 G4SubtractionSolid s5 // Triangular hole.
1897 ("s5",&bS,&bS2,G4Transform3D(rm,G4ThreeVector(x9,y9,0.)));
1898 G4SubtractionSolid logo4("logo4",&s4,&s5,G4Translate3D(-xtr,-ytr,0.));
1899 fp4 = logo4.CreatePolyhedron();
1900 /* Experiment with creating own polyhedron...
1901 int nNodes = 4;
1902 int nFaces = 4;
1903 double xyz[][3] = {{0,0,0},{1*m,0,0},{0,1*m,0},{0,0,1*m}};
1904 int faces[][4] = {{1,3,2,0},{1,2,4,0},{1,4,3,0},{2,3,4,0}};
1905 fp4 = new G4Polyhedron();
1906 fp4->createPolyhedron(nNodes,nFaces,xyz,faces);
1907 */
1908 fp4->SetVisAttributes(visAtts);
1909 fp4->Transform(G4Translate3D(0.55*h,0.,0.));
1911}
static const G4double d2
static constexpr double rad
Definition: G4SIunits.hh:129
static constexpr double pi
Definition: G4SIunits.hh:55
static const G4double angle[DIMMOTT]
CLHEP::Hep3Vector G4ThreeVector
HepGeom::Translate3D G4Translate3D
HepGeom::Transform3D G4Transform3D
double G4double
Definition: G4Types.hh:83
HepRotation & rotateZ(double delta)
Definition: Rotation.cc:87
Definition: G4Box.hh:56
Definition: G4Tubs.hh:75
void SetVisAttributes(const G4VisAttributes *)
Definition: G4Visible.cc:96
HepPolyhedron & Transform(const G4Transform3D &t)
G4bool transform(G4String &input, const G4String &type)

References angle, G4UnionSolid::CreatePolyhedron(), d2, pi, rad, CLHEP::HepRotation::rotateZ(), G4Visible::SetVisAttributes(), and G4coutFormatters::anonymous_namespace{G4coutFormatters.cc}::transform().

◆ ~G4Logo()

G4VisCommandSceneAddLogo::G4Logo::~G4Logo ( )

Definition at line 1913 of file G4VisCommandsSceneAdd.cc.

1913 {
1914 delete fpG;
1915 delete fp4;
1916}

Member Function Documentation

◆ operator()()

void G4VisCommandSceneAddLogo::G4Logo::operator() ( G4VGraphicsScene sceneHandler,
const G4ModelingParameters  
)

Definition at line 1918 of file G4VisCommandsSceneAdd.cc.

1919 {
1920 sceneHandler.BeginPrimitives();
1921 sceneHandler.AddPrimitive(*fpG);
1922 sceneHandler.AddPrimitive(*fp4);
1923 sceneHandler.EndPrimitives();
1924}
virtual void BeginPrimitives(const G4Transform3D &objectTransformation=G4Transform3D())=0
virtual void AddPrimitive(const G4Polyline &)=0
virtual void EndPrimitives()=0

Field Documentation

◆ fp4

G4Polyhedron * G4VisCommandSceneAddLogo::G4Logo::fp4
private

Definition at line 327 of file G4VisCommandsSceneAdd.hh.

◆ fpG

G4Polyhedron* G4VisCommandSceneAddLogo::G4Logo::fpG
private

Definition at line 327 of file G4VisCommandsSceneAdd.hh.


The documentation for this struct was generated from the following files: