The expiration time for new job artifacts in CI/CD pipelines is now 30 days (GitLab default). Previously generated artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

Commit aa39fc31 authored by Hossain Mahmud's avatar Hossain Mahmud
Browse files

little fixes on unsigned/size_t, extensions, and code clean up

parent 439722bb
......@@ -29,49 +29,41 @@
#include "abstractimagereader.h"
//#include <fstream>
//
//#include "tgt/filesystem.h"
//#include "core/datastructures/imagedata.h"
//#include "core/datastructures/imagerepresentationdisk.h"
//#include "core/datastructures/genericimagerepresentationlocal.h"
//#include "core/tools/textfileparser.h"
namespace campvis {
AbstractImageReader::AbstractImageReader()
: p_url("url", "Image URL", "")
, p_targetImageID("targetImageName", "Target Image ID", "AbstractImageReader.output", DataNameProperty::WRITE)
AbstractImageReader::AbstractImageReader()
: p_url("url", "Image URL", "")
, p_targetImageID("targetImageName", "Target Image ID", "AbstractImageReader.output", DataNameProperty::WRITE)
{
}
}
AbstractImageReader::~AbstractImageReader() {
}
AbstractImageReader::~AbstractImageReader() {
}
void AbstractImageReader::setURL(StringProperty p_url) {
this->p_url.setValue(p_url.getValue());
void AbstractImageReader::setURL(StringProperty p_url) {
this->p_url.setValue(p_url.getValue());
std::string url = this->p_url.getValue();
std::string url = this->p_url.getValue();
unsigned extPos = (unsigned) url.rfind('.');
if (extPos != std::string::npos) {
this->_ext = url.substr(extPos);
}
}
unsigned extPos = (unsigned) url.rfind('.');
if (extPos != std::string::npos) {
this->_ext = url.substr(extPos);
}
}
void AbstractImageReader::setTargetImageId(DataNameProperty& targetImageId) {
this->p_targetImageID.setValue(targetImageId.getValue());
std::set<AbstractProperty*> sharedProperties = targetImageId.getSharedProperties();
for(std::set<AbstractProperty*>::iterator it = sharedProperties.begin(); it != sharedProperties.end(); it++) {
this->p_targetImageID.addSharedProperty(*it);
}
}
void AbstractImageReader::setTargetImageId(DataNameProperty& targetImageId) {
this->p_targetImageID.setValue(targetImageId.getValue());
std::set<AbstractProperty*> sharedProperties = targetImageId.getSharedProperties();
for(std::set<AbstractProperty*>::iterator it = sharedProperties.begin(); it != sharedProperties.end(); it++) {
this->p_targetImageID.addSharedProperty(*it);
}
}
void AbstractImageReader::setTargetImageId(std::string imageId) {
this->p_targetImageID.setValue(imageId);
}
void AbstractImageReader::setTargetImageId(std::string imageId) {
this->p_targetImageID.setValue(imageId);
}
void AbstractImageReader::setTargetImageIdSharedProperty(DataNameProperty* sharedProperty) {
this->p_targetImageID.addSharedProperty(sharedProperty);
}
void AbstractImageReader::setTargetImageIdSharedProperty(DataNameProperty* sharedProperty) {
this->p_targetImageID.addSharedProperty(sharedProperty);
}
}
\ No newline at end of file
......@@ -37,19 +37,19 @@
#include "core/properties/datanameproperty.h"
#include "core/properties/floatingpointproperty.h"
//#include "modules/io/processors/csvdimagereader.h"
//#include "modules/io/processors/ltfimagereader.h"
//#include "modules/io/processors/mhdimagereader.h"
//#include "modules/io/processors/rawimagereader.h"
//#include "modules/io/processors/vtkimagereader.h"
#define EXT_MHD_FILE ".mhd"
#define EXT_CSV_FILE ".csv"
#define EXT_LTF_FILE ".ltf"
#define EXT_VTK_FILE ".vtk"
#define EXT_RQW_FILE ".raw"
namespace campvis {
/**
* Reads an image file into the pipeline. This is mainly a wrapper class. It uses
* the other image reader implemented for its tasks.
* the other image reader implemented for its tasks.
*
* Provides the interface for the classes that reads images from different types
* of files into ImageRepresentationDisk representation
* of files into ImageRepresentationDisk representation
*
*/
class AbstractImageReader : public AbstractProcessor {
......@@ -66,25 +66,23 @@ namespace campvis {
/// \see AbstractProcessor::getExtension()
virtual const std::string getExtension() = 0;
/// \see AbstractProcessor::getMetaProperties()
//virtual PropertyCollection& getMetaProperties() = 0;
/// functions to set the property of the readers
virtual void setURL(StringProperty p_url);
virtual void setTargetImageId(DataNameProperty& targetImageId);
virtual void setTargetImageId(std::string imageId);
virtual void setTargetImageIdSharedProperty(DataNameProperty* sharedProperty);
public:
/// functions to set the property of the readers
virtual void setURL(StringProperty p_url);
virtual void setTargetImageId(DataNameProperty& targetImageId);
virtual void setTargetImageId(std::string imageId);
virtual void setTargetImageIdSharedProperty(DataNameProperty* sharedProperty);
public:
StringProperty p_url; ///< URL for file to read
DataNameProperty p_targetImageID; ///< image ID for read image
DataNameProperty p_targetImageID; ///< image ID for read image
protected:
std::string _ext;
std::string _ext;
static const std::string loggerCat_;
private:
private:
};
......
......@@ -45,8 +45,8 @@ namespace campvis {
, p_imageOffset("ImageOffset", "Image Offset in mm", tgt::vec3(0.f), tgt::vec3(-10000.f), tgt::vec3(10000.f), tgt::vec3(0.1f))
, p_voxelSize("VoxelSize", "Voxel Size in mm", tgt::vec3(1.f), tgt::vec3(-100.f), tgt::vec3(100.f), tgt::vec3(0.1f))
{
this->_ext = ".csv";
this->p_targetImageID.setValue("CsvdImageReader.output");
this->_ext = EXT_CSV_FILE;
this->p_targetImageID.setValue("CsvdImageReader.output");
addProperty(&p_url);
addProperty(&p_targetImageID);
......@@ -179,9 +179,4 @@ namespace campvis {
validate(INVALID_RESULT);
}
//PropertyCollection& CsvdImageReader::getMetaProperties() {
// PropertyCollection dummy;
// return dummy;
//}
}
\ No newline at end of file
......@@ -64,11 +64,9 @@ namespace campvis {
virtual const std::string getAuthor() const { return "Christian Schulte zu Berge <christian.szb@in.tum.de>"; };
/// \see AbstractProcessor::getProcessorState()
virtual ProcessorState getProcessorState() const { return AbstractProcessor::EXPERIMENTAL; };
/// \see AbstractProcessor::getExtension()
virtual const std::string getExtension() { return _ext;};
/// \see AbstractProcessor::getMetaProperties()
//PropertyCollection& getMetaProperties();
virtual const std::string getExtension() { return _ext;};
Vec3Property p_imageOffset; ///< Image Offset in mm
Vec3Property p_voxelSize; ///< Voxel Size in mm
......
......@@ -44,133 +44,115 @@ namespace campvis {
GenericImageReader::GenericImageReader()
: AbstractProcessor()
, p_url("url", "Image URL", "")
{
//MhdImageReader* reader = new MhdImageReader();
//MetaProperty* meta = new MetaProperty(reader->getName()+"MetaProp", reader->getName());
//meta->addPropertyCollection(*reader);
//this->addProperty(meta);
//this->_readers.insert(std::pair<AbstractImageReader*, MetaProperty*>(reader, meta));
this->addReader(new CsvdImageReader());
this->addReader(new LtfImageReader());
this->addReader(new MhdImageReader());
this->addReader(new RawImageReader());
this->addReader(new VtkImageReader());
this->_ext = "";
this->_currentlyVisible = nullptr;
//this->_readers.push_back(new CsvdImageReader());
//this->_readers.push_back(new LtfImageReader());
//this->_readers.push_back(new MhdImageReader());
//this->_readers.push_back(new RawImageReader());
//this->_readers.push_back(new VtkImageReader());
}
{
this->addReader(new CsvdImageReader());
this->addReader(new LtfImageReader());
this->addReader(new MhdImageReader());
this->addReader(new RawImageReader());
this->addReader(new VtkImageReader());
this->_ext = "";
this->_currentlyVisible = nullptr;
}
GenericImageReader::~GenericImageReader() {
for(std::map<AbstractImageReader*, MetaProperty*>::iterator it = this->_readers.begin(); it != this->_readers.end(); it++) {
if (nullptr != it->first) delete it->first;
if (nullptr != it->second) delete it->second;
this->_readers.erase(it);
}
}
void GenericImageReader::init() {
}
void GenericImageReader::deinit() {
for(std::map<AbstractImageReader*, MetaProperty*>::iterator it = this->_readers.begin(); it != this->_readers.end(); it++) {
if (nullptr != it->first) delete it->first;
if (nullptr != it->second) delete it->second;
this->_readers.erase(it);
}
}
void GenericImageReader::process(DataContainer& data) {
for(std::map<AbstractImageReader*, MetaProperty*>::iterator it = this->_readers.begin(); it != this->_readers.end(); it++) {
if((it->first)->getExtension() == this->_ext) {
if(nullptr != this->_currentlyVisible) {
this->_currentlyVisible->setVisible(false);
}
(it->second)->setVisible(true);
this->_currentlyVisible = it->second;
(it->first)->process(data);
break;
}
}
return;
for(std::map<AbstractImageReader*, MetaProperty*>::iterator it = this->_readers.begin(); it != this->_readers.end(); it++) {
if((it->first)->getExtension() == this->_ext) {
if(nullptr != this->_currentlyVisible) {
this->_currentlyVisible->setVisible(false);
}
(it->second)->setVisible(true);
this->_currentlyVisible = it->second;
(it->first)->process(data);
break;
}
}
return;
}
void GenericImageReader::setURL(std::string p_url) {
this->p_url.setValue(p_url);
std::string url = this->p_url.getValue();
size_t extPos = url.rfind('.');
if (extPos != std::string::npos) {
this->_ext = url.substr(extPos);
}
for(std::map<AbstractImageReader*, MetaProperty*>::iterator it = this->_readers.begin(); it != this->_readers.end(); it++) {
if((it->first)->getExtension() == this->_ext) {
(it->first)->p_url.setValue(this->p_url.getValue());
break;
}
}
return;
}
void GenericImageReader::setURL(StringProperty p_url) {
return this->setURL(p_url.getValue());
}
void GenericImageReader::setURL(const char* p_url) {
return this->setURL(std::string(p_url));
}
void GenericImageReader::setTargetImageId(DataNameProperty& targetImageId) {
for(std::map<AbstractImageReader*, MetaProperty*>::iterator it = this->_readers.begin(); it != this->_readers.end(); it++) {
if((it->first)->getExtension() == this->_ext) {
(it->first)->p_targetImageID.setValue(targetImageId.getValue());
std::set<AbstractProperty*> sharedProperties = targetImageId.getSharedProperties();
for(std::set<AbstractProperty*>::iterator jt = sharedProperties.begin(); jt != sharedProperties.end(); jt++) {
(it->first)->p_targetImageID.addSharedProperty(*jt);
}
break;
}
}
return;
}
void GenericImageReader::setTargetImageId(const char* imageId) {
return this->setTargetImageId(std::string(imageId));
}
void GenericImageReader::setTargetImageId(std::string imageId) {
for(std::map<AbstractImageReader*, MetaProperty*>::iterator it = this->_readers.begin(); it != this->_readers.end(); it++) {
if((it->first)->getExtension() == this->_ext) {
(it->first)->p_targetImageID.setValue(imageId);
break;
}
}
return;
}
void GenericImageReader::setTargetImageIdSharedProperty(DataNameProperty* sharedProperty) {
for(std::map<AbstractImageReader*, MetaProperty*>::iterator it = this->_readers.begin(); it != this->_readers.end(); it++) {
if((it->first)->getExtension() == this->_ext) {
(it->first)->p_targetImageID.addSharedProperty(sharedProperty);
break;
}
}
return;
}
int GenericImageReader::addReader(AbstractImageReader* reader) {
MetaProperty* meta = new MetaProperty(reader->getName()+"MetaProp", reader->getName());
meta->addPropertyCollection(*reader);
meta->setVisible(false);
this->addProperty(meta);
this->_readers.insert(std::pair<AbstractImageReader*, MetaProperty*>(reader, meta));
return 0;
}
void GenericImageReader::setURL(std::string p_url) {
this->p_url.setValue(p_url);
std::string url = this->p_url.getValue();
unsigned extPos = (unsigned) url.rfind('.');
if (extPos != std::string::npos) {
this->_ext = url.substr(extPos);
}
for(std::map<AbstractImageReader*, MetaProperty*>::iterator it = this->_readers.begin(); it != this->_readers.end(); it++) {
if((it->first)->getExtension() == this->_ext) {
(it->first)->p_url.setValue(this->p_url.getValue());
/* if(nullptr != this->_currentlyVisible) {
this->_currentlyVisible->setVisible(false);
}
(it->second)->setVisible(true);
this->_currentlyVisible = it->second;*/
break;
}
}
return;
}
void GenericImageReader::setURL(StringProperty p_url) {
return this->setURL(p_url.getValue());
}
void GenericImageReader::setURL(const char* p_url) {
return this->setURL(std::string(p_url));
}
void GenericImageReader::setTargetImageId(DataNameProperty& targetImageId) {
for(std::map<AbstractImageReader*, MetaProperty*>::iterator it = this->_readers.begin(); it != this->_readers.end(); it++) {
if((it->first)->getExtension() == this->_ext) {
(it->first)->p_targetImageID.setValue(targetImageId.getValue());
std::set<AbstractProperty*> sharedProperties = targetImageId.getSharedProperties();
for(std::set<AbstractProperty*>::iterator jt = sharedProperties.begin(); jt != sharedProperties.end(); jt++) {
(it->first)->p_targetImageID.addSharedProperty(*jt);
}
break;
}
}
return;
}
void GenericImageReader::setTargetImageId(const char* imageId) {
return this->setTargetImageId(std::string(imageId));
}
void GenericImageReader::setTargetImageId(std::string imageId) {
for(std::map<AbstractImageReader*, MetaProperty*>::iterator it = this->_readers.begin(); it != this->_readers.end(); it++) {
if((it->first)->getExtension() == this->_ext) {
(it->first)->p_targetImageID.setValue(imageId);
break;
}
}
return;
}
void GenericImageReader::setTargetImageIdSharedProperty(DataNameProperty* sharedProperty) {
for(std::map<AbstractImageReader*, MetaProperty*>::iterator it = this->_readers.begin(); it != this->_readers.end(); it++) {
if((it->first)->getExtension() == this->_ext) {
(it->first)->p_targetImageID.addSharedProperty(sharedProperty);
break;
}
}
return;
}
//void GenericImageReader::setMetaProperties(PropertyCollection &metaProperties) {
// return;
//}
int GenericImageReader::addReader(AbstractImageReader* reader) {
MetaProperty* meta = new MetaProperty(reader->getName()+"MetaProp", reader->getName());
meta->addPropertyCollection(*reader);
meta->setVisible(false);
this->addProperty(meta);
this->_readers.insert(std::pair<AbstractImageReader*, MetaProperty*>(reader, meta));
return 0;
}
}
\ No newline at end of file
......@@ -46,7 +46,7 @@
namespace campvis {
/**
* Reads an image file into the pipeline. This is mainly a wrapper class. It uses
* the other image reader implemented for its tasks.
* the other image reader implemented for its tasks.
*
*/
class GenericImageReader : public AbstractProcessor {
......@@ -61,6 +61,11 @@ namespace campvis {
**/
virtual ~GenericImageReader();
/// \see AutoEvaluationPipeline::init()
virtual void init();
/// \see AutoEvaluationPipeline::deinit()
virtual void deinit();
/**
* Reads the MHD file into an ImageRepresentationDisk representation
......@@ -77,36 +82,36 @@ namespace campvis {
/// \see AbstractProcessor::getProcessorState()
virtual ProcessorState getProcessorState() const { return AbstractProcessor::TESTING; };
/// functions to set the property of the readers
void setURL(std::string p_url);
void setURL(StringProperty p_url);
void setURL(const char* p_url);
void setTargetImageId(DataNameProperty& targetImageId);
void setTargetImageId(std::string imageId);
void setTargetImageId(const char* imageId);
void setTargetImageIdSharedProperty(DataNameProperty* sharedProperty);
/// functions to set the property of the readers
void setURL(std::string p_url);
void setURL(StringProperty p_url);
void setURL(const char* p_url);
void setTargetImageId(DataNameProperty& targetImageId);
void setTargetImageId(std::string imageId);
void setTargetImageId(const char* imageId);
void setTargetImageIdSharedProperty(DataNameProperty* sharedProperty);
//void setMetaProperties(PropertyCollection &metaProperties);
//void setMetaProperties(PropertyCollection &metaProperties);
protected:
static const std::string loggerCat_;
private:
//std::vector<AbstractImageReader*> _readers;
std::map<AbstractImageReader*, MetaProperty*> _readers;
private:
//std::vector<AbstractImageReader*> _readers;
std::map<AbstractImageReader*, MetaProperty*> _readers;
StringProperty p_url;
std::string _ext;
MetaProperty* _currentlyVisible;
/**
* Adds a particular reader to the generic reader
* Creates MetaProperty wrapper for the added reader, that
* is freed from the destructor of the class
*
* /param reader pointer to the reader to be added
*/
int addReader(AbstractImageReader* reader);
std::string _ext;
MetaProperty* _currentlyVisible;
/**
* Adds a particular reader to the generic reader
* Creates MetaProperty wrapper for the added reader, that
* is freed from the destructor of the class
*
* /param reader pointer to the reader to be added
*/
int addReader(AbstractImageReader* reader);
};
......
......@@ -53,8 +53,8 @@ namespace campvis {
, p_imageOffset("ImageOffset", "Image Offset in mm", tgt::vec3(0.f), tgt::vec3(-10000.f), tgt::vec3(10000.f), tgt::vec3(0.1f))
, p_voxelSize("VoxelSize", "Voxel Size in mm", tgt::vec3(1.f), tgt::vec3(-100.f), tgt::vec3(100.f), tgt::vec3(0.1f))
{
this->_ext = ".ltf";
this->p_targetImageID.setValue("LtfImageReader.output");
this->_ext = EXT_LTF_FILE;
this->p_targetImageID.setValue("LtfImageReader.output");
addProperty(&p_url);
addProperty(&p_size);
......@@ -99,9 +99,5 @@ namespace campvis {
validate(INVALID_RESULT);
}
//PropertyCollection& LtfImageReader::getMetaProperties() {
// PropertyCollection dummy;
// return dummy;
//}
}
......@@ -66,11 +66,9 @@ namespace campvis {
virtual const std::string getAuthor() const { return "Christian Schulte zu Berge <christian.szb@in.tum.de>"; };
/// \see AbstractProcessor::getProcessorState()
virtual ProcessorState getProcessorState() const { return AbstractProcessor::EXPERIMENTAL; };
/// \see AbstractProcessor::getExtension()
virtual const std::string getExtension() { return _ext;};
/// \see AbstractProcessor::getMetaProperties()
//PropertyCollection& getMetaProperties();
virtual const std::string getExtension() { return _ext;};
IVec3Property p_size; ///< Image size
IntProperty p_numChannels; ///< Number of channels per element
......
......@@ -44,8 +44,8 @@ namespace campvis {
, p_imageOffset("ImageOffset", "Image Offset in mm", tgt::vec3(0.f), tgt::vec3(-10000.f), tgt::vec3(10000.f), tgt::vec3(0.1f))
, p_voxelSize("VoxelSize", "Voxel Size in mm", tgt::vec3(1.f), tgt::vec3(-100.f), tgt::vec3(100.f), tgt::vec3(0.1f))
{
this->_ext = ".mhd";
this->p_targetImageID.setValue("MhdImageReader.output");
this->_ext = EXT_MHD_FILE;
this->p_targetImageID.setValue("MhdImageReader.output");
addProperty(&p_url);
addProperty(&p_targetImageID);
addProperty(&p_imageOffset);
......@@ -198,8 +198,4 @@ namespace campvis {
validate(INVALID_RESULT);
}
//PropertyCollection& MhdImageReader::getMetaProperties() {
// PropertyCollection dummy;
// return dummy;
//}
}
\ No newline at end of file
......@@ -65,11 +65,9 @@ namespace campvis {
virtual const std::string getAuthor() const { return "Christian Schulte zu Berge <christian.szb@in.tum.de>"; };
/// \see AbstractProcessor::getProcessorState()
virtual ProcessorState getProcessorState() const { return AbstractProcessor::TESTING; };
/// \see AbstractProcessor::getExtension()
virtual const std::string getExtension() { return _ext;};
/// \see AbstractProcessor::getMetaProperties()
//PropertyCollection& getMetaProperties();
virtual const std::string getExtension() { return _ext;};
Vec3Property p_imageOffset; ///< Image Offset in mm
Vec3Property p_voxelSize; ///< Voxel Size in mm
......
......@@ -58,8 +58,8 @@ namespace campvis {
, p_imageOffset("ImageOffset", "Image Offset in mm", tgt::vec3(0.f), tgt::vec3(-10000.f), tgt::vec3(10000.f), tgt::vec3(0.1f))
, p_voxelSize("VoxelSize", "Voxel Size in mm", tgt::vec3(1.f), tgt::vec3(-100.f), tgt::vec3(100.f), tgt::vec3(0.1f))
{
this->_ext = ".raw";
this->p_targetImageID.setValue("RawImageReader.output");
this->_ext = EXT_RQW_FILE;
this->p_targetImageID.setValue("RawImageReader.output");
addProperty(&p_url);
addProperty(&p_size);
......@@ -90,8 +90,4 @@ namespace campvis {
validate(INVALID_RESULT);
}