Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Philipp Bock
campvis-public
Commits
4c214bf8
Commit
4c214bf8
authored
Oct 17, 2013
by
Christian Schulte zu Berge
Browse files
further work on CAMPCom module
parent
54537480
Changes
9
Hide whitespace changes
Inline
Side-by-side
core/datastructures/imagerepresentationlocal.cpp
View file @
4c214bf8
...
...
@@ -66,7 +66,7 @@ namespace campvis {
// test source image type via dynamic cast
if
(
const
ImageRepresentationDisk
*
tester
=
dynamic_cast
<
const
ImageRepresentationDisk
*>
(
source
))
{
return
c
onvertToGenericLocal
(
tester
,
tester
->
getImageData
());
return
c
reate
(
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
=
c
onvertToGenericLocal
(
source
,
wtp
);
toReturn
=
c
reate
(
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
->
getP
arent
()
),
\
const_cast
<
ImageData
*>
(
p
arent
),
\
reinterpret_cast
<
TypeTraits
<
baseType
,
numChannels
>::
ElementType
*>
(
wtp
.
_pointer
));
#define DISPATCH_DISK_TO_GENERIC_LOCAL_CONVERSION(numChannels) \
if
(
source
->
getP
arent
()
->
getNumChannels
()
==
(
numChannels
))
{
\
if
(
p
arent
->
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
core/datastructures/imagerepresentationlocal.h
View file @
4c214bf8
...
...
@@ -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
);
...
...
core/tools/weaklytypedpointer.cpp
View file @
4c214bf8
...
...
@@ -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.
}
...
...
core/tools/weaklytypedpointer.h
View file @
4c214bf8
...
...
@@ -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!
*/
...
...
modules/campcom/FindCAMPCom.cmake
View file @
4c214bf8
...
...
@@ -80,10 +80,11 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(CAMPCOM REQUIRED_VARS CAMPCOM_LIBRARY CAMPCOM_
if
(
CAMPCOM_FOUND
)
set
(
CAMPCOM_INCLUDE_DIRS
${
CAMPCOM_INCLUDE_DIR
}
)
set
(
CAMPCOM_LIBRARIES
${
CAMPCOM_LIBRARY
}
)
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
...
...
modules/campcom/campcom.cmake
View file @
4c214bf8
...
...
@@ -4,12 +4,19 @@ LIST(APPEND CMAKE_MODULE_PATH "${ModulesDir}/campcom")
FIND_PACKAGE
(
CAMPCom REQUIRED
)
IF
(
CAMPCOM_FOUND
)
LIST
(
APPEND ThisModIncludeDirs
${
CAMPCOM_INCLUDE_DIRS
}
)
#
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/campcommhdreceiver.cpp
View file @
4c214bf8
...
...
@@ -27,10 +27,13 @@
//
// ================================================================================================
#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"
;
...
...
@@ -44,6 +47,8 @@ namespace campvis {
,
p_voxelSize
(
"VoxelSize"
,
"Voxel Size in mm"
,
tgt
::
vec3
(
1.
f
),
tgt
::
vec3
(
-
100.
f
),
tgt
::
vec3
(
100.
f
),
tgt
::
vec3
(
0.1
f
))
,
_ccclient
(
0
)
{
_incomingMhd
=
0
;
addProperty
(
&
p_address
);
addProperty
(
&
p_targetImageID
);
addProperty
(
&
p_connect
);
...
...
@@ -62,17 +67,58 @@ namespace campvis {
void
CampcomMhdReceiver
::
deinit
()
{
p_connect
.
s_clicked
.
disconnect
(
this
);
_ccclient
->
disconnect
();
delete
_ccclient
;
if
(
_ccclient
)
{
_ccclient
->
disconnect
();
delete
_ccclient
;
}
_ccclient
=
0
;
}
void
CampcomMhdReceiver
::
process
(
DataContainer
&
data
)
{
validate
(
INVALID_RESULT
);
campcom
::
MHDImageData
*
mid
=
_incomingMhd
.
fetch_and_store
(
0
);
if
(
mid
==
0
)
return
;
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);
//
ImageRepresentation
Disk
::create(image,
url, pt, offset, e
);
//
image->setMappingInformation(ImageMappingInformation(size, imageOffset + p_imageOffset.getValue(), voxelSize * p_voxelSize.getValue()));
//
data.addData(p_targetImageID.getValue(), image);
ImageData
*
image
=
new
ImageData
(
dimensionality
,
size
,
numChannels
);
ImageRepresentation
Local
::
create
(
image
,
wtp
);
image
->
setMappingInformation
(
ImageMappingInformation
(
size
,
imageOffset
+
p_imageOffset
.
getValue
(),
voxelSize
*
p_voxelSize
.
getValue
()));
data
.
addData
(
p_targetImageID
.
getValue
(),
image
);
validate
(
INVALID_RESULT
);
}
...
...
@@ -84,7 +130,7 @@ namespace campvis {
_ccclient
=
0
;
}
_ccclient
=
new
campcom
::
CAMPComClient
(
"Campvis"
,
campcom
::
Device_
CAMPVis
,
p_address
.
getValue
());
_ccclient
=
new
campcom
::
CAMPComClient
(
"Campvis"
,
campcom
::
Device_
TestDevice
,
p_address
.
getValue
());
_ccclient
->
connect
();
if
(
_ccclient
->
isConnected
())
{
campcom
::
DataCallback
dc
;
...
...
@@ -94,12 +140,27 @@ namespace campvis {
}
else
{
LWARNING
(
"Could not connect to CAMPCom server."
);
delete
_ccclient
;
//
delete _ccclient;
_ccclient
=
0
;
}
}
void
CampcomMhdReceiver
::
ccReceiveImage
(
std
::
vector
<
campcom
::
Byte
>&
msg
)
{
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..."
);
campcom
::
MHDImageData
*
copy
=
new
campcom
::
MHDImageData
(
return_payload
);
campcom
::
MHDImageData
*
toDelete
=
_incomingMhd
.
fetch_and_store
(
copy
);
delete
toDelete
;
invalidate
(
INVALID_RESULT
);
}
else
{
LWARNING
(
"New MHDImageData received but it isn't valid!"
);
}
}
...
...
modules/campcom/processors/campcommhdreceiver.h
View file @
4c214bf8
...
...
@@ -36,6 +36,8 @@
#include
<CommonLib/DataTypes/MHDImageData.hpp>
#include
<ClientLib/src/CAMPComClient.hpp>
#include
<tbb/atomic.h>
#include
"core/pipeline/abstractprocessor.h"
#include
"core/properties/buttonproperty.h"
#include
"core/properties/datanameproperty.h"
...
...
@@ -95,6 +97,7 @@ namespace campvis {
void
ccSuccessCalback
(
bool
b
);
campcom
::
CAMPComClient
*
_ccclient
;
tbb
::
atomic
<
campcom
::
MHDImageData
*>
_incomingMhd
;
static
const
std
::
string
loggerCat_
;
};
...
...
modules/vis/processors/volumerenderer.cpp
View file @
4c214bf8
...
...
@@ -89,6 +89,7 @@ namespace campvis {
p_outputImage
.
addSharedProperty
(
&
_raycaster
.
p_targetImageID
);
p_inputVolume
.
s_changed
.
connect
(
this
,
&
VolumeRenderer
::
onPropertyChanged
);
}
VolumeRenderer
::~
VolumeRenderer
()
{
...
...
@@ -162,6 +163,9 @@ namespace campvis {
_eepGenerator
.
p_exitImageID
.
setValue
(
p_outputImage
.
getValue
()
+
".exitpoints"
);
_raycaster
.
p_exitImageID
.
setValue
(
p_outputImage
.
getValue
()
+
".exitpoints"
);
}
else
if
(
prop
==
&
p_inputVolume
)
{
invalidate
(
AbstractProcessor
::
INVALID_RESULT
|
PG_INVALID
);
}
VisualizationProcessor
::
onPropertyChanged
(
prop
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment