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 Rules_h
#define Rules_h
#include <map>
namespace Mantid
{
namespace Geometry
{
class Object;
class Surface;
/*!
\class Rule
\brief Object generation rule tree
\author S.Ansell
\version 1.0
\date April 2005
Base class for a rule item in the tree.
#ifndef Rules_h
#define Rules_h
#include <map>
namespace Mantid
{
namespace Geometry
{
class Object;
class Surface;
/*!
\class Rule
\brief Object generation rule tree
\author S.Ansell
\version 1.0
\date April 2005
Base class for a rule item in the tree.
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>
*/
class DLLExport Rule
{
private:
static Kernel::Logger& PLog; ///< The official logger
Rule* Parent; ///< Parent object (for tree)
static int addToKey(std::vector<int>& AV,const int passN=-1);
int getBaseKeys(std::vector<int>&) const; ///< Fills the vector with the surfaces
public:
static int makeCNFcopy(Rule*&); ///< Make Rule into a CNF format (slow)
static int makeFullDNF(Rule*&); ///< Make Rule into a full DNF format
static int makeCNF(Rule*&); ///< Make Rule into a CNF format
static int removeComplementary(Rule*&); ///< NOT WORKING
static int removeItem(Rule*& TRule,const int SurfN);
Rule();
Rule(Rule*);
Rule(const Rule&);
Rule& operator=(const Rule&);
virtual ~Rule();
virtual Rule* clone() const=0; ///< abstract clone object
virtual std::string className() const { return "Rule"; } ///< Returns class name as string
/// No leaf for a base rule
virtual Rule* leaf(const int =0) const { return 0; }
void setParent(Rule*);
Rule* getParent() const;
void makeParents();
int checkParents() const; ///< Debug test for parents
int getKeyList(std::vector<int>&) const;
int commonType() const; ///< Gets a common type
virtual void setLeaves(Rule*,Rule*)=0; ///< abstract set leaves
virtual void setLeaf(Rule*,const int =0) =0; ///< Abstract set
virtual int findLeaf(const Rule*) const =0; ///< Abstract find
virtual Rule* findKey(const int) =0; ///< Abstract key find
virtual int type() const { return 0; } ///< Null rule
/// Abstract: The point is within the object
virtual bool isValid(const Geometry::V3D&) const = 0;
/// Abstract Validity based on surface true/false map
virtual bool isValid(const std::map<int,int>&) const = 0;
/// Abstract: Can the rule be simplified
virtual int simplify() =0;
virtual int isComplementary() const { return 0; } ///< Always returns false (0)
int Eliminate(); ///< elimination not written
int substituteSurf(const int SurfN,const int newSurfN,Surface* SPtr);
/// Abstract Display
virtual std::string display() const=0;
/// Abstract Display Address
virtual std::string displayAddress() const=0;