Commit 03f2dc07 authored by schultezub's avatar schultezub
Browse files

Introducing Columbia module and ImageSeriesSplitter

fixed possible crash during image representation conversion disk->GL

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@515 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent 0a5144e7
......@@ -42,6 +42,10 @@
#include "modules/scr_msk/pipelines/uscompounding.h"
#endif
#ifdef CAMPVIS_HAS_MODULE_COLUMBIA
#include "modules/columbia/pipelines/columbia1.h"
#endif
using namespace campvis;
/**
......@@ -58,7 +62,7 @@ int main(int argc, char** argv) {
// app.addVisualizationPipeline("IXPV", new IxpvDemo());
//app.addVisualizationPipeline("SliceVis", new SliceVis());
//app.addVisualizationPipeline("DVRVis", new DVRVis());
app.addVisualizationPipeline("VolumeRendererDemo", new VolumeRendererDemo());
//app.addVisualizationPipeline("VolumeRendererDemo", new VolumeRendererDemo());
#ifdef HAS_KISSCL
//app.addVisualizationPipeline("DVR with OpenCL", new OpenCLPipeline());
#endif
......@@ -67,6 +71,11 @@ int main(int argc, char** argv) {
//app.addVisualizationPipeline("US Compounding", new UsCompounding());
#endif
#ifdef CAMPVIS_HAS_MODULE_COLUMBIA
app.addVisualizationPipeline("Columbia", new Columbia1());
#endif
app.init();
int toReturn = app.run();
......
......@@ -82,6 +82,12 @@ namespace campvis {
// test source image type via dynamic cast
if (const ImageRepresentationDisk* tester = dynamic_cast<const ImageRepresentationDisk*>(source)) {
WeaklyTypedPointer wtp = tester->getImageData();
if (wtp._pointer == 0) {
LERROR("Could not load image from disk during conversion.");
return 0;
}
ImageRepresentationGL* toReturn = ImageRepresentationGL::create(const_cast<ImageData*>(tester->getParent()), wtp);
delete wtp._pointer;
return toReturn;
......
# CMake file for columbia module
# Source files:
FILE(GLOB ThisModSources RELATIVE ${ModulesDir}
modules/columbia/pipelines/*.cpp
modules/columbia/processors/*.cpp
)
# Header files (including GLSL files so that they'll appear in VS projects)
FILE(GLOB ThisModHeaders RELATIVE ${ModulesDir}
modules/columbia/glsl/*.frag
modules/columbia/glsl/*.vert
modules/columbia/pipelines/*.h
modules/columbia/processors/*.h
)
SET(ThisModShaderDirectories "modules/columbia/glsl")
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// 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 Universitt Mnchen
// Boltzmannstr. 3, 85748 Garching b. Mnchen, Germany
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// 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.
//
// 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.
//
// ================================================================================================
#include "columbia1.h"
#include "tgt/event/keyevent.h"
#include "tgt/glcontext.h"
#include "tgt/qt/qtcontextmanager.h"
#include "core/datastructures/imagedata.h"
#include "core/classification/geometry1dtransferfunction.h"
#include "core/classification/tfgeometry1d.h"
namespace campvis {
Columbia1::Columbia1()
: VisualizationPipeline()
, _camera("camera", "Camera")
, _imageReader()
, _vr(_effectiveRenderTargetSize)
, _trackballEH(0)
{
addProperty(&_camera);
_trackballEH = new TrackballNavigationEventHandler(this, &_camera, _canvasSize.getValue());
_eventHandlers.push_back(_trackballEH);
addProcessor(&_imageReader);
addProcessor(&_splitter);
addProcessor(&_vr);
}
Columbia1::~Columbia1() {
delete _trackballEH;
}
void Columbia1::init() {
VisualizationPipeline::init();
_splitter.s_validated.connect(this, &Columbia1::onProcessorValidated);
_camera.addSharedProperty(&_vr.p_camera);
_vr.p_outputImage.setValue("vr");
_renderTargetID.setValue("vr");
_imageReader.p_url.setValue("D:/Medical Data/Columbia/inputs/FullVolumeLV_3D_25Hz_[IM_0004]_NIF_diffused_crop_00.ltf");
_imageReader.p_size.setValue(tgt::ivec3(224, 176, 208));
_imageReader.p_targetImageID.setValue("reader.output");
_imageReader.p_targetImageID.connect(&_splitter.p_inputID);
_splitter.p_outputID.connect(&_vr.p_inputVolume);
Geometry1DTransferFunction* dvrTF = new Geometry1DTransferFunction(128, tgt::vec2(0.f, 1.f));
dvrTF->addGeometry(TFGeometry1D::createQuad(tgt::vec2(.1f, .125f), tgt::col4(255, 0, 0, 32), tgt::col4(255, 0, 0, 32)));
dvrTF->addGeometry(TFGeometry1D::createQuad(tgt::vec2(.4f, .5f), tgt::col4(0, 255, 0, 128), tgt::col4(0, 255, 0, 128)));
static_cast<TransferFunctionProperty*>(_vr.getProperty("transferFunction"))->replaceTF(dvrTF);
_trackballEH->setViewportSize(_effectiveRenderTargetSize.getValue());
_effectiveRenderTargetSize.s_changed.connect<Columbia1>(this, &Columbia1::onRenderTargetSizeChanged);
}
void Columbia1::deinit() {
_effectiveRenderTargetSize.s_changed.disconnect(this);
VisualizationPipeline::deinit();
}
const std::string Columbia1::getName() const {
return "Columbia1";
}
void Columbia1::onRenderTargetSizeChanged(const AbstractProperty* prop) {
_trackballEH->setViewportSize(_canvasSize.getValue());
float ratio = static_cast<float>(_effectiveRenderTargetSize.getValue().x) / static_cast<float>(_effectiveRenderTargetSize.getValue().y);
_camera.setWindowRatio(ratio);
}
void Columbia1::onProcessorValidated(AbstractProcessor* processor) {
if (processor == &_splitter) {
// update camera
DataContainer::ScopedTypedData<ImageData> img(_data, _splitter.p_outputID.getValue());
if (img != 0) {
tgt::Bounds volumeExtent = img->getWorldBounds();
tgt::vec3 pos = volumeExtent.center() - tgt::vec3(0, 0, tgt::length(volumeExtent.diagonal()));
_trackballEH->setSceneBounds(volumeExtent);
_trackballEH->setCenter(volumeExtent.center());
_trackballEH->reinitializeCamera(pos, volumeExtent.center(), _camera.getValue().getUpVector());
}
}
}
}
\ No newline at end of file
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// 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".
//
// 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.
//
// 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.
//
// ================================================================================================
#ifndef COLUMBIA1_H__
#define COLUMBIA1_H__
#include "core/eventhandlers/trackballnavigationeventhandler.h"
#include "core/pipeline/visualizationpipeline.h"
#include "core/properties/cameraproperty.h"
#include "modules/io/processors/ltfimagereader.h"
#include "modules/columbia/processors/imageseriessplitter.h"
#include "modules/vis/processors/volumerenderer.h"
namespace campvis {
class Columbia1 : public VisualizationPipeline {
public:
/**
* Creates a VisualizationPipeline.
*/
Columbia1();
/**
* Virtual Destructor
**/
virtual ~Columbia1();
/// \see VisualizationPipeline::init()
virtual void init();
/// \see VisualizationPipeline::deinit()
virtual void deinit();
/// \see AbstractPipeline::getName()
virtual const std::string getName() const;
void onRenderTargetSizeChanged(const AbstractProperty* prop);
protected:
/**
* Slot getting called when one of the observed processors got validated.
* Updates the camera properties, when the input image has changed.
* \param processor The processor that emitted the signal
*/
virtual void onProcessorValidated(AbstractProcessor* processor);
CameraProperty _camera;
LtfImageReader _imageReader;
ImageSeriesSplitter _splitter;
VolumeRenderer _vr;
TrackballNavigationEventHandler* _trackballEH;
};
}
#endif // COLUMBIA1_H__
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// 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 Universitt Mnchen
// Boltzmannstr. 3, 85748 Garching b. Mnchen, Germany
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// 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.
//
// 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.
//
// ================================================================================================
#include "imageseriessplitter.h"
#include "core/datastructures/imageseries.h"
namespace campvis {
const std::string ImageSeriesSplitter::loggerCat_ = "CAMPVis.modules.io.ImageSeriesSplitter";
ImageSeriesSplitter::ImageSeriesSplitter()
: AbstractProcessor()
, p_inputID("InputID", "Input Image Series ID", "input", DataNameProperty::READ, AbstractProcessor::INVALID_RESULT | AbstractProcessor::INVALID_PROPERTIES)
, p_outputID("OutputID", "Output Image ID", "output", DataNameProperty::WRITE)
, p_imageIndex("ImageIndex", "Image to Select", 0, 0, 0)
{
addProperty(&p_inputID);
addProperty(&p_outputID);
addProperty(&p_imageIndex);
}
ImageSeriesSplitter::~ImageSeriesSplitter() {
}
void ImageSeriesSplitter::process(DataContainer& data) {
DataContainer::ScopedTypedData<ImageSeries> series(data, p_inputID.getValue());
if (series != 0) {
if (hasInvalidProperties()) {
p_imageIndex.setMaxValue(series->getNumImages());
}
if (p_imageIndex.getValue() < static_cast<int>(series->getNumImages())) {
data.addDataHandle(p_outputID.getValue(), series->getImage(p_imageIndex.getValue()));
p_outputID.issueWrite();
}
}
validate(INVALID_RESULT);
}
}
\ No newline at end of file
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// 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".
//
// 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.
//
// 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.
//
// ================================================================================================
#ifndef IMAGESERIESSPLITTER_H__
#define IMAGESERIESSPLITTER_H__
#include "core/pipeline/abstractprocessor.h"
#include "core/properties/datanameproperty.h"
#include "core/properties/numericproperty.h"
namespace campvis {
/**
* Splits an ImageSeries into its single images.
*/
class ImageSeriesSplitter : public AbstractProcessor {
public:
/**
* Constructs a new ImageSeriesSplitter Processor
**/
ImageSeriesSplitter();
/**
* Destructor
**/
virtual ~ImageSeriesSplitter();
/**
* Reads the raw file into an ImageRepresentationDisk representation
* \param data DataContainer to work on
*/
virtual void process(DataContainer& data);
/// \see AbstractProcessor::getName()
virtual const std::string getName() const { return "ImageSeriesSplitter"; };
/// \see AbstractProcessor::getDescription()
virtual const std::string getDescription() const { return "Splits an ImageSeries into its single images."; };
DataNameProperty p_inputID; ///< image ID for input image series
DataNameProperty p_outputID; ///< image ID for output image
IntProperty p_imageIndex; ///< index of the image to select
protected:
static const std::string loggerCat_;
};
}
#endif // IMAGESERIESSPLITTER_H__
......@@ -82,15 +82,17 @@ namespace campvis {
std::string noExt = tgt::FileSystem::fullBaseName(p_url.getValue());
std::string::size_type offset = noExt.find_last_not_of("0123456789");
if (offset != std::string::npos) {
++offset;
std::string base = noExt.substr(0, offset);
int index = StringUtils::fromString<int>(noExt.substr(offset));
ImageSeries* series = new ImageSeries();
while (tgt::FileSystem::fileExists(base + StringUtils::toString(index, noExt.size() - offset, '0') + ".ltf")) {
ImageData* image = new ImageData(dimensionality, p_size.getValue(), p_numChannels.getValue());
ImageRepresentationDisk::create(image, StringUtils::toString(index, noExt.size() - offset, '0'), p_baseType.getOptionValue(), 0, EndianHelper::getLocalEndianness());
ImageRepresentationDisk::create(image, base + StringUtils::toString(index, noExt.size() - offset, '0') + ".ltf", p_baseType.getOptionValue(), 0, EndianHelper::getLocalEndianness());
image->setMappingInformation(ImageMappingInformation(p_size.getValue(), p_imageOffset.getValue(), p_voxelSize.getValue()));
series->addImage(image);
++index;
}
data.addData(p_targetImageID.getValue(), series);
......
Markdown is supported
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