summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/astra/Config.h3
-rw-r--r--include/astra/VolumeGeometry2D.h6
-rw-r--r--include/astra/VolumeGeometry3D.h6
-rw-r--r--include/astra/XMLDocument.h3
-rw-r--r--matlab/mex/astra_mex_data2d_c.cpp4
-rw-r--r--matlab/mex/astra_mex_data3d_c.cpp2
-rw-r--r--matlab/mex/mexHelpFunctions.cpp107
-rw-r--r--matlab/mex/mexHelpFunctions.h5
-rw-r--r--src/Config.cpp12
-rw-r--r--src/VolumeGeometry2D.cpp20
-rw-r--r--src/VolumeGeometry3D.cpp23
-rw-r--r--src/XMLDocument.cpp8
12 files changed, 160 insertions, 39 deletions
diff --git a/include/astra/Config.h b/include/astra/Config.h
index 647462b..9893c90 100644
--- a/include/astra/Config.h
+++ b/include/astra/Config.h
@@ -31,6 +31,7 @@ $Id$
#include "Globals.h"
#include "XMLNode.h"
+#include "XMLDocument.h"
#include <set>
@@ -46,6 +47,8 @@ struct _AstraExport Config {
Config(XMLNode* _self);
~Config();
+ void initialize(std::string rootname);
+
XMLNode* self;
XMLNode* global;
};
diff --git a/include/astra/VolumeGeometry2D.h b/include/astra/VolumeGeometry2D.h
index fa0528d..28703d5 100644
--- a/include/astra/VolumeGeometry2D.h
+++ b/include/astra/VolumeGeometry2D.h
@@ -205,6 +205,12 @@ public:
*/
virtual bool isEqual(CVolumeGeometry2D*) const;
+ /** Get all settings in a Config object.
+ *
+ * @return Configuration Object.
+ */
+ virtual Config* getConfiguration() const;
+
/** Get the number of columns in the volume grid.
*
* @return Number of columns in the volume grid.
diff --git a/include/astra/VolumeGeometry3D.h b/include/astra/VolumeGeometry3D.h
index d5c8fff..ff94844 100644
--- a/include/astra/VolumeGeometry3D.h
+++ b/include/astra/VolumeGeometry3D.h
@@ -246,6 +246,12 @@ public:
*/
virtual bool isEqual(const CVolumeGeometry3D*) const;
+ /** Get all settings in a Config object.
+ *
+ * @return Configuration Object.
+ */
+ virtual Config* getConfiguration() const;
+
/** Get the number of columns in the volume grid.
*
* @return Number of columns in the volume grid.
diff --git a/include/astra/XMLDocument.h b/include/astra/XMLDocument.h
index c6f1b9a..869e1a3 100644
--- a/include/astra/XMLDocument.h
+++ b/include/astra/XMLDocument.h
@@ -86,6 +86,9 @@ public:
*/
void saveToFile(string sFilename);
+ /** convert and XML DOM tree to a string
+ */
+ std::string toString();
private:
diff --git a/matlab/mex/astra_mex_data2d_c.cpp b/matlab/mex/astra_mex_data2d_c.cpp
index bd70e1b..d07a13a 100644
--- a/matlab/mex/astra_mex_data2d_c.cpp
+++ b/matlab/mex/astra_mex_data2d_c.cpp
@@ -399,7 +399,9 @@ void astra_mex_data2d_get_geometry(int nlhs, mxArray* plhs[], int nrhs, const mx
}
else if (pDataObject->getType() == CFloat32Data2D::VOLUME) {
CFloat32VolumeData2D* pDataObject2 = dynamic_cast<CFloat32VolumeData2D*>(pDataObject);
- plhs[0] = createVolumeGeometryStruct(pDataObject2->getGeometry());
+ plhs[0] = config2struct(pDataObject2->getGeometry()->getConfiguration());
+ // mexErrMsgTxt(pDataObject2->getGeometry()->getConfiguration()->self->toString().c_str());
+ // plhs[0] = createVolumeGeometryStruct(pDataObject2->getGeometry());
}
}
}
diff --git a/matlab/mex/astra_mex_data3d_c.cpp b/matlab/mex/astra_mex_data3d_c.cpp
index 84bc0a4..5abdf50 100644
--- a/matlab/mex/astra_mex_data3d_c.cpp
+++ b/matlab/mex/astra_mex_data3d_c.cpp
@@ -300,7 +300,7 @@ void astra_mex_data3d_get_geometry(int nlhs, mxArray* plhs[], int nrhs, const mx
}
else if (pDataObject->getType() == CFloat32Data3D::VOLUME) {
CFloat32VolumeData3DMemory* pDataObject2 = dynamic_cast<CFloat32VolumeData3DMemory*>(pDataObject);
- plhs[0] = createVolumeGeometryStruct(pDataObject2->getGeometry());
+ plhs[0] = config2struct(pDataObject2->getGeometry()->getConfiguration());
}
}
diff --git a/matlab/mex/mexHelpFunctions.cpp b/matlab/mex/mexHelpFunctions.cpp
index 654f5c6..b57f27f 100644
--- a/matlab/mex/mexHelpFunctions.cpp
+++ b/matlab/mex/mexHelpFunctions.cpp
@@ -447,46 +447,46 @@ astra::CVolumeGeometry2D* parseVolumeGeometryStruct(const mxArray* prhs)
//-----------------------------------------------------------------------------------------
// create 2D volume geometry struct
-mxArray* createVolumeGeometryStruct(astra::CVolumeGeometry2D* _pVolGeom)
-{
- std::map<std::string, mxArray*> mGeometryInfo;
+// mxArray* createVolumeGeometryStruct(astra::CVolumeGeometry2D* _pVolGeom)
+// {
+// std::map<std::string, mxArray*> mGeometryInfo;
- mGeometryInfo["GridColCount"] = mxCreateDoubleScalar(_pVolGeom->getGridColCount());
- mGeometryInfo["GridRowCount"] = mxCreateDoubleScalar(_pVolGeom->getGridRowCount());
+// mGeometryInfo["GridColCount"] = mxCreateDoubleScalar(_pVolGeom->getGridColCount());
+// mGeometryInfo["GridRowCount"] = mxCreateDoubleScalar(_pVolGeom->getGridRowCount());
- std::map<std::string, mxArray*> mGeometryOptions;
- mGeometryOptions["WindowMinX"] = mxCreateDoubleScalar(_pVolGeom->getWindowMinX());
- mGeometryOptions["WindowMaxX"] = mxCreateDoubleScalar(_pVolGeom->getWindowMaxX());
- mGeometryOptions["WindowMinY"] = mxCreateDoubleScalar(_pVolGeom->getWindowMinY());
- mGeometryOptions["WindowMaxY"] = mxCreateDoubleScalar(_pVolGeom->getWindowMaxY());
+// std::map<std::string, mxArray*> mGeometryOptions;
+// mGeometryOptions["WindowMinX"] = mxCreateDoubleScalar(_pVolGeom->getWindowMinX());
+// mGeometryOptions["WindowMaxX"] = mxCreateDoubleScalar(_pVolGeom->getWindowMaxX());
+// mGeometryOptions["WindowMinY"] = mxCreateDoubleScalar(_pVolGeom->getWindowMinY());
+// mGeometryOptions["WindowMaxY"] = mxCreateDoubleScalar(_pVolGeom->getWindowMaxY());
- mGeometryInfo["option"] = buildStruct(mGeometryOptions);
+// mGeometryInfo["option"] = buildStruct(mGeometryOptions);
- return buildStruct(mGeometryInfo);
-}
+// return buildStruct(mGeometryInfo);
+// }
//-----------------------------------------------------------------------------------------
// create 3D volume geometry struct
-mxArray* createVolumeGeometryStruct(astra::CVolumeGeometry3D* _pVolGeom)
-{
- std::map<std::string, mxArray*> mGeometryInfo;
+// mxArray* createVolumeGeometryStruct(astra::CVolumeGeometry3D* _pVolGeom)
+// {
+// std::map<std::string, mxArray*> mGeometryInfo;
- mGeometryInfo["GridColCount"] = mxCreateDoubleScalar(_pVolGeom->getGridColCount());
- mGeometryInfo["GridRowCount"] = mxCreateDoubleScalar(_pVolGeom->getGridRowCount());
- mGeometryInfo["GridSliceCount"] = mxCreateDoubleScalar(_pVolGeom->getGridRowCount());
+// mGeometryInfo["GridColCount"] = mxCreateDoubleScalar(_pVolGeom->getGridColCount());
+// mGeometryInfo["GridRowCount"] = mxCreateDoubleScalar(_pVolGeom->getGridRowCount());
+// mGeometryInfo["GridSliceCount"] = mxCreateDoubleScalar(_pVolGeom->getGridRowCount());
- std::map<std::string, mxArray*> mGeometryOptions;
- mGeometryOptions["WindowMinX"] = mxCreateDoubleScalar(_pVolGeom->getWindowMinX());
- mGeometryOptions["WindowMaxX"] = mxCreateDoubleScalar(_pVolGeom->getWindowMaxX());
- mGeometryOptions["WindowMinY"] = mxCreateDoubleScalar(_pVolGeom->getWindowMinY());
- mGeometryOptions["WindowMaxY"] = mxCreateDoubleScalar(_pVolGeom->getWindowMaxY());
- mGeometryOptions["WindowMinZ"] = mxCreateDoubleScalar(_pVolGeom->getWindowMinZ());
- mGeometryOptions["WindowMaxZ"] = mxCreateDoubleScalar(_pVolGeom->getWindowMaxZ());
+// std::map<std::string, mxArray*> mGeometryOptions;
+// mGeometryOptions["WindowMinX"] = mxCreateDoubleScalar(_pVolGeom->getWindowMinX());
+// mGeometryOptions["WindowMaxX"] = mxCreateDoubleScalar(_pVolGeom->getWindowMaxX());
+// mGeometryOptions["WindowMinY"] = mxCreateDoubleScalar(_pVolGeom->getWindowMinY());
+// mGeometryOptions["WindowMaxY"] = mxCreateDoubleScalar(_pVolGeom->getWindowMaxY());
+// mGeometryOptions["WindowMinZ"] = mxCreateDoubleScalar(_pVolGeom->getWindowMinZ());
+// mGeometryOptions["WindowMaxZ"] = mxCreateDoubleScalar(_pVolGeom->getWindowMaxZ());
- mGeometryInfo["option"] = buildStruct(mGeometryOptions);
+// mGeometryInfo["option"] = buildStruct(mGeometryOptions);
- return buildStruct(mGeometryInfo);
-}
+// return buildStruct(mGeometryInfo);
+// }
//-----------------------------------------------------------------------------------------
string matlab2string(const mxArray* pField)
@@ -715,6 +715,12 @@ bool mex_is_scalar(const mxArray* pInput)
}
//-----------------------------------------------------------------------------------------
+mxArray* config2struct(astra::Config* cfg)
+{
+ return XMLNode2struct(cfg->self);
+}
+
+//-----------------------------------------------------------------------------------------
mxArray* XML2struct(astra::XMLDocument* xml)
{
XMLNode* node = xml->getRootNode();
@@ -724,9 +730,26 @@ mxArray* XML2struct(astra::XMLDocument* xml)
}
//-----------------------------------------------------------------------------------------
+mxArray* XMLNode2option(astra::XMLNode* node)
+{
+ char* end;
+ double content = ::strtod(node->getAttribute("value").c_str(), &end);
+ bool isnumber = !*end;
+
+ // float
+ if (isnumber) {
+ return mxCreateDoubleScalar(content);
+ }
+ // string
+ else {
+ return mxCreateString(node->getAttribute("value").c_str());
+ }
+}
+
mxArray* XMLNode2struct(astra::XMLNode* node)
{
- std::map<std::string, mxArray*> mList;
+ std::map<std::string, mxArray*> mList;
+ std::map<std::string, mxArray*> mOptions;
// type_attribute
if (node->hasAttribute("type")) {
@@ -736,11 +759,22 @@ mxArray* XMLNode2struct(astra::XMLNode* node)
list<XMLNode*> nodes = node->getNodes();
for (list<XMLNode*>::iterator it = nodes.begin(); it != nodes.end(); it++) {
XMLNode* subnode = (*it);
+
+ char* end;
+ double content = ::strtod(subnode->getContent().c_str(), &end);
+ bool isnumber = !*end;
+
+ // option
+ if (subnode->getName() == "Option") {
+ mOptions[subnode->getAttribute("key")] = XMLNode2option(subnode);
+ }
// list
- if (subnode->hasAttribute("listsize")) {
- cout << "lkmdsqldqsjkl" << endl;
- cout << " " << node->getContentNumericalArray().size() << endl;
- mList[subnode->getName()] = vectorToMxArray(node->getContentNumericalArray());
+ // else if (subnode->hasAttribute("listsize")) {
+ // mList[subnode->getName()] = vectorToMxArray(node->getContentNumericalArray());
+ // }
+ // float
+ else if (isnumber) {
+ mList[subnode->getName()] = mxCreateDoubleScalar(content);
}
// string
else {
@@ -749,9 +783,14 @@ mxArray* XMLNode2struct(astra::XMLNode* node)
delete subnode;
}
+ mList["options"] = buildStruct(mOptions);
return buildStruct(mList);
}
+
+
+
+
void get3DMatrixDims(const mxArray* x, mwSize *dims)
{
const mwSize* mdims = mxGetDimensions(x);
diff --git a/matlab/mex/mexHelpFunctions.h b/matlab/mex/mexHelpFunctions.h
index 8b65a04..f8a7d48 100644
--- a/matlab/mex/mexHelpFunctions.h
+++ b/matlab/mex/mexHelpFunctions.h
@@ -74,11 +74,12 @@ astra::CVolumeGeometry2D* parseVolumeGeometryStruct(const mxArray*);
mxArray* createProjectionGeometryStruct(astra::CProjectionGeometry2D*);
mxArray* createProjectionGeometryStruct(astra::CProjectionGeometry3D*);
-mxArray* createVolumeGeometryStruct(astra::CVolumeGeometry2D* _pReconGeom);
-mxArray* createVolumeGeometryStruct(astra::CVolumeGeometry3D* _pReconGeom);
+// mxArray* createVolumeGeometryStruct(astra::CVolumeGeometry2D* _pReconGeom);
+// mxArray* createVolumeGeometryStruct(astra::CVolumeGeometry3D* _pReconGeom);
astra::XMLDocument* struct2XML(string rootname, const mxArray* pStruct);
+mxArray* config2struct(astra::Config* cfg);
mxArray* XML2struct(astra::XMLDocument* xml);
mxArray* XMLNode2struct(astra::XMLNode* xml);
diff --git a/src/Config.cpp b/src/Config.cpp
index 3a3cb53..653935e 100644
--- a/src/Config.cpp
+++ b/src/Config.cpp
@@ -54,12 +54,24 @@ Config::Config(XMLNode* _self)
self = _self;
}
+//-----------------------------------------------------------------------------
Config::~Config()
{
delete self;
self = 0;
}
+//-----------------------------------------------------------------------------
+void Config::initialize(std::string rootname)
+{
+ if (self == 0) {
+ XMLDocument* doc = XMLDocument::createDocument(rootname);
+ self = doc->getRootNode();
+ }
+}
+
+
+//-----------------------------------------------------------------------------
template <class T>
ConfigStackCheck<T>::ConfigStackCheck(const char *_name, T* _obj, const Config& _cfg)
: object(_obj), cfg(&_cfg), name(_name)
diff --git a/src/VolumeGeometry2D.cpp b/src/VolumeGeometry2D.cpp
index 19aa905..d412914 100644
--- a/src/VolumeGeometry2D.cpp
+++ b/src/VolumeGeometry2D.cpp
@@ -152,7 +152,7 @@ CVolumeGeometry2D* CVolumeGeometry2D::clone()
}
//----------------------------------------------------------------------------------------
-// Initialization witha COnfig object
+// Initialization witha Config object
bool CVolumeGeometry2D::initialize(const Config& _cfg)
{
ASTRA_ASSERT(_cfg.self);
@@ -277,6 +277,24 @@ bool CVolumeGeometry2D::isEqual(CVolumeGeometry2D* _pGeom2) const
return true;
}
+
+//----------------------------------------------------------------------------------------
+// Get the configuration object
+Config* CVolumeGeometry2D::getConfiguration() const
+{
+ Config* cfg = new Config();
+ cfg->initialize("VolumeGeometry2D");
+
+ cfg->self->addChildNode("GridColCount", m_iGridColCount);
+ cfg->self->addChildNode("GridRowCount", m_iGridRowCount);
+
+ cfg->self->addOption("WindowMinX", m_fWindowMinX);
+ cfg->self->addOption("WindowMaxX", m_fWindowMaxX);
+ cfg->self->addOption("WindowMinY", m_fWindowMinY);
+ cfg->self->addOption("WindowMaxY", m_fWindowMaxY);
+
+ return cfg;
+}
//----------------------------------------------------------------------------------------
} // namespace astra
diff --git a/src/VolumeGeometry3D.cpp b/src/VolumeGeometry3D.cpp
index d7a93a9..66e6f0c 100644
--- a/src/VolumeGeometry3D.cpp
+++ b/src/VolumeGeometry3D.cpp
@@ -380,5 +380,28 @@ CVolumeGeometry2D * CVolumeGeometry3D::createVolumeGeometry2D() const
}
//----------------------------------------------------------------------------------------
+// Get the configuration object
+Config* CVolumeGeometry3D::getConfiguration() const
+{
+ Config* cfg = new Config();
+ cfg->initialize("VolumeGeometry3D");
+
+ cfg->self->addChildNode("GridColCount", m_iGridColCount);
+ cfg->self->addChildNode("GridRowCount", m_iGridRowCount);
+ cfg->self->addChildNode("GridSliceCount", m_iGridSliceCount);
+
+ cfg->self->addOption("WindowMinX", m_fWindowMinX);
+ cfg->self->addOption("WindowMaxX", m_fWindowMaxX);
+ cfg->self->addOption("WindowMinY", m_fWindowMinY);
+ cfg->self->addOption("WindowMaxY", m_fWindowMaxY);
+ cfg->self->addOption("WindowMinZ", m_fWindowMinZ);
+ cfg->self->addOption("WindowMaxZ", m_fWindowMaxZ);
+
+ return cfg;
+}
+//----------------------------------------------------------------------------------------
+
+
+//----------------------------------------------------------------------------------------
} // namespace astra
diff --git a/src/XMLDocument.cpp b/src/XMLDocument.cpp
index b39875b..406564f 100644
--- a/src/XMLDocument.cpp
+++ b/src/XMLDocument.cpp
@@ -109,4 +109,12 @@ void XMLDocument::saveToFile(string sFilename)
}
//-----------------------------------------------------------------------------
+std::string XMLDocument::toString()
+{
+ std::stringstream ss;
+ ss << *fDOMDocument->first_node();
+ return ss.str();
+}
+
+//-----------------------------------------------------------------------------