add geant4 scene and gcompose app
This commit is contained in:
72
src/HEP/Geant/testing/EventTest.cpp
Normal file
72
src/HEP/Geant/testing/EventTest.cpp
Normal file
@@ -0,0 +1,72 @@
|
||||
#include "Geant/Solid.h"
|
||||
#include "HEP/Geant/GeantEvent.h"
|
||||
#include "Math/TriangleMesh.h"
|
||||
#include "testing-prototype.h"
|
||||
#include <Geant4/G4Material.hh>
|
||||
#include <Geant4/G4NistManager.hh>
|
||||
#include <Geant4/G4LogicalVolume.hh>
|
||||
#include <Geant4/G4TessellatedSolid.hh>
|
||||
#include <string.h>
|
||||
|
||||
using namespace uLib;
|
||||
|
||||
int main() {
|
||||
BEGIN_TESTING(Geant Event);
|
||||
|
||||
// Test Solid initialization and NIST material //
|
||||
{
|
||||
Solid solid("test_solid");
|
||||
TEST1(solid.GetLogical() != nullptr);
|
||||
|
||||
solid.SetNistMaterial("G4_AIR");
|
||||
TEST1(solid.GetMaterial() != nullptr);
|
||||
TEST1(solid.GetMaterial()->GetName() == "G4_AIR");
|
||||
}
|
||||
|
||||
// Test TessellatedSolid with a simple mesh //
|
||||
{
|
||||
TessellatedSolid tsolid("test_tessellated");
|
||||
TEST1(tsolid.GetLogical() != nullptr);
|
||||
TEST1(tsolid.GetSolid() != nullptr);
|
||||
|
||||
// cube mesh //
|
||||
TriangleMesh mesh;
|
||||
mesh.AddPoint(Vector3f(0,0,0));
|
||||
mesh.AddPoint(Vector3f(1,0,0));
|
||||
mesh.AddPoint(Vector3f(0,1,0));
|
||||
mesh.AddPoint(Vector3f(1,1,0));
|
||||
mesh.AddPoint(Vector3f(0,0,1));
|
||||
mesh.AddPoint(Vector3f(1,0,1));
|
||||
mesh.AddPoint(Vector3f(0,1,1));
|
||||
mesh.AddPoint(Vector3f(1,1,1));
|
||||
|
||||
// create triangles (consistent outward winding) //
|
||||
// bottom (z=0)
|
||||
mesh.AddTriangle(Vector3i(0,2,3));
|
||||
mesh.AddTriangle(Vector3i(0,3,1));
|
||||
// top (z=1)
|
||||
mesh.AddTriangle(Vector3i(4,5,7));
|
||||
mesh.AddTriangle(Vector3i(4,7,6));
|
||||
// left (x=0)
|
||||
mesh.AddTriangle(Vector3i(0,4,6));
|
||||
mesh.AddTriangle(Vector3i(0,6,2));
|
||||
// right (x=1)
|
||||
mesh.AddTriangle(Vector3i(1,3,7));
|
||||
mesh.AddTriangle(Vector3i(1,7,5));
|
||||
// front (y=0)
|
||||
mesh.AddTriangle(Vector3i(0,1,5));
|
||||
mesh.AddTriangle(Vector3i(0,5,4));
|
||||
// back (y=1)
|
||||
mesh.AddTriangle(Vector3i(2,6,7));
|
||||
mesh.AddTriangle(Vector3i(2,7,3));
|
||||
|
||||
|
||||
|
||||
tsolid.SetMesh(mesh);
|
||||
// GeantEvent geant_event;
|
||||
|
||||
|
||||
}
|
||||
|
||||
END_TESTING
|
||||
}
|
||||
Reference in New Issue
Block a user