Skip to content

Commit

Permalink
Setting the world in the example to be invisable, and added a color t…
Browse files Browse the repository at this point in the history
…o one of the loaded meshes.
  • Loading branch information
christopherpoole committed Dec 11, 2014
1 parent 79bff14 commit 48d1f08
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
4 changes: 2 additions & 2 deletions examples/basic/macros/vis.mac
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

/vis/viewer/set/viewpointThetaPhi 60 30

#/vis/viewer/set/style solid
#/vis/viewer/set/hiddenEdge 1
/vis/viewer/set/style solid
/vis/viewer/set/hiddenEdge 1

/vis/scene/add/trajectories
/vis/scene/endOfEventAction accumulate
Expand Down
27 changes: 21 additions & 6 deletions examples/basic/src/DetectorConstruction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

#include "G4NistManager.hh"
#include "G4Material.hh"
#include "G4VisAttributes.hh"


DetectorConstruction::DetectorConstruction()
{;}
Expand All @@ -45,22 +47,35 @@ G4VPhysicalVolume* DetectorConstruction::Construct()
world_logical = new G4LogicalVolume(world_solid, air,"world_logical",0,0,0);
world_physical = new G4PVPlacement(0, G4ThreeVector(), world_logical,
"world_physical", 0, false, 0);
world_logical->SetVisAttributes(G4VisAttributes::Invisible);

// CAD model rotation.
G4RotationMatrix * rot = new G4RotationMatrix();
rot->rotateZ(90*deg);

// Load CAD file as tessellated solid //
offset = G4ThreeVector(-30*cm, 0, 0);
CADMesh * mesh = new CADMesh("../../models/cone.ply", "PLY", mm, offset, false);
offset = G4ThreeVector(-20*cm, 0, 0);

// Note that offset is applied to the points in mesh directly before placement.
CADMesh * mesh = new CADMesh("../../models/cone.ply", "PLY");
mesh->SetScale(mm);
mesh->SetOffset(offset);
mesh->SetReverse(false);

cad_solid = mesh->TessellatedMesh();
cad_logical = new G4LogicalVolume(cad_solid, water, "cad_logical", 0, 0, 0);
cad_physical = new G4PVPlacement(0, G4ThreeVector(), cad_logical,
cad_physical = new G4PVPlacement(rot, G4ThreeVector(), cad_logical,
"cad_physical", world_logical, false, 0);
cad_logical->SetVisAttributes(G4Color(0.5, 0.3, 1, 1));

// Load CAD file as tetrahedral mesh //
CADMesh * tet_mesh = new CADMesh("../../models/cone.ply", "PLY", water);
CADMesh * tet_mesh = new CADMesh("../../models/cone.ply", "PLY");
tet_mesh->SetScale(1.5);
tet_mesh->SetMaterial(water); // We have to do this before making the G4AssemblyVolume.

G4AssemblyVolume * cad_assembly = tet_mesh->TetrahedralMesh();

G4Translate3D translation(30*cm, 0., 0.);
G4RotationMatrix * rot = new G4RotationMatrix();
G4Translate3D translation(20*cm, 0., 0.);
G4Transform3D rotation = G4Rotate3D(*rot);
G4Transform3D transform = translation*rotation;

Expand Down

0 comments on commit 48d1f08

Please sign in to comment.