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

Modify the SolidAngle calculation for cylinders to EXCLUDE the end caps so...

Modify the SolidAngle calculation for cylinders to EXCLUDE the end caps so that it closely approximates the effects of shadowing for stacked cylinders. Also cleaned up some indentation in renderinging code and made an error message clearer in IPropertyManager. Re #2596
parent 64fc15a3
......@@ -104,28 +104,29 @@ public:
Workspace2D_sptr output2D = boost::dynamic_pointer_cast<Workspace2D>(output);
Workspace2D_sptr input2D = boost::dynamic_pointer_cast<Workspace2D>(input);
// Check that the output unit is correct
TS_ASSERT_EQUALS( output2D->getAxis(0)->unit()->unitID(), "TOF")
const size_t numberOfSpectra = output2D->getNumberHistograms();
TS_ASSERT_EQUALS( output2D->getAxis(0)->unit()->unitID(), "TOF");
const size_t numberOfSpectra = output2D->getNumberHistograms();
TS_ASSERT_EQUALS(numberOfSpectra, (int)Nhist);
for (size_t i = 0; i < numberOfSpectra-1; ++i) {
//all of the values should fall in this range for INES
TS_ASSERT_DELTA(output2D->readY(i)[0],0.00139,0.00001);
TS_ASSERT_DELTA(output2D->readX(i)[0],0.0,0.000001);
TS_ASSERT_DELTA(output2D->readX(i)[1],10000.0,0.000001);
TS_ASSERT_DELTA(output2D->readE(i)[0],0.0,0.000001);
}
//some specific, more accurate values
TS_ASSERT_DELTA(output2D->readY(5)[0],0.00139822,0.0000001);
TS_ASSERT_DELTA(output2D->readY(10)[0],0.00139822,0.0000001);
TS_ASSERT_DELTA(output2D->readY(20)[0],0.00139822,0.0000001);
TS_ASSERT_DELTA(output2D->readY(50)[0],0.00139822,0.0000001);
for (size_t i = 0; i < numberOfSpectra-1; ++i)
{
//all of the values should fall in this range for INES
TS_ASSERT_DELTA(output2D->readY(i)[0],0.00139,0.00001);
TS_ASSERT_DELTA(output2D->readX(i)[0],0.0,0.000001);
TS_ASSERT_DELTA(output2D->readX(i)[1],10000.0,0.000001);
TS_ASSERT_DELTA(output2D->readE(i)[0],0.0,0.000001);
}
//some specific, more accurate values
TS_ASSERT_DELTA(output2D->readY(5)[0],0.00139822,0.0000001);
TS_ASSERT_DELTA(output2D->readY(10)[0],0.00139822,0.0000001);
TS_ASSERT_DELTA(output2D->readY(20)[0],0.00139822,0.0000001);
TS_ASSERT_DELTA(output2D->readY(50)[0],0.00139822,0.0000001);
// Check 'dead' detector spectrum gives zero solid angle
TS_ASSERT_EQUALS(output2D->readY(143).front(), 0)
// Check 'dead' detector spectrum gives zero solid angle
TS_ASSERT_EQUALS(output2D->readY(143).front(), 0);
}
void testExecSubset()
......@@ -149,20 +150,19 @@ public:
// Check that the output unit is correct
TS_ASSERT_EQUALS( output2D->getAxis(0)->unit()->unitID(), "TOF")
const size_t numberOfSpectra = output2D->getNumberHistograms();
TS_ASSERT_EQUALS(numberOfSpectra,10);
for (size_t i = 0; i < numberOfSpectra; ++i) {
//all of the values should fall in this range for INES
TS_ASSERT_DELTA(output2D->readY(i)[0],0.0013,0.0001);
TS_ASSERT_DELTA(output2D->readX(i)[0],0.0,0.000001);
TS_ASSERT_DELTA(output2D->readX(i)[1],10000.0,0.000001);
TS_ASSERT_DELTA(output2D->readE(i)[0],0.0,0.000001);
}
const size_t numberOfSpectra = output2D->getNumberHistograms();
TS_ASSERT_EQUALS(numberOfSpectra,10);
for (size_t i = 0; i < numberOfSpectra; ++i) {
//all of the values should fall in this range for INES
TS_ASSERT_DELTA(output2D->readY(i)[0],0.0013,0.0001);
TS_ASSERT_DELTA(output2D->readX(i)[0],0.0,0.000001);
TS_ASSERT_DELTA(output2D->readX(i)[1],10000.0,0.000001);
TS_ASSERT_DELTA(output2D->readE(i)[0],0.0,0.000001);
}
}
private:
SolidAngle alg;
std::string inputSpace;
......
......@@ -8,66 +8,66 @@
namespace Mantid
{
namespace Geometry
{
namespace Geometry
{
/**
\class CacheGeometryGenerator
\brief Generates geometry using other geometry handlers or keeps the cache of the triangles
\author Mr. Srikanth Nagella
\date Jan 2009
\version 1.0
/**
\class CacheGeometryGenerator
\brief Generates geometry using other geometry handlers or keeps the cache of the triangles
\author Mr. Srikanth Nagella
\date Jan 2009
\version 1.0
This class is an cache for the geometry triangles and if needed generates the triangles using
other GeometryHandlers.
This class is an cache for the geometry triangles and if needed generates the triangles using
other GeometryHandlers.
Copyright &copy; 2007 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
Copyright &copy; 2007 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
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 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.
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/>.
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 Object;
class DLLExport CacheGeometryGenerator
{
private:
static Kernel::Logger& PLog; ///< Static reference to the logger class
Object *Obj; ///< Input Object
int mNoOfVertices; ///< number of vertices
int mNoOfTriangles; ///< number of triangles
double* mPoints; ///<double array or points
int* mFaces; ///< Integer array of faces
public:
CacheGeometryGenerator(Object *obj);
~CacheGeometryGenerator();
/// Generate the trangles
void Generate();
/// get the number of triangles
int getNumberOfTriangles();
/// get the number of points
int getNumberOfPoints();
/// get the triangle vertices
double* getTriangleVertices();
/// get the triangle faces
int* getTriangleFaces();
/// Sets the geometry cache using the triangulation information provided
void setGeometryCache(int noPts,int noFaces,double* pts,int* faces);
};
File change history is stored at: <https://svn.mantidproject.org/mantid/trunk/Code/Mantid>
*/
class Object;
class DLLExport CacheGeometryGenerator
{
private:
static Kernel::Logger& PLog; ///< Static reference to the logger class
Object *Obj; ///< Input Object
int mNoOfVertices; ///< number of vertices
int mNoOfTriangles; ///< number of triangles
double* mPoints; ///<double array or points
int* mFaces; ///< Integer array of faces
public:
CacheGeometryGenerator(Object *obj);
~CacheGeometryGenerator();
/// Generate the trangles
void Generate();
/// get the number of triangles
int getNumberOfTriangles();
/// get the number of points
int getNumberOfPoints();
/// get the triangle vertices
double* getTriangleVertices();
/// get the triangle faces
int* getTriangleFaces();
/// Sets the geometry cache using the triangulation information provided
void setGeometryCache(int noPts,int noFaces,double* pts,int* faces);
};
} // NAMESPACE Geometry
} // NAMESPACE Geometry
} // NAMESPACE Mantid
......
......@@ -8,70 +8,70 @@
namespace Mantid
{
namespace Geometry
{
/**
\class CacheGeometryHandler
\brief Place holder for geometry triangulation and rendering with caching triangles.
\author Srikanth Nagella
\date Jan 2009
\version 1.0
namespace Geometry
{
class GeometryHandler;
class CacheGeometryRenderer;
class CacheGeometryGenerator;
class IObjComponent;
class Object;
class V3D;
/**
\class CacheGeometryHandler
\brief Place holder for geometry triangulation and rendering with caching triangles.
\author Srikanth Nagella
\date Jan 2009
\version 1.0
This is an implementation class for handling geometry from cache, if the cache doesn't exist then the
triangulation is done using another triangulation handler and store in cache.
This is an implementation class for handling geometry from cache, if the cache doesn't exist then the
triangulation is done using another triangulation handler and store in cache.
Copyright &copy; 2008 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
Copyright &copy; 2008 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
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 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.
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/>.
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 GeometryHandler;
class CacheGeometryRenderer;
class CacheGeometryGenerator;
class IObjComponent;
class Object;
class V3D;
class DLLExport CacheGeometryHandler: public GeometryHandler
{
private:
static Kernel::Logger& PLog; ///< The official logger
CacheGeometryRenderer* Renderer; ///< Geometry renderer variable used for rendering Object/ObjComponent
CacheGeometryGenerator* Triangulator; ///< Geometry generator to triangulate Object
File change history is stored at: <https://svn.mantidproject.org/mantid/trunk/Code/Mantid>
*/
class DLLExport CacheGeometryHandler: public GeometryHandler
{
private:
static Kernel::Logger& PLog; ///< The official logger
CacheGeometryRenderer* Renderer; ///< Geometry renderer variable used for rendering Object/ObjComponent
CacheGeometryGenerator* Triangulator; ///< Geometry generator to triangulate Object
public:
CacheGeometryHandler(IObjComponent* obj); ///< Constructor
CacheGeometryHandler(boost::shared_ptr<Object> obj); ///< Constructor
CacheGeometryHandler(Object* obj); ///< Constructor
~CacheGeometryHandler(); ///< Destructor
GeometryHandler* createInstance(IObjComponent *comp);
GeometryHandler* createInstance(boost::shared_ptr<Object> obj);
void Triangulate();
void Render();
void Initialize();
bool canTriangulate(){return true;}
int NumberOfTriangles();
int NumberOfPoints();
double* getTriangleVertices();
int* getTriangleFaces();
/// Sets the geometry cache using the triangulation information provided
void setGeometryCache(int noPts,int noFaces,double* pts,int* faces);
};
public:
CacheGeometryHandler(IObjComponent* obj); ///< Constructor
CacheGeometryHandler(boost::shared_ptr<Object> obj); ///< Constructor
CacheGeometryHandler(Object* obj); ///< Constructor
~CacheGeometryHandler(); ///< Destructor
GeometryHandler* createInstance(IObjComponent *comp);
GeometryHandler* createInstance(boost::shared_ptr<Object> obj);
void Triangulate();
void Render();
void Initialize();
bool canTriangulate(){return true;}
int NumberOfTriangles();
int NumberOfPoints();
double* getTriangleVertices();
int* getTriangleFaces();
/// Sets the geometry cache using the triangulation information provided
void setGeometryCache(int noPts,int noFaces,double* pts,int* faces);
};
} // NAMESPACE Geometry
} // NAMESPACE Geometry
} // NAMESPACE Mantid
......
......@@ -8,55 +8,55 @@ namespace Mantid
namespace Geometry
{
class IObjComponent;
class V3D;
/**
\class CacheGeometryRenderer
\brief rendering geometry using opengl from the geometry cache.
\author Srikanth Nagella
\date Jan 2009
\version 1.0
\class CacheGeometryRenderer
\brief rendering geometry using opengl from the geometry cache.
\author Srikanth Nagella
\date Jan 2009
\version 1.0
This is an concrete class for rendering cached geometry using opengl.
This is an concrete class for rendering cached geometry using opengl.
Copyright &copy; 2008 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
Copyright &copy; 2008 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
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 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.
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/>.
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>
File change history is stored at: <https://svn.mantidproject.org/mantid/trunk/Code/Mantid>
*/
class IObjComponent;
class V3D;
class DLLExport CacheGeometryRenderer
class DLLExport CacheGeometryRenderer
{
private:
static Kernel::Logger& PLog; ///< The official logger
unsigned int iDisplaylistId; ///< OpenGL display list id
bool boolDisplaylistCreated; ///< flag to store whether display list is created or not
unsigned int iDisplaylistId; ///< OpenGL display list id
bool boolDisplaylistCreated; ///< flag to store whether display list is created or not
public:
CacheGeometryRenderer(); ///< Constructor
~CacheGeometryRenderer(); ///< Destructor
/// Render using an object component
void Render(IObjComponent* ObjComp) const;
/// Render using triangulation information
void Render(int noPts,int noFaces,double* points,int* faces) const;
/// Initialize using triangulation information
void Initialize(int noPts,int noFaces,double* points,int* faces);
/// Initialize using an object component
void Initialize(IObjComponent* ObjComp);
CacheGeometryRenderer(); ///< Constructor
~CacheGeometryRenderer(); ///< Destructor
/// Render using an object component
void Render(IObjComponent* ObjComp) const;
/// Render using triangulation information
void Render(int noPts,int noFaces,double* points,int* faces) const;
/// Initialize using triangulation information
void Initialize(int noPts,int noFaces,double* points,int* faces);
/// Initialize using an object component
void Initialize(IObjComponent* ObjComp);
};
} // NAMESPACE Geometry
......
......@@ -3,88 +3,92 @@
#include "MantidKernel/System.h"
#include "MantidKernel/Logger.h"
#include "MantidGeometry/IObjComponent.h"
#include "MantidGeometry/Objects/Object.h"
//#include <boost/weak_ptr.hppr>
#include "MantidGeometry/V3D.h"
#include <boost/shared_ptr.hpp>
#include <vector>
namespace Mantid
{
namespace Geometry
{
/**
\class GeometryHandler
\brief Place holder for geometry triangulation and rendering.
\author Srikanth Nagella
\date July 2008
\version 1.0
namespace Geometry
{
class IObjComponent;
class ObjComponent;
class Object;
This is an abstract class for handling geometry primitives.
/**
\class GeometryHandler
\brief Place holder for geometry triangulation and rendering.
\author Srikanth Nagella
\date July 2008
\version 1.0
Copyright &copy; 2008 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
This is an abstract class for handling geometry primitives.
This file is part of Mantid.
Copyright &copy; 2008 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
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.
This file is part of Mantid.
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.
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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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.
File change history is stored at: <https://svn.mantidproject.org/mantid/trunk/Code/Mantid>
*/
class ObjComponent;
class Object;
class DLLExport GeometryHandler
{
private:
static Kernel::Logger& PLog; ///< The official logger
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
protected:
IObjComponent *ObjComp; ///< ObjComponent that uses this geometry handler
Object *Obj; ///< Object that uses this geometry handler
bool boolTriangulated; ///< state of the geometry triangulation
bool boolIsInitialized; ///< state of the geometry initialization for rendering
public:
GeometryHandler(IObjComponent *comp); ///< Constructor
GeometryHandler(boost::shared_ptr<Object> obj); ///<Constructor
GeometryHandler(Object *obj); ///<Constructor
virtual ~GeometryHandler();
virtual GeometryHandler* createInstance(IObjComponent *)=0; ///< Create an instance of concrete geometry handler for ObjComponent
virtual GeometryHandler* createInstance(boost::shared_ptr<Object> )=0; ///< Create an instance of concrete geometry handler for Object
virtual void Triangulate()=0; ///< Triangulate the Object
virtual void Render()=0; ///< Render Object or ObjComponent
virtual void Initialize()=0; ///< Prepare/Initialize Object/ObjComponent to be rendered
/// Returns true if the shape can be triangulated
virtual bool canTriangulate(){return false;}
/// get the number of triangles
virtual int NumberOfTriangles(){return 0;}
/// get the number of points or vertices
virtual int NumberOfPoints(){return 0;}
/// Extract the vertices of the triangles
virtual double* getTriangleVertices(){return NULL;}
/// Extract the Faces of the triangles
virtual int* getTriangleFaces(){return NULL;}
/// Sets the geometry cache using the triangulation information provided
virtual void setGeometryCache(int noPts,int noFaces,double* pts,int* faces)
{
(void) noPts; (void) noFaces; (void) pts; (void) faces; //Avoid compiler warning
};
/// return the actual type and points of one of the "standard" objects, cuboid/cone/cyl/sphere
virtual void GetObjectGeom(int& mytype, std::vector<Geometry::V3D>& vectors, double& myradius, double & myheight)
{
(void) mytype; (void) vectors; (void) myradius; (void) myheight; //Avoid compiler warning
};
};
File change history is stored at: <https://svn.mantidproject.org/mantid/trunk/Code/Mantid>
*/
class DLLExport GeometryHandler
{
private:
static Kernel::Logger& PLog; ///< The official logger
} // NAMESPACE Geometry
protected:
IObjComponent *ObjComp; ///< ObjComponent that uses this geometry handler
Object *Obj; ///< Object that uses this geometry handler
bool boolTriangulated; ///< state of the geometry triangulation
bool boolIsInitialized; ///< state of the geometry initialization for rendering
public:
GeometryHandler(IObjComponent *comp); ///< Constructor
GeometryHandler(boost::shared_ptr<Object> obj); ///<Constructor
GeometryHandler(Object *obj); ///<Constructor
virtual ~GeometryHandler();
virtual GeometryHandler* createInstance(IObjComponent *)=0; ///< Create an instance of concrete geometry handler for ObjComponent
virtual GeometryHandler* createInstance(boost::shared_ptr<Object> )=0; ///< Create an instance of concrete geometry handler for Object
virtual void Triangulate()=0; ///< Triangulate the Object
virtual void Render()=0; ///< Render Object or ObjComponent
virtual void Initialize()=0; ///< Prepare/Initialize Object/ObjComponent to be rendered
/// Returns true if the shape can be triangulated
virtual bool canTriangulate(){return false;}
/// get the number of triangles
virtual int NumberOfTriangles(){return 0;}
/// get the number of points or vertices
virtual int NumberOfPoints(){return 0;}
/// Extract the vertices of the triangles
virtual double* getTriangleVertices(){return NULL;}
/// Extract the Faces of the triangles
virtual int* getTriangleFaces(){return NULL;}
/// Sets the geometry cache using the triangulation information provided
virtual void setGeometryCache(int noPts,int noFaces,double* pts,int* faces)
{
UNUSED_ARG(noPts); UNUSED_ARG(noFaces); UNUSED_ARG(pts); UNUSED_ARG(faces);
};
/// return the actual type and points of one of the "standard" objects, cuboid/cone/cyl/sphere
virtual void GetObjectGeom(int& mytype, std::vector<Geometry::V3D>& vectors, double& myradius, double & myheight)
{
UNUSED_ARG(vectors); UNUSED_ARG(myradius); UNUSED_ARG(myheight);
// Flag that this is unknown at this point