Commit 4eee7eb0 authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

Merge branch 'campcom' of /mnt/bigone/git/repositories/berge/campvis into development

parents 3f841777 795b4856
......@@ -66,7 +66,7 @@ namespace campvis {
// test source image type via dynamic cast
if (const ImageRepresentationDisk* tester = dynamic_cast<const ImageRepresentationDisk*>(source)) {
return convertToGenericLocal(tester, tester->getImageData());
return create(tester->getParent(), tester->getImageData());
}
else if (const ImageRepresentationGL* tester = dynamic_cast<const ImageRepresentationGL*>(source)) {
// FIXME: this here deadlocks, if called from OpenGL context (GLJobProc)!!!
......@@ -76,7 +76,7 @@ namespace campvis {
try {
tgt::GLContextScopedLock lock(context);
WeaklyTypedPointer wtp = tester->getWeaklyTypedPointer();
toReturn = convertToGenericLocal(source, wtp);
toReturn = create(source->getParent(), wtp);
}
catch (...) {
LERROR("An unknown error occured during conversion...");
......@@ -186,14 +186,15 @@ namespace campvis {
});
}
ImageRepresentationLocal* ImageRepresentationLocal::convertToGenericLocal(const AbstractImageRepresentation* source, const WeaklyTypedPointer& wtp) {
ImageRepresentationLocal* ImageRepresentationLocal::create(const ImageData* parent, WeaklyTypedPointer wtp) {
#define CONVERT_DISK_TO_GENERIC_LOCAL(baseType,numChannels) \
return GenericImageRepresentationLocal<baseType, numChannels>::create( \
const_cast<ImageData*>(source->getParent()), \
const_cast<ImageData*>(parent), \
reinterpret_cast< TypeTraits<baseType, numChannels>::ElementType*>(wtp._pointer));
#define DISPATCH_DISK_TO_GENERIC_LOCAL_CONVERSION(numChannels) \
if (source->getParent()->getNumChannels() == (numChannels)) { \
if (parent->getNumChannels() == (numChannels)) { \
switch (wtp._baseType) { \
case WeaklyTypedPointer::UINT8: \
CONVERT_DISK_TO_GENERIC_LOCAL(uint8_t, (numChannels)) \
......@@ -223,7 +224,7 @@ namespace campvis {
tgtAssert(false, "Should not reach this - wrong number of channel!");
return 0;
}
}
}
\ No newline at end of file
......@@ -63,6 +63,8 @@ namespace campvis {
*/
static ImageRepresentationLocal* tryConvertFrom(const AbstractImageRepresentation* source);
static ImageRepresentationLocal* create(const ImageData* parent, WeaklyTypedPointer wtp);
/// \see AbstractData::clone()
virtual ImageRepresentationLocal* clone(ImageData* newParent) const = 0;
......@@ -210,9 +212,6 @@ namespace campvis {
private:
static ImageRepresentationLocal* convertToGenericLocal(const AbstractImageRepresentation* source, const WeaklyTypedPointer& wtp);
// We don't want this data to be copied - clone() must be enough
// (read: We are too lazy to implement a correct copy constructor / assignment-operator)
ImageRepresentationLocal(const ImageRepresentationLocal& rhs);
......
......@@ -40,6 +40,13 @@ namespace campvis {
tgtAssert(_numChannels > 0 && _numChannels <= 4, "Number of channels out of bounds!");
};
WeaklyTypedPointer::WeaklyTypedPointer()
: _baseType(UINT8)
, _numChannels(0)
, _pointer(0)
{
}
WeaklyTypedPointer::~WeaklyTypedPointer() {
// We do _not_ own the pointer, so we don't need to delete it.
}
......
......@@ -105,6 +105,11 @@ namespace campvis {
*/
WeaklyTypedPointer(BaseType pt, size_t numChannels, void* ptr);
/**
* Empty default constructor, you have to initialize everything yourself.
*/
WeaklyTypedPointer();
/**
* Destructor, does _not_ delete the handled pointer!
*/
......
# - Find CAMPCOM
# Find the native CAMPCOM includes and library.
# Once done this will define
#
# CAMPCOM_INCLUDE_DIRS - where to find the CAMPCom header files etc.
# CAMPCOM_LIBRARIES - List of libraries when using CAMPCOM.
# CAMPCOM_FOUND - True if CAMPCOM found.
#
# CAMPCOM_VERSION_STRING - The version of CAMPCOM found (x.y.z)
# CAMPCOM_VERSION_MAJOR - The major version of CAMPCOM
# CAMPCOM_VERSION_MINOR - The minor version of CAMPCOM
# CAMPCOM_VERSION_PATCH - The patch version of CAMPCOM
# CAMPCOM_VERSION_TWEAK - The tweak version of CAMPCOM
#
# The following variable are provided for backward compatibility
#
# CAMPCOM_MAJOR_VERSION - The major version of CAMPCOM
# CAMPCOM_MINOR_VERSION - The minor version of CAMPCOM
# CAMPCOM_PATCH_VERSION - The patch version of CAMPCOM
#
# An includer may set CAMPCOM_ROOT to a CAMPCOM installation root to tell
# this module where to look.
set(_CAMPCOM_SEARCHES)
# Search CAMPCOM_ROOT first if it is set.
if(CAMPCOM_ROOT)
set(_CAMPCOM_SEARCH_ROOT PATHS ${CAMPCOM_ROOT} NO_DEFAULT_PATH)
list(APPEND _CAMPCOM_SEARCHES _CAMPCOM_SEARCH_ROOT)
endif()
# Normal search.
set(_CAMPCOM_SEARCH_NORMAL
PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\CAMPCOM;InstallPath]"
"$ENV{PROGRAMFILES}/CAMPCOM"
"$ENV{CAMPCOM_DIR}"
"$ENV{CAMPCOM_ROOT}"
"${CAMPCOM_BUILD}/bin"
"${CAMPCOM_BUILD}/bin/Debug"
"${CAMPCOM_BUILD}/bin/Release"
)
list(APPEND _CAMPCOM_SEARCHES _CAMPCOM_SEARCH_NORMAL)
set(CAMPCOM_NAMES CCClientLib CCCCommonLib CCServerLib)
# Try each search configuration.
foreach(search ${_CAMPCOM_SEARCHES})
find_path(CAMPCOM_INCLUDE_DIR NAMES CommonLib/Main/CAMPComDefinitions.h ${${search}} PATH_SUFFIXES include)
find_library(CAMPCOM_LIBRARY NAMES ${CAMPCOM_NAMES} ${${search}} PATH_SUFFIXES lib)
endforeach()
mark_as_advanced(CAMPCOM_LIBRARY CAMPCOM_INCLUDE_DIR)
if(CAMPCOM_INCLUDE_DIR AND EXISTS "${CAMPCOM_INCLUDE_DIR}/CommonLib/Main/CAMPComDefinitions.h")
file(STRINGS "${CAMPCOM_INCLUDE_DIR}/CommonLib/Main/CAMPComDefinitions.h" CAMPCOM_H REGEX "^#define CAMPCOM_VERSION \"[^\"]*\"$")
string(REGEX REPLACE "^.*CAMPCOM_VERSION \"([0-9]+).*$" "\\1" CAMPCOM_VERSION_MAJOR "${CAMPCOM_H}")
string(REGEX REPLACE "^.*CAMPCOM_VERSION \"[0-9]+\\.([0-9]+).*$" "\\1" CAMPCOM_VERSION_MINOR "${CAMPCOM_H}")
string(REGEX REPLACE "^.*CAMPCOM_VERSION \"[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" CAMPCOM_VERSION_PATCH "${CAMPCOM_H}")
set(CAMPCOM_VERSION_STRING "${CAMPCOM_VERSION_MAJOR}.${CAMPCOM_VERSION_MINOR}.${CAMPCOM_VERSION_PATCH}")
# only append a TWEAK version if it exists:
set(CAMPCOM_VERSION_TWEAK "")
if( "${CAMPCOM_H}" MATCHES "^.*CAMPCOM_VERSION \"[0-9]+\\.[0-9]+\\.[0-9]+\\.([0-9]+).*$")
set(CAMPCOM_VERSION_TWEAK "${CMAKE_MATCH_1}")
set(CAMPCOM_VERSION_STRING "${CAMPCOM_VERSION_STRING}.${CAMPCOM_VERSION_TWEAK}")
endif()
set(CAMPCOM_MAJOR_VERSION "${CAMPCOM_VERSION_MAJOR}")
set(CAMPCOM_MINOR_VERSION "${CAMPCOM_VERSION_MINOR}")
set(CAMPCOM_PATCH_VERSION "${CAMPCOM_VERSION_PATCH}")
endif()
# handle the QUIETLY and REQUIRED arguments and set CAMPCOM_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(CAMPCOM REQUIRED_VARS CAMPCOM_LIBRARY CAMPCOM_INCLUDE_DIR
VERSION_VAR CAMPCOM_VERSION_STRING)
if(CAMPCOM_FOUND)
set(CAMPCOM_INCLUDE_DIRS ${CAMPCOM_INCLUDE_DIR})
GET_FILENAME_COMPONENT(CcLibPath ${CAMPCOM_LIBRARY} PATH)
GET_FILENAME_COMPONENT(LibExt ${CAMPCOM_LIBRARY} EXT)
set(CAMPCOM_LIBRARIES "${CcLibPath}/CCClientLib${LibExt}" "${CcLibPath}/CCCommonLib${LibExt}" "${CcLibPath}/CCServerLib${LibExt}")
endif()
LIST(APPEND CAMPCOM_INCLUDE_DIRS
${CAMPCOM_INCLUDE_DIR}/CommonLib/MathLib
${CAMPCOM_INCLUDE_DIR}/CommonLib/MathLib/GL
${CAMPCOM_INCLUDE_DIR}/CommonLib/Messages
${CAMPCOM_INCLUDE_DIR}/CommonLib/Util
${CAMPCOM_INCLUDE_DIR}/CommonLib/Main
${CAMPCOM_INCLUDE_DIR}/CommonLib/Ext
${CAMPCOM_INCLUDE_DIR}/CommonLib/DataTypes
${CAMPCOM_INCLUDE_DIR}/TrackingLib/src
${CAMPCOM_INCLUDE_DIR}/TrackingLib/NDI
${CAMPCOM_INCLUDE_DIR}/TrackingLib/Ascension
${CAMPCOM_INCLUDE_DIR}/ClientLib/src
${CAMPCOM_INCLUDE_DIR}/ServerLib/src)
\ No newline at end of file
# CMake file for campcom module
LIST(APPEND CMAKE_MODULE_PATH "${ModulesDir}/campcom")
FIND_PACKAGE(CAMPCom REQUIRED)
IF(CAMPCOM_FOUND)
#LIST(APPEND ThisModIncludeDirs ${CAMPCOM_INCLUDE_DIRS})
LIST(APPEND ThisModExternalLibs ${CAMPCOM_LIBRARIES})
# dirty hack
INCLUDE("${CAMPCOM_INCLUDE_DIR}/cmake/campcom_use_file.cmake")
LIST(APPEND ThisModIncludeDirs ${CAMPCOM_INCLUDE_DIRS})
LIST(APPEND ThisModExternalLibs ${CAMPCOM_EXTERNAL_LIBS})
ELSE()
MESSAGE(FATAL_ERROR "Could not find CAMPCom. Please specify CAMPCOM_ROOT.")
ENDIF()
# Source files:
FILE(GLOB ThisModSources RELATIVE ${ModulesDir}
modules/campcom/pipelines/*.cpp
modules/campcom/processors/*.cpp
)
# Header files (including GLSL files so that they'll appear in VS projects)
FILE(GLOB ThisModHeaders RELATIVE ${ModulesDir}
modules/campcom/pipelines/*.h
modules/campcom/processors/*.h
)
SET(ThisModDependencies vis)
// ================================================================================================
//
// 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 "streamingmhddemo.h"
#include "tgt/event/keyevent.h"
#include "core/datastructures/imagedata.h"
#include "core/classification/geometry1dtransferfunction.h"
#include "core/classification/tfgeometry1d.h"
namespace campvis {
StreamingMhdDemo::StreamingMhdDemo(DataContainer* dc)
: AutoEvaluationPipeline(dc)
, _imageReader()
, _ve(&_canvasSize)
{
addProcessor(&_imageReader);
addProcessor(&_ve);
addEventListenerToBack(&_ve);
}
StreamingMhdDemo::~StreamingMhdDemo() {
}
void StreamingMhdDemo::init() {
AutoEvaluationPipeline::init();
_imageReader.s_validated.connect(this, &StreamingMhdDemo::onProcessorValidated);
_ve.p_outputImage.setValue("combine");
_renderTargetID.setValue("combine");
_imageReader.p_address.setValue("127.0.0.1");
_imageReader.p_targetImageID.setValue("reader.output");
_imageReader.p_targetImageID.addSharedProperty(&_ve.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*>(_ve.getProperty("TransferFunction"))->replaceTF(dvrTF);
_canvasSize.s_changed.connect<StreamingMhdDemo>(this, &StreamingMhdDemo::onRenderTargetSizeChanged);
}
void StreamingMhdDemo::deinit() {
_canvasSize.s_changed.disconnect(this);
AutoEvaluationPipeline::deinit();
}
void StreamingMhdDemo::onRenderTargetSizeChanged(const AbstractProperty* prop) {
}
void StreamingMhdDemo::onProcessorValidated(AbstractProcessor* processor) {
}
}
\ 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 STREAMINGMHDDEMO_H__
#define STREAMINGMHDDEMO_H__
#include "modules/campcom/processors/campcommhdreceiver.h"
#include "core/pipeline/autoevaluationpipeline.h"
#include "core/properties/cameraproperty.h"
#include "modules/vis/processors/volumeexplorer.h"
namespace campvis {
class StreamingMhdDemo : public AutoEvaluationPipeline {
public:
/**
* Creates a AutoEvaluationPipeline.
*/
StreamingMhdDemo(DataContainer* dc);
/**
* Virtual Destructor
**/
virtual ~StreamingMhdDemo();
/// \see AutoEvaluationPipeline::init()
virtual void init();
/// \see AutoEvaluationPipeline::deinit()
virtual void deinit();
/// \see AbstractPipeline::getName()
virtual const std::string getName() const { return getId(); };
static const std::string getId() { return "StreamingMhdDemo"; };
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);
CampcomMhdReceiver _imageReader;
VolumeExplorer _ve;
};
}
#endif // STREAMINGMHDDEMO_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.
//
// ================================================================================================
#define CAMPCOM_FAST_SERIALIZATION
#include "campcommhdreceiver.h"
#include "core/datastructures/imagedata.h"
#include "core/datastructures/genericimagerepresentationlocal.h"
#include "core/tools/stringutils.h"
namespace campvis {
const std::string CampcomMhdReceiver::loggerCat_ = "CAMPVis.modules.io.CampcomMhdReceiver";
CampcomMhdReceiver::CampcomMhdReceiver()
: AbstractProcessor()
, p_address("ServerAddress", "Server Address", "127.0.0.1")
, p_connect("Connect", "Connect to Server", AbstractProcessor::VALID)
, p_targetImageID("targetImageName", "Target Image ID", "CampcomMhdReceiver.output", DataNameProperty::WRITE)
, 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))
, _ccclient(0)
{
_incomingMhd = 0;
addProperty(&p_address);
addProperty(&p_targetImageID);
addProperty(&p_connect);
addProperty(&p_imageOffset);
addProperty(&p_voxelSize);
}
CampcomMhdReceiver::~CampcomMhdReceiver() {
}
void CampcomMhdReceiver::init() {
p_connect.s_clicked.connect(this, &CampcomMhdReceiver::onBtnConnectClicked);
}
void CampcomMhdReceiver::deinit() {
p_connect.s_clicked.disconnect(this);
if (_ccclient) {
_ccclient->disconnect();
delete _ccclient;
}
_ccclient = 0;
}
void CampcomMhdReceiver::process(DataContainer& data) {
validate(INVALID_RESULT);
// Get the last received MHD file:
// Use atomic fetch and store because at the same time CAMPCom may receive another file!
campcom::MHDImageData* mid = _incomingMhd.fetch_and_store(0);
if (mid == 0)
return;
// Transform campcom::MHDImageData to campvis::ImageData
int numChannels = 1;
size_t dimensionality = mid->NDims;
tgt::svec3 size(1);
for (int i = 0; i < mid->DimSize.size(); ++i)
size.elem[i] = mid->DimSize[i];
WeaklyTypedPointer wtp;
wtp._pointer = &(mid->imageData.front().front());
wtp._numChannels = numChannels;
std::string et = StringUtils::uppercase(mid->elementType);
if (et == "MET_UCHAR")
wtp._baseType = WeaklyTypedPointer::UINT8;
else if (et == "MET_CHAR")
wtp._baseType = WeaklyTypedPointer::INT8;
else if (et == "MET_USHORT")
wtp._baseType = WeaklyTypedPointer::UINT16;
else if (et == "MET_SHORT")
wtp._baseType = WeaklyTypedPointer::INT16;
else if (et == "MET_UINT")
wtp._baseType = WeaklyTypedPointer::UINT32;
else if (et == "MET_INT")
wtp._baseType = WeaklyTypedPointer::INT32;
else if (et == "MET_FLOAT")
wtp._baseType = WeaklyTypedPointer::FLOAT;
else {
LERROR("Error while parsing MHD header: Unsupported element type: " << et);
return;
}
tgt::vec3 imageOffset(0.f);
tgt::vec3 voxelSize(1.f);
// all parsing done - lets create the image:
ImageData* image = new ImageData(dimensionality, size, numChannels);
ImageRepresentationLocal::create(image, wtp);
image->setMappingInformation(ImageMappingInformation(size, imageOffset + p_imageOffset.getValue(), voxelSize * p_voxelSize.getValue()));
data.addData(p_targetImageID.getValue(), image);
}
void CampcomMhdReceiver::onBtnConnectClicked() {
// CAMPComClient does not support dis-/reconnect. So we have to delete it and recreate it.
if (_ccclient) {
_ccclient->disconnect();
delete _ccclient;
_ccclient = 0;
}
// create CAMPComClient and subscribe.
_ccclient = new campcom::CAMPComClient("Campvis", campcom::Device_TestDevice, p_address.getValue());
_ccclient->connect();
if (_ccclient->isConnected()) {
// use ugly boost magic to connect to member function (unfortunately CAMPCom only supports free functions...)
campcom::DataCallback dc = boost::bind(&CampcomMhdReceiver::ccReceiveImage, this, _1);
campcom::SuccessCallback sc = std::bind1st(std::mem_fun(&CampcomMhdReceiver::ccSuccessCallback), this);
_ccclient->subscribe(campcom::Type_Image, dc, sc);
}
else {
LWARNING("Could not connect to CAMPCom server.");
delete _ccclient;
_ccclient = 0;
}
}
void CampcomMhdReceiver::ccReceiveImage(std::vector<campcom::Byte>& msg) {
// Deserialize payload
campcom::MHDImageData return_payload;
campcom::Header header;
campcom::TypeHandler<campcom::MHDImageData>::deserializePayload(&msg[0], msg.size(), return_payload);
if (campcom::MHDImageData::isValid(return_payload)) {
LINFO("New valid MHDImageData received! Pushing it to the DataContainer...");
// putting the image into the DataContainer has to be done asynchroneously, because we
// don't know the DataContainer here... :/
// So copy the image one more time, but it into _incomingMhd and invalidate the processor.
// Use atomic fetch and store because at the same time we may convert the last received image!
campcom::MHDImageData* copy = new campcom::MHDImageData(return_payload);
// delete old image not yet converted (if present)
campcom::MHDImageData* toDelete = _incomingMhd.fetch_and_store(copy);
delete toDelete;
invalidate(INVALID_RESULT);
}
else {
LWARNING("New MHDImageData received but it isn't valid!");
}
}
void CampcomMhdReceiver::ccSuccessCallback(bool b) {
LINFO("CAMPCom subscribe callback: " << b);
}
}
\ 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 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