Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-10 07:50:28

0001 #include <csignal>
0002 #include "G4Orb.hh"
0003 #include "G4Box.hh"
0004 #include "G4UnionSolid.hh"
0005 #include "G4RotationMatrix.hh"
0006 
0007 #include "U4Solid.h"
0008 #include "U4SolidMaker.hh"
0009 
0010 #include "ssys.h"
0011 #include "sn.h"
0012 #include "s_csg.h"
0013 
0014 
0015 struct U4SolidTest
0016 {
0017     static void Setup();
0018 
0019     static constexpr const char* _Convert_level = "U4SolidTest__Convert_level" ;
0020     static int Convert(const G4VSolid* solid);
0021     static int Orb();
0022     static int Box();
0023     static int Uni();
0024 
0025     static constexpr const char* _MAKE = "U4SolidTest__MAKE" ;
0026     static int MAKE();
0027     static int ALL();
0028 
0029     static int Main();
0030 };
0031 
0032 
0033 void U4SolidTest::Setup()
0034 {
0035     s_csg* csg = new s_csg ;
0036     assert(csg);
0037     if(!csg) std::raise(SIGINT);
0038 }
0039 
0040 int U4SolidTest::Convert(const G4VSolid* solid )
0041 {
0042     int lvid = 0 ;
0043     int depth = 0 ;
0044     int level = ssys::getenvint(_Convert_level,1) ;
0045     sn* nd = U4Solid::Convert(solid, lvid, depth, level);
0046     std::cout
0047         << "[U4SolidTest::Convert nd.desc\n"
0048         <<   nd->desc()
0049         << "]U4SolidTest::Convert nd.desc\n"
0050         ;
0051 
0052     if(level > 2 ) std::cout
0053         << "\nU4SolidTest::Convert nd->render() \n\n"
0054         << nd->render()
0055         << "\n"
0056         ;
0057 
0058     if(level > 3 ) std::cout
0059         << "\nU4SolidTest::Convert nd->detail_r() \n\n"
0060         << nd->detail_r()
0061         << "\n"
0062         ;
0063 
0064     if(level > 3 ) std::cout
0065         << "\nU4SolidTest::Convert nd->desc_prim_all() \n\n"
0066         << nd->desc_prim_all(false)
0067         << "\n"
0068         ;
0069 
0070     std::cout << "sn::Desc.0.before-delete-expect-some-nodes\n"  << sn::Desc() << "\n" ;
0071 
0072     delete nd ;
0073     std::cout << "sn::Desc.1.after-delete-expect-no-nodes\n"  << sn::Desc() << "\n" ;
0074 
0075 
0076     return 0 ;
0077 }
0078 
0079 int U4SolidTest::Orb()
0080 {
0081     G4Orb* orb = new G4Orb("orb", 100.) ;
0082     return Convert(orb);
0083 }
0084 int U4SolidTest::Box()
0085 {
0086     G4Box* box = new G4Box("box", 100., 200., 300. ) ;
0087     return Convert(box);
0088 }
0089 int U4SolidTest::Uni()
0090 {
0091     G4Orb* orb = new G4Orb("orb", 100.) ;
0092     G4Box* box = new G4Box("box", 100., 200., 300. ) ;
0093 
0094     G4RotationMatrix* rot = new G4RotationMatrix(
0095             G4ThreeVector(0.707107,-0.707107,0.000000),
0096             G4ThreeVector(0.707107, 0.707107,0.000000),
0097             G4ThreeVector(0.000000, 0.000000,1.000000)
0098             );
0099     G4ThreeVector tla(50.,60.,70.);
0100     G4UnionSolid* orb_box = new G4UnionSolid( "orb_box", orb, box, rot, tla );
0101 
0102     return Convert(orb_box);
0103 }
0104 
0105 
0106 int U4SolidTest::MAKE()
0107 {
0108     const char* make = ssys::getenvvar(_MAKE, "LocalFastenerAcrylicConstruction4" );
0109     const G4VSolid* solid = U4SolidMaker::Make(make) ;
0110     return Convert(solid);
0111 }
0112 
0113 int U4SolidTest::ALL()
0114 {
0115     int rc = 0 ;
0116     rc += Orb();
0117     rc += Box();
0118     rc += Uni();
0119     rc += MAKE();
0120     return rc ;
0121 }
0122 
0123 int U4SolidTest::Main()
0124 {
0125     Setup();
0126     const char* TEST = ssys::getenvvar("TEST", "Orb");
0127     int rc = 0 ;
0128     if(     strcmp(TEST, "Orb") == 0 )  rc = Orb();
0129     else if(strcmp(TEST, "Box") == 0 )  rc = Box();
0130     else if(strcmp(TEST, "Uni") == 0 )  rc = Uni();
0131     else if(strcmp(TEST, "ALL") == 0 )  rc = ALL();
0132     else if(strcmp(TEST, "MAKE") == 0 )  rc = MAKE();
0133     return rc ;
0134 }
0135 
0136 int main(int argc, char** argv)
0137 {
0138     return U4SolidTest::Main();
0139 }
0140 
0141