Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CGoGN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
KennethVanhoey
CGoGN
Commits
951a7236
Commit
951a7236
authored
Dec 05, 2011
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MAJ img3DIO texture et text3D,
modification apps_cmake
parent
74a258a0
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
205 additions
and
235 deletions
+205
-235
Apps/Examples/Tests/CMakeLists.txt
Apps/Examples/Tests/CMakeLists.txt
+10
-7
README_APPS.TXT
README_APPS.TXT
+58
-0
build/apps_cmake.txt
build/apps_cmake.txt
+13
-14
include/Algo/MC/image.hpp
include/Algo/MC/image.hpp
+0
-1
include/Utils/img3D_IO.h
include/Utils/img3D_IO.h
+19
-24
include/Utils/textures.h
include/Utils/textures.h
+12
-12
include/Utils/textures.hpp
include/Utils/textures.hpp
+35
-92
src/Utils/img3D_IO.cpp
src/Utils/img3D_IO.cpp
+57
-84
src/Utils/text3d.cpp
src/Utils/text3d.cpp
+1
-1
No files found.
Apps/Examples/Tests/CMakeLists.txt
View file @
951a7236
cmake_minimum_required
(
VERSION 2.6
)
project
(
geometryAssertD
)
project
(
testing_debug
)
SET
(
CMAKE_BUILD_TYPE Debug
)
include_directories
(
${
CMAKE_CURRENT_BINARY_DIR
}
${
CGoGN_ROOT_DIR
}
/include
...
...
@@ -12,11 +11,15 @@ include_directories(
)
# define libs path
link_directories
(
${
CGoGN_ROOT_DIR
}
/lib/Debug
${
CGoGN_ROOT_DIR
}
/lib/Release
)
IF
(
WIN32
)
link_directories
(
${
CGoGN_ROOT_DIR
}
/lib/$
(
ConfigurationName
)
${
CGoGN_ROOT_DIR
}
/lib/Release
)
ELSE
(
WIN32
)
link_directories
(
${
CGoGN_ROOT_DIR
}
/lib/Debug
${
CGoGN_ROOT_DIR
}
/lib/Release
)
ENDIF
(
WIN32
)
#define exec to compile
...
...
README_APPS.TXT
0 → 100644
View file @
951a7236
Principe des applications dans CGoGN_Apps
Faire un repertoire CGoGN_Apps ou on veut. Y mettre des sous répertoires
contenant chacun une application/
Le CMakeLists.txt a la racine de l'application doit commencer par
cmake_minimum_required(VERSION 2.8)
PROJECT(NOM_DE_L_APPLICATION)
SET(CGoGN_ROOT_DIR ${CMAKE_SOURCE_DIR}/../../CGoGN)
INCLUDE(${CGoGN_ROOT_DIR}/build/apps_cmake.txt)
Le ../../CGoGN correspond au chemin relatif vers votre version de CGoGN
(ici placée au même niveau que CGoGN_Apps)
Si vous voulez faire des sous répertoires release et debug:
add_subdirectory(${CMAKE_SOURCE_DIR}/Release Release)
IF (NOT WIN32)
add_subdirectory(${CMAKE_SOURCE_DIR}/Debug Debug)
ENDIF (NOT WIN32)
Le CMakeLists (Release par exemple) doit ensuite contenir
SET(CMAKE_BUILD_TYPE Release)
link_directories( ${CGoGN_ROOT_DIR}/lib/Release/)
include_directories(
${CGoGN_ROOT_DIR}/include # for CGoGN
${COMMON_INCLUDES} # for thirdparty & system
${CMAKE_CURRENT_SOURCE_DIR} # for application
${CMAKE_CURRENT_BINARY_DIR} # for qt (ui,moc,etc.) if necessary
)
add_executable( mon_exec ${CMAKE_SOURCE_DIR}/mon_source.cpp)
target_link_libraries( mon_exec ${CGoGN_LIBS_R} ${COMMON_LIBS})
Pour le compiler le plus propre est de faire un repertoire build,
d'aller à l'interieur et de faire ccmake .. (j'ai bien ecrit "..")
ccmake (ou un equivalent type cmake-gui) permet de mettre à jour les variables,
ici WITH_QT, WITH_ASSIMP, WITH_NUMERICAL, WITH_ZINRI.
Ceci ajoutera automatiquement tout ce qu'il faut aux variables COMMON_INCLUDES
et COMMON_LIBS.
On peut aussi utiliser cmake avec l'option -D (moins pratique).
build/apps_cmake.txt
View file @
951a7236
# A mettre juste apres la definition de CGoGN_ROOT_DIR a la racine du CGoGN_Apps
# include(${CGoGN_ROOT_DIR}/build/apps_cmake.txt)
SET(CMAKE_MODULE_PATH
" ${CMAKE_MODULE_PATH} ${CGoGN_ROOT_DIR}/cmake_modules/"
)
SET(CMAKE_MODULE_PATH
${CGoGN_ROOT_DIR}/cmake_modules/
)
SET ( WITH_ASSIMP ON CACHE BOOL "need Assimp")
...
...
@@ -30,7 +30,7 @@ ENDIF (DEFINED ASSERTON)
add_definitions(-DSHADERPATH="${CGoGN_ROOT_DIR}/lib/Shaders/")
# define includes of external libs
SET(C
GoGN_EXT
_INCLUDES
SET(C
OMMON
_INCLUDES
${CGoGN_ROOT_DIR}/ThirdParty/glm
${OPENGL_INCLUDE_DIR}
${GLEW_INCLUDE_DIRS}
...
...
@@ -50,13 +50,13 @@ SET (COMMON_LIBS
#optionnal libs
IF (WITH_ASSIMP)
add_definitions(-DWITH_ASSIMP)
SET (C
GoGN_EXT_INCLUDES ${CGoGN_EXT
_INCLUDES} ThirdParty/Assimp/include)
SET (C
OMMON_INCLUDES ${COMMON
_INCLUDES} ThirdParty/Assimp/include)
SET (COMMON_LIBS ${COMMON_LIBS} assimp)
ENDIF (WITH_ASSIMP)
IF (WITH_ZINRI)
add_definitions(-DWITH_ZINRI)
SET (C
GoGN_EXT_INCLUDES ${CGoGN_EXT
_INCLUDES} ${CGoGN_ROOT_DIR}/ThirdParty/Zinri)
SET (C
OMMON_INCLUDES ${COMMON
_INCLUDES} ${CGoGN_ROOT_DIR}/ThirdParty/Zinri)
SET (COMMON_LIBS ${COMMON_LIBS} Zinri)
ENDIF (WITH_ZINRI)
...
...
@@ -66,16 +66,20 @@ IF (WITH_QT)
SET(QT_USE_QTOPENGL TRUE)
INCLUDE(${QT_USE_FILE})
ADD_DEFINITIONS(${QT_DEFINITIONS})
SET (C
GoGN_EXT_INCLUDES ${CGoGN_EXT
_INCLUDES} ${QT_INCLUDE_DIR})
SET (C
GoGN_EXT_LIBS ${CGoGN_EXT
_LIBS} ${QT_LIBRARIES})
SET (C
OMMON_INCLUDES ${COMMON
_INCLUDES} ${QT_INCLUDE_DIR})
SET (C
OMMON_LIBS ${COMMON
_LIBS} ${QT_LIBRARIES})
ENDIF (WITH_QT)
IF (WITH_NUMERICAL)
add_definitions(-DWITH_NUMERICAL)
SET (NUMERICAL_INCLUDES ${CGoGN_ROOT_DIR}/ThirdParty/Numerical ${CGoGN_ROOT_DIR}/ThirdParty/Numerical/UFconfig)
SET (NUMERICAL_LIBS f2c blas numerical lapack)
# SET (NUMERICAL_INCLUDES ${CGoGN_ROOT_DIR}/ThirdParty/Numerical ${CGoGN_ROOT_DIR}/ThirdParty/Numerical/UFconfig)
# SET (NUMERICAL_LIBS f2c blas numerical lapack)
SET (COMMON_INCLUDES ${COMMON_INCLUDES} ${CGoGN_ROOT_DIR}/ThirdParty/Numerical ${CGoGN_ROOT_DIR}/ThirdParty/Numerical/UFconfig)
SET (COMMON_LIBS ${COMMON_LIBS} f2c blas numerical lapack)
ENDIF (WITH_NUMERICAL)
# qq definition specifiques pour mac
IF(APPLE)
# attention a changer pour chercher la bonne version automatiquement
...
...
@@ -85,20 +89,15 @@ IF(APPLE)
SET(CMAKE_OSX_ARCHITECTURES x86_64)
ENDIF(APPLE)
# qq definition specifiques pour windows
IF(WIN32)
add_subdirectory(Release)
add_subdirectory(${CGoGN_ROOT_DIR}/Apps Apps)
set(CMAKE_PREFIX_PATH ${CGoGN_ROOT_DIR}/windows_dependencies CACHE STRING "path to dependencies")
set(CMAKE_CONFIGURATION_TYPES Release Debug)
set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "Only Release or Debug" FORCE)
ELSE(WIN32)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
add_subdirectory(Release)
add_subdirectory(Debug)
add_subdirectory(${CGoGN_ROOT_DIR}/Apps Apps)
ENDIF(WIN32)
SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin)
SET(CGoGN_LIBS_D topologyD algoD containerD utilsD)
...
...
include/Algo/MC/image.hpp
View file @
951a7236
...
...
@@ -180,7 +180,6 @@ void Image<DataType>::loadVox(char *filename)
template
<
typename
DataType
>
bool
Image
<
DataType
>::
loadPNG3D
(
const
char
*
filename
)
{
CGoGN
::
Utils
::
Img3D_IO
::
initIO
();
int
tag
;
//en fonction de DataType utiliser la bonne fonction de chargement,
...
...
include/Utils/img3D_IO.h
View file @
951a7236
...
...
@@ -32,7 +32,7 @@ namespace CGoGN
namespace
Utils
{
#ifdef WITH_QT
namespace
Img3D_IO
{
/**
...
...
@@ -40,13 +40,7 @@ namespace Img3D_IO
*/
enum
TYPEIMG
{
BOOL8
=
1
,
VAL8
,
RGB8
,
VAL16
,
VALFLOAT
};
#ifdef PORTED_TO_QIMAGE
/**
* Initialization of IO
* Necessary before any other call
*/
void
initIO
();
/**
* Load bool image (0/255)
...
...
@@ -113,7 +107,7 @@ namespace Img3D_IO
/**
* Load
16 bits value
image
* Load
RGB 8 bits
image
* Warning: the allocated data image contain w supplemntary bytes which store information
* @param filename evident
* @param w width of image (reference out)
...
...
@@ -125,11 +119,11 @@ namespace Img3D_IO
* @param tag image tag (reference out)
* @return a pointer on the image data (that have been allocated by function)
*/
// unsigned short* loadVal_16(const std::string& filename, int& w, int& h, int &d, float& vx, float& vy, float& vz, int& tag
);
unsigned
char
*
loadRGB
(
const
std
::
string
&
filename
,
int
&
w
,
int
&
h
,
int
&
d
,
float
&
vx
,
float
&
vy
,
float
&
vz
,
int
&
id
);
/**
* Save
16bits val
image
* Warning: the saved image contain w supplemntary bytes which store informations
* Save
RGB 8 bits
image
* Warning: the saved image contain
3
w supplemntary bytes which store informations
* Warning: origin of image is lower left
* @param filename evident
* @param data a pointer on the image data
...
...
@@ -141,10 +135,9 @@ namespace Img3D_IO
* @param vz voxel size z
* @param tag image tag
*/
// void saveVal_16(const std::string& filename, unsigned short* data, int w, int h, int d, float vx, float vy, float vz, int tag);
void
saveRGB
(
const
std
::
string
&
filename
,
unsigned
char
*
data
,
int
w
,
int
h
,
int
d
,
float
vx
,
float
vy
,
float
vz
,
int
tag
);
/**
* Load
float
value image
* Load
16 bits
value image
* Warning: the allocated data image contain w supplemntary bytes which store information
* @param filename evident
* @param w width of image (reference out)
...
...
@@ -156,10 +149,10 @@ namespace Img3D_IO
* @param tag image tag (reference out)
* @return a pointer on the image data (that have been allocated by function)
*/
//
float* loadVal_float(const std::string& filename, int& w, int& h, int &d, float& vx, float& vy, float& vz, int& id
);
//
unsigned short* loadVal_16(const std::string& filename, int& w, int& h, int &d, float& vx, float& vy, float& vz, int& tag
);
/**
* Save
float
val image
* Save
16bits
val image
* Warning: the saved image contain w supplemntary bytes which store informations
* Warning: origin of image is lower left
* @param filename evident
...
...
@@ -172,11 +165,10 @@ namespace Img3D_IO
* @param vz voxel size z
* @param tag image tag
*/
// void saveVal_float(const std::string& filename, float* data, int w, int h, int d, float vx, float vy, float vz, int tag);
// void saveVal_16(const std::string& filename, unsigned short* data, int w, int h, int d, float vx, float vy, float vz, int tag);
/**
* Load
RGB 8 bits
image
* Load
float value
image
* Warning: the allocated data image contain w supplemntary bytes which store information
* @param filename evident
* @param w width of image (reference out)
...
...
@@ -188,11 +180,11 @@ namespace Img3D_IO
* @param tag image tag (reference out)
* @return a pointer on the image data (that have been allocated by function)
*/
unsigned
char
*
loadRGB
(
const
std
::
string
&
filename
,
int
&
w
,
int
&
h
,
int
&
d
,
float
&
vx
,
float
&
vy
,
float
&
vz
,
int
&
id
);
// float* loadVal_float
(const std::string& filename, int& w, int& h, int &d, float& vx, float& vy, float& vz, int& id);
/**
* Save
RGB 8 bits
image
* Warning: the saved image contain
3
w supplemntary bytes which store informations
* Save
float val
image
* Warning: the saved image contain w supplemntary bytes which store informations
* Warning: origin of image is lower left
* @param filename evident
* @param data a pointer on the image data
...
...
@@ -204,10 +196,13 @@ namespace Img3D_IO
* @param vz voxel size z
* @param tag image tag
*/
void
saveRGB
(
const
std
::
string
&
filename
,
unsigned
char
*
data
,
int
w
,
int
h
,
int
d
,
float
vx
,
float
vy
,
float
vz
,
int
tag
);
#endif
// void saveVal_float(const std::string& filename, float* data, int w, int h, int d, float vx, float vy, float vz, int tag);
}
//namespace
#endif
}
//namespace
}
//namespace
...
...
include/Utils/textures.h
View file @
951a7236
...
...
@@ -197,13 +197,10 @@ public:
typedef
Geom
::
Vector
<
DIM
,
unsigned
int
>
COORD
;
protected:
/// id of image for DevIL
QImage
*
m_qimg
;
template
<
typename
TYPEDOUBLE
>
TYPE
applyFilterOneTexel
(
const
Filter
<
DIM
>&
filter
,
const
COORD
&
t
)
const
;
/// swap two texel in dim 1 image
void
swapTexels
(
unsigned
int
x0
,
unsigned
int
x1
);
...
...
@@ -225,21 +222,24 @@ public:
/// destructor
~
Image
();
/**
* swap two images
*/
virtual
void
swap
(
Image
<
DIM
,
TYPE
>&
img
);
/**
* Load from memory ptr,
* a copy if performed (ptr could be destructed just after calling
* @param ptr a pointer on memory source image (allocation must be coherent with other parameters)
* @param w width of image
* @param h heighy of image
* @param bpp byte per pixel of image
*/
bool
load
(
const
unsigned
char
*
ptr
,
unsigned
int
w
,
unsigned
int
h
,
unsigned
int
bpp
)
#ifdef WITH_QT
/// load from file
bool
load
(
const
std
::
string
&
filename
);
/// load from file with conversion (template type is type pixel image-
template
<
typename
TYPE2
>
bool
load
(
const
std
::
string
&
filename
,
void
(
*
convertFunc
)(
const
TYPE2
&
,
const
TYPE
&
));
/// load from file
void
save
(
const
std
::
string
&
filename
);
#endif
/**
* crop image
...
...
include/Utils/textures.hpp
View file @
951a7236
...
...
@@ -256,15 +256,13 @@ void ImageData<DIM,TYPE>::convert(ImageData<DIM,TYPE2>& output, TYPE2 (*convertF
// implementation class Image
template
<
unsigned
int
DIM
,
typename
TYPE
>
Image<DIM,TYPE>::Image():
m_qimg(NULL)
Image
<
DIM
,
TYPE
>::
Image
()
{
}
template
<
unsigned
int
DIM
,
typename
TYPE
>
Image
<
DIM
,
TYPE
>::
Image
(
const
COORD
&
size
)
:
ImageData<DIM,TYPE>(size),
m_qimg(NULL)
ImageData
<
DIM
,
TYPE
>
(
size
)
{
}
...
...
@@ -272,12 +270,11 @@ m_qimg(NULL)
template
<
unsigned
int
DIM
,
typename
TYPE
>
Image
<
DIM
,
TYPE
>::~
Image
()
{
if (this->m_qimg != NULL)
delete this->m_qimg;
m_qimg = NULL;
delete
[]
m_data_ptr
;
this
->
m_data_ptr
=
NULL
;
}
/*
template < unsigned int DIM, typename TYPE >
void Image<DIM,TYPE>::swap(Image<DIM,TYPE>& img)
{
...
...
@@ -290,69 +287,41 @@ void Image<DIM,TYPE>::swap(Image<DIM,TYPE>& img)
ImageData<DIM,TYPE>::swap(img);
}
*/
template
<
unsigned
int
DIM
,
typename
TYPE
>
bool Image<DIM,TYPE>::load(const
std::string& filename
)
bool
Image
<
DIM
,
TYPE
>::
load
(
const
unsigned
char
*
ptr
,
unsigned
int
w
,
unsigned
int
h
,
unsigned
int
bpp
)
{
CGoGN_STATIC_ASSERT
(
DIM
==
2
,
incompatible_Vector_constructor_dimension
);
QImage* ptr = new QImage(filename.c_str());
if (ptr == NULL)
{
delete ptr;
return false;
}
// get the info of images
unsigned int bpp = ptr->depth() / 8;
// compatible TYPE
if (bpp
<
sizeof(TYPE))
if
(
bpp
!=
sizeof
(
TYPE
))
{
CGoGNout << "Image::load incompatible type: bbp="
<<bpp
<< CGoGNendl;
CGoGNout
<<
"Image::load incompatible type: bbp="
<<
bpp
<<
CGoGNendl
;
CGoGNout
<<
"sizeof(TYPE)="
<<
sizeof
(
TYPE
)
<<
CGoGNendl
;
delete
ptr
;
return
false
;
}
// destroy old data
if (this->m_qimg != NULL)
delete this->m_qimg;
else if (this->m_data_ptr != NULL)
if
(
this
->
m_data_ptr
!=
NULL
)
delete
[]
this
->
m_data_ptr
;
if (bpp > sizeof(TYPE))
{
if (sizeof(TYPE) == 3)
{
QImage img = ptr->convertToFormat(QImage::Format_RGB888);
this->m_qimg = new QImage(img);
}
else if (sizeof(TYPE) == 1)
{
QImage img = ptr->convertToFormat(QImage::Format_Indexed8);
this->m_qimg = new QImage(img);
}
delete ptr;
}
else
this->m_qimg = ptr;
this->m_size[0] = this->m_qimg->width();
this->m_size[1] = m_qimg->height();
this
->
m_data_ptr
=
new
T
[
sizeof
(
TYPE
)
*
w
*
h
];
memcpy
(
this
->
m_data_ptr
,
img
.
bits
(),
sizeof
(
TYPE
)
*
w
*
h
);
this
->
m_size
[
0
]
=
w
;
this
->
m_size
[
1
]
=
h
;
this->m_data_ptr = reinterpret_cast<TYPE*>(m_qimg->bits());
this
->
computeSub
();
return
true
;
}
#ifdef WITH_QT
template
<
unsigned
int
DIM
,
typename
TYPE
>
template <typename TYPE2 >
bool Image<DIM,TYPE>::load(const std::string& filename, void (*convertFunc)(const TYPE2&, const TYPE&))
bool
Image
<
DIM
,
TYPE
>::
load
(
const
std
::
string
&
filename
)
{
CGoGN_STATIC_ASSERT
(
DIM
==
2
,
incompatible_Vector_constructor_dimension
);
...
...
@@ -360,7 +329,7 @@ bool Image<DIM,TYPE>::load(const std::string& filename, void (*convertFunc)(cons
if
(
ptr
==
NULL
)
{
delete ptr
;
CGoGNout
<<
"Impossible to load "
<<
filename
<<
std
::
endl
;
return
false
;
}
...
...
@@ -368,18 +337,16 @@ bool Image<DIM,TYPE>::load(const std::string& filename, void (*convertFunc)(cons
unsigned
int
bpp
=
ptr
->
depth
()
/
8
;
// compatible TYPE
if (bpp
!=
sizeof(TYPE))
if
(
bpp
<
sizeof
(
TYPE
))
{
CGoGNout << "Image::load incompatible type: bbp="
<<bpp
<< CGoGNendl;
CGoGNout
<<
"Image::load incompatible type: bbp="
<<
bpp
<<
CGoGNendl
;
CGoGNout
<<
"sizeof(TYPE)="
<<
sizeof
(
TYPE
)
<<
CGoGNendl
;
delete
ptr
;
return
false
;
}
// destroy old data
if (this->m_qimg != NULL)
delete this->m_qimg;
else if (this->m_data_ptr != NULL)
if
(
this
->
m_data_ptr
!=
NULL
)
delete
[]
this
->
m_data_ptr
;
if
(
bpp
>
sizeof
(
TYPE
))
...
...
@@ -387,34 +354,27 @@ bool Image<DIM,TYPE>::load(const std::string& filename, void (*convertFunc)(cons
if
(
sizeof
(
TYPE
)
==
3
)
{
QImage
img
=
ptr
->
convertToFormat
(
QImage
::
Format_RGB888
);
this->m_qimg = new QImage(img);
this
->
m_data_ptr
=
new
T
[
3
*
img
.
width
()
*
img
.
height
()];
memcpy
(
this
->
m_data_ptr
,
img
.
bits
(),
3
*
img
.
width
()
*
img
.
height
());
}
else
if
(
sizeof
(
TYPE
)
==
1
)
{
QImage
img
=
ptr
->
convertToFormat
(
QImage
::
Format_Indexed8
);
this->m_qimg = new QImage(img);
this
->
m_data_ptr
=
new
T
[
img
.
width
()
*
img
.
height
()];
memcpy
(
this
->
m_data_ptr
,
img
.
bits
(),
img
.
width
()
*
img
.
height
());
}
delete ptr;
}
else
this->m_qimg = ptr;
this->m_size[0] = this->m_qimg->width();
this->m_size[1] = m_qimg->height();
}
else
{
this
->
m_data_ptr
=
new
T
[
ptr
->
width
()
*
ptr
->
height
()];
memcpy
(
this
->
m_data_ptr
,
ptr
->
bits
(),
ptr
->
width
()
*
ptr
->
height
());
}
this
->
m_size
[
0
]
=
ptr
->
width
();
this
->
m_size
[
1
]
=
ptr
->
height
();
this
->
computeSub
();
this->m_data_ptr = new TYPE[this->m_sizeSub[1]];
TYPE2 *ptrSrc = reinterpret_cast<TYPE2*>(ptr->bits());
TYPE* ptrDst = this->m_data_ptr;
for (unsigned int i = 0; i < this->m_sizeSub[1]; ++i)
(*convertFunc)(*ptrSrc++, *ptrDst++);
delete this->m_qimg;
this->m_qimg=NULL;
delete
ptr
;
return
true
;
}
...
...
@@ -424,24 +384,7 @@ void Image<DIM,TYPE>::save(const std::string& filename)
{
CGoGN_STATIC_ASSERT
(
DIM
==
2
,
incompatible_Vector_constructor_dimension
);
if (this->m_qimg != NULL)
{
switch(sizeof(TYPE))
{
case 1:
this->m_qimg->save(QString(filename), QImage::Format_Indexed8);
break;
case 3:
this->m_qimg->save(QString(filename), QImage::Format_RGB888);
break;
case 4:
this->m_qimg->save(QString(filename), QImage::Format_ARGB32);
break;
default:
break;
}
}
else if (this->m_data_ptr != NULL)
if
(
this
->
m_data_ptr
!=
NULL
)
{
switch
(
sizeof
(
TYPE
))
{
...
...
@@ -468,7 +411,7 @@ void Image<DIM,TYPE>::save(const std::string& filename)
}
}
}
#endif
template
<
unsigned
int
DIM
,
typename
TYPE
>
...
...
src/Utils/img3D_IO.cpp
View file @
951a7236
...
...
@@ -34,14 +34,9 @@ namespace CGoGN
namespace
Utils
{
#ifdef WITH_QT
namespace
Img3D_IO
{
#ifdef PORTED_TO_QIMAGE
void
initIO
()
{
ilInit
();
iluInit
();
}
template
<
typename
DataType
>
DataType
*
compressZ8
(
DataType
*
src
,
int
w
,
int
h
,
int
d
,
int
&
new_d
)
...
...
@@ -169,34 +164,26 @@ void saveBool(const std::string& filename, unsigned char* data, int w, int h, in
unsigned
char
*
loadVal_8
(
const
std
::
string
&
filename
,
int
&
w
,
int
&
h
,
int
&
d
,
float
&
vx
,
float
&
vy
,
float
&
vz
,
int
&
tag
)
{
ilOriginFunc
(
IL_ORIGIN_LOWER_LEFT
);
ilEnable
(
IL_ORIGIN_SET
);
ILuint
imgName
;
ilGenImages
(
1
,
&
imgName
);
ilBindImage
(
imgName
);
ilLoadImage
(
filename
);
QImage
*
ptrImg
=
new
QImage
(
filename
.
c_str
());
if
(
ptrImg
==
NULL
)
return
NULL
;
// get the info of 2D image
w
=
ilGetInteger
(
IL_IMAGE_WIDTH
);
h
=
ilGetInteger
(
IL_IMAGE_HEIGHT
);
ILuint
bpp
=
ilGetInteger
(
IL_IMAGE_BYTES_PER_PIXEL
);
QImage
img
(
filename
,
QImage
::
Format_Indexed8
);
w
=
img
->
width
();
h
=
img
.
height
();
int
bpp
=
img
.
depth
();
w
=
ptrImg
->
width
();
h
=
ptrImg
->
height
();
unsigned
int
bpp
=
ptrImg
->
depth
();
// image OK ?
if
((
bpp
!=
8
))
return
NULL
;
unsigned
char
*
ptr
=
ilGetData
();
unsigned
char
*
ptr
=
bits
();
int
*
ptr_int
=
reinterpret_cast
<
int
*>
(
ptr
+
(
w
*
(
h
-
1
)));
int
t
=
*
ptr_int
++
;
if
((
t
!=
BOOL8
)
&&
(
t
!=
VAL8
))
return
NULL
;
tag
=
*
ptr_int
++
;
w
=
*
ptr_int
++
;
h
=
*
ptr_int
++
;
...
...
@@ -211,13 +198,15 @@ unsigned char* loadVal_8(const std::string& filename, int& w, int& h, int &d, fl
// uncompress data
unsigned
char
*
data
=
uncompressZ8
<
unsigned
char
>
(
ptr
,
w
,
h
,
d
);
// free il image
ilDeleteImages
(
1
,
&
imgName
);
delete
prtImg
;
// return 3D image
return
data
;
}
// t == VAL8
return
ptr
;
unsigned
char
*
ptr2
=
new
unsigned
char
[
w
*
h
*
d
];
memcpy
(
ptr2
,
ptr
,
w
*
h
*
d
);