Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /npsim/src/geocad/tests/integration_create_step.cxx was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 #include <filesystem>
0002 #include <iostream>
0003 #include <string>
0004 
0005 #include "TGeoManager.h"
0006 #include "TGeoMaterial.h"
0007 #include "TGeoMedium.h"
0008 #include "TGeoToStep.h"
0009 #include "TGeoVolume.h"
0010 
0011 namespace fs = std::filesystem;
0012 
0013 namespace {
0014 TGeoManager* make_test_geometry() {
0015   auto* geom = new TGeoManager("npdet_geo_test", "npdet geocad integration test");
0016   auto* mat  = new TGeoMaterial("Vacuum", 0, 0, 0);
0017   auto* med  = new TGeoMedium("Vacuum", 1, mat);
0018 
0019   auto* top   = geom->MakeBox("top", med, 100., 100., 100.);
0020   auto* child = geom->MakeBox("child", med, 10., 10., 10.);
0021   top->AddNode(child, 1);
0022   geom->SetTopVolume(top);
0023   geom->CloseGeometry();
0024   return geom;
0025 }
0026 } // namespace
0027 
0028 int main(int argc, char* argv[]) {
0029   if (argc != 2) {
0030     std::cerr << "Expected output path argument\n";
0031     return 1;
0032   }
0033 
0034   const fs::path out_path = argv[1];
0035   fs::remove(out_path);
0036 
0037   TGeoToStep converter(make_test_geometry());
0038   converter.CreateGeometry(out_path.string().c_str(), 2, 1.0);
0039 
0040   if (!fs::exists(out_path) || fs::file_size(out_path) == 0) {
0041     std::cerr << "STEP output file was not created\n";
0042     return 1;
0043   }
0044 
0045   return 0;
0046 }