Commit 851768ca authored by Kenneth Leiter's avatar Kenneth Leiter

Major updates to C interface.

Previous implementation of C interface passed raw pointers
up to user and it was unclear and inconsistent who owned the pointer
leading to bugs. The previous implementation lead to creation
of many copy constructors, many of which had bugs.

Now we pass opaque pointers to C which the user is *always* responsible for
freeing.

Remove broken copy constructors.

Update C tests so that all pass valgrind memory leak checks.
parent 701d36d4
......@@ -137,9 +137,11 @@
# define XDMFCORE_EXPORT
# define XDMFDSM_EXPORT
# define XDMF_EXPORT
# define XDMFUTILS_EXPORT
# define XDMFCORE_TEMPLATE
# define XDMFDSM_TEMPLATE
# define XDMF_TEMPLATE
# define XDMFUTILS_TEMPLATE
#else
/* Used to export/import from the dlls */
# undef XDMFCORE_EXPORT
......@@ -159,6 +161,12 @@
# define XDMF_EXPORT __declspec(dllimport)
# define XDMF_TEMPLATE extern
# endif /* XDMF_EXPORTS */
# undef XDMFUTILS_EXPORT
# define XDMFUTILS_EXPORT __declspec(dllimport)
# undef XDMFUTILS_TEMPLATE
# define XDMFUTILS_TEMPLATE extern
#endif
/* Compiler Warnings */
......@@ -178,8 +186,10 @@
#define XDMFCORE_EXPORT
#define XDMFDSM_EXPORT
#define XDMF_EXPORT
#define XDMFUTILS_EXPORT
#define XDMFCORE_TEMPLATE
#define XDMFDSM_TEMPLATE
#define XDMF_TEMPLATE
#define XDMFUTILS_TEMPLATE
#endif /* _WIN32 */
#endif /* _XDMF_HPP */
......@@ -37,11 +37,6 @@ XdmfAggregate::XdmfAggregate()
{
}
XdmfAggregate::XdmfAggregate(XdmfAggregate & refAggregate) :
XdmfArrayReference(refAggregate)
{
}
XdmfAggregate::~XdmfAggregate()
{
}
......@@ -213,57 +208,53 @@ XdmfAggregate::traverse(const shared_ptr<XdmfBaseVisitor> visitor)
XDMFAGGREGATE * XdmfAggregateNew()
{
try
{
shared_ptr<XdmfAggregate> generatedAggregate = XdmfAggregate::New();
return (XDMFAGGREGATE *)((void *)(new XdmfAggregate(*generatedAggregate.get())));
}
catch (...)
{
shared_ptr<XdmfAggregate> generatedAggregate = XdmfAggregate::New();
return (XDMFAGGREGATE *)((void *)(new XdmfAggregate(*generatedAggregate.get())));
}
shared_ptr<XdmfAggregate> * p = new shared_ptr<XdmfAggregate>(XdmfAggregate::New());
return (XDMFAGGREGATE *) p;
}
XDMFARRAY *
XdmfAggregateGetArray(XDMFAGGREGATE * aggregate, unsigned int index)
{
return (XDMFARRAY *)((void *)(((XdmfAggregate *)(aggregate))->getArray(index).get()));
shared_ptr<XdmfAggregate> & refAggregate = *(shared_ptr<XdmfAggregate> *)(aggregate);
shared_ptr<XdmfArray> * p = new shared_ptr<XdmfArray>(refAggregate->getArray(index));
return (XDMFARRAY *) p;
}
XDMFARRAY *
XdmfAggregateGetArrayByName(XDMFAGGREGATE * aggregate, char * name)
{
return (XDMFARRAY *)((void *)(((XdmfAggregate *)(aggregate))->getArray(name).get()));
shared_ptr<XdmfAggregate> & refAggregate = *(shared_ptr<XdmfAggregate> *)(aggregate);
shared_ptr<XdmfArray> * p = new shared_ptr<XdmfArray>(refAggregate->getArray(name));
return (XDMFARRAY *) p;
}
unsigned int
XdmfAggregateGetNumberArrays(XDMFAGGREGATE * aggregate)
{
return ((XdmfAggregate *)(aggregate))->getNumberArrays();
shared_ptr<XdmfAggregate> & refAggregate = *(shared_ptr<XdmfAggregate> *)(aggregate);
return refAggregate->getNumberArrays();
}
void
XdmfAggregateInsertArray(XDMFAGGREGATE * aggregate, XDMFARRAY * array, int transferOwnership)
{
if (transferOwnership) {
((XdmfAggregate *)(aggregate))->insert(shared_ptr<XdmfArray>((XdmfArray *)array));
}
else {
((XdmfAggregate *)(aggregate))->insert(shared_ptr<XdmfArray>((XdmfArray *)array, XdmfNullDeleter()));
}
shared_ptr<XdmfAggregate> & refAggregate = *(shared_ptr<XdmfAggregate> *)(aggregate);
shared_ptr<XdmfArray> & refArray = *(shared_ptr<XdmfArray> *)(array);
refAggregate->insert(refArray);
}
void
XdmfAggregateRemoveArray(XDMFAGGREGATE * aggregate, unsigned int index)
{
((XdmfAggregate *)(aggregate))->removeArray(index);
shared_ptr<XdmfAggregate> & refAggregate = *(shared_ptr<XdmfAggregate> *)(aggregate);
refAggregate->removeArray(index);
}
void
XdmfAggregateRemoveArrayByName(XDMFAGGREGATE * aggregate, char * name)
{
((XdmfAggregate *)(aggregate))->removeArray(name);
shared_ptr<XdmfAggregate> & refAggregate = *(shared_ptr<XdmfAggregate> *)(aggregate);
refAggregate->removeArray(name);
}
// C Wrappers for parent classes are generated by macros
......
......@@ -159,8 +159,6 @@ public:
void traverse(const shared_ptr<XdmfBaseVisitor> visitor);
XdmfAggregate(XdmfAggregate&);
protected:
XdmfAggregate();
......
......@@ -41,14 +41,6 @@ XdmfAttribute::XdmfAttribute() :
{
}
XdmfAttribute::XdmfAttribute(XdmfAttribute & refAttribute) :
XdmfArray(refAttribute),
mCenter(refAttribute.mCenter),
mName(refAttribute.mName),
mType(refAttribute.mType)
{
}
XdmfAttribute::~XdmfAttribute()
{
}
......@@ -149,33 +141,27 @@ XdmfAttribute::setType(const shared_ptr<const XdmfAttributeType> type)
XDMFATTRIBUTE * XdmfAttributeNew()
{
try
{
shared_ptr<XdmfAttribute> generatedAttribute = XdmfAttribute::New();
return (XDMFATTRIBUTE *)((void *)(new XdmfAttribute(*generatedAttribute.get())));
}
catch (...)
{
shared_ptr<XdmfAttribute> generatedAttribute = XdmfAttribute::New();
return (XDMFATTRIBUTE *)((void *)(new XdmfAttribute(*generatedAttribute.get())));
}
shared_ptr<XdmfAttribute> * p = new shared_ptr<XdmfAttribute>(XdmfAttribute::New());
return (XDMFATTRIBUTE *) p;
}
int XdmfAttributeGetCenter(XDMFATTRIBUTE * attribute)
{
if (((XdmfAttribute *)attribute)->getCenter() == XdmfAttributeCenter::Grid()) {
shared_ptr<XdmfAttribute> & refAttribute = *(shared_ptr<XdmfAttribute> *)(attribute);
const shared_ptr<const XdmfAttributeCenter> attributeCenter = refAttribute->getCenter();
if (attributeCenter == XdmfAttributeCenter::Grid()) {
return XDMF_ATTRIBUTE_CENTER_GRID;
}
else if (((XdmfAttribute *)attribute)->getCenter() == XdmfAttributeCenter::Cell()) {
else if (attributeCenter == XdmfAttributeCenter::Cell()) {
return XDMF_ATTRIBUTE_CENTER_CELL;
}
else if (((XdmfAttribute *)attribute)->getCenter() == XdmfAttributeCenter::Face()) {
else if (attributeCenter == XdmfAttributeCenter::Face()) {
return XDMF_ATTRIBUTE_CENTER_FACE;
}
else if (((XdmfAttribute *)attribute)->getCenter() == XdmfAttributeCenter::Edge()) {
else if (attributeCenter == XdmfAttributeCenter::Edge()) {
return XDMF_ATTRIBUTE_CENTER_EDGE;
}
else if (((XdmfAttribute *)attribute)->getCenter() == XdmfAttributeCenter::Node()) {
else if (attributeCenter == XdmfAttributeCenter::Node()) {
return XDMF_ATTRIBUTE_CENTER_NODE;
}
else {
......@@ -185,25 +171,27 @@ int XdmfAttributeGetCenter(XDMFATTRIBUTE * attribute)
int XdmfAttributeGetType(XDMFATTRIBUTE * attribute)
{
if (((XdmfAttribute *)attribute)->getType() == XdmfAttributeType::Scalar()) {
shared_ptr<XdmfAttribute> & refAttribute = *(shared_ptr<XdmfAttribute> *)(attribute);
const shared_ptr<const XdmfAttributeType> attributeType = refAttribute->getType();
if (attributeType == XdmfAttributeType::Scalar()) {
return XDMF_ATTRIBUTE_TYPE_SCALAR;
}
else if (((XdmfAttribute *)attribute)->getType() == XdmfAttributeType::Vector()) {
else if (attributeType == XdmfAttributeType::Vector()) {
return XDMF_ATTRIBUTE_TYPE_VECTOR;
}
else if (((XdmfAttribute *)attribute)->getType() == XdmfAttributeType::Tensor()) {
else if (attributeType == XdmfAttributeType::Tensor()) {
return XDMF_ATTRIBUTE_TYPE_TENSOR;
}
else if (((XdmfAttribute *)attribute)->getType() == XdmfAttributeType::Matrix()) {
else if (attributeType == XdmfAttributeType::Matrix()) {
return XDMF_ATTRIBUTE_TYPE_MATRIX;
}
else if (((XdmfAttribute *)attribute)->getType() == XdmfAttributeType::Tensor6()) {
else if (attributeType == XdmfAttributeType::Tensor6()) {
return XDMF_ATTRIBUTE_TYPE_TENSOR6;
}
else if (((XdmfAttribute *)attribute)->getType() == XdmfAttributeType::GlobalId()) {
else if (attributeType == XdmfAttributeType::GlobalId()) {
return XDMF_ATTRIBUTE_TYPE_GLOBALID;
}
else if (((XdmfAttribute *)attribute)->getType() == XdmfAttributeType::NoAttributeType()) {
else if (attributeType == XdmfAttributeType::NoAttributeType()) {
return XDMF_ATTRIBUTE_TYPE_NOTYPE;
}
else {
......@@ -214,26 +202,27 @@ int XdmfAttributeGetType(XDMFATTRIBUTE * attribute)
void XdmfAttributeSetCenter(XDMFATTRIBUTE * attribute, int center, int * status)
{
XDMF_ERROR_WRAP_START(status)
shared_ptr<XdmfAttribute> & refAttribute = *(shared_ptr<XdmfAttribute> *)(attribute);
switch(center) {
case XDMF_ATTRIBUTE_CENTER_GRID:
((XdmfAttribute *)attribute)->setCenter(XdmfAttributeCenter::Grid());
break;
case XDMF_ATTRIBUTE_CENTER_CELL:
((XdmfAttribute *)attribute)->setCenter(XdmfAttributeCenter::Cell());
break;
case XDMF_ATTRIBUTE_CENTER_FACE:
((XdmfAttribute *)attribute)->setCenter(XdmfAttributeCenter::Face());
break;
case XDMF_ATTRIBUTE_CENTER_EDGE:
((XdmfAttribute *)attribute)->setCenter(XdmfAttributeCenter::Edge());
break;
case XDMF_ATTRIBUTE_CENTER_NODE:
((XdmfAttribute *)attribute)->setCenter(XdmfAttributeCenter::Node());
break;
default:
XdmfError::message(XdmfError::FATAL,
"Error: Invalid Attribute Center: Code " + center);
break;
case XDMF_ATTRIBUTE_CENTER_GRID:
refAttribute->setCenter(XdmfAttributeCenter::Grid());
break;
case XDMF_ATTRIBUTE_CENTER_CELL:
refAttribute->setCenter(XdmfAttributeCenter::Cell());
break;
case XDMF_ATTRIBUTE_CENTER_FACE:
refAttribute->setCenter(XdmfAttributeCenter::Face());
break;
case XDMF_ATTRIBUTE_CENTER_EDGE:
refAttribute->setCenter(XdmfAttributeCenter::Edge());
break;
case XDMF_ATTRIBUTE_CENTER_NODE:
refAttribute->setCenter(XdmfAttributeCenter::Node());
break;
default:
XdmfError::message(XdmfError::FATAL,
"Error: Invalid Attribute Center: Code " + center);
break;
}
XDMF_ERROR_WRAP_END(status)
}
......@@ -241,32 +230,33 @@ void XdmfAttributeSetCenter(XDMFATTRIBUTE * attribute, int center, int * status)
void XdmfAttributeSetType(XDMFATTRIBUTE * attribute, int type, int * status)
{
XDMF_ERROR_WRAP_START(status)
shared_ptr<XdmfAttribute> & refAttribute = *(shared_ptr<XdmfAttribute> *)(attribute);
switch(type) {
case XDMF_ATTRIBUTE_TYPE_SCALAR:
((XdmfAttribute *)attribute)->setType(XdmfAttributeType::Scalar());
break;
case XDMF_ATTRIBUTE_TYPE_VECTOR:
((XdmfAttribute *)attribute)->setType(XdmfAttributeType::Vector());
break;
case XDMF_ATTRIBUTE_TYPE_TENSOR:
((XdmfAttribute *)attribute)->setType(XdmfAttributeType::Tensor());
break;
case XDMF_ATTRIBUTE_TYPE_MATRIX:
((XdmfAttribute *)attribute)->setType(XdmfAttributeType::Matrix());
break;
case XDMF_ATTRIBUTE_TYPE_TENSOR6:
((XdmfAttribute *)attribute)->setType(XdmfAttributeType::Tensor6());
break;
case XDMF_ATTRIBUTE_TYPE_GLOBALID:
((XdmfAttribute *)attribute)->setType(XdmfAttributeType::GlobalId());
break;
case XDMF_ATTRIBUTE_TYPE_NOTYPE:
((XdmfAttribute *)attribute)->setType(XdmfAttributeType::NoAttributeType());
break;
default:
XdmfError::message(XdmfError::FATAL,
"Error: Invalid Attribute Type: Code " + type);
break;
case XDMF_ATTRIBUTE_TYPE_SCALAR:
refAttribute->setType(XdmfAttributeType::Scalar());
break;
case XDMF_ATTRIBUTE_TYPE_VECTOR:
refAttribute->setType(XdmfAttributeType::Vector());
break;
case XDMF_ATTRIBUTE_TYPE_TENSOR:
refAttribute->setType(XdmfAttributeType::Tensor());
break;
case XDMF_ATTRIBUTE_TYPE_MATRIX:
refAttribute->setType(XdmfAttributeType::Matrix());
break;
case XDMF_ATTRIBUTE_TYPE_TENSOR6:
refAttribute->setType(XdmfAttributeType::Tensor6());
break;
case XDMF_ATTRIBUTE_TYPE_GLOBALID:
refAttribute->setType(XdmfAttributeType::GlobalId());
break;
case XDMF_ATTRIBUTE_TYPE_NOTYPE:
refAttribute->setType(XdmfAttributeType::NoAttributeType());
break;
default:
XdmfError::message(XdmfError::FATAL,
"Error: Invalid Attribute Type: Code " + type);
break;
}
XDMF_ERROR_WRAP_END(status)
}
......
......@@ -238,8 +238,6 @@ public:
*/
void setType(const shared_ptr<const XdmfAttributeType> type);
XdmfAttribute(XdmfAttribute &);
protected:
XdmfAttribute();
......
......@@ -24,9 +24,4 @@
#ifndef XDMFCONFIG_HPP_
#define XDMFCONFIG_HPP_
#cmakedefine BUILD_SHARED
#ifndef BUILD_SHARED
# define XDMFSTATIC
#endif
#endif
......@@ -24,15 +24,15 @@
#include <cmath>
#include "XdmfArray.hpp"
#include "XdmfCurvilinearGrid.hpp"
#include "XdmfError.hpp"
#include "XdmfGeometry.hpp"
#include "XdmfTopology.hpp"
#include "XdmfTopologyType.hpp"
#include "XdmfError.hpp"
/**
* PIMPL
*/
class XdmfCurvilinearGrid::XdmfCurvilinearGridImpl : public XdmfGridImpl {
class XdmfCurvilinearGrid::XdmfCurvilinearGridImpl {
public:
......@@ -194,15 +194,10 @@ public:
XdmfCurvilinearGridImpl(const shared_ptr<XdmfArray> numPoints) :
mDimensions(numPoints)
{
mGridType ="Curvilinear";
}
XdmfGridImpl * duplicate()
{
return new XdmfCurvilinearGridImpl(mDimensions);
}
shared_ptr<XdmfArray> mDimensions;
};
shared_ptr<XdmfCurvilinearGrid>
......@@ -240,15 +235,9 @@ XdmfCurvilinearGrid::New(const shared_ptr<XdmfArray> numPoints)
XdmfCurvilinearGrid::XdmfCurvilinearGrid(const shared_ptr<XdmfArray> numPoints) :
XdmfGrid(XdmfGeometry::New(),
XdmfCurvilinearGridImpl::XdmfTopologyCurvilinear::New(this))
{
mImpl = new XdmfCurvilinearGridImpl(numPoints);
}
XdmfCurvilinearGrid::XdmfCurvilinearGrid(XdmfCurvilinearGrid & refGrid) :
XdmfGrid(refGrid)
XdmfCurvilinearGridImpl::XdmfTopologyCurvilinear::New(this)),
mImpl(new XdmfCurvilinearGridImpl(numPoints))
{
mTopology = XdmfCurvilinearGridImpl::XdmfTopologyCurvilinear::New(this);
}
XdmfCurvilinearGrid::~XdmfCurvilinearGrid()
......@@ -265,7 +254,8 @@ void
XdmfCurvilinearGrid::copyGrid(shared_ptr<XdmfGrid> sourceGrid)
{
XdmfGrid::copyGrid(sourceGrid);
if (shared_ptr<XdmfCurvilinearGrid> classedGrid = shared_dynamic_cast<XdmfCurvilinearGrid>(sourceGrid))
if (shared_ptr<XdmfCurvilinearGrid> classedGrid =
shared_dynamic_cast<XdmfCurvilinearGrid>(sourceGrid))
{
// Copy stucture from read grid to this grid
this->setGeometry(classedGrid->getGeometry());
......@@ -283,7 +273,7 @@ XdmfCurvilinearGrid::getDimensions()
shared_ptr<const XdmfArray>
XdmfCurvilinearGrid::getDimensions() const
{
return ((XdmfCurvilinearGridImpl *)mImpl)->mDimensions;
return mImpl->mDimensions;
}
shared_ptr<XdmfGeometry>
......@@ -316,17 +306,16 @@ XdmfCurvilinearGrid::read()
{
if (mGridController)
{
if (shared_ptr<XdmfCurvilinearGrid> grid = shared_dynamic_cast<XdmfCurvilinearGrid>(mGridController->read()))
{
if (shared_ptr<XdmfCurvilinearGrid> grid =
shared_dynamic_cast<XdmfCurvilinearGrid>(mGridController->read())) {
// Copy stucture from read grid to this grid
copyGrid(grid);
}
else if (shared_ptr<XdmfGrid> grid = shared_dynamic_cast<XdmfGrid>(mGridController->read()))
{
else if (shared_ptr<XdmfGrid> grid =
shared_dynamic_cast<XdmfGrid>(mGridController->read())) {
XdmfError::message(XdmfError::FATAL, "Error: Grid Type Mismatch");
}
else
{
else {
XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Reference");
}
}
......@@ -343,7 +332,7 @@ XdmfCurvilinearGrid::release()
void
XdmfCurvilinearGrid::setDimensions(const shared_ptr<XdmfArray> dimensions)
{
((XdmfCurvilinearGridImpl *)mImpl)->mDimensions = dimensions;
mImpl->mDimensions = dimensions;
this->setIsChanged(true);
}
......@@ -359,49 +348,30 @@ XdmfCurvilinearGrid::setGeometry(const shared_ptr<XdmfGeometry> geometry)
XDMFCURVILINEARGRID * XdmfCurvilinearGridNew2D(unsigned int xNumPoints,
unsigned int yNumPoints)
{
try
{
shared_ptr<XdmfCurvilinearGrid> generatedGrid = XdmfCurvilinearGrid::New(xNumPoints, yNumPoints);
return (XDMFCURVILINEARGRID *)((void *)((XdmfItem *)(new XdmfCurvilinearGrid(*generatedGrid.get()))));
}
catch (...)
{
shared_ptr<XdmfCurvilinearGrid> generatedGrid = XdmfCurvilinearGrid::New(xNumPoints, yNumPoints);
return (XDMFCURVILINEARGRID *)((void *)((XdmfItem *)(new XdmfCurvilinearGrid(*generatedGrid.get()))));
}
shared_ptr<XdmfCurvilinearGrid> * p =
new shared_ptr<XdmfCurvilinearGrid>(XdmfCurvilinearGrid::New(xNumPoints,
yNumPoints));
return (XDMFCURVILINEARGRID *) p;
}
XDMFCURVILINEARGRID * XdmfCurvilinearGridNew3D(unsigned int xNumPoints,
unsigned int yNumPoints,
unsigned int zNumPoints)
{
try
{
shared_ptr<XdmfCurvilinearGrid> generatedGrid = XdmfCurvilinearGrid::New(xNumPoints, yNumPoints, zNumPoints);
return (XDMFCURVILINEARGRID *)((void *)((XdmfItem *)(new XdmfCurvilinearGrid(*generatedGrid.get()))));
}
catch (...)
{
shared_ptr<XdmfCurvilinearGrid> generatedGrid = XdmfCurvilinearGrid::New(xNumPoints, yNumPoints, zNumPoints);
return (XDMFCURVILINEARGRID *)((void *)((XdmfItem *)(new XdmfCurvilinearGrid(*generatedGrid.get()))));
}
shared_ptr<XdmfCurvilinearGrid> * p =
new shared_ptr<XdmfCurvilinearGrid>(XdmfCurvilinearGrid::New(xNumPoints,
yNumPoints,
zNumPoints));
return (XDMFCURVILINEARGRID *) p;
}
XDMFCURVILINEARGRID * XdmfCurvilinearGridNew(XDMFARRAY * numPoints, int * status)
{
XDMF_ERROR_WRAP_START(status)
try
{
shared_ptr<XdmfArray> tempArray = shared_ptr<XdmfArray>((XdmfArray *)numPoints, XdmfNullDeleter());
shared_ptr<XdmfCurvilinearGrid> generatedGrid = XdmfCurvilinearGrid::New(tempArray);
return (XDMFCURVILINEARGRID *)((void *)((XdmfItem *)(new XdmfCurvilinearGrid(*generatedGrid.get()))));
}
catch (...)
{
shared_ptr<XdmfArray> tempArray = shared_ptr<XdmfArray>((XdmfArray *)numPoints, XdmfNullDeleter());
shared_ptr<XdmfCurvilinearGrid> generatedGrid = XdmfCurvilinearGrid::New(tempArray);
return (XDMFCURVILINEARGRID *)((void *)((XdmfItem *)(new XdmfCurvilinearGrid(*generatedGrid.get()))));
}
shared_ptr<XdmfArray> & refNumPoints = *(shared_ptr<XdmfArray> *)(numPoints);
shared_ptr<XdmfCurvilinearGrid> * p =
new shared_ptr<XdmfCurvilinearGrid>(XdmfCurvilinearGrid::New(refNumPoints));
return (XDMFCURVILINEARGRID *) p;
XDMF_ERROR_WRAP_END(status)
return NULL;
}
......@@ -409,56 +379,34 @@ XDMFCURVILINEARGRID * XdmfCurvilinearGridNew(XDMFARRAY * numPoints, int * status
XDMFARRAY * XdmfCurvilinearGridGetDimensions(XDMFCURVILINEARGRID * grid, int * status)
{
XDMF_ERROR_WRAP_START(status)
try
{
XdmfItem * classedPointer = (XdmfItem *)grid;
XdmfCurvilinearGrid * gridPointer = dynamic_cast<XdmfCurvilinearGrid *>(classedPointer);
shared_ptr<XdmfArray> generatedArray = gridPointer->getDimensions();
return (XDMFARRAY *)((void *)generatedArray.get());
}
catch (...)
{
XdmfItem * classedPointer = (XdmfItem *)grid;
XdmfCurvilinearGrid * gridPointer = dynamic_cast<XdmfCurvilinearGrid *>(classedPointer);
shared_ptr<XdmfArray> generatedArray = gridPointer->getDimensions();
return (XDMFARRAY *)((void *)generatedArray.get());
}
shared_ptr<XdmfCurvilinearGrid> & refGrid = *(shared_ptr<XdmfCurvilinearGrid> *)(grid);
shared_ptr<XdmfArray> * dim = new shared_ptr<XdmfArray>(refGrid->getDimensions());
return (XDMFARRAY *) dim;
XDMF_ERROR_WRAP_END(status)
return NULL;
}
XDMFGEOMETRY * XdmfCurvilinearGridGetGeometry(XDMFCURVILINEARGRID * grid)
{
XdmfItem * classedPointer = (XdmfItem *)grid;
XdmfCurvilinearGrid * gridPointer = dynamic_cast<XdmfCurvilinearGrid *>(classedPointer);
shared_ptr<XdmfGeometry> generatedGeometry = gridPointer->getGeometry();
return (XDMFGEOMETRY *)((void *)generatedGeometry.get());
shared_ptr<XdmfCurvilinearGrid> & refGrid = *(shared_ptr<XdmfCurvilinearGrid> *)(grid);
shared_ptr<XdmfGeometry> * geometry = new shared_ptr<XdmfGeometry>(refGrid->getGeometry());
return (XDMFGEOMETRY *) geometry;
}
void XdmfCurvilinearGridSetDimensions(XDMFCURVILINEARGRID * grid, XDMFARRAY * dimensions, int passControl, int * status)
{
XDMF_ERROR_WRAP_START(status)
XdmfItem * classedPointer = (XdmfItem *)grid;
XdmfCurvilinearGrid * gridPointer = dynamic_cast<XdmfCurvilinearGrid *>(classedPointer);
if (passControl) {
gridPointer->setDimensions(shared_ptr<XdmfArray>((XdmfArray *)dimensions));
}
else {
gridPointer->setDimensions(shared_ptr<XdmfArray>((XdmfArray *)dimensions, XdmfNullDeleter()));
}
shared_ptr<XdmfCurvilinearGrid> & refGrid = *(shared_ptr<XdmfCurvilinearGrid> *)(grid);
shared_ptr<XdmfArray> & refDimensions = *(shared_ptr<XdmfArray> *)(dimensions);
refGrid->setDimensions(refDimensions);
XDMF_ERROR_WRAP_END(status)
}
void XdmfCurvilinearGridSetGeometry(XDMFCURVILINEARGRID * grid, XDMFGEOMETRY * geometry, int passControl)
{
XdmfItem * classedPointer = (XdmfItem *)grid;
XdmfCurvilinearGrid * gridPointer = dynamic_cast<XdmfCurvilinearGrid *>(classedPointer);
if (passControl) {
gridPointer->setGeometry(shared_ptr<XdmfGeometry>((XdmfGeometry *)geometry));
}
else {
gridPointer->setGeometry(shared_ptr<XdmfGeometry>((XdmfGeometry *)geometry, XdmfNullDeleter()));
}
shared_ptr<XdmfCurvilinearGrid> & refGrid = *(shared_ptr<XdmfCurvilinearGrid> *)(grid);
shared_ptr<XdmfGeometry> & refGeometry = *(shared_ptr<XdmfGeometry> *)(geometry);
refGrid->setGeometry(refGeometry);
}
XDMF_ITEM_C_CHILD_WRAPPER(XdmfCurvilinearGrid, XDMFCURVILINEARGRID)
......
......@@ -282,8 +282,6 @@ public:
*/
void setGeometry(const shared_ptr<XdmfGeometry> geometry);
XdmfCurvilinearGrid(XdmfCurvilinearGrid &);
protected:
XdmfCurvilinearGrid(const shared_ptr<XdmfArray> numPoints);
......@@ -299,11 +297,15 @@ private:
* PIMPL
*/
class XdmfCurvilinearGridImpl;
XdmfCurvilinearGrid(const XdmfCurvilinearGrid &); // Not implemented.
void operator=(const XdmfCurvilinearGrid &); // Not implemented.
void
copyGrid(shared_ptr<XdmfGrid> sourceGrid);
XdmfCurvilinearGridImpl * mImpl;
};
#endif
......
This diff is collapsed.
This diff is collapsed.
......@@ -40,13 +40,6 @@ XdmfGeometry::XdmfGeometry() :
{
}
XdmfGeometry::XdmfGeometry(XdmfGeometry & refGeometry) :
XdmfArray(refGeometry),
mType(refGeometry.mType),
mOrigin(refGeometry.mOrigin)
{
}
XdmfGeometry::~XdmfGeometry()
{
}
......@@ -235,69 +228,53 @@ XdmfGeometry::setType(const shared_ptr<const XdmfGeometryType> type)
XDMFGEOMETRY * XdmfGeometryNew()
{
try
{
shared_ptr<XdmfGeometry> generatedGeometry = XdmfGeometry::New();
return (XDMFGEOMETRY *)((void *)(new XdmfGeometry(*generatedGeometry.get())));
}
catch (...)
{
shared_ptr<XdmfGeometry> generatedGeometry = XdmfGeometry::New();
return (XDMFGEOMETRY *)((void *)(new XdmfGeometry(*generatedGeometry.get())));
}
shared_ptr<XdmfGeometry> * p = new shared_ptr<XdmfGeometry>(XdmfGeometry::New());
return (XDMFGEOMETRY *) p;
}
unsigned int XdmfGeometryGetNumberPoints(XDMFGEOMETRY * geometry)
{
return ((XdmfGeometry *) geometry)->getNumberPoints();
shared_ptr<XdmfGeometry> & refGeometry = *(shared_ptr<XdmfGeometry> *)(geometry);
return refGeometry->getNumberPoints();
}
double *
XdmfGeometryGetOrigin(XDMFGEOMETRY * geometry)
{
try
{
std::vector<double> tempVector = ((XdmfGeometry *)(geometry))->getOrigin();
unsigned int returnSize = tempVector.size();
double * returnArray = new double[returnSize]();
for (unsigned int i = 0; i < returnSize; ++i) {
returnArray[i] = tempVector[i];
}
return returnArray;
}
catch (...)
{
std::vector<double> tempVector = ((XdmfGeometry *)(geometry))->getOrigin();
unsigned int returnSize = tempVector.size();
double * returnArray = new double[returnSize]();
for (unsigned int i = 0; i < returnSize; ++i) {
returnArray[i] = tempVector[i];
}
return returnArray;
shared_ptr<XdmfGeometry> & refGeometry = *(shared_ptr<XdmfGeometry> *)(geometry);
std::vector<double> tempVector = refGeometry->getOrigin();