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
24c86b59
Commit
24c86b59
authored
May 09, 2016
by
Martyn Gigg
Browse files
Add an id attribute to an Object
Refs #16044
parent
5914bfee
Changes
3
Hide whitespace changes
Inline
Side-by-side
Framework/Geometry/inc/MantidGeometry/Objects/Object.h
View file @
24c86b59
...
...
@@ -74,9 +74,11 @@ public:
/// Return the top rule
const
Rule
*
topRule
()
const
{
return
TopRule
.
get
();
}
void
setID
(
const
std
::
string
&
id
)
{
m_id
=
id
;
}
inline
const
std
::
string
&
id
()
const
{
return
m_id
;
}
void
setName
(
const
int
nx
)
{
ObjN
ame
=
nx
;
}
///< Set Name
int
getName
()
const
{
return
ObjN
ame
;
}
///< Get Name
void
setName
(
const
int
nx
)
{
ObjN
um
=
nx
;
}
///< Set Name
int
getName
()
const
{
return
ObjN
um
;
}
///< Get Name
void
setMaterial
(
const
Kernel
::
Material
&
material
);
const
Kernel
::
Material
&
material
()
const
;
...
...
@@ -170,14 +172,10 @@ public:
std
::
string
getShapeXML
()
const
;
private:
int
ObjName
;
///< Creation number
std
::
unique_ptr
<
Rule
>
TopRule
;
///< Top rule [ Geometric scope of object]
int
procPair
(
std
::
string
&
Ln
,
std
::
map
<
int
,
std
::
unique_ptr
<
Rule
>>
&
Rlist
,
int
&
compUnit
)
const
;
std
::
unique_ptr
<
CompGrp
>
procComp
(
std
::
unique_ptr
<
Rule
>
)
const
;
int
checkSurfaceValid
(
const
Kernel
::
V3D
&
,
const
Kernel
::
V3D
&
)
const
;
BoundingBox
m_boundingBox
;
///< Object's bounding box
/// Calculate bounding box using Rule system
void
calcBoundingBoxByRule
();
...
...
@@ -188,17 +186,6 @@ private:
/// Calculate bounding box using object's geometric data
void
calcBoundingBoxByGeometry
();
// -- 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
(
Kernel
::
V3D
&
)
const
;
double
getTriangleSolidAngle
(
const
Kernel
::
V3D
&
a
,
const
Kernel
::
V3D
&
b
,
const
Kernel
::
V3D
&
c
,
...
...
@@ -217,6 +204,21 @@ private:
const
Mantid
::
Kernel
::
V3D
&
axis
,
const
double
radius
,
const
double
height
)
const
;
/// Top rule [ Geometric scope of object]
std
::
unique_ptr
<
Rule
>
TopRule
;
/// Object's bounding box
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
/// Creation number
int
ObjNum
;
/// Geometry Handle for rendering
boost
::
shared_ptr
<
GeometryHandler
>
handle
;
friend
class
CacheGeometryHandler
;
...
...
@@ -234,6 +236,8 @@ private:
double
*
getTriangleVertices
()
const
;
/// original shape xml used to generate this object.
std
::
string
m_shapeXML
;
/// Optional string identifier
std
::
string
m_id
;
/// material composition
Kernel
::
Material
m_material
;
...
...
Framework/Geometry/src/Objects/Object.cpp
View file @
24c86b59
...
...
@@ -34,28 +34,19 @@ using Kernel::Quat;
/**
* Default constuctor
*/
Object
::
Object
()
:
ObjName
(
0
),
TopRule
(),
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_material
()
// empty by default
{
handle
=
boost
::
make_shared
<
CacheGeometryHandler
>
(
this
);
}
Object
::
Object
()
:
Object
(
""
)
{}
/**
* Construct with original shape xml knowledge.
* @param shapeXML : string with original shape xml.
*/
Object
::
Object
(
const
std
::
string
&
shapeXML
)
:
ObjName
(
0
),
TopRule
(),
m_boundingBox
(),
AABBxMax
(
0
),
AABByMax
(
0
),
AABBzMax
(
0
),
AABBxMin
(
0
),
AABByMin
(
0
),
AABBzMin
(
0
),
boolBounded
(
false
),
:
TopRule
(),
m_boundingBox
(),
AABBxMax
(
0
),
AABByMax
(
0
),
AABBzMax
(
0
),
AABBxMin
(
0
),
AABByMin
(
0
),
AABBzMin
(
0
),
boolBounded
(
false
),
ObjNum
(
0
),
handle
(),
bGeometryCaching
(
false
),
vtkCacheReader
(
boost
::
shared_ptr
<
vtkGeometryCacheReader
>
()),
vtkCacheWriter
(
boost
::
shared_ptr
<
vtkGeometryCacheWriter
>
()),
m_shapeXML
(
shapeXML
),
m_material
()
// empty by default
m_shapeXML
(
shapeXML
),
m_id
(),
m_material
()
// empty by default
{
handle
=
boost
::
make_shared
<
CacheGeometryHandler
>
(
this
);
}
...
...
@@ -64,17 +55,7 @@ Object::Object(const std::string &shapeXML)
* Copy constructor
* @param A :: The object to initialise this copy from
*/
Object
::
Object
(
const
Object
&
A
)
:
ObjName
(
A
.
ObjName
),
TopRule
((
A
.
TopRule
)
?
A
.
TopRule
->
clone
()
:
nullptr
),
m_boundingBox
(
A
.
m_boundingBox
),
AABBxMax
(
A
.
AABBxMax
),
AABByMax
(
A
.
AABByMax
),
AABBzMax
(
A
.
AABBzMax
),
AABBxMin
(
A
.
AABBxMin
),
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_material
(
A
.
m_material
)
{
if
(
TopRule
)
createSurfaceList
();
}
Object
::
Object
(
const
Object
&
A
)
:
Object
()
{
*
this
=
A
;
}
/**
* Assignment operator
...
...
@@ -83,7 +64,6 @@ Object::Object(const Object &A)
*/
Object
&
Object
::
operator
=
(
const
Object
&
A
)
{
if
(
this
!=
&
A
)
{
ObjName
=
A
.
ObjName
;
TopRule
=
(
A
.
TopRule
)
?
A
.
TopRule
->
clone
()
:
nullptr
;
AABBxMax
=
A
.
AABBxMax
;
AABByMax
=
A
.
AABByMax
;
...
...
@@ -92,11 +72,13 @@ Object &Object::operator=(const Object &A) {
AABByMin
=
A
.
AABByMin
;
AABBzMin
=
A
.
AABBzMin
;
boolBounded
=
A
.
boolBounded
;
ObjNum
=
A
.
ObjNum
;
handle
=
A
.
handle
->
clone
();
bGeometryCaching
=
A
.
bGeometryCaching
;
vtkCacheReader
=
A
.
vtkCacheReader
;
vtkCacheWriter
=
A
.
vtkCacheWriter
;
m_shapeXML
=
A
.
m_shapeXML
;
m_id
=
A
.
m_id
;
m_material
=
A
.
m_material
;
if
(
TopRule
)
...
...
@@ -145,7 +127,7 @@ int Object::setObject(const int ON, const std::string &Ln) {
if
(
procString
(
Ln
))
// this currently does not fail:
{
SurList
.
clear
();
ObjN
ame
=
ON
;
ObjN
um
=
ON
;
return
1
;
}
...
...
@@ -235,7 +217,7 @@ int Object::complementaryObject(const int Cnum, std::string &Ln) {
std
::
string
Part
=
Ln
.
substr
(
posA
,
posB
-
(
posA
+
1
));
ObjN
ame
=
Cnum
;
ObjN
um
=
Cnum
;
if
(
procString
(
Part
))
{
SurList
.
clear
();
Ln
.
erase
(
posA
-
1
,
posB
+
1
);
// Delete brackets ( Part ) .
...
...
@@ -602,7 +584,7 @@ void Object::print() const {
}
}
std
::
cout
<<
"Name == "
<<
ObjN
ame
<<
std
::
endl
;
std
::
cout
<<
"Name == "
<<
ObjN
um
<<
std
::
endl
;
std
::
cout
<<
"Rules == "
<<
Rcount
<<
std
::
endl
;
std
::
vector
<
int
>::
const_iterator
mc
;
std
::
cout
<<
"Surface included == "
;
...
...
@@ -626,7 +608,7 @@ void Object::makeComplement() {
* Displays the rule tree
*/
void
Object
::
printTree
()
const
{
std
::
cout
<<
"Name == "
<<
ObjN
ame
<<
std
::
endl
;
std
::
cout
<<
"Name == "
<<
ObjN
um
<<
std
::
endl
;
std
::
cout
<<
TopRule
->
display
()
<<
std
::
endl
;
return
;
}
...
...
@@ -651,7 +633,7 @@ std::string Object::cellCompStr() const {
std
::
string
Object
::
str
()
const
{
std
::
ostringstream
cx
;
if
(
TopRule
)
{
cx
<<
ObjN
ame
<<
" "
;
cx
<<
ObjN
um
<<
" "
;
cx
<<
TopRule
->
display
();
}
return
cx
.
str
();
...
...
Framework/Geometry/test/ObjectTest.h
View file @
24c86b59
...
...
@@ -55,6 +55,7 @@ public:
void
testCopyConstructorGivesObjectWithSameAttributes
()
{
Object_sptr
original
=
ComponentCreationHelper
::
createSphere
(
1.0
,
V3D
(),
"sphere"
);
original
->
setID
(
"sp-1"
);
int
objType
(
-
1
);
double
radius
(
-
1.0
),
height
(
-
1.0
);
std
::
vector
<
V3D
>
pts
;
...
...
@@ -68,6 +69,7 @@ public:
objType
=
-
1
;
copy
.
GetObjectGeom
(
objType
,
pts
,
radius
,
height
);
TS_ASSERT_EQUALS
(
"sp-1"
,
copy
.
id
());
TS_ASSERT_EQUALS
(
2
,
objType
);
TS_ASSERT
(
boost
::
dynamic_pointer_cast
<
GluGeometryHandler
>
(
copy
.
getGeometryHandler
()));
...
...
@@ -80,6 +82,7 @@ public:
void
testAssignmentOperatorGivesObjectWithSameAttributes
()
{
Object_sptr
original
=
ComponentCreationHelper
::
createSphere
(
1.0
,
V3D
(),
"sphere"
);
original
->
setID
(
"sp-1"
);
int
objType
(
-
1
);
double
radius
(
-
1.0
),
height
(
-
1.0
);
std
::
vector
<
V3D
>
pts
;
...
...
@@ -94,6 +97,7 @@ public:
objType
=
-
1
;
lhs
.
GetObjectGeom
(
objType
,
pts
,
radius
,
height
);
TS_ASSERT_EQUALS
(
"sp-1"
,
lhs
.
id
());
TS_ASSERT_EQUALS
(
2
,
objType
);
TS_ASSERT
(
boost
::
dynamic_pointer_cast
<
GluGeometryHandler
>
(
lhs
.
getGeometryHandler
()));
...
...
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