Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Xdmf
Xdmf
Commits
b94acdde
Commit
b94acdde
authored
May 24, 2010
by
Kenneth Leiter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ENH: Add ability to read XML files from disk into Xdmf structures in memory.
parent
5e8d6200
Changes
37
Hide whitespace changes
Inline
Side-by-side
Showing
37 changed files
with
863 additions
and
74 deletions
+863
-74
CMakeLists.txt
CMakeLists.txt
+1
-0
Xdmf.i
Xdmf.i
+6
-3
XdmfArray.cpp
XdmfArray.cpp
+131
-3
XdmfArray.hpp
XdmfArray.hpp
+20
-6
XdmfArray.tpp
XdmfArray.tpp
+43
-17
XdmfAttribute.cpp
XdmfAttribute.cpp
+20
-1
XdmfAttribute.hpp
XdmfAttribute.hpp
+2
-0
XdmfAttributeCenter.cpp
XdmfAttributeCenter.cpp
+37
-2
XdmfAttributeCenter.hpp
XdmfAttributeCenter.hpp
+4
-0
XdmfAttributeType.cpp
XdmfAttributeType.cpp
+45
-2
XdmfAttributeType.hpp
XdmfAttributeType.hpp
+4
-0
XdmfDataItem.cpp
XdmfDataItem.cpp
+11
-0
XdmfDataItem.hpp
XdmfDataItem.hpp
+1
-0
XdmfDomain.cpp
XdmfDomain.cpp
+11
-1
XdmfDomain.hpp
XdmfDomain.hpp
+2
-0
XdmfGeometry.cpp
XdmfGeometry.cpp
+9
-1
XdmfGeometry.hpp
XdmfGeometry.hpp
+2
-0
XdmfGeometryType.cpp
XdmfGeometryType.cpp
+60
-1
XdmfGeometryType.hpp
XdmfGeometryType.hpp
+4
-0
XdmfGrid.cpp
XdmfGrid.cpp
+31
-1
XdmfGrid.hpp
XdmfGrid.hpp
+2
-0
XdmfHDF5Controller.cpp
XdmfHDF5Controller.cpp
+19
-5
XdmfHDF5Controller.hpp
XdmfHDF5Controller.hpp
+3
-7
XdmfHDF5Writer.cpp
XdmfHDF5Writer.cpp
+7
-4
XdmfItem.hpp
XdmfItem.hpp
+13
-1
XdmfObject.hpp
XdmfObject.hpp
+1
-0
XdmfReader.cpp
XdmfReader.cpp
+123
-0
XdmfReader.hpp
XdmfReader.hpp
+42
-0
XdmfTopology.cpp
XdmfTopology.cpp
+9
-1
XdmfTopology.hpp
XdmfTopology.hpp
+3
-0
XdmfTopologyType.cpp
XdmfTopologyType.cpp
+118
-2
XdmfTopologyType.hpp
XdmfTopologyType.hpp
+4
-0
XdmfWriter.cpp
XdmfWriter.cpp
+29
-14
XdmfWriter.hpp
XdmfWriter.hpp
+4
-0
loki/Visitor.h
loki/Visitor.h
+0
-2
tests/Cxx/CMakeLists.txt
tests/Cxx/CMakeLists.txt
+1
-0
tests/Cxx/TestXdmfReader.cpp
tests/Cxx/TestXdmfReader.cpp
+41
-0
No files found.
CMakeLists.txt
View file @
b94acdde
...
...
@@ -47,6 +47,7 @@ set(XdmfSources
XdmfItem
XdmfItemProperty
XdmfObject
XdmfReader
XdmfTopology
XdmfTopologyType
XdmfVisitor
...
...
Xdmf.i
View file @
b94acdde
...
...
@@ -14,11 +14,12 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
#
include
<
XdmfGeometry
.
hpp
>
#
include
<
XdmfGeometryType
.
hpp
>
#
include
<
XdmfGrid
.
hpp
>
#
include
<
XdmfHDF5Controller
.
hpp
>
#
include
<
XdmfHDF5Controller
.
hpp
>
#
include
<
XdmfHDF5Writer
.
hpp
>
#
include
<
XdmfItem
.
hpp
>
#
include
<
XdmfItemProperty
.
hpp
>
#
include
<
XdmfObject
.
hpp
>
#
include
<
XdmfReader
.
hpp
>
#
include
<
XdmfTopology
.
hpp
>
#
include
<
XdmfTopologyType
.
hpp
>
#
include
<
XdmfVisitor
.
hpp
>
...
...
@@ -58,6 +59,7 @@ namespace boost {
%
template
(
XdmfHDF5WriterPtr
)
boost
::
shared_ptr
<
XdmfHDF5Writer
>
;
%
template
(
XdmfItemPtr
)
boost
::
shared_ptr
<
XdmfItem
>
;
%
template
(
XdmfObjPtr
)
boost
::
shared_ptr
<
XdmfObject
>
;
%
template
(
XdmfReaderPtr
)
boost
::
shared_ptr
<
XdmfReader
>
;
%
template
(
XdmfTopologyPtr
)
boost
::
shared_ptr
<
XdmfTopology
>
;
%
template
(
XdmfVisitorPtr
)
boost
::
shared_ptr
<
XdmfVisitor
>
;
%
template
(
XdmfWriterPtr
)
boost
::
shared_ptr
<
XdmfWriter
>
;
...
...
@@ -91,6 +93,7 @@ SWIG_SHARED_PTR_DERIVED(XdmfHDF5Writer, XdmfVisitor);
SWIG_SHARED_PTR_DERIVED
(
XdmfHDF5Writer
,
Loki
::
BaseVisitor
)
;
SWIG_SHARED_PTR_DERIVED
(
XdmfHDF5Writer
,
XdmfObject
)
;
SWIG_SHARED_PTR_DERIVED
(
XdmfItem
,
XdmfObject
)
;
SWIG_SHARED_PTR_DERIVED
(
XdmfReader
,
XdmfObject
)
;
SWIG_SHARED_PTR_DERIVED
(
XdmfTopology
,
XdmfDataItem
)
;
SWIG_SHARED_PTR_DERIVED
(
XdmfTopology
,
XdmfItem
)
;
SWIG_SHARED_PTR_DERIVED
(
XdmfTopology
,
XdmfObject
)
;
...
...
@@ -103,15 +106,15 @@ SWIG_SHARED_PTR_DERIVED(XdmfWriter, XdmfObject);
%
include
XdmfObject
.
hpp
%
include
XdmfItem
.
hpp
%
include
XdmfDataItem
.
hpp
%
include
XdmfItemProperty
.
hpp
%
include
XdmfVisitor
.
hpp
%
include
XdmfHDF5Controller
.
hpp
%
include
XdmfHDF5Writer
.
hpp
%
include
XdmfReader
.
hpp
%
include
XdmfWriter
.
hpp
%
include
XdmfDataItem
.
hpp
%
include
XdmfAttribute
.
hpp
%
include
XdmfAttributeCenter
.
hpp
%
include
XdmfAttributeType
.
hpp
...
...
XdmfArray.cpp
View file @
b94acdde
...
...
@@ -5,10 +5,12 @@
* Author: kleiter
*/
#include <boost/foreach.hpp>
#include <boost/tokenizer.hpp>
#include <sstream>
#include "XdmfArray.hpp"
#include "XdmfHDF5Controller.hpp"
#include "XdmfVisitor.hpp"
#include <sstream>
class
XdmfArray
::
Clear
:
public
boost
::
static_visitor
<
void
>
{
public:
...
...
@@ -363,6 +365,8 @@ XdmfArray::~XdmfArray()
std
::
cout
<<
"Deleted Array "
<<
this
<<
std
::
endl
;
}
std
::
string
XdmfArray
::
ItemTag
=
"DataItem"
;
void
XdmfArray
::
copyValues
(
const
unsigned
int
startIndex
,
const
boost
::
shared_ptr
<
const
XdmfArray
>
values
,
const
unsigned
int
valuesStartIndex
,
const
unsigned
int
numValues
,
const
unsigned
int
arrayStride
,
const
unsigned
int
valuesStride
)
{
if
(
mHaveArrayPointer
)
...
...
@@ -410,7 +414,14 @@ boost::shared_ptr<const XdmfHDF5Controller> XdmfArray::getHDF5Controller() const
std
::
map
<
std
::
string
,
std
::
string
>
XdmfArray
::
getItemProperties
()
const
{
std
::
map
<
std
::
string
,
std
::
string
>
arrayProperties
;
arrayProperties
[
"Format"
]
=
"HDF"
;
if
(
mHDF5Controller
)
{
arrayProperties
[
"Format"
]
=
"HDF"
;
}
else
{
arrayProperties
[
"Format"
]
=
"XML"
;
}
arrayProperties
[
"DataType"
]
=
this
->
getType
();
std
::
stringstream
precision
;
precision
<<
this
->
getPrecision
();
...
...
@@ -423,7 +434,7 @@ std::map<std::string, std::string> XdmfArray::getItemProperties() const
std
::
string
XdmfArray
::
getItemTag
()
const
{
return
"Data
Item
"
;
return
Item
Tag
;
}
unsigned
int
XdmfArray
::
getPrecision
()
const
...
...
@@ -503,6 +514,50 @@ std::string XdmfArray::getValuesString() const
return
""
;
}
void
XdmfArray
::
initialize
(
const
std
::
string
&
type
,
const
unsigned
int
precision
)
{
if
(
type
.
compare
(
"Char"
)
==
0
&&
precision
==
1
)
{
this
->
initialize
<
char
>
();
}
else
if
(
type
.
compare
(
"Short"
)
==
0
&&
precision
==
2
)
{
this
->
initialize
<
short
>
();
}
else
if
(
type
.
compare
(
"Int"
)
==
0
&&
precision
==
4
)
{
this
->
initialize
<
int
>
();
}
else
if
(
type
.
compare
(
"Long"
)
==
0
&&
precision
==
8
)
{
this
->
initialize
<
long
>
();
}
else
if
(
type
.
compare
(
"Float"
)
==
0
&&
precision
==
4
)
{
this
->
initialize
<
float
>
();
}
else
if
(
type
.
compare
(
"Double"
)
==
0
&&
precision
==
8
)
{
this
->
initialize
<
double
>
();
}
else
if
(
type
.
compare
(
"UChar"
)
==
0
&&
precision
==
8
)
{
this
->
initialize
<
unsigned
char
>
();
}
else
if
(
type
.
compare
(
"UShort"
)
==
0
&&
precision
==
8
)
{
this
->
initialize
<
unsigned
short
>
();
}
else
if
(
type
.
compare
(
"UInt"
)
==
0
&&
precision
==
8
)
{
this
->
initialize
<
unsigned
int
>
();
}
else
{
assert
(
false
);
}
}
void
XdmfArray
::
internalizeArrayPointer
()
{
if
(
mHaveArrayPointer
)
...
...
@@ -511,6 +566,79 @@ void XdmfArray::internalizeArrayPointer()
}
}
void
XdmfArray
::
populateItem
(
const
std
::
map
<
std
::
string
,
std
::
string
>
&
itemProperties
,
std
::
vector
<
boost
::
shared_ptr
<
XdmfItem
>
>
&
childItems
)
{
std
::
string
contentVal
;
int
precisionVal
;
int
sizeVal
;
std
::
string
typeVal
;
std
::
map
<
std
::
string
,
std
::
string
>::
const_iterator
content
=
itemProperties
.
find
(
"Content"
);
if
(
content
!=
itemProperties
.
end
())
{
contentVal
=
content
->
second
;
}
else
{
assert
(
false
);
}
std
::
map
<
std
::
string
,
std
::
string
>::
const_iterator
precision
=
itemProperties
.
find
(
"Precision"
);
if
(
precision
!=
itemProperties
.
end
())
{
precisionVal
=
atoi
(
precision
->
second
.
c_str
());
}
else
{
assert
(
false
);
}
std
::
map
<
std
::
string
,
std
::
string
>::
const_iterator
size
=
itemProperties
.
find
(
"Dimensions"
);
if
(
size
!=
itemProperties
.
end
())
{
sizeVal
=
atoi
(
size
->
second
.
c_str
());
}
else
{
assert
(
false
);
}
std
::
map
<
std
::
string
,
std
::
string
>::
const_iterator
type
=
itemProperties
.
find
(
"DataType"
);
if
(
type
!=
itemProperties
.
end
())
{
typeVal
=
type
->
second
;
}
else
{
assert
(
false
);
}
std
::
map
<
std
::
string
,
std
::
string
>::
const_iterator
format
=
itemProperties
.
find
(
"Format"
);
if
(
format
!=
itemProperties
.
end
())
{
if
(
format
->
second
.
compare
(
"HDF"
)
==
0
)
{
mHDF5Controller
=
XdmfHDF5Controller
::
New
(
contentVal
,
precisionVal
,
sizeVal
,
typeVal
);
}
else
if
(
format
->
second
.
compare
(
"XML"
)
==
0
)
{
this
->
initialize
(
typeVal
,
precisionVal
);
this
->
reserve
(
sizeVal
);
boost
::
char_separator
<
char
>
sep
(
" "
);
boost
::
tokenizer
<
boost
::
char_separator
<
char
>
>
tokens
(
contentVal
,
sep
);
BOOST_FOREACH
(
std
::
string
t
,
tokens
)
{
double
val
=
atof
(
t
.
c_str
());
this
->
pushBack
(
val
);
}
}
else
{
assert
(
false
);
}
}
else
{
assert
(
false
);
}
}
void
XdmfArray
::
read
()
{
if
(
mHDF5Controller
)
...
...
XdmfArray.hpp
View file @
b94acdde
...
...
@@ -51,6 +51,7 @@ public:
XdmfNewMacro
(
XdmfArray
);
LOKI_DEFINE_VISITABLE
(
XdmfArray
,
XdmfItem
)
friend
class
XdmfHDF5Writer
;
static
std
::
string
ItemTag
;
/**
* Copy values from an XdmfArray into this array.
...
...
@@ -178,13 +179,19 @@ public:
template
<
typename
T
>
boost
::
shared_ptr
<
std
::
vector
<
T
>
>
initialize
();
/**
* Copy a value to the back of this array
*/
template
<
typename
T
>
void
pushBack
(
T
&
value
);
/**
* Read data from disk into memory.
*/
void
read
();
/**
* Release all data
held by this XdmfArra
y.
* Release all data
from currently held in memor
y.
*/
void
release
();
...
...
@@ -200,10 +207,10 @@ public:
* to val. If numValues is less than the current size, values at indices larger than numValues are removed.
*
* @param numValues the number of values to resize this array to.
* @param val the number to initialize newly created values to, if needed.
* @param val
ue
the number to initialize newly created values to, if needed.
*/
template
<
typename
T
>
void
resize
(
const
unsigned
int
numValues
,
const
T
&
val
=
0
);
void
resize
(
const
unsigned
int
numValues
,
const
T
&
val
ue
=
0
);
/**
* Attach an hdf5 controller to this XdmfArray.
...
...
@@ -277,6 +284,7 @@ protected:
XdmfArray
();
virtual
~
XdmfArray
();
virtual
void
populateItem
(
const
std
::
map
<
std
::
string
,
std
::
string
>
&
itemProperties
,
std
::
vector
<
boost
::
shared_ptr
<
XdmfItem
>
>
&
childItems
);
private:
...
...
@@ -287,7 +295,7 @@ private:
class
Clear
;
class
CopyArrayValues
;
template
<
typename
T
>
template
<
typename
T
>
class
CopyValues
;
class
GetCapacity
;
...
...
@@ -296,20 +304,26 @@ private:
class
GetSize
;
class
GetType
;
template
<
typename
T
>
template
<
typename
T
>
class
GetValuesCopy
;
class
GetValuesPointer
;
class
GetValuesString
;
class
InternalizeArrayPointer
;
class
NewArray
;
template
<
typename
T
>
class
PushBack
;
class
Reserve
;
template
<
typename
T
>
template
<
typename
T
>
class
Resize
;
struct
NullDeleter
;
void
initialize
(
const
std
::
string
&
type
,
const
unsigned
int
precision
);
/**
* After setValues(const T * const array) is called, XdmfArray stores a pointer that is not allowed to be modified through
* the XdmfArray API. If the user desires to modify the contents of the pointer, they must do so without calling any
...
...
XdmfArray.tpp
View file @
b94acdde
// Includes
#include "XdmfArray.hpp"
template
<
typename
T
>
template
<
typename
T
>
class
XdmfArray
::
CopyValues
:
public
boost
::
static_visitor
<
void
>
{
public:
...
...
@@ -41,7 +41,7 @@ private:
const
unsigned
int
mValuesStride
;
};
template
<
typename
T
>
template
<
typename
T
>
class
XdmfArray
::
GetValuesCopy
:
public
boost
::
static_visitor
<
void
>
{
public:
...
...
@@ -81,7 +81,27 @@ private:
const
unsigned
int
mValuesStride
;
};
template
<
typename
T
>
template
<
typename
T
>
class
XdmfArray
::
PushBack
:
public
boost
::
static_visitor
<
void
>
{
public:
PushBack
(
const
T
&
val
)
:
mVal
(
val
)
{
}
template
<
typename
U
>
void
operator
()(
boost
::
shared_ptr
<
std
::
vector
<
U
>
>
&
array
)
const
{
array
->
push_back
((
U
)
mVal
);
}
private:
const
T
&
mVal
;
};
template
<
typename
T
>
class
XdmfArray
::
Resize
:
public
boost
::
static_visitor
<
void
>
{
public:
...
...
@@ -110,7 +130,7 @@ struct XdmfArray::NullDeleter
}
};
template
<
typename
T
>
template
<
typename
T
>
void
XdmfArray
::
copyValues
(
const
unsigned
int
startIndex
,
const
T
*
const
valuesPointer
,
const
unsigned
int
numValues
,
const
unsigned
int
arrayStride
,
const
unsigned
int
valuesStride
)
{
if
(
mHaveArrayPointer
)
...
...
@@ -121,7 +141,7 @@ void XdmfArray::copyValues(const unsigned int startIndex, const T * const values
{
initialize
<
T
>
();
}
boost
::
apply_visitor
(
CopyValues
<
T
>
(
startIndex
,
valuesPointer
,
numValues
,
arrayStride
,
valuesStride
),
mArray
);
boost
::
apply_visitor
(
CopyValues
<
T
>
(
startIndex
,
valuesPointer
,
numValues
,
arrayStride
,
valuesStride
),
mArray
);
}
template
<
typename
T
>
...
...
@@ -167,11 +187,7 @@ void XdmfArray::getValuesCopy(const unsigned int startIndex, T * valuesPointer,
{
boost
::
apply_visitor
(
GetValuesCopy
<
T
>
(
startIndex
,
valuesPointer
,
numValues
,
arrayStride
,
valuesStride
),
mArrayPointer
);
}
else
if
(
mHDF5Controller
)
{
assert
(
"Need to complete"
);
}
assert
(
"Throw Exception No Data"
);
assert
(
false
);
}
template
<
typename
T
>
...
...
@@ -193,8 +209,18 @@ boost::shared_ptr<std::vector<T> > XdmfArray::initialize()
return
newArray
;
}
template
<
typename
T
>
void
XdmfArray
::
pushBack
(
T
&
value
)
{
if
(
mHaveArrayPointer
)
{
internalizeArrayPointer
();
}
return
boost
::
apply_visitor
(
PushBack
<
T
>
(
value
),
mArray
);
}
template
<
typename
T
>
void
XdmfArray
::
resize
(
const
unsigned
int
numValues
,
const
T
&
val
)
void
XdmfArray
::
resize
(
const
unsigned
int
numValues
,
const
T
&
val
ue
)
{
if
(
mHaveArrayPointer
)
{
...
...
@@ -204,10 +230,10 @@ void XdmfArray::resize(const unsigned int numValues, const T & val)
{
initialize
<
T
>
();
}
return
boost
::
apply_visitor
(
Resize
<
T
>
(
numValues
,
val
),
mArray
);
return
boost
::
apply_visitor
(
Resize
<
T
>
(
numValues
,
val
ue
),
mArray
);
}
template
<
typename
T
>
template
<
typename
T
>
void
XdmfArray
::
setValues
(
const
T
*
const
arrayPointer
,
const
unsigned
int
numValues
,
const
bool
transferOwnership
)
{
// Remove contents of internal array.
...
...
@@ -229,7 +255,7 @@ void XdmfArray::setValues(const T * const arrayPointer, const unsigned int numVa
mArrayPointerNumValues
=
numValues
;
}
template
<
typename
T
>
template
<
typename
T
>
void
XdmfArray
::
setValues
(
std
::
vector
<
T
>
&
array
,
const
bool
transferOwnership
)
{
if
(
mHaveArrayPointer
)
...
...
@@ -249,7 +275,7 @@ void XdmfArray::setValues(std::vector<T> & array, const bool transferOwnership)
mHaveArray
=
true
;
}
template
<
typename
T
>
template
<
typename
T
>
void
XdmfArray
::
setValues
(
boost
::
shared_ptr
<
std
::
vector
<
T
>
>
array
)
{
if
(
mHaveArrayPointer
)
...
...
@@ -260,7 +286,7 @@ void XdmfArray::setValues(boost::shared_ptr<std::vector<T> > array)
mHaveArray
=
true
;
}
template
<
typename
T
>
template
<
typename
T
>
bool
XdmfArray
::
swap
(
std
::
vector
<
T
>
&
array
)
{
if
(
mHaveArrayPointer
)
...
...
@@ -283,7 +309,7 @@ bool XdmfArray::swap(std::vector<T> & array)
}
}
template
<
typename
T
>
template
<
typename
T
>
bool
XdmfArray
::
swap
(
boost
::
shared_ptr
<
std
::
vector
<
T
>
>
array
)
{
return
this
->
swap
(
*
array
.
get
());
...
...
XdmfAttribute.cpp
View file @
b94acdde
...
...
@@ -20,6 +20,8 @@ XdmfAttribute::~XdmfAttribute()
std
::
cout
<<
"Deleted Attribute "
<<
this
<<
std
::
endl
;
}
std
::
string
XdmfAttribute
::
ItemTag
=
"Attribute"
;
XdmfAttributeCenter
XdmfAttribute
::
getAttributeCenter
()
const
{
return
mAttributeCenter
;
...
...
@@ -41,7 +43,7 @@ std::map<std::string, std::string> XdmfAttribute::getItemProperties() const
std
::
string
XdmfAttribute
::
getItemTag
()
const
{
return
"Attribute"
;
return
ItemTag
;
}
std
::
string
XdmfAttribute
::
getName
()
const
...
...
@@ -49,6 +51,23 @@ std::string XdmfAttribute::getName() const
return
mName
;
}
void
XdmfAttribute
::
populateItem
(
const
std
::
map
<
std
::
string
,
std
::
string
>
&
itemProperties
,
std
::
vector
<
boost
::
shared_ptr
<
XdmfItem
>
>
&
childItems
)
{
std
::
map
<
std
::
string
,
std
::
string
>::
const_iterator
name
=
itemProperties
.
find
(
"Name"
);
if
(
name
!=
itemProperties
.
end
())
{
mName
=
name
->
second
;
}
else
{
assert
(
false
);
}
mAttributeCenter
=
XdmfAttributeCenter
::
New
(
itemProperties
);
mAttributeType
=
XdmfAttributeType
::
New
(
itemProperties
);
XdmfDataItem
::
populateItem
(
itemProperties
,
childItems
);
}
void
XdmfAttribute
::
setAttributeCenter
(
const
XdmfAttributeCenter
&
attributeCenter
)
{
mAttributeCenter
=
attributeCenter
;
...
...
XdmfAttribute.hpp
View file @
b94acdde
...
...
@@ -18,6 +18,7 @@ public:
XdmfNewMacro
(
XdmfAttribute
);
LOKI_DEFINE_VISITABLE
(
XdmfAttribute
,
XdmfDataItem
)
static
std
::
string
ItemTag
;
/**
* Get the XdmfAttributeCenter associated with this attribute.
...
...
@@ -69,6 +70,7 @@ protected:
XdmfAttribute
();
virtual
~
XdmfAttribute
();
virtual
void
populateItem
(
const
std
::
map
<
std
::
string
,
std
::
string
>
&
itemProperties
,
std
::
vector
<
boost
::
shared_ptr
<
XdmfItem
>
>
&
childItems
);
private:
...
...
XdmfAttributeCenter.cpp
View file @
b94acdde
...
...
@@ -35,13 +35,48 @@ XdmfAttributeCenter XdmfAttributeCenter::Node()
XdmfAttributeCenter
::
XdmfAttributeCenter
(
const
std
::
string
&
name
)
:
mName
(
name
)
{};
{
}
XdmfAttributeCenter
::
XdmfAttributeCenter
(
const
XdmfAttributeCenter
&
attributeCenter
)
:
mName
(
attributeCenter
.
mName
)
{
}
XdmfAttributeCenter
XdmfAttributeCenter
::
New
(
const
std
::
map
<
std
::
string
,
std
::
string
>
&
itemProperties
)
{
std
::
map
<
std
::
string
,
std
::
string
>::
const_iterator
center
=
itemProperties
.
find
(
"Center"
);
if
(
center
!=
itemProperties
.
end
())
{
const
std
::
string
centerVal
=
center
->
second
;
if
(
centerVal
.
compare
(
"Grid"
)
==
0
)
{
return
Grid
();
}
else
if
(
centerVal
.
compare
(
"Cell"
)
==
0
)
{
return
Cell
();
}
else
if
(
centerVal
.
compare
(
"Face"
)
==
0
)
{
return
Face
();
}
else
if
(
centerVal
.
compare
(
"Edge"
)
==
0
)
{
return
Edge
();
}
else
if
(
centerVal
.
compare
(
"Node"
)
==
0
)
{
return
Node
();
}
else
{
assert
(
false
);
}
}
assert
(
false
);
}
XdmfAttributeCenter
&
XdmfAttributeCenter
::
operator
=
(
const
XdmfAttributeCenter
&
attributeCenter
)
{
if
(
this
!=
&
attributeCenter
)
...
...
@@ -68,5 +103,5 @@ std::string XdmfAttributeCenter::getName() const
void
XdmfAttributeCenter
::
getProperties
(
std
::
map
<
std
::
string
,
std
::
string
>
&
collectedProperties
)
const
{
collectedProperties
[
"Center"
]
=
this
->
mName
;
collectedProperties
[
"Center"
]
=
mName
;
}
XdmfAttributeCenter.hpp
View file @
b94acdde
...
...
@@ -23,6 +23,8 @@ class XdmfAttributeCenter : public XdmfItemProperty {
public:
friend
class
XdmfAttribute
;
// Supported Xdmf Attribute Centers
static
XdmfAttributeCenter
Grid
();
static
XdmfAttributeCenter
Cell
();
...
...
@@ -71,6 +73,8 @@ protected:
private:
static
XdmfAttributeCenter
New
(
const
std
::
map
<
std
::
string
,
std
::
string
>
&
itemProperties
);
std
::
string
mName
;
};
...
...
XdmfAttributeType.cpp
View file @
b94acdde
...
...
@@ -45,13 +45,56 @@ XdmfAttributeType XdmfAttributeType::GlobalId()
XdmfAttributeType
::
XdmfAttributeType
(
const
std
::
string
&
name
)
:
mName
(
name
)
{};
{
}
XdmfAttributeType
::
XdmfAttributeType
(
const
XdmfAttributeType
&
attributeType
)
:
mName
(
attributeType
.
mName
)
{
}
XdmfAttributeType
XdmfAttributeType
::
New
(
const
std
::
map
<
std
::
string
,
std
::
string
>
&
itemProperties
)
{
std
::
map
<
std
::
string
,
std
::
string
>::
const_iterator
type
=
itemProperties
.
find
(
"AttributeType"
);
if
(
type
!=
itemProperties
.
end
())
{
const
std
::
string
typeVal
=
type
->
second
;
if
(
typeVal
.
compare
(
"None"
)
==
0
)
{
return
NoAttributeType
();
}
else
if
(
typeVal
.
compare
(
"Scalar"
)
==
0
)
{
return
Scalar
();
}
else
if
(
typeVal
.
compare
(
"Vector"
)
==
0
)
{
return
Vector
();
}