Skip to content
Snippets Groups Projects
Commit 99578131 authored by Johannes Junggeburth's avatar Johannes Junggeburth :dog2:
Browse files

Merge branch 'ShapeCleanUpVol2' into 'main'

GeoShapes -- Minor class & method clean up

See merge request !245
parents 1a430fcb 326400c5
No related branches found
No related tags found
1 merge request!245GeoShapes -- Minor class & method clean up
Pipeline #6735260 passed
...@@ -18,31 +18,34 @@ ...@@ -18,31 +18,34 @@
#include "GeoModelKernel/GeoDefinitions.h" #include "GeoModelKernel/GeoDefinitions.h"
#include <vector> #include <vector>
typedef GeoTrf::Vector3D GeoFacetVertex; using GeoFacetVertex = GeoTrf::Vector3D;
// ** Base class // ** Base class
class GeoFacet : public RCBase class GeoFacet : public RCBase
{ {
public: public:
enum GeoFacetVertexType enum GeoFacetVertexType {
{
ABSOLUTE, ABSOLUTE,
RELATIVE RELATIVE
}; };
inline size_t getNumberOfVertices() const; inline size_t getNumberOfVertices() const {
inline GeoFacetVertex getVertex(size_t) const; return m_nVertices;
inline GeoFacetVertexType getVertexType() const; }
inline GeoFacetVertex getVertex(size_t index) const {
return (index<m_nVertices ? m_vertices[index] : GeoFacetVertex(999999.,999999.,999999.));
}
inline GeoFacetVertexType getVertexType() const {
return m_vertexType;
}
protected: protected:
GeoFacet() GeoFacet() = default;
: m_nVertices(0), virtual ~GeoFacet() = default;
m_vertexType(ABSOLUTE) {};
virtual ~GeoFacet(){};
size_t m_nVertices; size_t m_nVertices{0};
std::vector<GeoFacetVertex> m_vertices; std::vector<GeoFacetVertex> m_vertices{};
GeoFacetVertexType m_vertexType; GeoFacetVertexType m_vertexType{GeoFacetVertexType::ABSOLUTE};
}; };
// Triangular facet // Triangular facet
...@@ -50,40 +53,21 @@ class GeoTriangularFacet : public GeoFacet ...@@ -50,40 +53,21 @@ class GeoTriangularFacet : public GeoFacet
{ {
public: public:
GeoTriangularFacet(GeoFacetVertex GeoTriangularFacet(GeoFacetVertex
,GeoFacetVertex ,GeoFacetVertex
,GeoFacetVertex ,GeoFacetVertex
,GeoFacetVertexType); ,GeoFacetVertexType);
virtual ~GeoTriangularFacet(); virtual ~GeoTriangularFacet() = default;
}; };
// Quadrangular facet // Quadrangular facet
class GeoQuadrangularFacet : public GeoFacet class GeoQuadrangularFacet : public GeoFacet {
{
public: public:
GeoQuadrangularFacet(GeoFacetVertex GeoQuadrangularFacet(GeoFacetVertex ,GeoFacetVertex, GeoFacetVertex,
,GeoFacetVertex GeoFacetVertex ,GeoFacetVertexType);
,GeoFacetVertex
,GeoFacetVertex
,GeoFacetVertexType);
virtual ~GeoQuadrangularFacet(); virtual ~GeoQuadrangularFacet() = default;
}; };
// Inline methods
inline size_t GeoFacet::getNumberOfVertices() const
{
return m_nVertices;
}
inline GeoFacetVertex GeoFacet::getVertex(size_t index) const
{
return (index<m_nVertices ? m_vertices[index] : GeoFacetVertex(999999.,999999.,999999.));
}
inline GeoFacet::GeoFacetVertexType GeoFacet::getVertexType() const
{
return m_vertexType;
}
#endif #endif
/* /*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
*/ */
#ifndef GEOMODELKERNEL_GEOPCON_H #ifndef GEOMODELKERNEL_GEOPCON_H
...@@ -17,8 +17,7 @@ ...@@ -17,8 +17,7 @@
#include "GeoModelKernel/GeoShape.h" #include "GeoModelKernel/GeoShape.h"
#include <vector> #include <vector>
class GeoPcon : public GeoShape class GeoPcon : public GeoShape {
{
public: public:
// Constructor for the PCON. Note that the constructor // Constructor for the PCON. Note that the constructor
// does not fully build this object. The PCON is not valid // does not fully build this object. The PCON is not valid
...@@ -36,10 +35,14 @@ class GeoPcon : public GeoShape ...@@ -36,10 +35,14 @@ class GeoPcon : public GeoShape
virtual bool contains (double x, double y, double z) const; virtual bool contains (double x, double y, double z) const;
// Returns the PCON shape type, as a string. // Returns the PCON shape type, as a string.
virtual const std::string & type () const; virtual const std::string& type() const {
return getClassType();
}
// Returns the PCON shape type, as a coded integer. // Returns the PCON shape type, as a coded integer.
virtual ShapeType typeID () const; virtual ShapeType typeID() const {
return getClassTypeID();
}
// Add another plane to the polycone A minimum of two // Add another plane to the polycone A minimum of two
// planes are required to create a valid polycone. // planes are required to create a valid polycone.
...@@ -47,38 +50,56 @@ class GeoPcon : public GeoShape ...@@ -47,38 +50,56 @@ class GeoPcon : public GeoShape
// Returns the number of planes that have been created for // Returns the number of planes that have been created for
// the polycone. // the polycone.
unsigned int getNPlanes () const; unsigned int getNPlanes() const {
return m_zPlane.size();
}
// True if the polycone has at least two planes. False // True if the polycone has at least two planes. False
// otherwise. // otherwise.
bool isValid () const; bool isValid() const {
return getNPlanes() >= 2;
}
// Get the Z Position of the specified plane. // Get the Z Position of the specified plane.
const double & getZPlane (unsigned int i) const; double getZPlane(unsigned int i) const {
return m_zPlane[i];
}
// Get the RMin of the specified plane. // Get the RMin of the specified plane.
const double & getRMinPlane (unsigned int i) const; double getRMinPlane(unsigned int i) const {
return m_rMinPlane[i];
}
// Get the Z Position of the specified plane. // Get the Z Position of the specified plane.
const double & getRMaxPlane (unsigned int i) const; double getRMaxPlane(unsigned int i) const {
return m_rMaxPlane[i];
}
// Executes a GeoShapeAction // Executes a GeoShapeAction
virtual void exec (GeoShapeAction *action) const; virtual void exec (GeoShapeAction *action) const;
// For type identification. // For type identification.
static const std::string& getClassType (); static const std::string& getClassType() {
return s_classType;
}
// For type identification. // For type identification.
static ShapeType getClassTypeID (); static ShapeType getClassTypeID() {
return s_classTypeID;
}
// Starting angle of the segment in radians. // Starting angle of the segment in radians.
const double& getSPhi () const; double getSPhi() const {
return m_sPhi;
}
// Delta angle of the segment in radians. // Delta angle of the segment in radians.
const double& getDPhi () const; double getDPhi() const {
return m_dPhi;
}
protected: protected:
virtual ~GeoPcon(); virtual ~GeoPcon() = default;
private: private:
...@@ -89,58 +110,14 @@ class GeoPcon : public GeoShape ...@@ -89,58 +110,14 @@ class GeoPcon : public GeoShape
double m_dPhi{0.}; double m_dPhi{0.};
// Z Position of poly-cone planes. // Z Position of poly-cone planes.
std::vector<double> m_zPlane; std::vector<double> m_zPlane{};
// Minimum radius of poly-cone planes. // Minimum radius of poly-cone planes.
std::vector<double> m_rMinPlane; std::vector<double> m_rMinPlane{};
// Maximum radius of poly-cone planes. // Maximum radius of poly-cone planes.
std::vector<double> m_rMaxPlane; std::vector<double> m_rMaxPlane{};
}; };
inline unsigned int GeoPcon::getNPlanes () const
{
return m_zPlane.size ();
}
inline bool GeoPcon::isValid () const
{
return getNPlanes () >= 2;
}
inline const double & GeoPcon::getZPlane (unsigned int i) const
{
return m_zPlane[i];
}
inline const double & GeoPcon::getRMinPlane (unsigned int i) const
{
return m_rMinPlane[i];
}
inline const double & GeoPcon::getRMaxPlane (unsigned int i) const
{
return m_rMaxPlane[i];
}
inline const std::string& GeoPcon::getClassType ()
{
return s_classType;
}
inline ShapeType GeoPcon::getClassTypeID ()
{
return s_classTypeID;
}
inline const double& GeoPcon::getSPhi () const
{
return m_sPhi;
}
inline const double& GeoPcon::getDPhi () const
{
return m_dPhi;
}
#endif #endif
...@@ -27,10 +27,14 @@ class GeoPgon : public GeoShape ...@@ -27,10 +27,14 @@ class GeoPgon : public GeoShape
virtual bool contains (double x, double y, double z) const; virtual bool contains (double x, double y, double z) const;
// Returns the PGON shape type, as a string. // Returns the PGON shape type, as a string.
virtual const std::string & type () const; virtual const std::string & type() const {
return getClassType();
}
// Returns the PGON shape type, as a coded integer. // Returns the PGON shape type, as a coded integer.
virtual ShapeType typeID () const; virtual ShapeType typeID() const {
return getClassTypeID();
}
// Add another plane to the polygon. A minimum of two // Add another plane to the polygon. A minimum of two
// planes are required to create a valid polygon. // planes are required to create a valid polygon.
...@@ -38,111 +42,79 @@ class GeoPgon : public GeoShape ...@@ -38,111 +42,79 @@ class GeoPgon : public GeoShape
// Returns the number of planes that have been created for // Returns the number of planes that have been created for
// the polygon. // the polygon.
unsigned int getNPlanes () const; unsigned int getNPlanes() const {
return m_zPlane.size ();
}
// True if the polygon has at least two planes. False // True if the polygon has at least two planes. False
// otherwise. // otherwise.
bool isValid () const; bool isValid() const {
return m_zPlane.size () >= 2;
}
// Get the Z Position of the specified plane. // Get the Z Position of the specified plane.
const double & getZPlane (unsigned int i) const; double getZPlane (unsigned int i) const {
return m_zPlane[i];
}
// Get the RMin of the specified plane. // Get the RMin of the specified plane.
const double & getRMinPlane (unsigned int i) const; double getRMinPlane (unsigned int i) const {
return m_rMinPlane[i];
}
// Get the Z Position of the specified plane. // Get the Z Position of the specified plane.
const double & getRMaxPlane (unsigned int i) const; double getRMaxPlane (unsigned int i) const {
return m_rMaxPlane[i];
}
// Executes a GeoShapeAction // Executes a GeoShapeAction
virtual void exec (GeoShapeAction *action) const; virtual void exec (GeoShapeAction *action) const;
// For type identification. // For type identification.
static const std::string& getClassType (); static const std::string& getClassType() {
return s_classType;
}
// For type identification. // For type identification.
static ShapeType getClassTypeID (); static ShapeType getClassTypeID() {
return s_classTypeID;
}
// Starting angle of the segment in radians. // Starting angle of the segment in radians.
const double& getSPhi () const; double getSPhi() const {
return m_sPhi;
}
// Delta angle of the segment in radians. // Delta angle of the segment in radians.
const double& getDPhi () const; double getDPhi() const {
return m_dPhi;
}
// Number of sides in each polygonal segment. // Number of sides in each polygonal segment.
const unsigned int& getNSides () const; unsigned int getNSides () const{
return m_nSides;
}
protected: protected:
virtual ~GeoPgon(); virtual ~GeoPgon() = default;
private: private:
GeoPgon(const GeoPgon &right);
GeoPgon & operator=(const GeoPgon &right);
static const std::string s_classType; static const std::string s_classType;
static const ShapeType s_classTypeID; static const ShapeType s_classTypeID;
double m_sPhi; double m_sPhi{0.};
double m_dPhi; double m_dPhi{0.};
unsigned int m_nSides; unsigned int m_nSides{0};
// Z Position of polygon planes. // Z Position of polygon planes.
std::vector<double> m_zPlane; std::vector<double> m_zPlane{};
// Minimum radius of polygon planes. // Minimum radius of polygon planes.
std::vector<double> m_rMinPlane; std::vector<double> m_rMinPlane{};
// Maximum radius of polygon planes. // Maximum radius of polygon planes.
std::vector<double> m_rMaxPlane; std::vector<double> m_rMaxPlane{};
}; };
inline unsigned int GeoPgon::getNPlanes () const
{
return m_zPlane.size ();
}
inline bool GeoPgon::isValid () const
{
return m_zPlane.size () >= 2;
}
inline const double & GeoPgon::getZPlane (unsigned int i) const
{
return m_zPlane[i];
}
inline const double & GeoPgon::getRMinPlane (unsigned int i) const
{
return m_rMinPlane[i];
}
inline const double & GeoPgon::getRMaxPlane (unsigned int i) const
{
return m_rMaxPlane[i];
}
inline const std::string& GeoPgon::getClassType ()
{
return s_classType;
}
inline ShapeType GeoPgon::getClassTypeID ()
{
return s_classTypeID;
}
inline const double& GeoPgon::getSPhi () const
{
return m_sPhi;
}
inline const double& GeoPgon::getDPhi () const
{
return m_dPhi;
}
inline const unsigned int& GeoPgon::getNSides () const
{
return m_nSides;
}
#endif #endif
/* /*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
*/ */
#ifndef GEOMODELKERNEL_GEOTRAP_H #ifndef GEOMODELKERNEL_GEOTRAP_H
...@@ -63,7 +63,7 @@ class GeoTrap : public GeoShape ...@@ -63,7 +63,7 @@ class GeoTrap : public GeoShape
double getDydzn () const { return m_dydzn; } double getDydzn () const { return m_dydzn; }
// X half length at -z, -y. // X half length at -z, -y.
double getDxdyndzn () const { return m_dxdyndzn; } double getDxdyndzn () const { return m_dxdyndzn; }
// X half length at -z, +y. // X half length at -z, +y.
double getDxdypdzn () const { return m_dxdypdzn; } double getDxdypdzn () const { return m_dxdypdzn; }
......
...@@ -20,9 +20,6 @@ GeoTriangularFacet::GeoTriangularFacet(GeoFacetVertex v0 ...@@ -20,9 +20,6 @@ GeoTriangularFacet::GeoTriangularFacet(GeoFacetVertex v0
} }
GeoTriangularFacet::~GeoTriangularFacet()
{
}
// ___________________ Triangular Facet ________________________ // ___________________ Triangular Facet ________________________
GeoQuadrangularFacet::GeoQuadrangularFacet(GeoFacetVertex v0 GeoQuadrangularFacet::GeoQuadrangularFacet(GeoFacetVertex v0
...@@ -41,7 +38,3 @@ GeoQuadrangularFacet::GeoQuadrangularFacet(GeoFacetVertex v0 ...@@ -41,7 +38,3 @@ GeoQuadrangularFacet::GeoQuadrangularFacet(GeoFacetVertex v0
m_vertices[3] = v3; m_vertices[3] = v3;
} }
GeoQuadrangularFacet::~GeoQuadrangularFacet()
{
}
...@@ -16,9 +16,6 @@ GeoPcon::GeoPcon (double SPhi, double DPhi) ...@@ -16,9 +16,6 @@ GeoPcon::GeoPcon (double SPhi, double DPhi)
{ {
} }
GeoPcon::~GeoPcon()
{
}
double GeoPcon::volume () const double GeoPcon::volume () const
{ {
...@@ -95,16 +92,6 @@ bool GeoPcon::contains (double x, double y, double z) const ...@@ -95,16 +92,6 @@ bool GeoPcon::contains (double x, double y, double z) const
return false; return false;
} }
const std::string & GeoPcon::type () const
{
return s_classType;
}
ShapeType GeoPcon::typeID () const
{
return s_classTypeID;
}
void GeoPcon::addPlane (double ZPlane, double RMinPlane, double RMaxPlane) void GeoPcon::addPlane (double ZPlane, double RMinPlane, double RMaxPlane)
{ {
m_zPlane.push_back (ZPlane); m_zPlane.push_back (ZPlane);
......
...@@ -17,10 +17,6 @@ GeoPgon::GeoPgon (double SPhi, double DPhi, unsigned int NSides) ...@@ -17,10 +17,6 @@ GeoPgon::GeoPgon (double SPhi, double DPhi, unsigned int NSides)
{ {
} }
GeoPgon::~GeoPgon()
{
}
double GeoPgon::volume () const double GeoPgon::volume () const
{ {
#ifndef M_PI #ifndef M_PI
...@@ -155,16 +151,6 @@ bool GeoPgon::contains (double x, double y, double z) const ...@@ -155,16 +151,6 @@ bool GeoPgon::contains (double x, double y, double z) const
return false; return false;
} }
const std::string & GeoPgon::type () const
{
return s_classType;
}
ShapeType GeoPgon::typeID () const
{
return s_classTypeID;
}
void GeoPgon::addPlane (double ZPlane, double RMinPlane, double RMaxPlane) void GeoPgon::addPlane (double ZPlane, double RMinPlane, double RMaxPlane)
{ {
m_zPlane.push_back (ZPlane); m_zPlane.push_back (ZPlane);
......
/* /*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
*/ */
#include "GeoModelKernel/GeoShapeShift.h" #include "GeoModelKernel/GeoShapeShift.h"
#include "GeoModelKernel/GeoShapeAction.h" #include "GeoModelKernel/GeoShapeAction.h"
#include <array>
const std::string GeoShapeShift::s_classType = "Shift"; const std::string GeoShapeShift::s_classType = "Shift";
const ShapeType GeoShapeShift::s_classTypeID = 0x03; const ShapeType GeoShapeShift::s_classTypeID = 0x03;
...@@ -17,9 +19,9 @@ void GeoShapeShift::extent (double& xmin, double& ymin, double& zmin, ...@@ -17,9 +19,9 @@ void GeoShapeShift::extent (double& xmin, double& ymin, double& zmin,
{ {
const GeoShape* shape = getOp(); const GeoShape* shape = getOp();
const GeoTrf::Transform3D& trans = getX(); const GeoTrf::Transform3D& trans = getX();
double x_min, y_min, z_min, x_max, y_max, z_max; double x_min{0.}, y_min{0.}, z_min{0.}, x_max{0.}, y_max{0.}, z_max{0.};
shape->extent(x_min, y_min, z_min, x_max, y_max, z_max); shape->extent(x_min, y_min, z_min, x_max, y_max, z_max);
GeoTrf::Vector3D vv[8]; std::array<GeoTrf::Vector3D, 8> vv{};
vv[0] = trans * GeoTrf::Vector3D(x_min, y_min, z_min); vv[0] = trans * GeoTrf::Vector3D(x_min, y_min, z_min);
vv[1] = trans * GeoTrf::Vector3D(x_max, y_min, z_min); vv[1] = trans * GeoTrf::Vector3D(x_max, y_min, z_min);
vv[2] = trans * GeoTrf::Vector3D(x_min, y_max, z_min); vv[2] = trans * GeoTrf::Vector3D(x_min, y_max, z_min);
......
...@@ -23,8 +23,8 @@ double GeoShapeUnion::volume () const ...@@ -23,8 +23,8 @@ double GeoShapeUnion::volume () const
void GeoShapeUnion::extent (double& xmin, double& ymin, double& zmin, void GeoShapeUnion::extent (double& xmin, double& ymin, double& zmin,
double& xmax, double& ymax, double& zmax) const double& xmax, double& ymax, double& zmax) const
{ {
double xminA, yminA, zminA, xmaxA, ymaxA, zmaxA; double xminA{0.}, yminA{0.}, zminA{0.}, xmaxA{0.}, ymaxA{0.}, zmaxA{0.};
double xminB, yminB, zminB, xmaxB, ymaxB, zmaxB; double xminB{0.}, yminB{0.}, zminB{0.}, xmaxB{0.}, ymaxB{0.}, zmaxB{0.};
getOpA()->extent(xminA, yminA, zminA, xmaxA, ymaxA, zmaxA); getOpA()->extent(xminA, yminA, zminA, xmaxA, ymaxA, zmaxA);
getOpB()->extent(xminB, yminB, zminB, xmaxB, ymaxB, zmaxB); getOpB()->extent(xminB, yminB, zminB, xmaxB, ymaxB, zmaxB);
xmin = std::min(xminA, xminB); xmin = std::min(xminA, xminB);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment