Commit 6632e999 authored by Kenneth Leiter's avatar Kenneth Leiter

ENH: Add XdmfGeometryType to XdmfGeometry in a similar implementation as...

ENH: Add XdmfGeometryType to XdmfGeometry in a similar implementation as XdmfTopologyType.  Add tests for XdmfGeometry.  Add XdmfItem, an abstract class that is able to be traversed by an XdmfVisitor to write out its information to XML and HDF5 or other heavy data formats.  Modify XdmfGeometry, XdmfGrid, XdmfTopology, and XdmfAttribute to inherit from XdmfItem.
parent ac19e9d4
...@@ -11,26 +11,33 @@ if(Boost_FOUND) ...@@ -11,26 +11,33 @@ if(Boost_FOUND)
message(${Boost_INCLUDE_DIRS}) message(${Boost_INCLUDE_DIRS})
endif(Boost_FOUND) endif(Boost_FOUND)
find_package(PythonLibs REQUIRED) option(XDMF_WRAP_PYTHON ON)
if(PYTHONLIBS_FOUND) if(XDMF_WRAP_PYTHON)
include_directories(${PYTHON_INCLUDE_DIRS}) find_package(PythonLibs REQUIRED)
endif(PYTHONLIBS_FOUND) if(PYTHONLIBS_FOUND)
include_directories(${PYTHON_INCLUDE_DIRS})
endif(PYTHONLIBS_FOUND)
endif(XDMF_WRAP_PYTHON)
set(XdmfSources set(XdmfSources
XdmfGeometry XdmfGeometry
XdmfGrid XdmfGrid
XdmfItem
XdmfObject XdmfObject
XdmfTopology XdmfTopology
XdmfVisitor
) )
add_library(Xdmf ${XdmfSources}) add_library(Xdmf ${XdmfSources})
add_library(_Xdmf MODULE XdmfPython) if(XDMF_WRAP_PYTHON)
set_target_properties(_Xdmf PROPERTIES PREFIX "") add_library(_Xdmf MODULE XdmfPython)
target_link_libraries(_Xdmf Xdmf) set_target_properties(_Xdmf PROPERTIES PREFIX "")
if(WIN32 OR APPLE) target_link_libraries(_Xdmf Xdmf)
target_link_libraries(_Xdmf ${PYTHON_LIBRARY}) if(WIN32 OR APPLE)
endif(WIN32 OR APPLE) target_link_libraries(_Xdmf ${PYTHON_LIBRARY})
endif(WIN32 OR APPLE)
endif(XDMF_WRAP_PYTHON)
configure_file(Xdmf.py Xdmf.py COPYONLY) configure_file(Xdmf.py Xdmf.py COPYONLY)
......
...@@ -7,28 +7,35 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i ...@@ -7,28 +7,35 @@ swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
%include std_vector.i %include std_vector.i
namespace boost { namespace boost {
template<class T> class shared_ptr template<class T> class shared_ptr
{ {
public: public:
T * operator-> () const; T * operator-> () const;
}; };
} }
%template(XdmfGeometryPtr) boost::shared_ptr<XdmfGeometry>; %template(XdmfGeometryPtr) boost::shared_ptr<XdmfGeometry>;
%template(XdmfGridPtr) boost::shared_ptr<XdmfGrid>; %template(XdmfGridPtr) boost::shared_ptr<XdmfGrid>;
%template(XdmfItemPtr) boost::shared_ptr<XdmfItem>;
%template(XdmfObjPtr) boost::shared_ptr<XdmfObject>; %template(XdmfObjPtr) boost::shared_ptr<XdmfObject>;
%template(XdmfTopologyPtr) boost::shared_ptr<XdmfTopology>; %template(XdmfTopologyPtr) boost::shared_ptr<XdmfTopology>;
%template(XdmfVisitorPtr) boost::shared_ptr<XdmfVisitor>;
%module Xdmf %module Xdmf
%{ %{
#include <XdmfGeometry.hpp> #include <XdmfGeometry.hpp>
#include <XdmfGrid.hpp> #include <XdmfGrid.hpp>
#include <XdmfObject.hpp> #include <XdmfItem.hpp>
#include <XdmfTopology.hpp> #include <XdmfObject.hpp>
#include <XdmfTopology.hpp>
#include <XdmfVisitor.hpp>
%} %}
%include XdmfObject.hpp %include XdmfObject.hpp
%include XdmfItem.hpp
%include XdmfVisitor.hpp
%include XdmfGeometry.hpp %include XdmfGeometry.hpp
%include XdmfGrid.hpp %include XdmfGrid.hpp
%include XdmfTopology.hpp %include XdmfTopology.hpp
...@@ -109,6 +109,10 @@ class XdmfGeometryPtr(_object): ...@@ -109,6 +109,10 @@ class XdmfGeometryPtr(_object):
__swig_destroy__ = _Xdmf.delete_XdmfGeometryPtr __swig_destroy__ = _Xdmf.delete_XdmfGeometryPtr
__del__ = lambda self : None; __del__ = lambda self : None;
def New(self): return _Xdmf.XdmfGeometryPtr_New(self) def New(self): return _Xdmf.XdmfGeometryPtr_New(self)
def getGeometryType(self): return _Xdmf.XdmfGeometryPtr_getGeometryType(self)
def setGeometryType(self, *args): return _Xdmf.XdmfGeometryPtr_setGeometryType(self, *args)
def getGeometryTypeAsString(self): return _Xdmf.XdmfGeometryPtr_getGeometryTypeAsString(self)
def getDimensions(self): return _Xdmf.XdmfGeometryPtr_getDimensions(self)
def printSelf(self): return _Xdmf.XdmfGeometryPtr_printSelf(self) def printSelf(self): return _Xdmf.XdmfGeometryPtr_printSelf(self)
XdmfGeometryPtr_swigregister = _Xdmf.XdmfGeometryPtr_swigregister XdmfGeometryPtr_swigregister = _Xdmf.XdmfGeometryPtr_swigregister
XdmfGeometryPtr_swigregister(XdmfGeometryPtr) XdmfGeometryPtr_swigregister(XdmfGeometryPtr)
...@@ -135,6 +139,23 @@ class XdmfGridPtr(_object): ...@@ -135,6 +139,23 @@ class XdmfGridPtr(_object):
XdmfGridPtr_swigregister = _Xdmf.XdmfGridPtr_swigregister XdmfGridPtr_swigregister = _Xdmf.XdmfGridPtr_swigregister
XdmfGridPtr_swigregister(XdmfGridPtr) XdmfGridPtr_swigregister(XdmfGridPtr)
class XdmfItemPtr(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, XdmfItemPtr, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, XdmfItemPtr, name)
__repr__ = _swig_repr
def __deref__(self): return _Xdmf.XdmfItemPtr___deref__(self)
def __init__(self):
this = _Xdmf.new_XdmfItemPtr()
try: self.this.append(this)
except: self.this = this
__swig_destroy__ = _Xdmf.delete_XdmfItemPtr
__del__ = lambda self : None;
def printSelf(self): return _Xdmf.XdmfItemPtr_printSelf(self)
XdmfItemPtr_swigregister = _Xdmf.XdmfItemPtr_swigregister
XdmfItemPtr_swigregister(XdmfItemPtr)
class XdmfObjPtr(_object): class XdmfObjPtr(_object):
__swig_setmethods__ = {} __swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, XdmfObjPtr, name, value) __setattr__ = lambda self, name, value: _swig_setattr(self, XdmfObjPtr, name, value)
...@@ -148,7 +169,6 @@ class XdmfObjPtr(_object): ...@@ -148,7 +169,6 @@ class XdmfObjPtr(_object):
except: self.this = this except: self.this = this
__swig_destroy__ = _Xdmf.delete_XdmfObjPtr __swig_destroy__ = _Xdmf.delete_XdmfObjPtr
__del__ = lambda self : None; __del__ = lambda self : None;
def New(self): return _Xdmf.XdmfObjPtr_New(self)
def printSelf(self): return _Xdmf.XdmfObjPtr_printSelf(self) def printSelf(self): return _Xdmf.XdmfObjPtr_printSelf(self)
XdmfObjPtr_swigregister = _Xdmf.XdmfObjPtr_swigregister XdmfObjPtr_swigregister = _Xdmf.XdmfObjPtr_swigregister
XdmfObjPtr_swigregister(XdmfObjPtr) XdmfObjPtr_swigregister(XdmfObjPtr)
...@@ -167,41 +187,117 @@ class XdmfTopologyPtr(_object): ...@@ -167,41 +187,117 @@ class XdmfTopologyPtr(_object):
__swig_destroy__ = _Xdmf.delete_XdmfTopologyPtr __swig_destroy__ = _Xdmf.delete_XdmfTopologyPtr
__del__ = lambda self : None; __del__ = lambda self : None;
def New(self): return _Xdmf.XdmfTopologyPtr_New(self) def New(self): return _Xdmf.XdmfTopologyPtr_New(self)
def getXdmfTopologyType(self): return _Xdmf.XdmfTopologyPtr_getXdmfTopologyType(self) def getTopologyType(self): return _Xdmf.XdmfTopologyPtr_getTopologyType(self)
def setTopologyType(self, *args): return _Xdmf.XdmfTopologyPtr_setTopologyType(self, *args) def setTopologyType(self, *args): return _Xdmf.XdmfTopologyPtr_setTopologyType(self, *args)
def getTopologyTypeAsString(self): return _Xdmf.XdmfTopologyPtr_getTopologyTypeAsString(self) def getTopologyTypeAsString(self): return _Xdmf.XdmfTopologyPtr_getTopologyTypeAsString(self)
def getNodesPerElement(self): return _Xdmf.XdmfTopologyPtr_getNodesPerElement(self)
def printSelf(self): return _Xdmf.XdmfTopologyPtr_printSelf(self) def printSelf(self): return _Xdmf.XdmfTopologyPtr_printSelf(self)
XdmfTopologyPtr_swigregister = _Xdmf.XdmfTopologyPtr_swigregister XdmfTopologyPtr_swigregister = _Xdmf.XdmfTopologyPtr_swigregister
XdmfTopologyPtr_swigregister(XdmfTopologyPtr) XdmfTopologyPtr_swigregister(XdmfTopologyPtr)
class XdmfVisitorPtr(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, XdmfVisitorPtr, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, XdmfVisitorPtr, name)
__repr__ = _swig_repr
def __deref__(self): return _Xdmf.XdmfVisitorPtr___deref__(self)
def __init__(self):
this = _Xdmf.new_XdmfVisitorPtr()
try: self.this.append(this)
except: self.this = this
__swig_destroy__ = _Xdmf.delete_XdmfVisitorPtr
__del__ = lambda self : None;
def New(self): return _Xdmf.XdmfVisitorPtr_New(self)
def printSelf(self): return _Xdmf.XdmfVisitorPtr_printSelf(self)
XdmfVisitorPtr_swigregister = _Xdmf.XdmfVisitorPtr_swigregister
XdmfVisitorPtr_swigregister(XdmfVisitorPtr)
class XdmfObject(_object): class XdmfObject(_object):
__swig_setmethods__ = {} __swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, XdmfObject, name, value) __setattr__ = lambda self, name, value: _swig_setattr(self, XdmfObject, name, value)
__swig_getmethods__ = {} __swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, XdmfObject, name) __getattr__ = lambda self, name: _swig_getattr(self, XdmfObject, name)
def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined") def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined - class is abstract")
__repr__ = _swig_repr __repr__ = _swig_repr
__swig_getmethods__["New"] = lambda x: _Xdmf.XdmfObject_New
if _newclass:New = staticmethod(_Xdmf.XdmfObject_New)
def printSelf(self): return _Xdmf.XdmfObject_printSelf(self) def printSelf(self): return _Xdmf.XdmfObject_printSelf(self)
XdmfObject_swigregister = _Xdmf.XdmfObject_swigregister XdmfObject_swigregister = _Xdmf.XdmfObject_swigregister
XdmfObject_swigregister(XdmfObject) XdmfObject_swigregister(XdmfObject)
def XdmfObject_New(): class XdmfItem(XdmfObject):
return _Xdmf.XdmfObject_New() __swig_setmethods__ = {}
XdmfObject_New = _Xdmf.XdmfObject_New for _s in [XdmfObject]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
__setattr__ = lambda self, name, value: _swig_setattr(self, XdmfItem, name, value)
__swig_getmethods__ = {}
for _s in [XdmfObject]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
__getattr__ = lambda self, name: _swig_getattr(self, XdmfItem, name)
def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined - class is abstract")
__repr__ = _swig_repr
XdmfItem_swigregister = _Xdmf.XdmfItem_swigregister
XdmfItem_swigregister(XdmfItem)
class XdmfGeometry(XdmfObject): class XdmfVisitor(XdmfObject):
__swig_setmethods__ = {} __swig_setmethods__ = {}
for _s in [XdmfObject]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) for _s in [XdmfObject]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
__setattr__ = lambda self, name, value: _swig_setattr(self, XdmfGeometry, name, value) __setattr__ = lambda self, name, value: _swig_setattr(self, XdmfVisitor, name, value)
__swig_getmethods__ = {} __swig_getmethods__ = {}
for _s in [XdmfObject]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) for _s in [XdmfObject]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
__getattr__ = lambda self, name: _swig_getattr(self, XdmfVisitor, name)
def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined")
__repr__ = _swig_repr
__swig_getmethods__["New"] = lambda x: _Xdmf.XdmfVisitor_New
if _newclass:New = staticmethod(_Xdmf.XdmfVisitor_New)
def printSelf(self): return _Xdmf.XdmfVisitor_printSelf(self)
XdmfVisitor_swigregister = _Xdmf.XdmfVisitor_swigregister
XdmfVisitor_swigregister(XdmfVisitor)
def XdmfVisitor_New():
return _Xdmf.XdmfVisitor_New()
XdmfVisitor_New = _Xdmf.XdmfVisitor_New
class XdmfGeometryType(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, XdmfGeometryType, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, XdmfGeometryType, name)
def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined")
__repr__ = _swig_repr
__swig_getmethods__["dimensions"] = _Xdmf.XdmfGeometryType_dimensions_get
if _newclass:dimensions = _swig_property(_Xdmf.XdmfGeometryType_dimensions_get)
__swig_getmethods__["name"] = _Xdmf.XdmfGeometryType_name_get
if _newclass:name = _swig_property(_Xdmf.XdmfGeometryType_name_get)
def __eq__(self, *args): return _Xdmf.XdmfGeometryType___eq__(self, *args)
def __ne__(self, *args): return _Xdmf.XdmfGeometryType___ne__(self, *args)
__swig_destroy__ = _Xdmf.delete_XdmfGeometryType
__del__ = lambda self : None;
XdmfGeometryType_swigregister = _Xdmf.XdmfGeometryType_swigregister
XdmfGeometryType_swigregister(XdmfGeometryType)
cvar = _Xdmf.cvar
XdmfGeometryType.NoGeometry = _Xdmf.cvar.XdmfGeometryType_NoGeometry
XdmfGeometryType.XYZ = _Xdmf.cvar.XdmfGeometryType_XYZ
XdmfGeometryType.XY = _Xdmf.cvar.XdmfGeometryType_XY
XdmfGeometryType.X_Y_Z = _Xdmf.cvar.XdmfGeometryType_X_Y_Z
XdmfGeometryType.X_Y = _Xdmf.cvar.XdmfGeometryType_X_Y
XdmfGeometryType.VXVYVZ = _Xdmf.cvar.XdmfGeometryType_VXVYVZ
XdmfGeometryType.Origin_DXDYDZ = _Xdmf.cvar.XdmfGeometryType_Origin_DXDYDZ
XdmfGeometryType.VXVY = _Xdmf.cvar.XdmfGeometryType_VXVY
XdmfGeometryType.Origin_DXDY = _Xdmf.cvar.XdmfGeometryType_Origin_DXDY
class XdmfGeometry(XdmfItem):
__swig_setmethods__ = {}
for _s in [XdmfItem]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
__setattr__ = lambda self, name, value: _swig_setattr(self, XdmfGeometry, name, value)
__swig_getmethods__ = {}
for _s in [XdmfItem]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
__getattr__ = lambda self, name: _swig_getattr(self, XdmfGeometry, name) __getattr__ = lambda self, name: _swig_getattr(self, XdmfGeometry, name)
def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined") def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined")
__repr__ = _swig_repr __repr__ = _swig_repr
__swig_getmethods__["New"] = lambda x: _Xdmf.XdmfGeometry_New __swig_getmethods__["New"] = lambda x: _Xdmf.XdmfGeometry_New
if _newclass:New = staticmethod(_Xdmf.XdmfGeometry_New) if _newclass:New = staticmethod(_Xdmf.XdmfGeometry_New)
def getGeometryType(self): return _Xdmf.XdmfGeometry_getGeometryType(self)
def setGeometryType(self, *args): return _Xdmf.XdmfGeometry_setGeometryType(self, *args)
def getGeometryTypeAsString(self): return _Xdmf.XdmfGeometry_getGeometryTypeAsString(self)
def getDimensions(self): return _Xdmf.XdmfGeometry_getDimensions(self)
def printSelf(self): return _Xdmf.XdmfGeometry_printSelf(self) def printSelf(self): return _Xdmf.XdmfGeometry_printSelf(self)
XdmfGeometry_swigregister = _Xdmf.XdmfGeometry_swigregister XdmfGeometry_swigregister = _Xdmf.XdmfGeometry_swigregister
XdmfGeometry_swigregister(XdmfGeometry) XdmfGeometry_swigregister(XdmfGeometry)
...@@ -210,12 +306,12 @@ def XdmfGeometry_New(): ...@@ -210,12 +306,12 @@ def XdmfGeometry_New():
return _Xdmf.XdmfGeometry_New() return _Xdmf.XdmfGeometry_New()
XdmfGeometry_New = _Xdmf.XdmfGeometry_New XdmfGeometry_New = _Xdmf.XdmfGeometry_New
class XdmfGrid(XdmfObject): class XdmfGrid(XdmfItem):
__swig_setmethods__ = {} __swig_setmethods__ = {}
for _s in [XdmfObject]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) for _s in [XdmfItem]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
__setattr__ = lambda self, name, value: _swig_setattr(self, XdmfGrid, name, value) __setattr__ = lambda self, name, value: _swig_setattr(self, XdmfGrid, name, value)
__swig_getmethods__ = {} __swig_getmethods__ = {}
for _s in [XdmfObject]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) for _s in [XdmfItem]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
__getattr__ = lambda self, name: _swig_getattr(self, XdmfGrid, name) __getattr__ = lambda self, name: _swig_getattr(self, XdmfGrid, name)
def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined") def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined")
__repr__ = _swig_repr __repr__ = _swig_repr
...@@ -240,17 +336,23 @@ class XdmfTopologyType(_object): ...@@ -240,17 +336,23 @@ class XdmfTopologyType(_object):
__getattr__ = lambda self, name: _swig_getattr(self, XdmfTopologyType, name) __getattr__ = lambda self, name: _swig_getattr(self, XdmfTopologyType, name)
def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined") def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined")
__repr__ = _swig_repr __repr__ = _swig_repr
__swig_getmethods__["numberVertices"] = _Xdmf.XdmfTopologyType_numberVertices_get NoCellType = _Xdmf.XdmfTopologyType_NoCellType
if _newclass:numberVertices = _swig_property(_Xdmf.XdmfTopologyType_numberVertices_get) Linear = _Xdmf.XdmfTopologyType_Linear
Quadratic = _Xdmf.XdmfTopologyType_Quadratic
Arbitrary = _Xdmf.XdmfTopologyType_Arbitrary
Structured = _Xdmf.XdmfTopologyType_Structured
__swig_getmethods__["nodesPerElement"] = _Xdmf.XdmfTopologyType_nodesPerElement_get
if _newclass:nodesPerElement = _swig_property(_Xdmf.XdmfTopologyType_nodesPerElement_get)
__swig_getmethods__["name"] = _Xdmf.XdmfTopologyType_name_get __swig_getmethods__["name"] = _Xdmf.XdmfTopologyType_name_get
if _newclass:name = _swig_property(_Xdmf.XdmfTopologyType_name_get) if _newclass:name = _swig_property(_Xdmf.XdmfTopologyType_name_get)
__swig_getmethods__["cellType"] = _Xdmf.XdmfTopologyType_cellType_get
if _newclass:cellType = _swig_property(_Xdmf.XdmfTopologyType_cellType_get)
def __eq__(self, *args): return _Xdmf.XdmfTopologyType___eq__(self, *args) def __eq__(self, *args): return _Xdmf.XdmfTopologyType___eq__(self, *args)
def __ne__(self, *args): return _Xdmf.XdmfTopologyType___ne__(self, *args) def __ne__(self, *args): return _Xdmf.XdmfTopologyType___ne__(self, *args)
__swig_destroy__ = _Xdmf.delete_XdmfTopologyType __swig_destroy__ = _Xdmf.delete_XdmfTopologyType
__del__ = lambda self : None; __del__ = lambda self : None;
XdmfTopologyType_swigregister = _Xdmf.XdmfTopologyType_swigregister XdmfTopologyType_swigregister = _Xdmf.XdmfTopologyType_swigregister
XdmfTopologyType_swigregister(XdmfTopologyType) XdmfTopologyType_swigregister(XdmfTopologyType)
cvar = _Xdmf.cvar
XdmfTopologyType.NoTopology = _Xdmf.cvar.XdmfTopologyType_NoTopology XdmfTopologyType.NoTopology = _Xdmf.cvar.XdmfTopologyType_NoTopology
XdmfTopologyType.Polyvertex = _Xdmf.cvar.XdmfTopologyType_Polyvertex XdmfTopologyType.Polyvertex = _Xdmf.cvar.XdmfTopologyType_Polyvertex
XdmfTopologyType.Polyline = _Xdmf.cvar.XdmfTopologyType_Polyline XdmfTopologyType.Polyline = _Xdmf.cvar.XdmfTopologyType_Polyline
...@@ -276,20 +378,21 @@ XdmfTopologyType.ThreeDSMesh = _Xdmf.cvar.XdmfTopologyType_ThreeDSMesh ...@@ -276,20 +378,21 @@ XdmfTopologyType.ThreeDSMesh = _Xdmf.cvar.XdmfTopologyType_ThreeDSMesh
XdmfTopologyType.ThreeDRectMesh = _Xdmf.cvar.XdmfTopologyType_ThreeDRectMesh XdmfTopologyType.ThreeDRectMesh = _Xdmf.cvar.XdmfTopologyType_ThreeDRectMesh
XdmfTopologyType.ThreeDCoRectMesh = _Xdmf.cvar.XdmfTopologyType_ThreeDCoRectMesh XdmfTopologyType.ThreeDCoRectMesh = _Xdmf.cvar.XdmfTopologyType_ThreeDCoRectMesh
class XdmfTopology(XdmfObject): class XdmfTopology(XdmfItem):
__swig_setmethods__ = {} __swig_setmethods__ = {}
for _s in [XdmfObject]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) for _s in [XdmfItem]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
__setattr__ = lambda self, name, value: _swig_setattr(self, XdmfTopology, name, value) __setattr__ = lambda self, name, value: _swig_setattr(self, XdmfTopology, name, value)
__swig_getmethods__ = {} __swig_getmethods__ = {}
for _s in [XdmfObject]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{})) for _s in [XdmfItem]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
__getattr__ = lambda self, name: _swig_getattr(self, XdmfTopology, name) __getattr__ = lambda self, name: _swig_getattr(self, XdmfTopology, name)
def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined") def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined")
__repr__ = _swig_repr __repr__ = _swig_repr
__swig_getmethods__["New"] = lambda x: _Xdmf.XdmfTopology_New __swig_getmethods__["New"] = lambda x: _Xdmf.XdmfTopology_New
if _newclass:New = staticmethod(_Xdmf.XdmfTopology_New) if _newclass:New = staticmethod(_Xdmf.XdmfTopology_New)
def getXdmfTopologyType(self): return _Xdmf.XdmfTopology_getXdmfTopologyType(self) def getTopologyType(self): return _Xdmf.XdmfTopology_getTopologyType(self)
def setTopologyType(self, *args): return _Xdmf.XdmfTopology_setTopologyType(self, *args) def setTopologyType(self, *args): return _Xdmf.XdmfTopology_setTopologyType(self, *args)
def getTopologyTypeAsString(self): return _Xdmf.XdmfTopology_getTopologyTypeAsString(self) def getTopologyTypeAsString(self): return _Xdmf.XdmfTopology_getTopologyTypeAsString(self)
def getNodesPerElement(self): return _Xdmf.XdmfTopology_getNodesPerElement(self)
def printSelf(self): return _Xdmf.XdmfTopology_printSelf(self) def printSelf(self): return _Xdmf.XdmfTopology_printSelf(self)
XdmfTopology_swigregister = _Xdmf.XdmfTopology_swigregister XdmfTopology_swigregister = _Xdmf.XdmfTopology_swigregister
XdmfTopology_swigregister(XdmfTopology) XdmfTopology_swigregister(XdmfTopology)
......
...@@ -8,9 +8,9 @@ ...@@ -8,9 +8,9 @@
#ifndef XDMFATTRIBUTE_HPP_ #ifndef XDMFATTRIBUTE_HPP_
#define XDMFATTRIBUTE_HPP_ #define XDMFATTRIBUTE_HPP_
#include "XdmfObject.hpp" #include "XdmfItem.hpp"
class XdmfAttribute : public XdmfObject { class XdmfAttribute : public XdmfItem {
XdmfNewMacro(XdmfAttribute); XdmfNewMacro(XdmfAttribute);
......
...@@ -7,7 +7,19 @@ ...@@ -7,7 +7,19 @@
#include "XdmfGeometry.hpp" #include "XdmfGeometry.hpp"
XdmfGeometry::XdmfGeometry() // Supported XdmfGeometryTypes
const XdmfGeometryType XdmfGeometryType::NoGeometry("NONE", 0);
const XdmfGeometryType XdmfGeometryType::XYZ("XYZ", 3);
const XdmfGeometryType XdmfGeometryType::XY("XY", 2);
const XdmfGeometryType XdmfGeometryType::X_Y_Z("X_Y_Z", 3);
const XdmfGeometryType XdmfGeometryType::X_Y("X_Y", 2);
const XdmfGeometryType XdmfGeometryType::VXVYVZ("VXVYVZ", 3);
const XdmfGeometryType XdmfGeometryType::Origin_DXDYDZ("ORIGIN_DXDYDZ", 3);
const XdmfGeometryType XdmfGeometryType::VXVY("VXVY", 2);
const XdmfGeometryType XdmfGeometryType::Origin_DXDY("ORIGIN_DXDY", 2);
XdmfGeometry::XdmfGeometry() :
mGeometryType(&XdmfGeometryType::NoGeometry)
{ {
std::cout << "Created Geometry " << this << std::endl; std::cout << "Created Geometry " << this << std::endl;
} }
...@@ -17,6 +29,27 @@ XdmfGeometry::~XdmfGeometry() ...@@ -17,6 +29,27 @@ XdmfGeometry::~XdmfGeometry()
std::cout << "Deleted Geometry " << this << std::endl; std::cout << "Deleted Geometry " << this << std::endl;
} }
const XdmfGeometryType& XdmfGeometry::getGeometryType() const
{
return *mGeometryType;
}
void XdmfGeometry::setGeometryType(const XdmfGeometryType& geomType)
{
mGeometryType = &geomType;
return;
}
const std::string XdmfGeometry::getGeometryTypeAsString() const
{
return mGeometryType->name;
}
const int XdmfGeometry::getDimensions() const
{
return mGeometryType->dimensions;
}
const std::string XdmfGeometry::printSelf() const const std::string XdmfGeometry::printSelf() const
{ {
return "XdmfGeometry"; return "XdmfGeometry";
......
...@@ -8,13 +8,102 @@ ...@@ -8,13 +8,102 @@
#ifndef XDMFGEOMETRY_HPP_ #ifndef XDMFGEOMETRY_HPP_
#define XDMFGEOMETRY_HPP_ #define XDMFGEOMETRY_HPP_
#include "XdmfObject.hpp" #include "XdmfItem.hpp"
class XdmfGeometry : public XdmfObject { class XdmfGeometryType {
public:
const int dimensions;
const std::string name;
// Supported Xdmf Geometry Types
static const XdmfGeometryType NoGeometry;
static const XdmfGeometryType XYZ;
static const XdmfGeometryType XY;
static const XdmfGeometryType X_Y_Z;
static const XdmfGeometryType X_Y;
static const XdmfGeometryType VXVYVZ;
static const XdmfGeometryType Origin_DXDYDZ;
static const XdmfGeometryType VXVY;
static const XdmfGeometryType Origin_DXDY;
/*
* Compare two XdmfGeometry types for equality. Each geometry type has a single static instance meaning that
* equality can be determined by determining if they have the same pointer value.
*
* @param an XdmfGeometryType to compare equality to.
* @return true iff the XdmfGeometryTypes are equal.
*/
bool operator==(const XdmfGeometryType& top) const
{
return (this == &top) ? true : false;
}
/**
* Compare two XdmfGeometry types for inequality. Each geometry type has a single static instance meaning that
* equality can be determined by determining if they have the same pointer value.
*
* @param XdmfGeometryType to compare inequality to.
* @return true iff the XdmfGeometryTypes are not equal.
*/
bool operator!=(const XdmfGeometryType& top) const
{
return (this != &top) ? true : false;
}
protected:
/**
* Protected constructor for XdmfGeometryType. The constructor is protected because all geometry types supported
* by Xdmf should be accessed through static public instances of XdmfGeometryType - i.e. XdmfGeometryType::XYZ.
*/
XdmfGeometryType(const std::string& name, const int& dimensions) :
name(name),
dimensions(dimensions)
{};
private:
//XdmfTopologyType(const XdmfTopologyType&); // Not implemented.
//void operator=(const XdmfTopologyType&); // Not implemented.
};
class XdmfGeometry : public XdmfItem {
public: public:
XdmfNewMacro(XdmfGeometry); XdmfNewMacro(XdmfGeometry);
/**
* Get the XdmfGeometryType associated with this Geometry.
*
* @return XdmfGeometryType.
*/
const XdmfGeometryType& getGeometryType() const;
/**
* Set the XdmfGeometryType associated with this Geometry.
*
* @param XdmfGeometryType to set.
*/
void setGeometryType(const XdmfGeometryType&);
/**
* Get the name of the GeometryType associated with this Geometry.
*
* @return std::string containing name of the GeometryType.
*/
const std::string getGeometryTypeAsString() const;
/**
* Get the number of dimensions for this Geometry.
*
* @return int giving number of dimensions: i.e. XY = 2, XYZ = 3.
*/
const int getDimensions() const;
virtual const std::string printSelf() const; virtual const std::string printSelf() const;
protected: protected:
...@@ -24,15 +113,11 @@ protected: ...@@ -24,15 +113,11 @@ protected:
private: private:
class Delete
{
public:
void operator()(XdmfGeometry * p) { delete p; }
};
XdmfGeometry(const XdmfGeometry&); // Not implemented. XdmfGeometry(const XdmfGeometry&); // Not implemented.
void operator=(const XdmfGeometry&); // Not implemented. void operator=(const XdmfGeometry&); // Not implemented.
const XdmfGeometryType * mGeometryType;
}; };
#endif /* XDMFGEOMETRY_HPP_ */ #endif /* XDMFGEOMETRY_HPP_ */
...@@ -9,11 +9,11 @@ ...@@ -9,11 +9,11 @@
#include "XdmfGeometry.hpp" #include "XdmfGeometry.hpp"
#include "XdmfTopology.hpp" #include "XdmfTopology.hpp"
XdmfGrid::XdmfGrid() XdmfGrid::XdmfGrid() :
mGeometry(XdmfGeometry::New()),
mTopology(XdmfTopology::New())
{ {
std::cout << "Created Grid " << this << std::endl; std::cout << "Created Grid " << this << std::endl;
mGeometry = XdmfGeometry::New();
mTopology = XdmfTopology::New();
} }
XdmfGrid::~XdmfGrid() XdmfGrid::~XdmfGrid()
......
...@@ -6,16 +6,15 @@ ...@@ -6,16 +6,15 @@
// Forward Declarations // Forward Declarations
class XdmfAttribute; class XdmfAttribute;
class XdmfAttributeVector;
class XdmfGeometry; class XdmfGeometry;
class XdmfTopology; class XdmfTopology;
class XdmfVisitor;
// Includes // Includes
#include "XdmfObject.hpp" #include "XdmfItem.hpp"
#include <vector> #include <vector>
class XdmfGrid : public XdmfObject { class XdmfGrid : public XdmfItem {
public: public:
...@@ -31,6 +30,8 @@ public: ...@@ -31,6 +30,8 @@ public:
// Set the XdmfTopology for this grid // Set the XdmfTopology for this grid
XdmfSetValueMacro(Topology, boost::shared_ptr<XdmfTopology>); XdmfSetValueMacro(Topology, boost::shared_ptr<XdmfTopology>);
//virtual void write(XdmfVisitor&) const;
virtual const std::string printSelf() const; virtual const std::string printSelf() const;
protected: protected:
......
#include "XdmfItem.hpp"
XdmfItem::XdmfItem()
{
}
XdmfItem::~XdmfItem()
{
}
/**
* An XdmfItem replaces the XdmfElement class in the previous version of Xdmf. An XdmfElement represents and item that can be
* visited by an XdmfLightDataVisitor and have it's contents added to an XdmfFile. These include XdmfGrids, XdmfSets,
* XdmfTopologies, etc.
*
* This is an abstract base class.
*/
#ifndef XDMFITEM_HPP_
#define XDMFITEM_HPP_
class XdmfVisitor;
// Includes
#include "XdmfObject.hpp"
class XdmfItem : public XdmfObject {
public:
//virtual const std::string printSelf() const = 0;
//virtual void write(XdmfVisitor&) const = 0;