Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
paulgessinger committed Dec 10, 2024
1 parent 364ba59 commit 58a7df6
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 57 deletions.
7 changes: 4 additions & 3 deletions Core/include/Acts/Geometry/Blueprint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ class GeometryContext;
///
/// The construction phases are documented in @c BlueprintNode, which is the
/// base class for all nodes in the tree.
/// @note This class inherits from @c BlueprintNode privately, because it is
/// only ever intended to be the top-level node, and not anywhere else in
/// the tree.
/// @note This class inherits from @c BlueprintNode, but hides the main
/// blueprint construction phase overloads. The @c Blueprint class is
/// only ever intended to be the top-level node, and not anywhere else
/// in the tree.
class Blueprint : public BlueprintNode {
public:
struct Config {
Expand Down
14 changes: 6 additions & 8 deletions Core/include/Acts/Geometry/BlueprintNode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ class LayerBlueprintNode;
/// carried out.
class BlueprintNode {
public:
/// Can be default constructed
BlueprintNode() = default;

/// Virtual destructor to ensure correct cleanup
virtual ~BlueprintNode() = default;

Expand Down Expand Up @@ -179,11 +176,11 @@ class BlueprintNode {
/// overload will invoke the constructor of @ref Acts::TrackingVolume and use
/// that volume to create the node.
/// @param transform The transform of the volume
/// @param volbounds The bounds of the volume
/// @param volumeBounds The bounds of the volume
/// @param volumeName The name of the volume
/// @param callback An optional callback that receives the node as an argument
StaticBlueprintNode& addStaticVolume(
const Transform3& transform, std::shared_ptr<VolumeBounds> volbounds,
const Transform3& transform, std::shared_ptr<VolumeBounds> volumeBounds,
const std::string& volumeName = "undefined",
const std::function<void(StaticBlueprintNode& cylinder)>& callback = {});

Expand Down Expand Up @@ -256,11 +253,11 @@ class BlueprintNode {

/// Print the node tree starting from this node to graphviz format
/// @param os The stream to print to
void graphViz(std::ostream& os) const;
void graphviz(std::ostream& os) const;

/// Method that writes a representatiohn of **this node only** to graphviz.
/// This should generally not be called on its own, but through the @ref
/// BlueprintNode::graphViz method.
/// BlueprintNode::graphviz method.
/// @param os The stream to print to
virtual void addToGraphviz(std::ostream& os) const;

Expand Down Expand Up @@ -294,4 +291,5 @@ class BlueprintNode {
std::size_t m_depth{0};
std::vector<std::shared_ptr<BlueprintNode>> m_children{};
};
}; // namespace Acts

} // namespace Acts
2 changes: 0 additions & 2 deletions Core/include/Acts/Geometry/BlueprintOptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ struct BlueprintOptions {

void validate() const;

~BlueprintOptions();

private:
static std::unique_ptr<NavigationPolicyFactory>
makeDefaultNavigationPolicyFactory();
Expand Down
10 changes: 6 additions & 4 deletions Core/include/Acts/Geometry/CylinderContainerBlueprintNode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace Acts {
/// if this is not the case.
class CylinderContainerBlueprintNode final : public BlueprintNode {
public:
/// Main constructor for t he cylinder container node.
/// Main constructor for the cylinder container node.
/// @param name The name of the node (for debug only)
/// @param direction The stacking direction
/// @param attachmentStrategy The attachment strategy for the stack
Expand Down Expand Up @@ -136,11 +136,13 @@ class CylinderContainerBlueprintNode final : public BlueprintNode {

std::string m_name;

BinningValue m_direction;
BinningValue m_direction = BinningValue::binZ;

CylinderVolumeStack::AttachmentStrategy m_attachmentStrategy;
CylinderVolumeStack::AttachmentStrategy m_attachmentStrategy{
CylinderVolumeStack::AttachmentStrategy::Midpoint};

CylinderVolumeStack::ResizeStrategy m_resizeStrategy;
CylinderVolumeStack::ResizeStrategy m_resizeStrategy{
CylinderVolumeStack::ResizeStrategy::Expand};

// Is only initialized during `build`
std::vector<Volume*> m_childVolumes;
Expand Down
27 changes: 21 additions & 6 deletions Core/include/Acts/Geometry/LayerBlueprintNode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include "Acts/Geometry/StaticBlueprintNode.hpp"

#include <iosfwd>
#include <ostream>

namespace Acts {

Expand Down Expand Up @@ -100,6 +100,26 @@ class LayerBlueprintNode : public StaticBlueprintNode {
/// @return The layer type
const LayerType& layerType() const;

/// Output operator for the layer type enum.
/// @param os The output stream
/// @param type The layer type
friend std::ostream& operator<<(std::ostream& os,
LayerBlueprintNode::LayerType type) {
switch (type) {
using enum LayerBlueprintNode::LayerType;
case Cylinder:
os << "Cylinder";
break;
case Disc:
os << "Disc";
break;
case Plane:
os << "Plane";
break;
}
return os;
}

private:
/// @copydoc Acts::BlueprintNode::addToGraphviz
void addToGraphviz(std::ostream& os) const override;
Expand All @@ -118,9 +138,4 @@ class LayerBlueprintNode : public StaticBlueprintNode {
LayerType m_layerType = LayerType::Cylinder;
};

/// Output operator for the layer type enum.
/// @param os The output stream
/// @param type The layer type
std::ostream& operator<<(std::ostream& os, LayerBlueprintNode::LayerType type);

} // namespace Acts
1 change: 0 additions & 1 deletion Core/include/Acts/Geometry/StaticBlueprintNode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class StaticBlueprintNode : public BlueprintNode {
/// Build-phase of the blueprint construction. Returns the wrapped volume for
/// sizing.
Volume& build(const BlueprintOptions& options, const GeometryContext& gctx,

const Logger& logger = Acts::getDummyLogger()) override;

/// @copydoc BlueprintNode::connect
Expand Down
18 changes: 8 additions & 10 deletions Core/src/Geometry/BlueprintNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "Acts/Navigation/INavigationPolicy.hpp"
#include "Acts/Navigation/TryAllNavigationPolicy.hpp"

#include <concepts>
#include <ostream>

namespace Acts {
Expand All @@ -27,13 +28,10 @@ bool hasDescendent(const BlueprintNode& descendent,
return true;
}

for (const auto& child : ancestor.children()) {
if (hasDescendent(descendent, child)) {
return true;
}
}

return false;
return std::ranges::any_of(ancestor.children(),
[&](const auto& child) -> bool {
return hasDescendent(descendent, child);
});
}
} // namespace

Expand Down Expand Up @@ -107,11 +105,11 @@ StaticBlueprintNode& BlueprintNode::addStaticVolume(
}

StaticBlueprintNode& BlueprintNode::addStaticVolume(
const Transform3& transform, std::shared_ptr<VolumeBounds> volbounds,
const Transform3& transform, std::shared_ptr<VolumeBounds> volumeBounds,
const std::string& volumeName,
const std::function<void(StaticBlueprintNode& cylinder)>& callback) {
return addStaticVolume(std::make_unique<TrackingVolume>(
transform, std::move(volbounds), volumeName),
transform, std::move(volumeBounds), volumeName),
callback);
}

Expand Down Expand Up @@ -158,7 +156,7 @@ void BlueprintNode::clearChildren() {
m_children.clear();
}

void BlueprintNode::graphViz(std::ostream& os) const {
void BlueprintNode::graphviz(std::ostream& os) const {
os << "digraph BlueprintNode {" << std::endl;
addToGraphviz(os);
os << "}" << std::endl;
Expand Down
2 changes: 0 additions & 2 deletions Core/src/Geometry/BlueprintOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,4 @@ BlueprintOptions::makeDefaultNavigationPolicyFactory() {
.asUniquePtr();
}

BlueprintOptions::~BlueprintOptions() = default;

} // namespace Acts
16 changes: 0 additions & 16 deletions Core/src/Geometry/LayerBlueprintNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,20 +146,4 @@ void LayerBlueprintNode::addToGraphviz(std::ostream& os) const {
BlueprintNode::addToGraphviz(os);
}

std::ostream& operator<<(std::ostream& os, LayerBlueprintNode::LayerType type) {
switch (type) {
using enum LayerBlueprintNode::LayerType;
case Cylinder:
os << "Cylinder";
break;
case Disc:
os << "Disc";
break;
case Plane:
os << "Plane";
break;
}
return os;
}

} // namespace Acts
4 changes: 2 additions & 2 deletions Examples/Python/src/Blueprint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,9 @@ void addBlueprint(Context& ctx) {
.def("clearChildren", &BlueprintNode::clearChildren)
.def_property_readonly("name", &BlueprintNode::name)
.def_property_readonly("depth", &BlueprintNode::depth)
.def("graphViz", [](BlueprintNode& self, const py::object& fh) {
.def("graphviz", [](BlueprintNode& self, const py::object& fh) {
std::stringstream ss;
self.graphViz(ss);
self.graphviz(ss);
fh.attr("write")(ss.str());
});

Expand Down
2 changes: 1 addition & 1 deletion Examples/Python/tests/test_blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def write(root: acts.BlueprintNode, stage: int):
gz = tmp_path / f"blueprint_{stage}.dot"
print(gz)
with gz.open("w") as fh:
root.graphViz(fh)
root.graphviz(fh)

base = acts.Transform3.Identity()

Expand Down
2 changes: 1 addition & 1 deletion Examples/Scripts/Python/blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@


with open("blueprint.dot", "w") as fh:
root.graphViz(fh)
root.graphviz(fh)


gctx = acts.GeometryContext()
Expand Down
2 changes: 1 addition & 1 deletion Tests/UnitTests/Core/Geometry/BlueprintApiTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ BOOST_AUTO_TEST_CASE(NodeApiTestContainers) {
});

std::ofstream dot{"api_test_container.dot"};
root->graphViz(dot);
root->graphviz(dot);

auto trackingGeometry = root->construct({}, gctx, *logger);

Expand Down

0 comments on commit 58a7df6

Please sign in to comment.