Skip to content
Snippets Groups Projects
Commit 930ed375 authored by Johannes Junggeburth's avatar Johannes Junggeburth 🐕
Browse files

GeoModelKernel - Tidy the GeoAccessVolumeAction & minor tidy in the GeoMaterial & GeoVolumeCursor

parent 14782434
No related branches found
No related tags found
1 merge request!412Query is nothing else than a std::optional but just came earlier
/*
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
*/
#ifndef GeoAccessVolumeAction_h
......@@ -25,7 +25,7 @@ class GeoAccessVolumeAction final : public GeoNodeAction
public:
GeoAccessVolumeAction (unsigned int Index, const GeoVAlignmentStore* store);
virtual ~GeoAccessVolumeAction() override;
virtual ~GeoAccessVolumeAction() =default;
/// Handles a Transform.
virtual void handleTransform (const GeoTransform *xform) override;
......@@ -70,49 +70,42 @@ class GeoAccessVolumeAction final : public GeoNodeAction
virtual void handleSerialIdentifier(const GeoSerialIdentifier *sI) override;
private:
GeoAccessVolumeAction(const GeoAccessVolumeAction &right);
GeoAccessVolumeAction & operator=(const GeoAccessVolumeAction &right);
/// Returns a pointer to the ith physical volume under this one.
PVConstLink m_volume;
PVConstLink m_volume{};
/// The transformation to the ith volume.
GeoTrf::Transform3D m_transform;
GeoTrf::Transform3D m_transform{GeoTrf::Transform3D::Identity()};
/// The default transformation to the ith volume.
GeoTrf::Transform3D m_defTransform;
GeoTrf::Transform3D m_defTransform{GeoTrf::Transform3D::Identity()};
/// The volume which we are interested in seeking.
unsigned int m_index;
unsigned int m_index{0};
/// The volume which we are interested in seeking.
unsigned int m_counter;
unsigned int m_counter{0};
/// The name of the volume. From a nametag or a serial denominator.
mutable std::string m_name;
/// The identifier of the volume. From an identifier tag.
mutable Query<int> m_id;
mutable std::string m_name{};
/// A pointer to a name tag. If the volume is named.
const GeoNameTag *m_nameTag;
const GeoNameTag *m_nameTag{nullptr};
/// A pointer to a serial denominator. If one exists.
const GeoSerialDenominator *m_serialDenominator;
const GeoSerialDenominator *m_serialDenominator{nullptr};
/// A pointer to an identifier tag. If the volume is identified.
const GeoIdentifierTag *m_idTag;
const GeoIdentifierTag *m_idTag{nullptr};
/// List of Pending Transformations.
std::vector<const GeoTransform *> m_pendingTransformList;
std::vector<const GeoTransform *> m_pendingTransformList{};
/// Position of the serial denominator. Used to assign a numeric suffix to the name, eg BaseName+99
unsigned int m_serialDenomPosition;
unsigned int m_serialDenomPosition{0};
const GeoSerialIdentifier *m_serialIdentifier;
unsigned int m_serialIdentPosition;
const GeoVAlignmentStore* m_alignStore;
const GeoSerialIdentifier *m_serialIdentifier{nullptr};
unsigned int m_serialIdentPosition{0};
const GeoVAlignmentStore* m_alignStore{nullptr};
};
#endif
......@@ -74,14 +74,18 @@ class GeoMaterial : public RCBase {
double getFraction (int i) const;
// The name of the material.
const std::string& getName () const;
const std::string& getName () const{
return m_name;
}
// The density of the material.
const double& getDensity () const;
double getDensity () const{
return m_density;
}
// Gives an integral identifier for the material. For
// convenience.
const unsigned int& getID () const;
unsigned int getID () const {
return m_iD;
}
protected:
virtual ~GeoMaterial() = default;
......@@ -121,19 +125,4 @@ class GeoMaterial : public RCBase {
};
inline const std::string& GeoMaterial::getName () const
{
return m_name;
}
inline const double& GeoMaterial::getDensity () const
{
return m_density;
}
inline const unsigned int& GeoMaterial::getID () const
{
return m_iD;
}
#endif
/*
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
*/
#ifndef GEOMODELKERNEL_GEONODEACTION_H
......@@ -40,10 +40,10 @@ class GeoNodeAction
{ ALL_ANCESTORS = -1, SELF = 0, SELF_AND_CHILDREN = 1 };
public:
GeoNodeAction();
GeoNodeAction() = default;
GeoNodeAction(const GeoNodeAction &right) = delete;
GeoNodeAction & operator=(const GeoNodeAction &right) = delete;
virtual ~GeoNodeAction();
virtual ~GeoNodeAction() = default;
// Handles a Node.
virtual void handleNode (const GeoGraphNode *);
......@@ -109,15 +109,15 @@ class GeoNodeAction
protected:
// Termination flag; causes an abortion of action execution.
bool m_terminate;
bool m_terminate{false};
private:
// A limit may be placed upon the depth to which the action
// descends. 0 = self. 1 = self and children.
Query<unsigned int> m_depth;
Query<unsigned int> m_depth{};
GeoNodePath m_path;
GeoNodePath m_path{};
};
#endif
/*
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
*/
#include "GeoModelKernel/GeoAccessVolumeAction.h"
......@@ -9,26 +9,13 @@
#include <string>
GeoAccessVolumeAction::GeoAccessVolumeAction(unsigned int Index, const GeoVAlignmentStore* store)
: m_transform(GeoTrf::Transform3D::Identity())
, m_defTransform(GeoTrf::Transform3D::Identity())
, m_index(Index)
, m_counter(0)
, m_nameTag(nullptr)
, m_serialDenominator(nullptr)
, m_idTag(nullptr)
, m_serialDenomPosition(0)
, m_serialIdentifier(nullptr)
, m_serialIdentPosition(0)
, m_alignStore(store)
{
GeoAccessVolumeAction::GeoAccessVolumeAction(unsigned int Index, const GeoVAlignmentStore* store):
m_index(Index),
m_alignStore(store) {
setDepthLimit (1);
m_pendingTransformList.reserve(1);
}
GeoAccessVolumeAction::~GeoAccessVolumeAction()
{
}
void GeoAccessVolumeAction::handleTransform (const GeoTransform *xform)
{
......@@ -137,8 +124,7 @@ const GeoTrf::Transform3D & GeoAccessVolumeAction::getDefTransform () const
return m_defTransform;
}
const std::string & GeoAccessVolumeAction::getName () const
{
const std::string & GeoAccessVolumeAction::getName () const {
if(m_name.empty()) {
if(m_nameTag) {
m_name = m_nameTag->getName();
......@@ -199,16 +185,14 @@ void GeoAccessVolumeAction::handleIdentifierTag (const GeoIdentifierTag *idTag)
m_serialIdentPosition = 0;
}
Query<int> GeoAccessVolumeAction::getId () const
{
Query<int> id;
Query<int> GeoAccessVolumeAction::getId () const {
if(m_idTag) {
id = Query<int>(m_idTag->getIdentifier());
return Query<int>(m_idTag->getIdentifier());
}
else if(m_serialIdentifier) {
id = Query<int>(m_index - m_serialIdentPosition + m_serialIdentifier->getBaseId());
return Query<int>(m_index - m_serialIdentPosition + m_serialIdentifier->getBaseId());
}
return id;
return std::nullopt;
}
void GeoAccessVolumeAction::handleSerialIdentifier(const GeoSerialIdentifier *sI)
......
/*
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
*/
#include "GeoModelKernel/GeoNodeAction.h"
GeoNodeAction::GeoNodeAction()
: m_terminate (false)
{
}
GeoNodeAction::~GeoNodeAction()
{
}
void GeoNodeAction::handleNode (const GeoGraphNode *)
{
// Do nothing...
......@@ -64,9 +55,8 @@ void GeoNodeAction::setDepthLimit (unsigned int limit)
m_depth = limit;
}
void GeoNodeAction::clearDepthLimit ()
{
m_depth = Query < unsigned int >();
void GeoNodeAction::clearDepthLimit () {
m_depth = std::nullopt;
}
void GeoNodeAction::handleSerialTransformer (const GeoSerialTransformer *)
......
......@@ -255,19 +255,16 @@ std::string GeoVolumeCursor::getName () const
return name;
}
Query<int> GeoVolumeCursor::getId () const
{
Query<int> id;
Query<int> GeoVolumeCursor::getId () const {
if (m_idTag) {
id = Query<int> (m_idTag->getIdentifier ());
return Query<int>{m_idTag->getIdentifier ()};
}
else if (m_serialIdentifier) {
id = Query<int> (m_volCount - m_serialIdentPosition - 1 + m_serialIdentifier->getBaseId());
return Query<int>{m_volCount - m_serialIdentPosition - 1 + m_serialIdentifier->getBaseId()};
}
return id;
return std::nullopt;
}
bool GeoVolumeCursor::hasAlignableTransform() const
{
bool GeoVolumeCursor::hasAlignableTransform() const {
return m_hasAlignTrans;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment