Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
mantidproject
mantid
Commits
f08c20e4
Commit
f08c20e4
authored
Oct 13, 2014
by
Gigg, Martyn Anthony
Browse files
Put Geometry::Object back to storing the material.
Refs #9842
parent
1638b974
Changes
3
Hide whitespace changes
Inline
Side-by-side
Code/Mantid/Framework/Geometry/inc/MantidGeometry/Objects/Object.h
View file @
f08c20e4
...
...
@@ -5,19 +5,19 @@
// Includes
//----------------------------------------------------------------------
#include
"MantidGeometry/DllConfig.h"
#include
"MantidKernel/
V3D
.h"
#include
"MantidKernel/
Material
.h"
#include
"MantidKernel/Quat.h"
#include
"MantidKernel/V3D.h"
#include
"BoundingBox.h"
#include
<map>
namespace
Mantid
{
//----------------------------------------------------------------------
// Forward declarations
//----------------------------------------------------------------------
namespace
Geometry
{
//----------------------------------------------------------------------
// Forward declarations
//----------------------------------------------------------------------
class
Rule
;
class
CompGrp
;
class
Surface
;
...
...
@@ -76,6 +76,9 @@ namespace Mantid
void
setName
(
const
int
nx
)
{
ObjName
=
nx
;
}
///< Set Name
int
getName
()
const
{
return
ObjName
;
}
///< Get Name
void
setMaterial
(
const
Kernel
::
Material
&
material
);
const
Kernel
::
Material
&
material
()
const
;
/// Return whether this object has a valid shape
bool
hasValidShape
()
const
;
int
setObject
(
const
int
ON
,
const
std
::
string
&
Ln
);
...
...
@@ -132,7 +135,7 @@ namespace Mantid
const
BoundingBox
&
getBoundingBox
()
const
;
/// Define axis-aligned bounding box
void
defineBoundingBox
(
const
double
&
xmax
,
const
double
&
ymax
,
const
double
&
zmax
,
const
double
&
xmin
,
const
double
&
ymin
,
const
double
&
zmin
);
/// Set a null bounding box for this object
/// Set a null bounding box for this object
void
setNullBoundingBox
();
// find internal point to object
int
getPointInObject
(
Kernel
::
V3D
&
point
)
const
;
...
...
@@ -176,11 +179,11 @@ namespace Mantid
double
getTriangleSolidAngle
(
const
Kernel
::
V3D
&
a
,
const
Kernel
::
V3D
&
b
,
const
Kernel
::
V3D
&
c
,
const
Kernel
::
V3D
&
observer
)
const
;
double
CuboidSolidAngle
(
const
Kernel
::
V3D
observer
,
const
std
::
vector
<
Kernel
::
V3D
>
vectors
)
const
;
double
SphereSolidAngle
(
const
Kernel
::
V3D
observer
,
const
std
::
vector
<
Kernel
::
V3D
>
vectors
,
const
double
radius
)
const
;
double
CylinderSolidAngle
(
const
Kernel
::
V3D
&
observer
,
const
Mantid
::
Kernel
::
V3D
&
centre
,
const
Mantid
::
Kernel
::
V3D
&
axis
,
double
CylinderSolidAngle
(
const
Kernel
::
V3D
&
observer
,
const
Mantid
::
Kernel
::
V3D
&
centre
,
const
Mantid
::
Kernel
::
V3D
&
axis
,
const
double
radius
,
const
double
height
)
const
;
double
ConeSolidAngle
(
const
Kernel
::
V3D
&
observer
,
const
Mantid
::
Kernel
::
V3D
&
centre
,
const
Mantid
::
Kernel
::
V3D
&
axis
,
double
ConeSolidAngle
(
const
Kernel
::
V3D
&
observer
,
const
Mantid
::
Kernel
::
V3D
&
centre
,
const
Mantid
::
Kernel
::
V3D
&
axis
,
const
double
radius
,
const
double
height
)
const
;
/// Geometry Handle for rendering
...
...
@@ -200,6 +203,8 @@ namespace Mantid
double
*
getTriangleVertices
()
const
;
/// original shape xml used to generate this object.
std
::
string
m_shapeXML
;
/// material composition
Kernel
::
Material
m_material
;
protected:
std
::
vector
<
const
Surface
*>
SurList
;
///< Full surfaces (make a map including complementary object ?)
...
...
Code/Mantid/Framework/Geometry/src/Objects/Object.cpp
View file @
f08c20e4
...
...
@@ -4,7 +4,6 @@
#include
"MantidKernel/MultiThreaded.h"
#include
"MantidGeometry/Objects/Rules.h"
#include
"MantidGeometry/Objects/Track.h"
#include
"MantidGeometry/Objects/BoundingBox.h"
#include
"MantidGeometry/Surfaces/Surface.h"
#include
"MantidGeometry/Surfaces/LineIntersectVisit.h"
...
...
@@ -36,7 +35,8 @@ namespace Mantid
ObjName
(
0
),
TopRule
(
0
),
m_boundingBox
(),
AABBxMax
(
0
),
AABByMax
(
0
),
AABBzMax
(
0
),
AABBxMin
(
0
),
AABByMin
(
0
),
AABBzMin
(
0
),
boolBounded
(
false
),
handle
(),
bGeometryCaching
(
false
),
vtkCacheReader
(
boost
::
shared_ptr
<
vtkGeometryCacheReader
>
()),
vtkCacheWriter
(
boost
::
shared_ptr
<
vtkGeometryCacheWriter
>
())
vtkCacheWriter
(
boost
::
shared_ptr
<
vtkGeometryCacheWriter
>
()),
m_material
()
// empty by default
{
handle
=
boost
::
shared_ptr
<
GeometryHandler
>
(
new
CacheGeometryHandler
(
this
));
}
...
...
@@ -49,7 +49,7 @@ namespace Mantid
ObjName
(
0
),
TopRule
(
0
),
m_boundingBox
(),
AABBxMax
(
0
),
AABByMax
(
0
),
AABBzMax
(
0
),
AABBxMin
(
0
),
AABByMin
(
0
),
AABBzMin
(
0
),
boolBounded
(
false
),
handle
(),
bGeometryCaching
(
false
),
vtkCacheReader
(
boost
::
shared_ptr
<
vtkGeometryCacheReader
>
()),
vtkCacheWriter
(
boost
::
shared_ptr
<
vtkGeometryCacheWriter
>
()),
m_shapeXML
(
shapeXML
)
vtkGeometryCacheWriter
>
()),
m_shapeXML
(
shapeXML
)
,
m_material
()
// empty by default
{
handle
=
boost
::
shared_ptr
<
GeometryHandler
>
(
new
CacheGeometryHandler
(
this
));
}
...
...
@@ -64,7 +64,7 @@ namespace Mantid
AABByMin
(
A
.
AABByMin
),
AABBzMin
(
A
.
AABBzMin
),
boolBounded
(
A
.
boolBounded
),
handle
(
A
.
handle
->
clone
()),
bGeometryCaching
(
A
.
bGeometryCaching
),
vtkCacheReader
(
A
.
vtkCacheReader
),
vtkCacheWriter
(
A
.
vtkCacheWriter
),
m_shapeXML
(
A
.
m_shapeXML
)
m_shapeXML
(
A
.
m_shapeXML
)
,
m_material
(
A
.
m_material
)
{
if
(
TopRule
)
createSurfaceList
();
}
...
...
@@ -93,6 +93,7 @@ namespace Mantid
vtkCacheReader
=
A
.
vtkCacheReader
;
vtkCacheWriter
=
A
.
vtkCacheWriter
;
m_shapeXML
=
A
.
m_shapeXML
;
m_material
=
A
.
m_material
;
if
(
TopRule
)
createSurfaceList
();
}
...
...
@@ -108,6 +109,22 @@ namespace Mantid
delete
TopRule
;
}
/**
* @param material The new Material that the object is composed from
*/
void
Object
::
setMaterial
(
const
Kernel
::
Material
&
material
)
{
m_material
=
material
;
}
/**
* @return The Material that the object is composed from
*/
const
Kernel
::
Material
&
Object
::
material
()
const
{
return
m_material
;
}
/**
* Returns whether this object has a valid shape
* @returns True if the surface list is populated and there is a
...
...
Code/Mantid/Framework/Geometry/test/ObjectTest.h
View file @
f08c20e4
...
...
@@ -11,7 +11,6 @@
#include
<boost/shared_ptr.hpp>
#include
"MantidKernel/V3D.h"
#include
"MantidGeometry/Objects/Object.h"
#include
"MantidGeometry/Surfaces/Cylinder.h"
#include
"MantidGeometry/Surfaces/Sphere.h"
...
...
@@ -20,9 +19,10 @@
#include
"MantidGeometry/Surfaces/SurfaceFactory.h"
#include
"MantidGeometry/Objects/Track.h"
#include
"MantidGeometry/Rendering/GluGeometryHandler.h"
#include
"MantidGeometry/Objects/BoundingBox.h"
#include
"MantidGeometry/Objects/ShapeFactory.h"
#include
"MantidKernel/Material.h"
#include
"MantidTestHelpers/ComponentCreationHelper.h"
using
namespace
Mantid
;
...
...
@@ -34,6 +34,25 @@ class ObjectTest: public CxxTest::TestSuite
public:
void
testDefaultObjectHasEmptyMaterial
()
{
Object
obj
;
TSM_ASSERT_DELTA
(
"Expected a zero number density"
,
0.0
,
obj
.
material
().
numberDensity
(),
1e-12
);
}
void
testObjectSetMaterialReplacesExisting
()
{
using
Mantid
::
Kernel
::
Material
;
Object
obj
;
TSM_ASSERT_DELTA
(
"Expected a zero number density"
,
0.0
,
obj
.
material
().
numberDensity
(),
1e-12
);
obj
.
setMaterial
(
Material
(
"arm"
,
PhysicalConstants
::
getNeutronAtom
(
13
),
45.0
));
TSM_ASSERT_DELTA
(
"Expected a number density of 45"
,
45.0
,
obj
.
material
().
numberDensity
(),
1e-12
);
}
void
testCopyConstructorGivesObjectWithSameAttributes
()
{
Object_sptr
original
=
ComponentCreationHelper
::
createSphere
(
1.0
,
V3D
(),
"sphere"
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment