51 xml_comp_t x_step = x_det.child(_Unicode(step_file));
52 xml_comp_t x_pos = x_det.child(_Unicode(position));
53 xml_comp_t x_rot = x_det.child(_Unicode(rotation));
54 xml_comp_t x_mat = x_det.child(_Unicode(material));
56 std::string name = x_det.nameStr();
57 std::string path = x_step.attr<std::string>(_Unicode(path));
62 printout(INFO,
"G4OCCT_STEPSolid",
"Imported '%s' from '%s'; %zu triangles in tessellated solid",
63 name.c_str(), path.c_str(), geom.triangles.size());
69 const std::size_t nTriangles = geom.triangles.size();
70 if (nTriangles >
static_cast<std::size_t
>(std::numeric_limits<int>::max())) {
71 throw std::runtime_error(
"G4OCCT_STEPSolid: tessellation of '" + path +
"' produced " +
72 std::to_string(nTriangles) +
73 " triangles, which exceeds TessellatedSolid's int capacity");
75 TessellatedSolid tess(name +
"_tess",
static_cast<int>(nTriangles));
76 for (
const auto& tri : geom.triangles) {
77 tess.addFacet(TessellatedSolid::Vertex(tri.v[0].x, tri.v[0].y, tri.v[0].z),
78 TessellatedSolid::Vertex(tri.v[1].x, tri.v[1].y, tri.v[1].z),
79 TessellatedSolid::Vertex(tri.v[2].x, tri.v[2].y, tri.v[2].z));
81 tess.ptr()->CloseShape(
true,
true,
false);
84 Material mat = description.material(x_mat.attr<std::string>(_Unicode(name)));
85 Volume vol(name +
"_vol", tess, mat);
86 vol.setVisAttributes(description, x_det.visStr());
88 DetElement det(name, x_det.id());
89 Position pos(x_pos.x(), x_pos.y(), x_pos.z());
90 RotationZYX rot(x_rot.z(), x_rot.y(), x_rot.x());
91 PlacedVolume pv = description.pickMotherVolume(det).placeVolume(vol, Transform3D(rot, pos));
92 pv.addPhysVolID(
"system", x_det.id());