Commit f0246ede authored by Ken Leiter (Civ's avatar Ken Leiter (Civ

ENH: Initial Commit

parents
project(Xdmf2)
cmake_minimum_required(VERSION 2.6)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
set(BUILD_SHARED_LIBS true)
find_package(Boost REQUIRED)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
message(${Boost_INCLUDE_DIRS})
endif(Boost_FOUND)
find_package(PythonLibs REQUIRED)
if(PYTHONLIBS_FOUND)
include_directories(${PYTHON_INCLUDE_DIRS})
endif(PYTHONLIBS_FOUND)
set(XdmfSources
XdmfGeometry
XdmfGrid
XdmfObject
XdmfTopology
)
add_library(Xdmf ${XdmfSources})
add_library(_Xdmf MODULE XdmfPython)
set_target_properties(_Xdmf PROPERTIES PREFIX "")
target_link_libraries(_Xdmf Xdmf)
configure_file(Xdmf.py Xdmf.py COPYONLY)
add_executable(XdmfTest test.cpp)
target_link_libraries(XdmfTest Xdmf)
/*
XdmfPython.cpp:
swig -v -c++ -python -o XdmfPython.cpp Xdmf.i
*/
%include std_string.i
%include std_vector.i
namespace boost {
template<class T> class shared_ptr
{
public:
T * operator-> () const;
};
}
%template(XdmfGeometryPtr) boost::shared_ptr<XdmfGeometry>;
%template(XdmfGridPtr) boost::shared_ptr<XdmfGrid>;
%template(XdmfObjPtr) boost::shared_ptr<XdmfObject>;
%template(XdmfTopologyPtr) boost::shared_ptr<XdmfTopology>;
%module Xdmf
%{
#include <XdmfGeometry.hpp>
#include <XdmfGrid.hpp>
#include <XdmfObject.hpp>
#include <XdmfTopology.hpp>
%}
%include XdmfObject.hpp
%include XdmfGeometry.hpp
%include XdmfGrid.hpp
%include XdmfTopology.hpp
/*
XdmfPython.cpp:
swig -v -c++ -make_default -python -shadow -I/share/kleiter/boost-1.41.0-install/include -o XdmfPython.cpp Xdmf.i
*/
%include std_string.i
%include std_vector.i
namespace boost {
template<class T> class shared_ptr
{
public:
T * operator-> () const;
};
}
%template(XdmfGridPtr) boost::shared_ptr<XdmfGrid>;
%module Xdmf
%{
#include <XdmfGeometry.hpp>
#include <XdmfGrid.hpp>
#include <XdmfObject.hpp>
#include <XdmfTopology.hpp>
%}
%include XdmfObject.hpp
%include XdmfGeometry.hpp
%include XdmfGrid.hpp
%include XdmfObject.hpp
%include XdmfTopology.hpp
# This file was automatically generated by SWIG (http://www.swig.org).
# Version 1.3.37
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
# This file is compatible with both classic and new-style classes.
from sys import version_info
if version_info >= (2,6,0):
def swig_import_helper():
from os.path import dirname
import imp
try:
fp, pathname, description = imp.find_module('_Xdmf', [dirname(__file__)])
_mod = imp.load_module('_Xdmf', fp, pathname, description)
finally:
if fp is not None: fp.close()
return _mod
_Xdmf = swig_import_helper()
del swig_import_helper
else:
import _Xdmf
del version_info
try:
_swig_property = property
except NameError:
pass # Python < 2.2 doesn't have 'property'.
def _swig_setattr_nondynamic(self,class_type,name,value,static=1):
if (name == "thisown"): return self.this.own(value)
if (name == "this"):
if type(value).__name__ == 'SwigPyObject':
self.__dict__[name] = value
return
method = class_type.__swig_setmethods__.get(name,None)
if method: return method(self,value)
if (not static) or hasattr(self,name):
self.__dict__[name] = value
else:
raise AttributeError("You cannot add attributes to %s" % self)
def _swig_setattr(self,class_type,name,value):
return _swig_setattr_nondynamic(self,class_type,name,value,0)
def _swig_getattr(self,class_type,name):
if (name == "thisown"): return self.this.own()
method = class_type.__swig_getmethods__.get(name,None)
if method: return method(self)
raise AttributeError(name)
def _swig_repr(self):
try: strthis = "proxy of " + self.this.__repr__()
except: strthis = ""
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
try:
_object = object
_newclass = 1
except AttributeError:
class _object : pass
_newclass = 0
class SwigPyIterator(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, SwigPyIterator, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, SwigPyIterator, name)
def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined")
__repr__ = _swig_repr
__swig_destroy__ = _Xdmf.delete_SwigPyIterator
__del__ = lambda self : None;
def value(self): return _Xdmf.SwigPyIterator_value(self)
def incr(self, n = 1): return _Xdmf.SwigPyIterator_incr(self, n)
def decr(self, n = 1): return _Xdmf.SwigPyIterator_decr(self, n)
def distance(self, *args): return _Xdmf.SwigPyIterator_distance(self, *args)
def equal(self, *args): return _Xdmf.SwigPyIterator_equal(self, *args)
def copy(self): return _Xdmf.SwigPyIterator_copy(self)
def next(self): return _Xdmf.SwigPyIterator_next(self)
def __next__(self): return _Xdmf.SwigPyIterator___next__(self)
def previous(self): return _Xdmf.SwigPyIterator_previous(self)
def advance(self, *args): return _Xdmf.SwigPyIterator_advance(self, *args)
def __eq__(self, *args): return _Xdmf.SwigPyIterator___eq__(self, *args)
def __ne__(self, *args): return _Xdmf.SwigPyIterator___ne__(self, *args)
def __iadd__(self, *args): return _Xdmf.SwigPyIterator___iadd__(self, *args)
def __isub__(self, *args): return _Xdmf.SwigPyIterator___isub__(self, *args)
def __add__(self, *args): return _Xdmf.SwigPyIterator___add__(self, *args)
def __sub__(self, *args): return _Xdmf.SwigPyIterator___sub__(self, *args)
def __iter__(self): return self
SwigPyIterator_swigregister = _Xdmf.SwigPyIterator_swigregister
SwigPyIterator_swigregister(SwigPyIterator)
class XdmfGeometryPtr(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, XdmfGeometryPtr, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, XdmfGeometryPtr, name)
__repr__ = _swig_repr
def __deref__(self): return _Xdmf.XdmfGeometryPtr___deref__(self)
def __init__(self):
this = _Xdmf.new_XdmfGeometryPtr()
try: self.this.append(this)
except: self.this = this
__swig_destroy__ = _Xdmf.delete_XdmfGeometryPtr
__del__ = lambda self : None;
def New(self): return _Xdmf.XdmfGeometryPtr_New(self)
def printSelf(self): return _Xdmf.XdmfGeometryPtr_printSelf(self)
XdmfGeometryPtr_swigregister = _Xdmf.XdmfGeometryPtr_swigregister
XdmfGeometryPtr_swigregister(XdmfGeometryPtr)
class XdmfGridPtr(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, XdmfGridPtr, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, XdmfGridPtr, name)
__repr__ = _swig_repr
def __deref__(self): return _Xdmf.XdmfGridPtr___deref__(self)
def __init__(self):
this = _Xdmf.new_XdmfGridPtr()
try: self.this.append(this)
except: self.this = this
__swig_destroy__ = _Xdmf.delete_XdmfGridPtr
__del__ = lambda self : None;
def New(self): return _Xdmf.XdmfGridPtr_New(self)
def getGeometry(self): return _Xdmf.XdmfGridPtr_getGeometry(self)
def setGeometry(self, *args): return _Xdmf.XdmfGridPtr_setGeometry(self, *args)
def getTopology(self): return _Xdmf.XdmfGridPtr_getTopology(self)
def setTopology(self, *args): return _Xdmf.XdmfGridPtr_setTopology(self, *args)
def printSelf(self): return _Xdmf.XdmfGridPtr_printSelf(self)
XdmfGridPtr_swigregister = _Xdmf.XdmfGridPtr_swigregister
XdmfGridPtr_swigregister(XdmfGridPtr)
class XdmfObjPtr(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, XdmfObjPtr, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, XdmfObjPtr, name)
__repr__ = _swig_repr
def __deref__(self): return _Xdmf.XdmfObjPtr___deref__(self)
def __init__(self):
this = _Xdmf.new_XdmfObjPtr()
try: self.this.append(this)
except: self.this = this
__swig_destroy__ = _Xdmf.delete_XdmfObjPtr
__del__ = lambda self : None;
def New(self): return _Xdmf.XdmfObjPtr_New(self)
def printSelf(self): return _Xdmf.XdmfObjPtr_printSelf(self)
XdmfObjPtr_swigregister = _Xdmf.XdmfObjPtr_swigregister
XdmfObjPtr_swigregister(XdmfObjPtr)
class XdmfTopologyPtr(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, XdmfTopologyPtr, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, XdmfTopologyPtr, name)
__repr__ = _swig_repr
def __deref__(self): return _Xdmf.XdmfTopologyPtr___deref__(self)
def __init__(self):
this = _Xdmf.new_XdmfTopologyPtr()
try: self.this.append(this)
except: self.this = this
__swig_destroy__ = _Xdmf.delete_XdmfTopologyPtr
__del__ = lambda self : None;
def New(self): return _Xdmf.XdmfTopologyPtr_New(self)
def printSelf(self): return _Xdmf.XdmfTopologyPtr_printSelf(self)
XdmfTopologyPtr_swigregister = _Xdmf.XdmfTopologyPtr_swigregister
XdmfTopologyPtr_swigregister(XdmfTopologyPtr)
class XdmfObject(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, XdmfObject, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, XdmfObject, name)
def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined")
__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)
XdmfObject_swigregister = _Xdmf.XdmfObject_swigregister
XdmfObject_swigregister(XdmfObject)
def XdmfObject_New():
return _Xdmf.XdmfObject_New()
XdmfObject_New = _Xdmf.XdmfObject_New
class XdmfGeometry(XdmfObject):
__swig_setmethods__ = {}
for _s in [XdmfObject]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
__setattr__ = lambda self, name, value: _swig_setattr(self, XdmfGeometry, name, value)
__swig_getmethods__ = {}
for _s in [XdmfObject]: __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 printSelf(self): return _Xdmf.XdmfGeometry_printSelf(self)
XdmfGeometry_swigregister = _Xdmf.XdmfGeometry_swigregister
XdmfGeometry_swigregister(XdmfGeometry)
def XdmfGeometry_New():
return _Xdmf.XdmfGeometry_New()
XdmfGeometry_New = _Xdmf.XdmfGeometry_New
class XdmfGrid(XdmfObject):
__swig_setmethods__ = {}
for _s in [XdmfObject]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
__setattr__ = lambda self, name, value: _swig_setattr(self, XdmfGrid, name, value)
__swig_getmethods__ = {}
for _s in [XdmfObject]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
__getattr__ = lambda self, name: _swig_getattr(self, XdmfGrid, name)
def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined")
__repr__ = _swig_repr
__swig_getmethods__["New"] = lambda x: _Xdmf.XdmfGrid_New
if _newclass:New = staticmethod(_Xdmf.XdmfGrid_New)
def getGeometry(self): return _Xdmf.XdmfGrid_getGeometry(self)
def setGeometry(self, *args): return _Xdmf.XdmfGrid_setGeometry(self, *args)
def getTopology(self): return _Xdmf.XdmfGrid_getTopology(self)
def setTopology(self, *args): return _Xdmf.XdmfGrid_setTopology(self, *args)
def printSelf(self): return _Xdmf.XdmfGrid_printSelf(self)
XdmfGrid_swigregister = _Xdmf.XdmfGrid_swigregister
XdmfGrid_swigregister(XdmfGrid)
def XdmfGrid_New():
return _Xdmf.XdmfGrid_New()
XdmfGrid_New = _Xdmf.XdmfGrid_New
class XdmfTopology(XdmfObject):
__swig_setmethods__ = {}
for _s in [XdmfObject]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
__setattr__ = lambda self, name, value: _swig_setattr(self, XdmfTopology, name, value)
__swig_getmethods__ = {}
for _s in [XdmfObject]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
__getattr__ = lambda self, name: _swig_getattr(self, XdmfTopology, name)
def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined")
__repr__ = _swig_repr
__swig_getmethods__["New"] = lambda x: _Xdmf.XdmfTopology_New
if _newclass:New = staticmethod(_Xdmf.XdmfTopology_New)
def printSelf(self): return _Xdmf.XdmfTopology_printSelf(self)
XdmfTopology_swigregister = _Xdmf.XdmfTopology_swigregister
XdmfTopology_swigregister(XdmfTopology)
def XdmfTopology_New():
return _Xdmf.XdmfTopology_New()
XdmfTopology_New = _Xdmf.XdmfTopology_New
/*
* XdmfAttribute.hpp
*
* Created on: Jan 25, 2010
* Author: kleiter
*/
#ifndef XDMFATTRIBUTE_HPP_
#define XDMFATTRIBUTE_HPP_
#include "XdmfObject.hpp"
class XdmfAttribute : public XdmfObject {
XdmfNewMacro(XdmfAttribute);
};
#endif /* XDMFATTRIBUTE_HPP_ */
/*
* XdmfGrid.cpp
*
* Created on: Jan 29, 2010
* Author: kleiter
*/
#include "XdmfGeometry.hpp"
XdmfGeometry::XdmfGeometry()
{
std::cout << "Created Geometry " << this << std::endl;
}
XdmfGeometry::~XdmfGeometry()
{
std::cout << "Deleted Geometry " << this << std::endl;
}
std::string XdmfGeometry::printSelf() const
{
return "XdmfGeometry";
}
/*
* XdmfGeometry.hpp
*
* Created on: Jan 25, 2010
* Author: kleiter
*/
#ifndef XDMFGEOMETRY_HPP_
#define XDMFGEOMETRY_HPP_
#include "XdmfObject.hpp"
class XdmfGeometry : public XdmfObject {
public:
XdmfNewMacro(XdmfGeometry);
virtual std::string printSelf() const;
protected:
XdmfGeometry();
virtual ~XdmfGeometry();
private:
class Delete
{
public:
void operator()(XdmfGeometry * p) { delete p; }
};
XdmfGeometry(const XdmfGeometry&); // Not implemented.
void operator=(const XdmfGeometry&); // Not implemented.
};
#endif /* XDMFGEOMETRY_HPP_ */
/*
* XdmfGrid.cpp
*
* Created on: Jan 25, 2010
* Author: kleiter
*/
#include "XdmfGrid.hpp"
#include "XdmfGeometry.hpp"
#include "XdmfTopology.hpp"
XdmfGrid::XdmfGrid()
{
std::cout << "Created Grid " << this << std::endl;
mGeometry = XdmfGeometry::New();
mTopology = XdmfTopology::New();
}
XdmfGrid::~XdmfGrid()
{
std::cout << "Deleted Grid " << this << std::endl;
}
std::string XdmfGrid::printSelf() const
{
return "XdmfGrid containing a " + mGeometry->printSelf() + " and a " + mTopology->printSelf();
}
// Kenneth Leiter
// Xdmf Smart Pointer Test
#ifndef XDMFGRID_HPP_
#define XDMFGRID_HPP_
// Forward Declarations
class XdmfAttribute;
class XdmfAttributeVector;
class XdmfGeometry;
class XdmfTopology;
// Includes
#include "XdmfObject.hpp"
#include <vector>
class XdmfGrid : public XdmfObject {
public:
XdmfNewMacro(XdmfGrid);
// Get the XdmfGeometry for this grid
XdmfGetValueMacro(Geometry, boost::shared_ptr<XdmfGeometry>);
// Set the XdmfGeometry for this grid
XdmfSetValueMacro(Geometry, boost::shared_ptr<XdmfGeometry>);
// Get the XdmfTopology for this grid
XdmfGetValueMacro(Topology, boost::shared_ptr<XdmfTopology>);
// Set the XdmfTopology for this grid
XdmfSetValueMacro(Topology, boost::shared_ptr<XdmfTopology>);
virtual std::string printSelf() const;
protected:
XdmfGrid();
virtual ~XdmfGrid();
private:
XdmfGrid(const XdmfGrid&); // Not implemented.
void operator=(const XdmfGrid&); // Not implemented.
boost::shared_ptr<XdmfGeometry> mGeometry;
boost::shared_ptr<XdmfTopology> mTopology;
std::vector<boost::shared_ptr<XdmfAttribute> > mAttributes;
};
#endif /* XDMFGRID_HPP_ */
/*
* XdmfObject.cpp
*
* Created on: Feb 1, 2010
* Author: kleiter
*/
#include "XdmfObject.hpp"
XdmfObject::XdmfObject()
{
}
XdmfObject::~XdmfObject()
{
}
std::string XdmfObject::printSelf() const
{
return "XdmfObject";
}
std::ostream& operator<<(std::ostream& out, const XdmfObject& ob)
{
out << ob.printSelf();
return out;
}
/*
* XdmfObject.hpp
*
* Created on: Feb 1, 2010
* Author: kleiter
*/
#ifndef XDMFOBJECT_HPP_
#define XDMFOBJECT_HPP_
#include "boost/shared_ptr.hpp"
#include <iostream>
#include <ostream>
#define XdmfNewMacro(type) \
template <typename T> friend void boost::checked_delete(T * x); \
static boost::shared_ptr<type> New() \
{ \
boost::shared_ptr<type> p(new type()); \
return p; \
}
#define XdmfGetValueMacro(var,type) \
type get##var () \
{ \
return ( this->m##var ); \
}
#define XdmfSetValueMacro(var,type) \
void set##var (type _arg) \
{ \
this->m##var = _arg; \
}
class XdmfObject {
public:
XdmfNewMacro(XdmfObject);
virtual std::string printSelf() const;
protected:
XdmfObject();
virtual ~XdmfObject();
};
std::ostream& operator<<(std::ostream& out, const XdmfObject& ob);
#endif /* XDMFOBJECT_HPP_ */
This diff is collapsed.
/*
* XdmfGrid.cpp
*
* Created on: Jan 29, 2010
* Author: kleiter
*/
#include "XdmfTopology.hpp"
XdmfTopology::XdmfTopology()
{
std::cout << "Created Topology " << this << std::endl;
}
XdmfTopology::~XdmfTopology()
{
std::cout << "Deleted Topology " << this << std::endl;
}
std::string XdmfTopology::printSelf() const
{
return "XdmfTopology";
}
/*
* XdmfTopology.hpp
*
* Created on: Jan 25, 2010
* Author: kleiter
*/
#ifndef XDMFTOPOLOGY_HPP_
#define XDMFTOPOLOGY_HPP_
#include "XdmfObject.hpp"
class XdmfTopology : public XdmfObject {
public:
XdmfNewMacro(XdmfTopology);
virtual std::string printSelf() const;
protected:
XdmfTopology();
virtual ~XdmfTopology();
private: