Commit d9c8a53c authored by Ken Leiter (Civ's avatar Ken Leiter (Civ
Browse files

ENH: Start separating XdmfItem properties from their respective classes - XdmfGeometryType.

parent 282d5e4f
...@@ -24,6 +24,7 @@ set(XdmfSources ...@@ -24,6 +24,7 @@ set(XdmfSources
XdmfAttributeCenter XdmfAttributeCenter
XdmfAttributeType XdmfAttributeType
XdmfGeometry XdmfGeometry
XdmfGeometryType
XdmfGrid XdmfGrid
XdmfItem XdmfItem
XdmfObject XdmfObject
......
...@@ -28,6 +28,7 @@ namespace boost { ...@@ -28,6 +28,7 @@ namespace boost {
#include <XdmfAttributeCenter.hpp> #include <XdmfAttributeCenter.hpp>
#include <XdmfAttributeType.hpp> #include <XdmfAttributeType.hpp>
#include <XdmfGeometry.hpp> #include <XdmfGeometry.hpp>
#include <XdmfGeometryType.hpp>
#include <XdmfGrid.hpp> #include <XdmfGrid.hpp>
#include <XdmfItem.hpp> #include <XdmfItem.hpp>
#include <XdmfObject.hpp> #include <XdmfObject.hpp>
...@@ -44,5 +45,6 @@ namespace boost { ...@@ -44,5 +45,6 @@ namespace boost {
%include XdmfAttributeCenter.hpp %include XdmfAttributeCenter.hpp
%include XdmfAttributeType.hpp %include XdmfAttributeType.hpp
%include XdmfGeometry.hpp %include XdmfGeometry.hpp
%include XdmfGeometryType.hpp
%include XdmfGrid.hpp %include XdmfGrid.hpp
%include XdmfTopology.hpp %include XdmfTopology.hpp
...@@ -426,6 +426,30 @@ def XdmfAttributeType_GlobalId(): ...@@ -426,6 +426,30 @@ def XdmfAttributeType_GlobalId():
return _Xdmf.XdmfAttributeType_GlobalId() return _Xdmf.XdmfAttributeType_GlobalId()
XdmfAttributeType_GlobalId = _Xdmf.XdmfAttributeType_GlobalId XdmfAttributeType_GlobalId = _Xdmf.XdmfAttributeType_GlobalId
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)
def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined")
__repr__ = _swig_repr
__swig_getmethods__["New"] = lambda x: _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 write(self, *args): return _Xdmf.XdmfGeometry_write(self, *args)
XdmfGeometry_swigregister = _Xdmf.XdmfGeometry_swigregister
XdmfGeometry_swigregister(XdmfGeometry)
def XdmfGeometry_New():
return _Xdmf.XdmfGeometry_New()
XdmfGeometry_New = _Xdmf.XdmfGeometry_New
class XdmfGeometryType(_object): class XdmfGeometryType(_object):
__swig_setmethods__ = {} __swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, XdmfGeometryType, name, value) __setattr__ = lambda self, name, value: _swig_setattr(self, XdmfGeometryType, name, value)
...@@ -499,30 +523,6 @@ def XdmfGeometryType_Origin_DXDY(): ...@@ -499,30 +523,6 @@ def XdmfGeometryType_Origin_DXDY():
return _Xdmf.XdmfGeometryType_Origin_DXDY() return _Xdmf.XdmfGeometryType_Origin_DXDY()
XdmfGeometryType_Origin_DXDY = _Xdmf.XdmfGeometryType_Origin_DXDY XdmfGeometryType_Origin_DXDY = _Xdmf.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)
def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined")
__repr__ = _swig_repr
__swig_getmethods__["New"] = lambda x: _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 write(self, *args): return _Xdmf.XdmfGeometry_write(self, *args)
XdmfGeometry_swigregister = _Xdmf.XdmfGeometry_swigregister
XdmfGeometry_swigregister(XdmfGeometry)
def XdmfGeometry_New():
return _Xdmf.XdmfGeometry_New()
XdmfGeometry_New = _Xdmf.XdmfGeometry_New
class XdmfGrid(XdmfItem): class XdmfGrid(XdmfItem):
__swig_setmethods__ = {} __swig_setmethods__ = {}
for _s in [XdmfItem]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) for _s in [XdmfItem]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
......
...@@ -9,9 +9,9 @@ ...@@ -9,9 +9,9 @@
#include "XdmfVisitor.hpp" #include "XdmfVisitor.hpp"
XdmfAttribute::XdmfAttribute() : XdmfAttribute::XdmfAttribute() :
mName(""), mName(""),
mAttributeType(XdmfAttributeType::NoAttributeType()), mAttributeType(XdmfAttributeType::NoAttributeType()),
mAttributeCenter(XdmfAttributeCenter::Grid()) mAttributeCenter(XdmfAttributeCenter::Grid())
{ {
std::cout << "Created Attribute " << this << std::endl; std::cout << "Created Attribute " << this << std::endl;
} }
......
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
#define XDMFATTRIBUTE_HPP_ #define XDMFATTRIBUTE_HPP_
#include "XdmfItem.hpp" #include "XdmfItem.hpp"
#include "XdmfAttributeType.hpp"
#include "XdmfAttributeCenter.hpp" #include "XdmfAttributeCenter.hpp"
#include "XdmfAttributeType.hpp"
class XdmfAttribute : public XdmfItem { class XdmfAttribute : public XdmfItem {
...@@ -44,7 +44,7 @@ public: ...@@ -44,7 +44,7 @@ public:
* *
* @param XdmfAttributeType to set. * @param XdmfAttributeType to set.
*/ */
void setAttributeType(const XdmfAttributeType&); void setAttributeType(const XdmfAttributeType& attributeType);
/** /**
* Get the name of the AttributeType associated with this Attribute. * Get the name of the AttributeType associated with this Attribute.
...@@ -65,7 +65,7 @@ public: ...@@ -65,7 +65,7 @@ public:
* *
* @param XdmfAttributeCenter to set. * @param XdmfAttributeCenter to set.
*/ */
void setAttributeCenter(const XdmfAttributeCenter&); void setAttributeCenter(const XdmfAttributeCenter& attributeCenter);
/** /**
* Get the name of the AttributeCenter associated with this Attribute. * Get the name of the AttributeCenter associated with this Attribute.
......
...@@ -44,8 +44,8 @@ public: ...@@ -44,8 +44,8 @@ public:
*/ */
bool operator!=(const XdmfAttributeCenter& attributeCenter) const; bool operator!=(const XdmfAttributeCenter& attributeCenter) const;
XdmfAttributeCenter(const XdmfAttributeCenter&); XdmfAttributeCenter(const XdmfAttributeCenter& attributeCenter);
XdmfAttributeCenter& operator=(const XdmfAttributeCenter&); XdmfAttributeCenter& operator=(const XdmfAttributeCenter& attributeCenter);
protected: protected:
......
...@@ -46,8 +46,8 @@ public: ...@@ -46,8 +46,8 @@ public:
*/ */
bool operator!=(const XdmfAttributeType& top) const; bool operator!=(const XdmfAttributeType& top) const;
XdmfAttributeType(const XdmfAttributeType&); XdmfAttributeType(const XdmfAttributeType& attributeType);
XdmfAttributeType& operator=(const XdmfAttributeType&); XdmfAttributeType& operator=(const XdmfAttributeType& attributeType);
protected: protected:
......
...@@ -8,70 +8,6 @@ ...@@ -8,70 +8,6 @@
#include "XdmfGeometry.hpp" #include "XdmfGeometry.hpp"
#include "XdmfVisitor.hpp" #include "XdmfVisitor.hpp"
// Supported XdmfGeometryTypes
XdmfGeometryType XdmfGeometryType::NoGeometryType()
{
return XdmfGeometryType("NONE", 0);
}
XdmfGeometryType XdmfGeometryType::XYZ()
{
return XdmfGeometryType("XYZ", 3);
}
XdmfGeometryType XdmfGeometryType::XY()
{
return XdmfGeometryType("XY", 2);
}
XdmfGeometryType XdmfGeometryType::X_Y_Z()
{
return XdmfGeometryType("X_Y_Z", 3);
}
XdmfGeometryType XdmfGeometryType::X_Y()
{
return XdmfGeometryType("X_Y", 2);
}
XdmfGeometryType XdmfGeometryType::VXVYVZ()
{
return XdmfGeometryType("VXVYVZ", 3);
}
XdmfGeometryType XdmfGeometryType::Origin_DXDYDZ()
{
return XdmfGeometryType("ORIGIN_DXDYDZ", 3);
}
XdmfGeometryType XdmfGeometryType::VXVY()
{
return XdmfGeometryType("VXVY", 2);
}
XdmfGeometryType XdmfGeometryType::Origin_DXDY()
{
return XdmfGeometryType("ORIGIN_DXDY", 2);
}
XdmfGeometryType::XdmfGeometryType(const XdmfGeometryType& geomType):
mDimensions(geomType.mDimensions),
mName(geomType.mName)
{
}
XdmfGeometryType& XdmfGeometryType::operator=(const XdmfGeometryType& geomType)
{
if(this != &geomType)
{
mDimensions = geomType.mDimensions;
mName = geomType.mName;
}
return *this;
}
int XdmfGeometryType::getDimensions() const
{
return mDimensions;
}
std::string XdmfGeometryType::getName() const
{
return mName;
}
XdmfGeometry::XdmfGeometry() : XdmfGeometry::XdmfGeometry() :
mGeometryType(XdmfGeometryType::NoGeometryType()) mGeometryType(XdmfGeometryType::NoGeometryType())
{ {
......
...@@ -10,77 +10,7 @@ ...@@ -10,77 +10,7 @@
// Includes // Includes
#include "XdmfItem.hpp" #include "XdmfItem.hpp"
#include "XdmfGeometryType.hpp"
class XdmfGeometryType {
public:
// Supported Xdmf Geometry Types
static XdmfGeometryType NoGeometryType();
static XdmfGeometryType XYZ();
static XdmfGeometryType XY();
static XdmfGeometryType X_Y_Z();
static XdmfGeometryType X_Y();
static XdmfGeometryType VXVYVZ();
static XdmfGeometryType Origin_DXDYDZ();
static XdmfGeometryType VXVY();
static XdmfGeometryType Origin_DXDY();
/**
* Get the dimensions of this geometry type - i.e. XYZ = 3.
*
* @return an int containing number of dimensions.
*/
int getDimensions() const;
/**
* Get the name of this geometry type
*
* @return a string containing the name.
*/
std::string getName() const;
/*
* Compare two XdmfGeometry types for equality.
*
* @param an XdmfGeometryType to compare equality to.
* @return true iff the XdmfGeometryTypes are equal.
*/
bool operator==(const XdmfGeometryType& top) const
{
return mDimensions == top.mDimensions && mName.compare(top.mName) == 0;
}
/**
* Compare two XdmfGeometry types for inequality.
*
* @param XdmfGeometryType to compare inequality to.
* @return true iff the XdmfGeometryTypes are not equal.
*/
bool operator!=(const XdmfGeometryType& top) const
{
return !this->operator ==(top);
}
XdmfGeometryType(const XdmfGeometryType&);
XdmfGeometryType& operator=(const XdmfGeometryType&);
protected:
/**
* Protected constructor for XdmfGeometryType. The constructor is protected because all geometry types supported
* by Xdmf should be accessed through more specific static methods that construct XdmfGeometryTypes - i.e. XdmfGeometryType::XYZ().
*/
XdmfGeometryType(const std::string& name, const int& dimensions) :
mName(name),
mDimensions(dimensions)
{};
private:
int mDimensions;
std::string mName;
};
class XdmfGeometry : public XdmfItem { class XdmfGeometry : public XdmfItem {
......
/*
* XdmfGeometryType.cpp
*
* Created on: Jan 29, 2010
* Author: kleiter
*/
#include "XdmfGeometryType.hpp"
// Supported XdmfGeometryTypes
XdmfGeometryType XdmfGeometryType::NoGeometryType()
{
return XdmfGeometryType("NONE", 0);
}
XdmfGeometryType XdmfGeometryType::XYZ()
{
return XdmfGeometryType("XYZ", 3);
}
XdmfGeometryType XdmfGeometryType::XY()
{
return XdmfGeometryType("XY", 2);
}
XdmfGeometryType XdmfGeometryType::X_Y_Z()
{
return XdmfGeometryType("X_Y_Z", 3);
}
XdmfGeometryType XdmfGeometryType::X_Y()
{
return XdmfGeometryType("X_Y", 2);
}
XdmfGeometryType XdmfGeometryType::VXVYVZ()
{
return XdmfGeometryType("VXVYVZ", 3);
}
XdmfGeometryType XdmfGeometryType::Origin_DXDYDZ()
{
return XdmfGeometryType("ORIGIN_DXDYDZ", 3);
}
XdmfGeometryType XdmfGeometryType::VXVY()
{
return XdmfGeometryType("VXVY", 2);
}
XdmfGeometryType XdmfGeometryType::Origin_DXDY()
{
return XdmfGeometryType("ORIGIN_DXDY", 2);
}
XdmfGeometryType::XdmfGeometryType(const XdmfGeometryType& geometryType):
mDimensions(geometryType.mDimensions),
mName(geometryType.mName)
{
}
XdmfGeometryType::XdmfGeometryType(const std::string& name, const int& dimensions) :
mName(name),
mDimensions(dimensions)
{};
XdmfGeometryType& XdmfGeometryType::operator=(const XdmfGeometryType& geometryType)
{
if(this != &geometryType)
{
mDimensions = geometryType.mDimensions;
mName = geometryType.mName;
}
return *this;
}
bool XdmfGeometryType::operator==(const XdmfGeometryType& geometryType) const
{
return mDimensions == geometryType.mDimensions && mName.compare(geometryType.mName) == 0;
}
bool XdmfGeometryType::operator!=(const XdmfGeometryType& geometryType) const
{
return !this->operator==(geometryType);
}
int XdmfGeometryType::getDimensions() const
{
return mDimensions;
}
std::string XdmfGeometryType::getName() const
{
return mName;
}
/*
* XdmfGeometryType.hpp
*
* Created on: Jan 25, 2010
* Author: kleiter
*/
#ifndef XDMFGEOMETRYTYPE_HPP_
#define XDMFGEOMETRYTYPE_HPP_
#include <string>
class XdmfGeometryType {
public:
// Supported Xdmf Geometry Types
static XdmfGeometryType NoGeometryType();
static XdmfGeometryType XYZ();
static XdmfGeometryType XY();
static XdmfGeometryType X_Y_Z();
static XdmfGeometryType X_Y();
static XdmfGeometryType VXVYVZ();
static XdmfGeometryType Origin_DXDYDZ();
static XdmfGeometryType VXVY();
static XdmfGeometryType Origin_DXDY();
/**
* Get the dimensions of this geometry type - i.e. XYZ = 3.
*
* @return an int containing number of dimensions.
*/
int getDimensions() const;
/**
* Get the name of this geometry type
*
* @return a string containing the name.
*/
std::string getName() const;
/*
* Compare two XdmfGeometry types for equality.
*
* @param an XdmfGeometryType to compare equality to.
* @return true iff the XdmfGeometryTypes are equal.
*/
bool operator==(const XdmfGeometryType& geometryType) const;
/**
* Compare two XdmfGeometry types for inequality.
*
* @param XdmfGeometryType to compare inequality to.
* @return true iff the XdmfGeometryTypes are not equal.
*/
bool operator!=(const XdmfGeometryType& geometryType) const;
XdmfGeometryType(const XdmfGeometryType& geometryType);
XdmfGeometryType& operator=(const XdmfGeometryType& geometryType);
protected:
/**
* Protected constructor for XdmfGeometryType. The constructor is protected because all geometry types supported
* by Xdmf should be accessed through more specific static methods that construct XdmfGeometryTypes - i.e. XdmfGeometryType::XYZ().
*/
XdmfGeometryType(const std::string& name, const int& dimensions);
private:
int mDimensions;
std::string mName;
};
#endif /* XDMFATTRIBUTETYPE_HPP_ */
...@@ -3309,6 +3309,7 @@ SWIG_From_unsigned_SS_int (unsigned int value) ...@@ -3309,6 +3309,7 @@ SWIG_From_unsigned_SS_int (unsigned int value)
#include <XdmfAttributeCenter.hpp> #include <XdmfAttributeCenter.hpp>
#include <XdmfAttributeType.hpp> #include <XdmfAttributeType.hpp>
#include <XdmfGeometry.hpp> #include <XdmfGeometry.hpp>
#include <XdmfGeometryType.hpp>
#include <XdmfGrid.hpp> #include <XdmfGrid.hpp>
#include <XdmfItem.hpp> #include <XdmfItem.hpp>
#include <XdmfObject.hpp> #include <XdmfObject.hpp>
...@@ -7263,6 +7264,185 @@ SWIGINTERN PyObject *XdmfAttributeType_swigregister(PyObject *SWIGUNUSEDPARM(sel ...@@ -7263,6 +7264,185 @@ SWIGINTERN PyObject *XdmfAttributeType_swigregister(PyObject *SWIGUNUSEDPARM(sel
return SWIG_Py_Void(); return SWIG_Py_Void();
} }
SWIGINTERN PyObject *_wrap_XdmfGeometry_New(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
boost::shared_ptr< XdmfGeometry > result;
if (!PyArg_ParseTuple(args,(char *)":XdmfGeometry_New")) SWIG_fail;
result = XdmfGeometry::New();
resultobj = SWIG_NewPointerObj((new boost::shared_ptr< XdmfGeometry >(static_cast< const boost::shared_ptr< XdmfGeometry >& >(result))), SWIGTYPE_p_boost__shared_ptrT_XdmfGeometry_t, SWIG_POINTER_OWN | 0 );
return resultobj;
fail:
return NULL;
}
SWIGINTERN PyObject *_wrap_XdmfGeometry_getGeometryType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
XdmfGeometry *arg1 = (XdmfGeometry *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
PyObject * obj0 = 0 ;
SwigValueWrapper< XdmfGeometryType > result;
if (!PyArg_ParseTuple(args,(char *)"O:XdmfGeometry_getGeometryType",&obj0)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGeometry, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGeometry_getGeometryType" "', argument " "1"" of type '" "XdmfGeometry const *""'");
}
arg1 = reinterpret_cast< XdmfGeometry * >(argp1);
result = ((XdmfGeometry const *)arg1)->getGeometryType();
resultobj = SWIG_NewPointerObj((new XdmfGeometryType(static_cast< const XdmfGeometryType& >(result))), SWIGTYPE_p_XdmfGeometryType, SWIG_POINTER_OWN | 0 );
return resultobj;
fail:
return NULL;
}
SWIGINTERN PyObject *_wrap_XdmfGeometry_setGeometryType(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
XdmfGeometry *arg1 = (XdmfGeometry *) 0 ;
XdmfGeometryType *arg2 = 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
void *argp2 = 0 ;
int res2 = 0 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
if (!PyArg_ParseTuple(args,(char *)"OO:XdmfGeometry_setGeometryType",&obj0,&obj1)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGeometry, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGeometry_setGeometryType" "', argument " "1"" of type '" "XdmfGeometry *""'");
}
arg1 = reinterpret_cast< XdmfGeometry * >(argp1);
res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_XdmfGeometryType, 0 | 0);
if (!SWIG_IsOK(res2)) {
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "XdmfGeometry_setGeometryType" "', argument " "2"" of type '" "XdmfGeometryType const &""'");
}
if (!argp2) {
SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "XdmfGeometry_setGeometryType" "', argument " "2"" of type '" "XdmfGeometryType const &""'");
}
arg2 = reinterpret_cast< XdmfGeometryType * >(argp2);
(arg1)->setGeometryType((XdmfGeometryType const &)*arg2);
resultobj = SWIG_Py_Void();
return resultobj;
fail:
return NULL;
}
SWIGINTERN PyObject *_wrap_XdmfGeometry_getGeometryTypeAsString(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
XdmfGeometry *arg1 = (XdmfGeometry *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
PyObject * obj0 = 0 ;
std::string result;
if (!PyArg_ParseTuple(args,(char *)"O:XdmfGeometry_getGeometryTypeAsString",&obj0)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_XdmfGeometry, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "XdmfGeometry_getGeometryTypeAsString" "', argument " "1"" of type '" "XdmfGeometry const *""'");
}
arg1 = reinterpret_cast< XdmfGeometry * >(argp1);
result = ((XdmfGeometry const *)arg1)->getGeometryTypeAsString();