48 if (b.substr(0, 1) ==
"/" || a.empty()) {
52 if (a.substr(a.size() - 1) ==
"/") {
53 return a.substr(a.size() - 1) +
"/" + b;
61 return (getcwd(buffer,
sizeof(buffer)) !=
nullptr ?
std::string(buffer)
87 if (not transform.isApprox(Transform3::Identity())) {
88 surfaceHedron.
move(transform);
90 drawPolyhedron(helper, surfaceHedron, viewConfig);
99 _outputDir ==
"." ? getWorkingDirectory() : _outputDir;
102 for (
const auto& sf : surfaceArray.
surfaces()) {
103 ViewConfig vConfig = sf->associatedDetectorElement() !=
nullptr
106 drawSurface(helper, *sf, gctx, transform, vConfig);
107 auto sfExtent = sf->polyhedronRepresentation(gctx, 1).extent();
108 arrayExtent.
extend(sfExtent);
119 auto axes = surfaceArray.
getAxes();
120 if (not binning.empty() and binning.size() == 2 and axes.size() == 2) {
122 if (binning[0] ==
binPhi and binning[1] ==
binZ) {
125 auto zValues = axes[1]->getBinEdges();
130 double cphi = std::cos(
phi);
131 double sphi = std::sin(
phi);
132 Vector3 p1(R * cphi, R * sphi, axes[1]->getMin());
133 Vector3 p0(R * cphi, R * sphi, axes[1]->getMax());
134 drawSegment(helper, transform * p0, transform * p1, gridConfig);
139 for (
auto z : zValues) {
140 for (
const auto& cvbSf : cvbOrientedSurfaces) {
141 drawSurface(helper, *cvbSf.first, gctx,
146 }
else if (binning[0] ==
binR and binning[1] ==
binPhi) {
148 auto rValues = axes[0]->getBinEdges();
152 for (
auto r : rValues) {
156 for (
const auto& cvbSf : cvbOrientedSurfaces) {
157 drawSurface(helper, *cvbSf.first, gctx,
161 double rMin = axes[0]->getMin();
162 double rMax = axes[0]->getMax();
164 double cphi = std::cos(
phi);
165 double sphi = std::sin(
phi);
166 Vector3 p1(rMax * cphi, rMax * sphi, z);
167 Vector3 p0(rMin * cphi, rMin * sphi, z);
168 drawSegment(helper, transform * p0, transform * p1, gridConfig);
185 for (
const auto& bs : bSurfaces) {
186 drawSurface(helper, bs->surfaceRepresentation(),
gctx,
transform,
201 if (links->size() == 2) {
202 drawSurface(helper, *
surface, gctx, transform, connected);
204 drawSurface(helper, *
surface, gctx, transform, disconnected);
215 drawSurface(helper, *
surface, gctx, transform, viewConfig);
219 for (
auto portal : volume.
portals()) {
220 drawPortal(helper, *portal, gctx, transform, connected, unconnected);
224 for (
auto subvolume : volume.
volumes()) {
225 drawDetectorVolume(helper, *subvolume, gctx, transform, connected,
226 unconnected, viewConfig);
235 _outputDir ==
"." ? getWorkingDirectory() : _outputDir;
239 if (layerVolume !=
nullptr) {
240 drawVolume(helper, *layerVolume, gctx, Transform3::Identity(),
244 drawSurface(helper, layerSurface, gctx, Transform3::Identity(),
255 if (surfaceArray !=
nullptr) {
256 drawSurfaceArray(helper, *surfaceArray, gctx, Transform3::Identity(),
257 sensitiveConfig, layerConfig, gridConfig, outputDir);
269 _outputDir ==
"." ? getWorkingDirectory() : _outputDir;
272 for (
const auto& tv : subVolumes) {
273 drawTrackingVolume(helper, *tv, gctx, containerView, volumeView,
274 layerView, sensitiveView, gridView, writeIt, tag,
289 std::vector<std::string> repChar = {
"::" };
291 for (
const auto& rchar : repChar) {
292 while (vname.find(rchar) != std::string::npos) {
293 vname.replace(vname.find(rchar), rchar.size(),
std::string(
"_"));
300 std::stringstream vs;
304 for (
const auto* current = &tVolume; current->
motherVolume() !=
nullptr;
306 ids.push_back(current->motherVolume()->geometryId().volume());
309 for (
size_t i =
ids.size() - 1;
i <
ids.size(); --
i) {
310 vs <<
"_v" <<
ids[
i];
318 for (
const auto& bs : bSurfaces) {
319 drawSurface(helper, bs->surfaceRepresentation(),
gctx,
320 Transform3::Identity(), vcConfig);
324 helper.write(outputName);
331 for (
const auto&
tl : layers) {
340 drawLayer(helper, *
tl, gctx, lConfig, sConfig, gConfig, outputDir);
355 auto direction =
Vector3(end - start).normalized();
356 double hlength = 0.5 *
Vector3(end - start).norm();
360 lrotation.col(0) = unitVectors.first;
361 lrotation.col(1) = unitVectors.second;
362 lrotation.col(2) = direction;
365 double alength = (thickness > 0.) ? arrowLength * thickness : 2.;
366 if (alength > hlength) {
372 }
else if (arrows != 0) {
373 hlength -= 0.5 * alength;
374 lcenter -=
Vector3(arrows * 0.5 * alength * direction);
378 if (thickness > 0.) {
379 auto ltransform = Transform3::Identity();
380 ltransform.prerotate(lrotation);
381 ltransform.pretranslate(lcenter);
383 auto lbounds = std::make_shared<CylinderBounds>(
thickness, hlength);
384 auto line = Surface::makeShared<CylinderSurface>(ltransform, lbounds);
389 helper.line(start, end, viewConfig.
color);
394 double awith = thickness * arrowWidth;
395 double alpha = atan2(thickness * arrowWidth, alength);
396 auto plateBounds = std::make_shared<RadialBounds>(
thickness, awith);
399 auto aetransform = Transform3::Identity();
400 aetransform.prerotate(lrotation);
401 aetransform.pretranslate(end);
403 auto coneBounds = std::make_shared<ConeBounds>(
alpha, -alength, 0.);
404 auto cone = Surface::makeShared<ConeSurface>(aetransform, coneBounds);
408 auto aptransform = Transform3::Identity();
409 aptransform.prerotate(lrotation);
410 aptransform.pretranslate(
Vector3(end - alength * direction));
412 auto plate = Surface::makeShared<DiscSurface>(aptransform, plateBounds);
416 if (arrows < 0 or arrows == 2) {
417 auto astransform = Transform3::Identity();
418 astransform.prerotate(lrotation);
419 astransform.pretranslate(start);
422 auto coneBounds = std::make_shared<ConeBounds>(
alpha, 0., alength);
423 auto cone = Surface::makeShared<ConeSurface>(astransform, coneBounds);
427 auto aptransform = Transform3::Identity();
428 aptransform.prerotate(lrotation);
429 aptransform.pretranslate(
Vector3(start + alength * direction));
431 auto plate = Surface::makeShared<DiscSurface>(aptransform, plateBounds);
441 drawSegmentBase(helper, start, end, 0, 0., 0., viewConfig);
446 double arrowLength,
double arrowWidth,
const ViewConfig& viewConfig) {
447 drawSegmentBase(helper, start, end, -1, arrowLength, arrowWidth, viewConfig);
452 double arrowLength,
double arrowWidth,
const ViewConfig& viewConfig) {
453 drawSegmentBase(helper, start, end, 1, arrowLength, arrowWidth, viewConfig);
459 double arrowLength,
double arrowWidth,
461 drawSegmentBase(helper, start, end, 2, arrowLength, arrowWidth, viewConfig);