Skip to content
Snippets Groups Projects
Commit be230037 authored by Evgueni Tcherniaev's avatar Evgueni Tcherniaev
Browse files

Added contains(x,y,z); Implemented GeoShape::volume() that calculates volume using MC method

parent 02ed0364
No related branches found
No related tags found
1 merge request!197Added extent() and contains() methods. Completed implementation of volume calculation for Boolean shapes.
Showing
with 75 additions and 6 deletions
...@@ -20,6 +20,9 @@ class GeoBox : public GeoShape ...@@ -20,6 +20,9 @@ class GeoBox : public GeoShape
virtual void extent (double& xmin, double& ymin, double& zmin, virtual void extent (double& xmin, double& ymin, double& zmin,
double& xmax, double& ymax, double& zmax) const; double& xmax, double& ymax, double& zmax) const;
// Returns true if the shape contains the point, false otherwise.
virtual bool contains (double x, double y, double z) const;
// Returns the BOX shape type, as a string // Returns the BOX shape type, as a string
virtual const std::string & type () const; virtual const std::string & type () const;
......
...@@ -19,6 +19,9 @@ class GeoCons : public GeoShape ...@@ -19,6 +19,9 @@ class GeoCons : public GeoShape
virtual void extent (double& xmin, double& ymin, double& zmin, virtual void extent (double& xmin, double& ymin, double& zmin,
double& xmax, double& ymax, double& zmax) const; double& xmax, double& ymax, double& zmax) const;
// Returns true if the shape contains the point, false otherwise.
virtual bool contains (double x, double y, double z) const;
// Returns the CONS shape type, as a string. // Returns the CONS shape type, as a string.
virtual const std::string & type () const; virtual const std::string & type () const;
......
...@@ -27,6 +27,9 @@ class GeoEllipticalTube : public GeoShape ...@@ -27,6 +27,9 @@ class GeoEllipticalTube : public GeoShape
virtual void extent (double& xmin, double& ymin, double& zmin, virtual void extent (double& xmin, double& ymin, double& zmin,
double& xmax, double& ymax, double& zmax) const; double& xmax, double& ymax, double& zmax) const;
// Returns true if the shape contains the point, false otherwise.
virtual bool contains (double x, double y, double z) const;
// Returns the ELLIPTICAL TUBE shape type, as a string // Returns the ELLIPTICAL TUBE shape type, as a string
virtual const std::string & type () const; virtual const std::string & type () const;
......
...@@ -24,6 +24,9 @@ class GeoGenericTrap : public GeoShape ...@@ -24,6 +24,9 @@ class GeoGenericTrap : public GeoShape
virtual void extent (double& xmin, double& ymin, double& zmin, virtual void extent (double& xmin, double& ymin, double& zmin,
double& xmax, double& ymax, double& zmax) const; double& xmax, double& ymax, double& zmax) const;
// Returns true if the shape contains the point, false otherwise.
virtual bool contains (double x, double y, double z) const;
// Returns the GENERIC TRAP shape type, as a string. // Returns the GENERIC TRAP shape type, as a string.
virtual const std::string& type() const; virtual const std::string& type() const;
......
...@@ -20,6 +20,9 @@ class GeoPara : public GeoShape ...@@ -20,6 +20,9 @@ class GeoPara : public GeoShape
virtual void extent (double& xmin, double& ymin, double& zmin, virtual void extent (double& xmin, double& ymin, double& zmin,
double& xmax, double& ymax, double& zmax) const; double& xmax, double& ymax, double& zmax) const;
// Returns true if the shape contains the point, false otherwise.
virtual bool contains (double x, double y, double z) const;
// Returns the PARA shape type, as a string. // Returns the PARA shape type, as a string.
virtual const std::string & type () const; virtual const std::string & type () const;
......
...@@ -32,6 +32,9 @@ class GeoPcon : public GeoShape ...@@ -32,6 +32,9 @@ class GeoPcon : public GeoShape
virtual void extent (double& xmin, double& ymin, double& zmin, virtual void extent (double& xmin, double& ymin, double& zmin,
double& xmax, double& ymax, double& zmax) const; double& xmax, double& ymax, double& zmax) const;
// Returns true if the shape contains the point, false otherwise.
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;
......
...@@ -23,6 +23,9 @@ class GeoPgon : public GeoShape ...@@ -23,6 +23,9 @@ class GeoPgon : public GeoShape
virtual void extent (double& xmin, double& ymin, double& zmin, virtual void extent (double& xmin, double& ymin, double& zmin,
double& xmax, double& ymax, double& zmax) const; double& xmax, double& ymax, double& zmax) const;
// Returns true if the shape contains the point, false otherwise.
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;
......
...@@ -42,13 +42,16 @@ class GeoShape : public RCBase ...@@ -42,13 +42,16 @@ class GeoShape : public RCBase
GeoShape (); GeoShape ();
// Returns the volume of the shape, for mass inventory. // Returns the volume of the shape, for mass inventory.
virtual double volume () const = 0; virtual double volume () const;
// Returns the bonding box of the shape. // Returns the bonding box of the shape.
virtual void extent (double& xmin, double& ymin, double& zmin, virtual void extent (double& xmin, double& ymin, double& zmin,
double& xmax, double& ymax, double& zmax) const = 0; double& xmax, double& ymax, double& zmax) const = 0;
// Boolean OR operation for shapes // Returns true if the shape contains the point, false otherwise.
virtual bool contains (double x, double y, double z) const = 0;
// Boolean OR operation for shapes.
const GeoShapeUnion & add (const GeoShape& shape) const; const GeoShapeUnion & add (const GeoShape& shape) const;
// Subtraction operation for shapes. // Subtraction operation for shapes.
......
...@@ -24,6 +24,9 @@ class GeoShapeIntersection : public GeoShape ...@@ -24,6 +24,9 @@ class GeoShapeIntersection : public GeoShape
virtual void extent (double& xmin, double& ymin, double& zmin, virtual void extent (double& xmin, double& ymin, double& zmin,
double& xmax, double& ymax, double& zmax) const; double& xmax, double& ymax, double& zmax) const;
// Returns true if the shape contains the point, false otherwise
virtual bool contains (double x, double y, double z) const;
// Returns the AND shape type, as a string. // Returns the AND shape type, as a string.
virtual const std::string & type () const; virtual const std::string & type () const;
...@@ -58,6 +61,9 @@ class GeoShapeIntersection : public GeoShape ...@@ -58,6 +61,9 @@ class GeoShapeIntersection : public GeoShape
// The second shape operand in the AND operation. // The second shape operand in the AND operation.
const GeoShape* m_opB; const GeoShape* m_opB;
// Cached volume
mutable double fVolume = -1.;
static const std::string s_classType; static const std::string s_classType;
static const ShapeType s_classTypeID; static const ShapeType s_classTypeID;
......
...@@ -27,6 +27,9 @@ class GeoShapeShift : public GeoShape ...@@ -27,6 +27,9 @@ class GeoShapeShift : public GeoShape
virtual void extent (double& xmin, double& ymin, double& zmin, virtual void extent (double& xmin, double& ymin, double& zmin,
double& xmax, double& ymax, double& zmax) const; double& xmax, double& ymax, double& zmax) const;
// Returns true if the shape contains the point, false otherwise
virtual bool contains (double x, double y, double z) const;
// Returns the OR shape type, as a string. // Returns the OR shape type, as a string.
virtual const std::string & type () const; virtual const std::string & type () const;
......
...@@ -26,6 +26,9 @@ class GeoShapeSubtraction : public GeoShape ...@@ -26,6 +26,9 @@ class GeoShapeSubtraction : public GeoShape
virtual void extent (double& xmin, double& ymin, double& zmin, virtual void extent (double& xmin, double& ymin, double& zmin,
double& xmax, double& ymax, double& zmax) const; double& xmax, double& ymax, double& zmax) const;
// Returns true if the shape contains the point, false otherwise
virtual bool contains (double x, double y, double z) const;
// Returns the NOT shape type, as a string. // Returns the NOT shape type, as a string.
virtual const std::string & type () const; virtual const std::string & type () const;
...@@ -54,12 +57,15 @@ class GeoShapeSubtraction : public GeoShape ...@@ -54,12 +57,15 @@ class GeoShapeSubtraction : public GeoShape
GeoShapeSubtraction(const GeoShapeSubtraction &right); GeoShapeSubtraction(const GeoShapeSubtraction &right);
GeoShapeSubtraction & operator=(const GeoShapeSubtraction &right); GeoShapeSubtraction & operator=(const GeoShapeSubtraction &right);
// The shape operand in the Subtraction operation // The first shape operand in the Subtraction operation
const GeoShape* m_opA; const GeoShape* m_opA;
// The shape operand in the Subtraction operation // The second shape operand in the Subtraction operation
const GeoShape* m_opB; const GeoShape* m_opB;
// Cached volume
mutable double fVolume = -1.;
static const std::string s_classType; static const std::string s_classType;
static const ShapeType s_classTypeID; static const ShapeType s_classTypeID;
......
...@@ -24,6 +24,9 @@ class GeoShapeUnion : public GeoShape ...@@ -24,6 +24,9 @@ class GeoShapeUnion : public GeoShape
virtual void extent (double& xmin, double& ymin, double& zmin, virtual void extent (double& xmin, double& ymin, double& zmin,
double& xmax, double& ymax, double& zmax) const; double& xmax, double& ymax, double& zmax) const;
// Returns true if the shape contains the point, false otherwise
virtual bool contains (double x, double y, double z) const;
// Returns the OR shape type, as a string. // Returns the OR shape type, as a string.
virtual const std::string & type () const; virtual const std::string & type () const;
...@@ -52,12 +55,15 @@ class GeoShapeUnion : public GeoShape ...@@ -52,12 +55,15 @@ class GeoShapeUnion : public GeoShape
GeoShapeUnion(const GeoShapeUnion &right); GeoShapeUnion(const GeoShapeUnion &right);
GeoShapeUnion & operator=(const GeoShapeUnion &right); GeoShapeUnion & operator=(const GeoShapeUnion &right);
// The first shape operand in the OR operation. // The first shape operand in the OR operation
const GeoShape* m_opA; const GeoShape* m_opA;
// The second shape operand in the OR operation. // The second shape operand in the OR operation
const GeoShape* m_opB; const GeoShape* m_opB;
// Cached volume
mutable double fVolume = -1.;
static const std::string s_classType; static const std::string s_classType;
static const ShapeType s_classTypeID; static const ShapeType s_classTypeID;
......
...@@ -34,6 +34,9 @@ class GeoSimplePolygonBrep : public GeoShape ...@@ -34,6 +34,9 @@ class GeoSimplePolygonBrep : public GeoShape
virtual void extent (double& xmin, double& ymin, double& zmin, virtual void extent (double& xmin, double& ymin, double& zmin,
double& xmax, double& ymax, double& zmax) const; double& xmax, double& ymax, double& zmax) const;
// Returns true if the shape contains the point, false otherwise.
virtual bool contains (double x, double y, double z) const;
// Returns the BREP shape type, as a string // Returns the BREP shape type, as a string
virtual const std::string& type() const; virtual const std::string& type() const;
......
...@@ -23,6 +23,9 @@ class GeoTessellatedSolid : public GeoShape ...@@ -23,6 +23,9 @@ class GeoTessellatedSolid : public GeoShape
virtual void extent (double& xmin, double& ymin, double& zmin, virtual void extent (double& xmin, double& ymin, double& zmin,
double& xmax, double& ymax, double& zmax) const; double& xmax, double& ymax, double& zmax) const;
// Returns true if the shape contains the point, false otherwise.
virtual bool contains (double x, double y, double z) const;
// Returns the TESSELLATED SOLID shape type, as a string // Returns the TESSELLATED SOLID shape type, as a string
virtual const std::string& type() const; virtual const std::string& type() const;
......
...@@ -20,6 +20,9 @@ class GeoTorus : public GeoShape ...@@ -20,6 +20,9 @@ class GeoTorus : public GeoShape
virtual void extent (double& xmin, double& ymin, double& zmin, virtual void extent (double& xmin, double& ymin, double& zmin,
double& xmax, double& ymax, double& zmax) const; double& xmax, double& ymax, double& zmax) const;
// Returns true if the shape contains the point, false otherwise.
virtual bool contains (double x, double y, double z) const;
// Returns the TORUS shape type, as a string. // Returns the TORUS shape type, as a string.
virtual const std::string & type () const; virtual const std::string & type () const;
......
...@@ -25,6 +25,9 @@ class GeoTrap : public GeoShape ...@@ -25,6 +25,9 @@ class GeoTrap : public GeoShape
virtual void extent (double& xmin, double& ymin, double& zmin, virtual void extent (double& xmin, double& ymin, double& zmin,
double& xmax, double& ymax, double& zmax) const; double& xmax, double& ymax, double& zmax) const;
// Returns true if the shape contains the point, false otherwise.
virtual bool contains (double x, double y, double z) const;
// Returns the TRAP shape type, as a string. // Returns the TRAP shape type, as a string.
virtual const std::string & type () const; virtual const std::string & type () const;
......
...@@ -19,6 +19,9 @@ class GeoTrd : public GeoShape ...@@ -19,6 +19,9 @@ class GeoTrd : public GeoShape
virtual void extent (double& xmin, double& ymin, double& zmin, virtual void extent (double& xmin, double& ymin, double& zmin,
double& xmax, double& ymax, double& zmax) const; double& xmax, double& ymax, double& zmax) const;
// Returns true if the shape contains the point, false otherwise.
virtual bool contains (double x, double y, double z) const;
// Returns the TRD shape type, as a string. // Returns the TRD shape type, as a string.
virtual const std::string & type () const; virtual const std::string & type () const;
......
...@@ -19,6 +19,9 @@ class GeoTube : public GeoShape ...@@ -19,6 +19,9 @@ class GeoTube : public GeoShape
virtual void extent (double& xmin, double& ymin, double& zmin, virtual void extent (double& xmin, double& ymin, double& zmin,
double& xmax, double& ymax, double& zmax) const; double& xmax, double& ymax, double& zmax) const;
// Returns true if the shape contains the point, false otherwise.
virtual bool contains (double x, double y, double z) const;
// Returns the TUBE shape type, as a string. // Returns the TUBE shape type, as a string.
virtual const std::string & type () const; virtual const std::string & type () const;
......
...@@ -19,6 +19,9 @@ class GeoTubs : public GeoShape ...@@ -19,6 +19,9 @@ class GeoTubs : public GeoShape
virtual void extent (double& xmin, double& ymin, double& zmin, virtual void extent (double& xmin, double& ymin, double& zmin,
double& xmax, double& ymax, double& zmax) const; double& xmax, double& ymax, double& zmax) const;
// Returns true if the shape contains the point, false otherwise.
virtual bool contains (double x, double y, double z) const;
// Returns the TUBS shape type, as a string. // Returns the TUBS shape type, as a string.
virtual const std::string & type () const; virtual const std::string & type () const;
......
...@@ -70,6 +70,9 @@ class GeoTwistedTrap : public GeoShape ...@@ -70,6 +70,9 @@ class GeoTwistedTrap : public GeoShape
virtual void extent (double& xmin, double& ymin, double& zmin, virtual void extent (double& xmin, double& ymin, double& zmin,
double& xmax, double& ymax, double& zmax) const; double& xmax, double& ymax, double& zmax) const;
// Returns true if the shape contains the point, false otherwise.
virtual bool contains (double x, double y, double z) const;
// Returns the TWISTED TRAP shape type, as a string. // Returns the TWISTED TRAP shape type, as a string.
virtual const std::string & type () const; virtual const std::string & type () const;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment