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
}
else // The normal situation
{
L2s[i] = outgoing.begin()->Dist;
L2s[i] = outgoing.begin()->distFromStart;
}
}
}
......
......@@ -108,7 +108,7 @@ void AnyShapeAbsorption::initialiseCachedDistances()
// the element in this case.
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);
// Also calculate element volume here
m_elementVolumes.push_back(XSliceThickness*YSliceThickness*ZSliceThickness);
......
......@@ -120,7 +120,7 @@ void CylinderAbsorption::initialiseCachedDistances()
Track incoming(m_elementPositions[counter], m_beamDirection*-1.0);
m_sampleObject->interceptSurface(incoming);
m_L1s[counter] = incoming.begin()->Dist;
m_L1s[counter] = incoming.begin()->distFromStart;
// Also calculate element volumes here
const double outerR = R + (m_deltaR / 2.0);
......
......@@ -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");
}
// 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
......
......@@ -106,7 +106,7 @@ void FlatPlateAbsorption::initialiseCachedDistances()
// Create track for distance in sample before scattering point
Track incoming(m_elementPositions[counter], m_beamDirection*-1.0);
m_sampleObject->interceptSurface(incoming);
m_L1s[counter] = incoming.begin()->Dist;
m_L1s[counter] = incoming.begin()->distFromStart;
// Also calculate element volume here
m_elementVolumes[counter] = m_XSliceThickness*m_YSliceThickness*m_ZSliceThickness;
......
......@@ -320,7 +320,7 @@ double He3TubeEfficiency::distToSurface(const Geometry::V3D start,
}
// the first part of the track will be the part inside the shape,
// return its length
return track.begin()->Length;
return track.begin()->distInsideObject;
}
/**
......
......@@ -70,10 +70,14 @@ public:
/// Get a detector at given XY indices.
boost::shared_ptr<Detector> getAtXY(int X, int Y) const;
/// Return the number of pixels in the X direction
int xpixels() const;
/// Return the number of pixels in the Y direction
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 ----------------
......@@ -88,9 +92,7 @@ public:
/// Finds the approximate solid angle covered by the component when viewed from the point given
double solidAngle(const V3D& observer) const;
BoundingBox getBoundingBox() const;
/// Retrieve the cached bounding box
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
......@@ -131,8 +133,6 @@ private:
/// Pointer to the shape of the pixels in this detector array.
boost::shared_ptr<Object> mShape;
};
DLLExport std::ostream& operator<<(std::ostream&, const RectangularDetector&);
......
#ifndef MATERIAL_H
#define MATERIAL_H
#ifndef MANTID_GEOMETRY_MATERIAL_H_
#define MANTID_GEOMETRY_MATERIAL_H_
#include "MantidKernel/System.h"
#include <string>
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.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
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
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);
File change history is stored at: <https://svn.mantidproject.org/mantid/trunk/Code/Mantid>
/// 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; }
/// Get the total cross section
double getScat() const { return scoh+sinc; }
/// Get the scattering cross section
double getCoh() const { return scoh; }
/// Get the incoherent cross section
double getInc() const { return sinc; }
double getScatFrac(const double Wave) const;
double getAtten(const double Wave) const;
double getAttenAbs(const double Wave) const;
/**
* Returns the name
* @returns A string containing the name of the material
*/
inline const std::string& name() const { return m_name; }
/**
* Get the density
* @returns The density of the material
*/
inline double density() const { return m_density; }
/**
* 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
class vtkGeometryCacheReader;
class vtkGeometryCacheWriter;
class BoundingBox;
/*!
\class Object
\brief Global object for object
......@@ -41,8 +41,7 @@ namespace Mantid
\date July 2007
\author S. Ansell
An object is a collection of Rules and
surface object
An object is a collection of Rules and surface objects
Copyright &copy; 2007-2010 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
......@@ -66,86 +65,27 @@ namespace Mantid
*/
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:
/// Default constructor
Object();
/// Copy constructor
Object(const Object&);
/// Assignment operator
Object& operator=(const Object&);
/// Destructor
virtual ~Object();
/// Return the top rule
const Rule* topRule() const { return TopRule; }
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 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 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 createSurfaceList(const int outFlag=0); ///< create Surface list
int addSurfString(const std::string&); ///< Not implemented
......@@ -212,6 +152,63 @@ namespace Mantid
void setVtkGeometryCacheWriter(boost::shared_ptr<vtkGeometryCacheWriter>);
///set vtkGeometryCache reader
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
......
#ifndef MANTID_GEOMETRY_TRACK_H_
#define MANTID_GEOMETRY_TRACK_H_
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidKernel/System.h"
#include "MantidGeometry/V3D.h"
namespace Mantid
{
//----------------------------------------------------------------------
// Forward Declaration
//----------------------------------------------------------------------
namespace Kernel
{
class Logger;
}
namespace Geometry
{
/*!
\struct TUnit
\version 1.0
\author S. Ansell
\brief For a leg of a track
Copyright &copy; 2007 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
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>
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
struct DLLExport TUnit
{
V3D PtA; ///< Init Point
V3D PtB; ///< Exit Point
double Dist; ///< Total distance from track begin
double Length; ///< Total distance Distance [at end]
int ObjID; ///< ObjectID
TUnit(const Geometry::V3D& A,const Geometry::V3D& B,const double D,const int ID);
/// Less than operator
int operator<(const TUnit& A) const
{ return Dist<A.Dist; }
/// Less than operator
int operator<(const double& A) const
{ return Dist<A; }
};
/*!
Ordering for TPartial is special since we need
that when dist is close that the +/- flag is taken into
account.
*/
struct TPartial
{
int ObjID; ///< ObjectID
int Direction; ///< Flag direction
V3D PtA; ///< Point
double Dist; ///< Total distance from track begin
TPartial(const int ID,const int flag,const Geometry::V3D& PVec,const double D);
int operator<(const TPartial& A) const;
};
/*!
\class Track
\version 1.0
\author S. Ansell
\brief Order List of track units.
*/
class DLLExport Track
{
public:
typedef std::vector<TUnit> LType; ///< Type for the Link storage
typedef std::vector<TPartial> PType; ///< Type for the partial
private:
static Kernel::Logger& PLog; ///< The official logger
Geometry::V3D iPt; ///< Start Point
Geometry::V3D uVec; ///< unit vector to direction
int iObj; ///< Initial object
LType Link; ///< Track units
PType surfPoints; ///< Track units
public:
Track(const Geometry::V3D& StartPt,const Geometry::V3D& UV,const int initObj=0);
Track(const Track&);
Track& operator=(const Track&);
~Track();
void addPoint(const int ID,const int Direct,const Geometry::V3D& Pt);
int addTUnit(const int ID,const Geometry::V3D& Apt,const Geometry::V3D& Bpt,
const double D);
void removeCoJoins();
void buildLink();
// get/set
void setFirst(const Geometry::V3D&,const Geometry::V3D&);
const Geometry::V3D& getInit() const { return iPt; } ///< Get the start point
const Geometry::V3D& getUVec() const { return uVec; } ///< Get the direction
LType::const_iterator begin() const { return Link.begin(); } ///< Iterator pointing to start of collection