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
Branches
Tags
1 merge request!245GeoShapes -- Minor class & method clean up
Pipeline #6735260 passed
......@@ -18,31 +18,34 @@
#include "GeoModelKernel/GeoDefinitions.h"
#include <vector>
typedef GeoTrf::Vector3D GeoFacetVertex;
using GeoFacetVertex = GeoTrf::Vector3D;
// ** Base class
class GeoFacet : public RCBase
{
public:
enum GeoFacetVertexType
{
enum GeoFacetVertexType {
ABSOLUTE,
RELATIVE
};
inline size_t getNumberOfVertices() const;
inline GeoFacetVertex getVertex(size_t) const;
inline GeoFacetVertexType getVertexType() const;
inline size_t getNumberOfVertices() const {
return m_nVertices;
}
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:
GeoFacet()
: m_nVertices(0),
m_vertexType(ABSOLUTE) {};
virtual ~GeoFacet(){};
GeoFacet() = default;
virtual ~GeoFacet() = default;
size_t m_nVertices;
std::vector<GeoFacetVertex> m_vertices;
GeoFacetVertexType m_vertexType;
size_t m_nVertices{0};
std::vector<GeoFacetVertex> m_vertices{};
GeoFacetVertexType m_vertexType{GeoFacetVertexType::ABSOLUTE};
};
// Triangular facet
......@@ -50,40 +53,21 @@ class GeoTriangularFacet : public GeoFacet
{
public:
GeoTriangularFacet(GeoFacetVertex
,GeoFacetVertex
,GeoFacetVertex
,GeoFacetVertexType);
,GeoFacetVertex
,GeoFacetVertex
,GeoFacetVertexType);
virtual ~GeoTriangularFacet();
virtual ~GeoTriangularFacet() = default;
};
// Quadrangular facet
class GeoQuadrangularFacet : public GeoFacet
{
class GeoQuadrangularFacet : public GeoFacet {
public:
GeoQuadrangularFacet(GeoFacetVertex
,GeoFacetVertex
,GeoFacetVertex
,GeoFacetVertex
,GeoFacetVertexType);
GeoQuadrangularFacet(GeoFacetVertex ,GeoFacetVertex, 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
/*
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
......@@ -17,8 +17,7 @@
#include "GeoModelKernel/GeoShape.h"
#include <vector>
class GeoPcon : public GeoShape
{
class GeoPcon : public GeoShape {
public:
// Constructor for the PCON. Note that the constructor
// does not fully build this object. The PCON is not valid
......@@ -36,10 +35,14 @@ class GeoPcon : public GeoShape
virtual bool contains (double x, double y, double z) const;
// 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.
virtual ShapeType typeID () const;
virtual ShapeType typeID() const {
return getClassTypeID();
}
// Add another plane to the polycone A minimum of two
// planes are required to create a valid polycone.
......@@ -47,38 +50,56 @@ class GeoPcon : public GeoShape
// Returns the number of planes that have been created for
// the polycone.
unsigned int getNPlanes () const;
unsigned int getNPlanes() const {
return m_zPlane.size();
}
// True if the polycone has at least two planes. False
// otherwise.
bool isValid () const;
bool isValid() const {
return getNPlanes() >= 2;
}
// 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.
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.
const double & getRMaxPlane (unsigned int i) const;
double getRMaxPlane(unsigned int i) const {
return m_rMaxPlane[i];
}
// Executes a GeoShapeAction
virtual void exec (GeoShapeAction *action) const;
// For type identification.
static const std::string& getClassType ();
static const std::string& getClassType() {
return s_classType;
}
// For type identification.
static ShapeType getClassTypeID ();
static ShapeType getClassTypeID() {
return s_classTypeID;
}
// Starting angle of the segment in radians.
const double& getSPhi () const;
double getSPhi() const {
return m_sPhi;
}
// Delta angle of the segment in radians.
const double& getDPhi () const;
double getDPhi() const {
return m_dPhi;
}
protected:
virtual ~GeoPcon();
virtual ~GeoPcon() = default;
private:
......@@ -89,58 +110,14 @@ class GeoPcon : public GeoShape
double m_dPhi{0.};
// Z Position of poly-cone planes.
std::vector<double> m_zPlane;
std::vector<double> m_zPlane{};
// Minimum radius of poly-cone planes.
std::vector<double> m_rMinPlane;
std::vector<double> m_rMinPlane{};
// 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
......@@ -27,10 +27,14 @@ class GeoPgon : public GeoShape
virtual bool contains (double x, double y, double z) const;
// 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.
virtual ShapeType typeID () const;
virtual ShapeType typeID() const {
return getClassTypeID();
}
// Add another plane to the polygon. A minimum of two
// planes are required to create a valid polygon.
......@@ -38,111 +42,79 @@ class GeoPgon : public GeoShape
// Returns the number of planes that have been created for
// the polygon.
unsigned int getNPlanes () const;
unsigned int getNPlanes() const {
return m_zPlane.size ();
}
// True if the polygon has at least two planes. False
// otherwise.
bool isValid () const;
bool isValid() const {
return m_zPlane.size () >= 2;
}
// 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.
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.
const double & getRMaxPlane (unsigned int i) const;
double getRMaxPlane (unsigned int i) const {
return m_rMaxPlane[i];
}
// Executes a GeoShapeAction
virtual void exec (GeoShapeAction *action) const;
// For type identification.
static const std::string& getClassType ();
static const std::string& getClassType() {
return s_classType;
}
// For type identification.
static ShapeType getClassTypeID ();
static ShapeType getClassTypeID() {
return s_classTypeID;
}
// Starting angle of the segment in radians.
const double& getSPhi () const;
double getSPhi() const {
return m_sPhi;
}
// Delta angle of the segment in radians.
const double& getDPhi () const;
double getDPhi() const {
return m_dPhi;
}
// Number of sides in each polygonal segment.
const unsigned int& getNSides () const;
unsigned int getNSides () const{
return m_nSides;
}
protected:
virtual ~GeoPgon();
virtual ~GeoPgon() = default;
private:
GeoPgon(const GeoPgon &right);
GeoPgon & operator=(const GeoPgon &right);
static const std::string s_classType;
static const ShapeType s_classTypeID;
double m_sPhi;
double m_dPhi;
unsigned int m_nSides;
double m_sPhi{0.};
double m_dPhi{0.};
unsigned int m_nSides{0};
// Z Position of polygon planes.
std::vector<double> m_zPlane;
std::vector<double> m_zPlane{};
// Minimum radius of polygon planes.
std::vector<double> m_rMinPlane;
std::vector<double> m_rMinPlane{};
// 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
/*
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
......@@ -63,7 +63,7 @@ class GeoTrap : public GeoShape
double getDydzn () const { return m_dydzn; }
// X half length at -z, -y.
double getDxdyndzn () const { return m_dxdyndzn; }
double getDxdyndzn () const { return m_dxdyndzn; }
// X half length at -z, +y.
double getDxdypdzn () const { return m_dxdypdzn; }
......
......@@ -20,9 +20,6 @@ GeoTriangularFacet::GeoTriangularFacet(GeoFacetVertex v0
}
GeoTriangularFacet::~GeoTriangularFacet()
{
}
// ___________________ Triangular Facet ________________________
GeoQuadrangularFacet::GeoQuadrangularFacet(GeoFacetVertex v0
......@@ -41,7 +38,3 @@ GeoQuadrangularFacet::GeoQuadrangularFacet(GeoFacetVertex v0
m_vertices[3] = v3;
}
GeoQuadrangularFacet::~GeoQuadrangularFacet()
{
}
......@@ -16,9 +16,6 @@ GeoPcon::GeoPcon (double SPhi, double DPhi)
{
}
GeoPcon::~GeoPcon()
{
}
double GeoPcon::volume () const
{
......@@ -95,16 +92,6 @@ bool GeoPcon::contains (double x, double y, double z) const
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)
{
m_zPlane.push_back (ZPlane);
......
......@@ -17,10 +17,6 @@ GeoPgon::GeoPgon (double SPhi, double DPhi, unsigned int NSides)
{
}
GeoPgon::~GeoPgon()
{
}
double GeoPgon::volume () const
{
#ifndef M_PI
......@@ -155,16 +151,6 @@ bool GeoPgon::contains (double x, double y, double z) const
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)
{
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/GeoShapeAction.h"
#include <array>
const std::string GeoShapeShift::s_classType = "Shift";
const ShapeType GeoShapeShift::s_classTypeID = 0x03;
......@@ -17,9 +19,9 @@ void GeoShapeShift::extent (double& xmin, double& ymin, double& zmin,
{
const GeoShape* shape = getOp();
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);
GeoTrf::Vector3D vv[8];
std::array<GeoTrf::Vector3D, 8> vv{};
vv[0] = trans * GeoTrf::Vector3D(x_min, 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);
......
......@@ -23,8 +23,8 @@ double GeoShapeUnion::volume () const
void GeoShapeUnion::extent (double& xmin, double& ymin, double& zmin,
double& xmax, double& ymax, double& zmax) const
{
double xminA, yminA, zminA, xmaxA, ymaxA, zmaxA;
double xminB, yminB, zminB, xmaxB, ymaxB, zmaxB;
double xminA{0.}, yminA{0.}, zminA{0.}, xmaxA{0.}, ymaxA{0.}, zmaxA{0.};
double xminB{0.}, yminB{0.}, zminB{0.}, xmaxB{0.}, ymaxB{0.}, zmaxB{0.};
getOpA()->extent(xminA, yminA, zminA, xmaxA, ymaxA, zmaxA);
getOpB()->extent(xminB, yminB, zminB, xmaxB, ymaxB, zmaxB);
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