Commit eebbe173 authored by Gigg, Martyn Anthony's avatar Gigg, Martyn Anthony
Browse files

More updates to geometry for ray tracing/Monte Carlo framework, Re #1212.

Removed unused material fields from Object class, Re #1735
parent 0838697e
...@@ -312,7 +312,7 @@ void AbsorptionCorrection::calculateDistances(const Geometry::IDetector_const_sp ...@@ -312,7 +312,7 @@ void AbsorptionCorrection::calculateDistances(const Geometry::IDetector_const_sp
} }
else // The normal situation else // The normal situation
{ {
L2s[i] = outgoing.begin()->Dist; L2s[i] = outgoing.begin()->distFromStart;
} }
} }
} }
......
...@@ -108,7 +108,7 @@ void AnyShapeAbsorption::initialiseCachedDistances() ...@@ -108,7 +108,7 @@ void AnyShapeAbsorption::initialiseCachedDistances()
// the element in this case. // the element in this case.
if ( m_sampleObject->interceptSurface(incoming) > 0 ) if ( m_sampleObject->interceptSurface(incoming) > 0 )
{ {
m_L1s.push_back(incoming.begin()->Dist); m_L1s.push_back(incoming.begin()->distFromStart);
m_elementPositions.push_back(currentPosition); m_elementPositions.push_back(currentPosition);
// Also calculate element volume here // Also calculate element volume here
m_elementVolumes.push_back(XSliceThickness*YSliceThickness*ZSliceThickness); m_elementVolumes.push_back(XSliceThickness*YSliceThickness*ZSliceThickness);
......
...@@ -120,7 +120,7 @@ void CylinderAbsorption::initialiseCachedDistances() ...@@ -120,7 +120,7 @@ void CylinderAbsorption::initialiseCachedDistances()
Track incoming(m_elementPositions[counter], m_beamDirection*-1.0); Track incoming(m_elementPositions[counter], m_beamDirection*-1.0);
m_sampleObject->interceptSurface(incoming); m_sampleObject->interceptSurface(incoming);
m_L1s[counter] = incoming.begin()->Dist; m_L1s[counter] = incoming.begin()->distFromStart;
// Also calculate element volumes here // Also calculate element volumes here
const double outerR = R + (m_deltaR / 2.0); const double outerR = R + (m_deltaR / 2.0);
......
...@@ -350,7 +350,7 @@ double DetectorEfficiencyCor::distToSurface(const V3D start, const Object *shape ...@@ -350,7 +350,7 @@ double DetectorEfficiencyCor::distToSurface(const V3D start, const Object *shape
throw std::invalid_argument("Fatal error interpreting the shape of a detector"); throw std::invalid_argument("Fatal error interpreting the shape of a detector");
} }
// the first part of the track will be the part inside the shape, return its length // the first part of the track will be the part inside the shape, return its length
return track.begin()->Length; return track.begin()->distInsideObject;
} }
/** Calculates detector efficiency, copied from the fortran code in effic_3he_cylinder.for /** Calculates detector efficiency, copied from the fortran code in effic_3he_cylinder.for
......
...@@ -106,7 +106,7 @@ void FlatPlateAbsorption::initialiseCachedDistances() ...@@ -106,7 +106,7 @@ void FlatPlateAbsorption::initialiseCachedDistances()
// Create track for distance in sample before scattering point // Create track for distance in sample before scattering point
Track incoming(m_elementPositions[counter], m_beamDirection*-1.0); Track incoming(m_elementPositions[counter], m_beamDirection*-1.0);
m_sampleObject->interceptSurface(incoming); m_sampleObject->interceptSurface(incoming);
m_L1s[counter] = incoming.begin()->Dist; m_L1s[counter] = incoming.begin()->distFromStart;
// Also calculate element volume here // Also calculate element volume here
m_elementVolumes[counter] = m_XSliceThickness*m_YSliceThickness*m_ZSliceThickness; m_elementVolumes[counter] = m_XSliceThickness*m_YSliceThickness*m_ZSliceThickness;
......
...@@ -320,7 +320,7 @@ double He3TubeEfficiency::distToSurface(const Geometry::V3D start, ...@@ -320,7 +320,7 @@ double He3TubeEfficiency::distToSurface(const Geometry::V3D start,
} }
// the first part of the track will be the part inside the shape, // the first part of the track will be the part inside the shape,
// return its length // return its length
return track.begin()->Length; return track.begin()->distInsideObject;
} }
/** /**
......
...@@ -70,10 +70,14 @@ public: ...@@ -70,10 +70,14 @@ public:
/// Get a detector at given XY indices. /// Get a detector at given XY indices.
boost::shared_ptr<Detector> getAtXY(int X, int Y) const; boost::shared_ptr<Detector> getAtXY(int X, int Y) const;
/// Return the number of pixels in the X direction
int xpixels() const; int xpixels() const;
/// Return the number of pixels in the Y direction
int ypixels() const; int ypixels() const;
// This should inherit the getBoundingBox implementation from CompAssembly but
// the multiple inheritance seems to confuse it so we'll explicityly tell it that here
using CompAssembly::getBoundingBox;
// ------------ IObjComponent methods ---------------- // ------------ IObjComponent methods ----------------
...@@ -88,9 +92,7 @@ public: ...@@ -88,9 +92,7 @@ public:
/// Finds the approximate solid angle covered by the component when viewed from the point given /// Finds the approximate solid angle covered by the component when viewed from the point given
double solidAngle(const V3D& observer) const; double solidAngle(const V3D& observer) const;
/// Retrieve the cached bounding box
BoundingBox getBoundingBox() const;
void getBoundingBox(double &xmax, double &ymax, double &zmax, double &xmin, double &ymin, double &zmin) const; void getBoundingBox(double &xmax, double &ymax, double &zmax, double &xmin, double &ymin, double &zmin) const;
///Try to find a point that lies within (or on) the object ///Try to find a point that lies within (or on) the object
...@@ -131,8 +133,6 @@ private: ...@@ -131,8 +133,6 @@ private:
/// Pointer to the shape of the pixels in this detector array. /// Pointer to the shape of the pixels in this detector array.
boost::shared_ptr<Object> mShape; boost::shared_ptr<Object> mShape;
}; };
DLLExport std::ostream& operator<<(std::ostream&, const RectangularDetector&); DLLExport std::ostream& operator<<(std::ostream&, const RectangularDetector&);
......
#ifndef MATERIAL_H #ifndef MANTID_GEOMETRY_MATERIAL_H_
#define MATERIAL_H #define MANTID_GEOMETRY_MATERIAL_H_
#include "MantidKernel/System.h" #include "MantidKernel/System.h"
#include <string> #include <string>
namespace Mantid namespace Mantid
{ {
namespace Kernel
{
class Logger;
}
namespace Geometry
{
/*!
\class Material
\brief Nuetronic information on the material
\author S. Ansell
\version 1.0
\date July 2007
This can be extended so that more sophisticated material
components can be used.
\todo This class nees to have a base class.
Copyright &copy; 2007 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory namespace Geometry
{
/**
Simple class defining a material. It holds basic information:
<UL>
<LI>Temperature (Kelvin)</LI>
<LI>Pressure (KPa) </LI>
<LI>Density (kg/m^3)</LI>
<LI>Coherent scattering cross section</LI>
<LI>Incoherent scattering cross section</LI>
<LI>Absorption cross section</LI>
</UL>
Copyright &copy; 2007-2010 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
This file is part of Mantid. This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or the Free Software Foundation; either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
Mantid is distributed in the hope that it will be useful, Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://svn.mantidproject.org/mantid/trunk/Code/Mantid>
*/
class DLLExport Material
{
private:
static Kernel::Logger& PLog; ///< The official logger File change history is stored at: <https://svn.mantidproject.org/mantid/trunk/Code/Mantid>
std::string Name; ///< Name
double density; ///< number density [atom/A^3]
double scoh; ///< scattering cross section
double sinc; ///< incoherrrent cross section
double sabs; ///< Absorption cross section
public:
Material();
Material(const std::string& N,const double D,
const double S,const double I,const double A);
Material(const double D,const double S,const double I,const double A);
Material(const Material&);
virtual Material* clone() const;
Material& operator=(const Material&);
virtual ~Material();
/// Set the name
void setName(const std::string& N) { Name=N; }
void setDensity(const double D);
void setScat(const double S,const double I,const double A);
/// Get the number density */
double getAtomDensity() const { return density; } class DLLExport Material
{
public:
/// Constructor
explicit Material(const std::string & name, const double density,
const double temperature, const double pressure,
const double coherentXsec, const double incoherentXsec,
const double absorbXsec);
/// Set the name /**
const std::string& getName() const { return Name; } * Returns the name
/// Get the total cross section * @returns A string containing the name of the material
double getScat() const { return scoh+sinc; } */
/// Get the scattering cross section inline const std::string& name() const { return m_name; }
double getCoh() const { return scoh; } /**
/// Get the incoherent cross section * Get the density
double getInc() const { return sinc; } * @returns The density of the material
double getScatFrac(const double Wave) const; */
double getAtten(const double Wave) const; inline double density() const { return m_density; }
double getAttenAbs(const double Wave) const; /**
* Get the temperature
* @returns The temperature of the material
*/
inline double temperature() const { return m_temperature; }
/**
* Get the pressure
* @returns The pressure of the material
*/
inline double pressure() const { return m_pressure; }
/**
* Get the total cross section
* @returns The sum of the coherent and incoherent scattering cross section
*/
inline double totalCrossSection() const { return m_coherentXsec + m_incoherentXsec; }
/**
* Get the coherent cross section
* @returns The coherent scattering cross section
*/
inline double coherentCrossSection() const { return m_coherentXsec; }
/**
* Get the incoherent cross section
* @returns The incoherent scattering cross section
*/
inline double incoherentCrossSection() const { return m_incoherentXsec; }
/**
* Get the absorption cross section
* @returns The absorption scattering cross section
*/
inline double absorptionCrossSection() const { return m_absorbXsec; }
double calcAtten(const double Wave,const double Length) const; private:
/// Default constructor
}; Material();
private:
/// Material name
std::string m_name;
/// Density in kg/m^3
double m_density;
/// Temperature
double m_temperature;
/// Pressure
double m_pressure;
/// Coherent scattering cross section
double m_coherentXsec;
/// Incoherent scattering cross section
double m_incoherentXsec;
/// Absorption cross section
double m_absorbXsec;
};
} // NAMESPACE Geometry
} // NAMESPACE Mantid }
}
#endif #endif //MANTID_GEOMETRY_MATERIAL_H_
...@@ -33,7 +33,7 @@ namespace Mantid ...@@ -33,7 +33,7 @@ namespace Mantid
class vtkGeometryCacheReader; class vtkGeometryCacheReader;
class vtkGeometryCacheWriter; class vtkGeometryCacheWriter;
class BoundingBox; class BoundingBox;
/*! /*!
\class Object \class Object
\brief Global object for object \brief Global object for object
...@@ -41,8 +41,7 @@ namespace Mantid ...@@ -41,8 +41,7 @@ namespace Mantid
\date July 2007 \date July 2007
\author S. Ansell \author S. Ansell
An object is a collection of Rules and An object is a collection of Rules and surface objects
surface object
Copyright &copy; 2007-2010 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory Copyright &copy; 2007-2010 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
...@@ -66,86 +65,27 @@ namespace Mantid ...@@ -66,86 +65,27 @@ namespace Mantid
*/ */
class DLLExport Object class DLLExport Object
{ {
private:
static Kernel::Logger& PLog; ///< The official logger
int ObjName; ///< Creation number
int MatN; ///< Material Number
double Tmp; ///< Temperature (K)
double density; ///< Density
Rule* TopRule; ///< Top rule [ Geometric scope of object]
int procPair(std::string& Ln,std::map<int,Rule*>& Rlist,int& compUnit) const;
CompGrp* procComp(Rule*) const;
int checkSurfaceValid(const Geometry::V3D&,const Geometry::V3D&) const;
boost::shared_ptr<BoundingBox> m_boundingBox;
// -- DEPRECATED --
mutable double AABBxMax, ///< xmax of Axis aligned bounding box cache
AABByMax, ///< ymax of Axis aligned bounding box cache
AABBzMax, ///< zmax of Axis aligned bounding box cache
AABBxMin, ///< xmin of Axis aligned bounding box cache
AABByMin, ///< xmin of Axis aligned bounding box cache
AABBzMin; ///< zmin of Axis Aligned Bounding Box Cache
mutable bool boolBounded; ///< flag true if a bounding box exists, either by getBoundingBox or defineBoundingBox
// -- --
int searchForObject(Geometry::V3D&) const;
double getTriangleSolidAngle(const V3D& a, const V3D& b, const V3D& c, const V3D& observer) const;
double CuboidSolidAngle(const V3D observer, const std::vector<Geometry::V3D> vectors) const;
double SphereSolidAngle(const V3D observer, const std::vector<Geometry::V3D> vectors, const double radius) const;
double CylinderSolidAngle(const V3D & observer, const Mantid::Geometry::V3D & centre,
const Mantid::Geometry::V3D & axis,
const double radius, const double height) const;
double ConeSolidAngle(const V3D & observer, const Mantid::Geometry::V3D & centre,
const Mantid::Geometry::V3D & axis,
const double radius, const double height) const;
/// Geometry Handle for rendering
boost::shared_ptr<GeometryHandler> handle;
friend class CacheGeometryHandler;
/// Is geometry caching enabled?
bool bGeometryCaching;
/// a pointer to a class for reading from the geometry cache
boost::shared_ptr<vtkGeometryCacheReader> vtkCacheReader;
/// a pointer to a class for writing to the geometry cache
boost::shared_ptr<vtkGeometryCacheWriter> vtkCacheWriter;
void updateGeometryHandler();
/// for solid angle from triangulation
int NumberOfTriangles() const;
int NumberOfPoints() const;
int* getTriangleFaces() const;
double* getTriangleVertices() const;
void GetObjectGeom(int& type, std::vector<Geometry::V3D>& vectors, double& myradius, double & myheight) const;
protected:
std::vector<const Surface*> SurList; ///< Full surfaces (make a map including complementary object ?)
public: public:
/// Default constructor
Object(); Object();
/// Copy constructor
Object(const Object&); Object(const Object&);
/// Assignment operator
Object& operator=(const Object&); Object& operator=(const Object&);
/// Destructor
virtual ~Object(); virtual ~Object();
/// Return the top rule /// Return the top rule
const Rule* topRule() const { return TopRule; } const Rule* topRule() const { return TopRule; }
void setName(const int nx) { ObjName=nx; } ///< Set Name void setName(const int nx) { ObjName=nx; } ///< Set Name
void setTemp(const double A) { Tmp=A; } ///< Set temperature [Kelvin] int getName() const { return ObjName; } ///< Get Name
int setObject(const int ON,const std::string& Ln); int setObject(const int ON,const std::string& Ln);
int procString(const std::string& Line); int procString(const std::string& Line);
void setMaterial(const int MatIndex) { MatN=MatIndex; } ///< Set Material index
void setDensity(const double D) { density=D; } ///< Set Density [Atom/A^3]
int complementaryObject(const int Cnum,std::string& Ln); ///< Process a complementary object int complementaryObject(const int Cnum,std::string& Ln); ///< Process a complementary object
int hasComplement() const; int hasComplement() const;
int getName() const { return ObjName; } ///< Get Name
int getMat() const { return MatN; } ///< Get Material ID
double getTemp() const { return Tmp; } ///< Get Temperature [K]
double getDensity() const { return density; } ///< Get Density [Atom/A^3]
int populate(const std::map<int,Surface*>&); int populate(const std::map<int,Surface*>&);
int createSurfaceList(const int outFlag=0); ///< create Surface list int createSurfaceList(const int outFlag=0); ///< create Surface list
int addSurfString(const std::string&); ///< Not implemented int addSurfString(const std::string&); ///< Not implemented
...@@ -212,6 +152,63 @@ namespace Mantid ...@@ -212,6 +152,63 @@ namespace Mantid
void setVtkGeometryCacheWriter(boost::shared_ptr<vtkGeometryCacheWriter>); void setVtkGeometryCacheWriter(boost::shared_ptr<vtkGeometryCacheWriter>);
///set vtkGeometryCache reader ///set vtkGeometryCache reader
void setVtkGeometryCacheReader(boost::shared_ptr<vtkGeometryCacheReader>); void setVtkGeometryCacheReader(boost::shared_ptr<vtkGeometryCacheReader>);
private:
static Kernel::Logger& PLog; ///< The official logger
int ObjName; ///< Creation number
//int MatN; ///< Material Number
//double Tmp; ///< Temperature (K)
//double density; ///< Density
Rule* TopRule; ///< Top rule [ Geometric scope of object]
int procPair(std::string& Ln,std::map<int,Rule*>& Rlist,int& compUnit) const;
CompGrp* procComp(Rule*) const;
int checkSurfaceValid(const Geometry::V3D&,const Geometry::V3D&) const;
boost::shared_ptr<BoundingBox> m_boundingBox;
// -- DEPRECATED --
mutable double AABBxMax, ///< xmax of Axis aligned bounding box cache
AABByMax, ///< ymax of Axis aligned bounding box cache
AABBzMax, ///< zmax of Axis aligned bounding box cache
AABBxMin, ///< xmin of Axis aligned bounding box cache
AABByMin, ///< xmin of Axis aligned bounding box cache
AABBzMin; ///< zmin of Axis Aligned Bounding Box Cache
mutable bool boolBounded; ///< flag true if a bounding box exists, either by getBoundingBox or defineBoundingBox
// -- --
int searchForObject(Geometry::V3D&) const;
double getTriangleSolidAngle(const V3D& a, const V3D& b, const V3D& c, const V3D& observer) const;
double CuboidSolidAngle(const V3D observer, const std::vector<Geometry::V3D> vectors) const;
double SphereSolidAngle(const V3D observer, const std::vector<Geometry::V3D> vectors, const double radius) const;
double CylinderSolidAngle(const V3D & observer, const Mantid::Geometry::V3D & centre,
const Mantid::Geometry::V3D & axis,
const double radius, const double height) const;
double ConeSolidAngle(const V3D & observer, const Mantid::Geometry::V3D & centre,
const Mantid::Geometry::V3D & axis,
const double radius, const double height) const;
/// Geometry Handle for rendering
boost::shared_ptr<GeometryHandler> handle;
friend class CacheGeometryHandler;
/// Is geometry caching enabled?
bool bGeometryCaching;
/// a pointer to a class for reading from the geometry cache
boost::shared_ptr<vtkGeometryCacheReader> vtkCacheReader;
/// a pointer to a class for writing to the geometry cache
boost::shared_ptr<vtkGeometryCacheWriter> vtkCacheWriter;
void updateGeometryHandler();
/// for solid angle from triangulation
int NumberOfTriangles() const;
int NumberOfPoints() const;
int* getTriangleFaces() const;
double* getTriangleVertices() const;
void GetObjectGeom(int& type, std::vector<Geometry::V3D>& vectors, double& myradius, double & myheight) const;
protected:
std::vector<const Surface*> SurList; ///< Full surfaces (make a map including complementary object ?)
}; };
} // NAMESPACE Geometry } // NAMESPACE Geometry
......
#ifndef MANTID_GEOMETRY_TRACK_H_ #ifndef MANTID_GEOMETRY_TRACK_H_
#define MANTID_GEOMETRY_TRACK_H_ #define MANTID_GEOMETRY_TRACK_H_
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Includes // Includes
//---------------------------------------------------------------------- //----------------------------------------------------------------------
#include "MantidKernel/System.h" #include "MantidKernel/System.h"
#include "MantidGeometry/V3D.h" #include "MantidGeometry/V3D.h"
#include "MantidGeometry/Tolerance.h"
namespace Mantid
{ namespace Mantid
//---------------------------------------------------------------------- {
// Forward Declaration //----------------------------------------------------------------------
//---------------------------------------------------------------------- // Forward Declaration
namespace Kernel //----------------------------------------------------------------------
{ namespace Kernel
class Logger; {
} class Logger;