Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
9.2.2023: Due to updates GitLab will be unavailable for some minutes between 9:00 and 11:00.
Open sidebar
CAMP
campvis-public
Commits
a5c67131
Commit
a5c67131
authored
Dec 30, 2013
by
Christian Schulte zu Berge
Browse files
Implemented image conversion Disk -> GenericLocal if base type and number of channels matches
parent
634d2db1
Changes
2
Hide whitespace changes
Inline
Side-by-side
core/datastructures/genericimagerepresentationlocal.h
View file @
a5c67131
...
...
@@ -26,6 +26,7 @@
#define GENERICIMAGEREPRESENTATIONLOCAL_H__
#include
"core/datastructures/imagerepresentationlocal.h"
#include
"core/datastructures/imagerepresentationdisk.h"
#include
"core/tools/typetraits.h"
#include
<cstring>
// needed for memcpy
...
...
@@ -150,7 +151,7 @@ namespace campvis {
* \param data Pointer to the image data, must not be 0, GenericImageRepresentationLocal takes ownership of this pointer!
* \return A pointer to the newly created ImageRepresentationDisk, you do \b not own this pointer!
*/
static
GenericImageRepresentationLocal
<
BASETYPE
,
NUMCHANNELS
>*
create
(
ImageData
*
parent
,
ElementType
*
data
);
static
GenericImageRepresentationLocal
<
BASETYPE
,
NUMCHANNELS
>*
create
(
const
ImageData
*
parent
,
ElementType
*
data
);
/**
* Destructor
...
...
@@ -280,8 +281,8 @@ namespace campvis {
// = Template implementation ======================================================================
template
<
typename
BASETYPE
,
size_t
NUMCHANNELS
>
campvis
::
GenericImageRepresentationLocal
<
BASETYPE
,
NUMCHANNELS
>*
campvis
::
GenericImageRepresentationLocal
<
BASETYPE
,
NUMCHANNELS
>::
create
(
ImageData
*
parent
,
ElementType
*
data
)
{
ThisType
*
toReturn
=
new
ThisType
(
parent
,
data
);
campvis
::
GenericImageRepresentationLocal
<
BASETYPE
,
NUMCHANNELS
>*
campvis
::
GenericImageRepresentationLocal
<
BASETYPE
,
NUMCHANNELS
>::
create
(
const
ImageData
*
parent
,
ElementType
*
data
)
{
ThisType
*
toReturn
=
new
ThisType
(
const_cast
<
ImageData
*>
(
parent
)
,
data
);
toReturn
->
addToParent
();
return
toReturn
;
}
...
...
@@ -306,6 +307,12 @@ namespace campvis {
template
<
typename
BASETYPE
,
size_t
NUMCHANNELS
>
GenericImageRepresentationLocal
<
BASETYPE
,
NUMCHANNELS
>*
campvis
::
GenericImageRepresentationLocal
<
BASETYPE
,
NUMCHANNELS
>::
tryConvertFrom
(
const
AbstractImageRepresentation
*
source
)
{
if
(
const
ImageRepresentationDisk
*
tester
=
dynamic_cast
<
const
ImageRepresentationDisk
*>
(
source
))
{
if
(
tester
->
getBaseType
()
==
TypeTraits
<
BASETYPE
,
NUMCHANNELS
>::
weaklyTypedPointerBaseType
&&
tester
->
getParent
()
->
getNumChannels
()
==
NUMCHANNELS
)
{
WeaklyTypedPointer
wtp
=
tester
->
getImageData
();
return
create
(
tester
->
getParent
(),
static_cast
<
ElementType
*>
(
wtp
.
_pointer
));
}
}
return
0
;
}
...
...
core/tools/weaklytypedpointer.cpp
View file @
a5c67131
...
...
@@ -32,7 +32,7 @@ namespace campvis {
,
_numChannels
(
numChannels
)
,
_pointer
(
ptr
)
{
tgtAssert
(
_numChannels
>
0
&&
_numChannels
<=
4
,
"Number of channels out of bounds!"
);
tgtAssert
(
_numChannels
>
0
,
"Number of channels out of bounds!"
);
};
WeaklyTypedPointer
::
WeaklyTypedPointer
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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