Commit 439722bb authored by Hossain Mahmud's avatar Hossain Mahmud
Browse files

Loading can be done with genericImageReader, however, assertion fails for...

Loading can be done with genericImageReader, however, assertion fails for sliders. thread ownership issues
parent 2dd497e1
......@@ -64,28 +64,10 @@ namespace campvis {
**/
virtual ~AbstractImageReader();
/**
* Provides the interface for the classes that reads images from different types
* of files into ImageRepresentationDisk representation
* \param data DataContainer to work on
*/
//virtual void process(DataContainer& data);
///// \see AbstractProcessor::getName()
//virtual const std::string getName() = 0;
///// \see AbstractProcessor::getDescription()
//virtual const std::string getDescription() = 0;
///// \see AbstractProcessor::getAuthor()
//virtual const std::string getAuthor() = 0;
///// \see AbstractProcessor::getProcessorState()
//virtual ProcessorState getProcessorState() = 0;
/// \see AbstractProcessor::getExtension()
virtual const std::string getExtension() = 0;
/// \see AbstractProcessor::getMetaProperties()
virtual PropertyCollection& getMetaProperties() = 0;
//virtual PropertyCollection& getMetaProperties() = 0;
/// functions to set the property of the readers
virtual void setURL(StringProperty p_url);
......
......@@ -45,7 +45,7 @@ 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->_ext = ".csv";
this->p_targetImageID.setValue("CsvdImageReader.output");
addProperty(&p_url);
......@@ -180,8 +180,8 @@ namespace campvis {
}
PropertyCollection& CsvdImageReader::getMetaProperties() {
PropertyCollection dummy;
return dummy;
}
//PropertyCollection& CsvdImageReader::getMetaProperties() {
// PropertyCollection dummy;
// return dummy;
//}
}
\ No newline at end of file
......@@ -68,7 +68,7 @@ namespace campvis {
/// \see AbstractProcessor::getExtension()
virtual const std::string getExtension() { return _ext;};
/// \see AbstractProcessor::getMetaProperties()
PropertyCollection& getMetaProperties();
//PropertyCollection& getMetaProperties();
Vec3Property p_imageOffset; ///< Image Offset in mm
Vec3Property p_voxelSize; ///< Voxel Size in mm
......
......@@ -45,76 +45,105 @@ namespace campvis {
: AbstractProcessor()
, p_url("url", "Image URL", "")
{
//CsvdImageReader *_csvdImageReader = new CsvdImageReader();
//this->_readers.push_back(_csvdImageReader);
//LtfImageReader *_ltfImageReader = new LtfImageReader();
//this->_readers.push_back(_ltfImageReader);
//MhdImageReader *_mhdImageReader = new MhdImageReader();
//this->_readers.push_back(_mhdImageReader);
//RawImageReader *_rawImageReader = new RawImageReader();
//this->_readers.push_back(_rawImageReader);
//VtkImageReader *_vtkImageReader = new VtkImageReader();
//this->_readers.push_back(_vtkImageReader);
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());
//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());
}
GenericImageReader::~GenericImageReader() {
for(std::vector<AbstractImageReader*>::iterator it = this->_readers.begin(); it != this->_readers.end(); it++) {
delete *it;
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::vector<AbstractImageReader*>::iterator it = this->_readers.begin(); it != this->_readers.end(); it++) {
if((*it)->getExtension() == this->_ext) {
(*it)->process(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;
}
void GenericImageReader::setURL(StringProperty p_url) {
this->p_url.setValue(p_url.getValue());
for(std::vector<AbstractImageReader*>::iterator it = this->_readers.begin(); it != this->_readers.end(); it++) {
if((*it)->getExtension() == this->_ext) {
(*it)->p_url.setValue(this->p_url.getValue());
break;
}
}
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::vector<AbstractImageReader*>::iterator it = this->_readers.begin(); it != this->_readers.end(); it++) {
if((*it)->getExtension() == this->_ext) {
(*it)->p_targetImageID.setValue(targetImageId.getValue());
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)->p_targetImageID.addSharedProperty(*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::vector<AbstractImageReader*>::iterator it = this->_readers.begin(); it != this->_readers.end(); it++) {
if((*it)->getExtension() == this->_ext) {
(*it)->p_targetImageID.setValue(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;
}
}
......@@ -122,17 +151,26 @@ namespace campvis {
}
void GenericImageReader::setTargetImageIdSharedProperty(DataNameProperty* sharedProperty) {
for(std::vector<AbstractImageReader*>::iterator it = this->_readers.begin(); it != this->_readers.end(); it++) {
if((*it)->getExtension() == this->_ext) {
(*it)->p_targetImageID.addSharedProperty(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;
//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
......@@ -35,6 +35,7 @@
#include "core/pipeline/abstractprocessor.h"
#include "core/properties/datanameproperty.h"
#include "core/properties/floatingpointproperty.h"
#include "core/properties/metaproperty.h"
#include "modules/io/processors/csvdimagereader.h"
#include "modules/io/processors/ltfimagereader.h"
......@@ -77,29 +78,36 @@ namespace campvis {
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);
void setMetaProperties(PropertyCollection &metaProperties);
//void setMetaProperties(PropertyCollection &metaProperties);
protected:
static const std::string loggerCat_;
private:
std::vector<AbstractImageReader*> _readers;
//std::vector<AbstractImageReader*> _readers;
std::map<AbstractImageReader*, MetaProperty*> _readers;
StringProperty p_url;
std::string _ext;
MetaProperty* _currentlyVisible;
CsvdImageReader _csvdImageReader;
LtfImageReader _ltfImageReader;
MhdImageReader _mhdImageReader;
RawImageReader _rawImageReader;
VtkImageReader _vtkImageReader;
/**
* 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::map<std::string, std::string> _extMap;
};
}
......
......@@ -53,7 +53,7 @@ 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->_ext = ".ltf";
this->p_targetImageID.setValue("LtfImageReader.output");
addProperty(&p_url);
......@@ -100,8 +100,8 @@ namespace campvis {
validate(INVALID_RESULT);
}
PropertyCollection& LtfImageReader::getMetaProperties() {
PropertyCollection dummy;
return dummy;
}
//PropertyCollection& LtfImageReader::getMetaProperties() {
// PropertyCollection dummy;
// return dummy;
//}
}
......@@ -70,7 +70,7 @@ namespace campvis {
/// \see AbstractProcessor::getExtension()
virtual const std::string getExtension() { return _ext;};
/// \see AbstractProcessor::getMetaProperties()
PropertyCollection& getMetaProperties();
//PropertyCollection& getMetaProperties();
IVec3Property p_size; ///< Image size
IntProperty p_numChannels; ///< Number of channels per element
......
......@@ -44,7 +44,7 @@ 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->_ext = ".mhd";
this->p_targetImageID.setValue("MhdImageReader.output");
addProperty(&p_url);
addProperty(&p_targetImageID);
......@@ -198,8 +198,8 @@ namespace campvis {
validate(INVALID_RESULT);
}
PropertyCollection& MhdImageReader::getMetaProperties() {
PropertyCollection dummy;
return dummy;
}
//PropertyCollection& MhdImageReader::getMetaProperties() {
// PropertyCollection dummy;
// return dummy;
//}
}
\ No newline at end of file
......@@ -69,7 +69,7 @@ namespace campvis {
/// \see AbstractProcessor::getExtension()
virtual const std::string getExtension() { return _ext;};
/// \see AbstractProcessor::getMetaProperties()
PropertyCollection& getMetaProperties();
//PropertyCollection& getMetaProperties();
Vec3Property p_imageOffset; ///< Image Offset in mm
Vec3Property p_voxelSize; ///< Voxel Size in mm
......
......@@ -58,7 +58,7 @@ 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->_ext = ".raw";
this->p_targetImageID.setValue("RawImageReader.output");
addProperty(&p_url);
......@@ -90,8 +90,8 @@ namespace campvis {
validate(INVALID_RESULT);
}
PropertyCollection& RawImageReader::getMetaProperties() {
PropertyCollection dummy;
return dummy;
}
//PropertyCollection& RawImageReader::getMetaProperties() {
// PropertyCollection dummy;
// return dummy;
//}
}
......@@ -71,7 +71,7 @@ namespace campvis {
/// \see AbstractProcessor::getExtension()
virtual const std::string getExtension() { return _ext;};
/// \see AbstractProcessor::getMetaProperties()
PropertyCollection& getMetaProperties();
//PropertyCollection& getMetaProperties();
IVec3Property p_size; ///< Image size
IntProperty p_numChannels; ///< Number of channels per element
......
......@@ -48,7 +48,7 @@ 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 = "vtk";
this->_ext = ".vtk";
this->p_targetImageID.setValue("VtkImageReader.output");
addProperty(&p_url);
......@@ -268,8 +268,8 @@ namespace campvis {
data.addData(p_targetImageID.getValue(), g);
}
PropertyCollection& VtkImageReader::getMetaProperties() {
PropertyCollection dummy;
return dummy;
}
//PropertyCollection& VtkImageReader::getMetaProperties() {
// PropertyCollection dummy;
// return dummy;
//}
}
\ No newline at end of file
......@@ -70,7 +70,7 @@ namespace campvis {
/// \see AbstractProcessor::getExtension()
virtual const std::string getExtension() { return _ext;};
/// \see AbstractProcessor::getMetaProperties()
PropertyCollection& getMetaProperties();
//PropertyCollection& getMetaProperties();
Vec3Property p_imageOffset; ///< Image Offset in mm
Vec3Property p_voxelSize; ///< Voxel Size in mm
......
......@@ -2,23 +2,28 @@
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012-2013, all rights reserved,
// If not explicitly stated otherwise: Copyright (C) 2012, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universität München
// Boltzmannstr. 3, 85748 Garching b. München, Germany
//
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// The licensing of this softare is not yet resolved. Until then, redistribution in source or
// binary forms outside the CAMP chair is not permitted, unless explicitly stated in legal form.
// However, the names of the original authors and the above copyright notice must retain in its
// original state in any case.
//
// Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
// Legal disclaimer provided by the BSD license:
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ================================================================================================
......@@ -53,10 +58,14 @@ namespace campvis {
_ve.p_outputImage.setValue("combine");
_renderTargetID.setValue("combine");
_imageReader.p_url.setValue(CAMPVIS_SOURCE_DIR "/modules/vis/sampledata/smallHeart.mhd");
_imageReader.p_targetImageID.setValue("reader.output");
_imageReader.p_targetImageID.addSharedProperty(&_ve.p_inputVolume);
//_imageReader.p_url.setValue("D:\\hiwi\\CAMPVis Datasets\\smallHeart.mhd");
//_imageReader.p_targetImageID.setValue("reader.output");
//_imageReader.p_targetImageID.addSharedProperty(&_ve.p_inputVolume);
_imageReader.setURL("D:\\hiwi\\CAMPVis Datasets\\smallHeart.mhd");
_imageReader.setTargetImageId("reader.output");
_imageReader.setTargetImageIdSharedProperty(&_ve.p_inputVolume);
Geometry1DTransferFunction* dvrTF = new Geometry1DTransferFunction(128, tgt::vec2(0.f, .05f));
dvrTF->addGeometry(TFGeometry1D::createQuad(tgt::vec2(.1f, .125f), tgt::col4(255, 0, 0, 32), tgt::col4(255, 0, 0, 32)));
......
......@@ -28,6 +28,7 @@
#include "core/pipeline/autoevaluationpipeline.h"
#include "core/properties/cameraproperty.h"
#include "modules/io/processors/mhdimagereader.h"
#include "modules/io/processors/genericimagereader.h"
#include "modules/vis/processors/volumeexplorer.h"
namespace campvis {
......@@ -63,7 +64,8 @@ namespace campvis {
*/
virtual void onProcessorValidated(AbstractProcessor* processor);
MhdImageReader _imageReader;
//MhdImageReader _imageReader;
GenericImageReader _imageReader;
VolumeExplorer _ve;
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment