mirror of https://github.com/CGAL/cgal
Second merge
This commit is contained in:
commit
0e4aa8525e
|
|
@ -62,14 +62,6 @@
|
||||||
#include "mincio.h"
|
#include "mincio.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** the first file format is initialized to null */
|
|
||||||
static PTRIMAGE_FORMAT firstFormat=NULL;
|
|
||||||
|
|
||||||
/** the Inrimage file format (default format) is initialized to null */
|
|
||||||
static PTRIMAGE_FORMAT InrimageFormat=NULL;
|
|
||||||
|
|
||||||
struct Remove_supported_file_format {
|
struct Remove_supported_file_format {
|
||||||
~Remove_supported_file_format()
|
~Remove_supported_file_format()
|
||||||
{
|
{
|
||||||
|
|
@ -77,9 +69,52 @@ struct Remove_supported_file_format {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef CGAL_HEADER_ONLY
|
||||||
|
|
||||||
|
inline PTRIMAGE_FORMAT & get_static_firstFormat()
|
||||||
|
{
|
||||||
|
static PTRIMAGE_FORMAT firstFormat = NULL;
|
||||||
|
return firstFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline PTRIMAGE_FORMAT & get_static_inrimageFormat()
|
||||||
|
{
|
||||||
|
static PTRIMAGE_FORMAT inrimageFormat = NULL;
|
||||||
|
return inrimageFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Remove_supported_file_format & get_static_rsff()
|
||||||
|
{
|
||||||
|
static Remove_supported_file_format rsff;
|
||||||
|
return rsff;
|
||||||
|
}
|
||||||
|
// Dummy call to get_static_rsff(), otherwise it would not get instanced
|
||||||
|
static Remove_supported_file_format &rsff_dummy_ref = get_static_rsff();
|
||||||
|
|
||||||
|
|
||||||
|
#else // not header-only
|
||||||
|
|
||||||
|
/** the first file format is initialized to null */
|
||||||
|
static PTRIMAGE_FORMAT firstFormat = NULL;
|
||||||
|
inline PTRIMAGE_FORMAT & get_static_firstFormat()
|
||||||
|
{
|
||||||
|
return firstFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** the Inrimage file format (default format) is initialized to null */
|
||||||
|
static PTRIMAGE_FORMAT InrimageFormat = NULL;
|
||||||
|
inline PTRIMAGE_FORMAT & get_static_inrimageFormat()
|
||||||
|
{
|
||||||
|
return InrimageFormat;
|
||||||
|
}
|
||||||
|
|
||||||
static Remove_supported_file_format rsff;
|
static Remove_supported_file_format rsff;
|
||||||
|
inline Remove_supported_file_format & get_static_rsff()
|
||||||
|
{
|
||||||
|
return rsff;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
/*--------------------------------------------------
|
/*--------------------------------------------------
|
||||||
*
|
*
|
||||||
|
|
@ -511,7 +546,7 @@ _image *_initImage() {
|
||||||
im->imageFormat = NULL;
|
im->imageFormat = NULL;
|
||||||
|
|
||||||
/** eventually initializes the supported file formats */
|
/** eventually initializes the supported file formats */
|
||||||
if (firstFormat==NULL)
|
if (get_static_firstFormat()==NULL)
|
||||||
initSupportedFileFormat();
|
initSupportedFileFormat();
|
||||||
/* return image descriptor */
|
/* return image descriptor */
|
||||||
return im;
|
return im;
|
||||||
|
|
@ -569,7 +604,7 @@ _image *_createImage(int x, int y, int z, int v,
|
||||||
im->imageFormat = NULL;
|
im->imageFormat = NULL;
|
||||||
|
|
||||||
/** eventually initializes the supported file formats */
|
/** eventually initializes the supported file formats */
|
||||||
if (firstFormat==NULL)
|
if (get_static_firstFormat()==NULL)
|
||||||
initSupportedFileFormat();
|
initSupportedFileFormat();
|
||||||
/* return image descriptor */
|
/* return image descriptor */
|
||||||
return im;
|
return im;
|
||||||
|
|
@ -812,7 +847,7 @@ int _writeImage(_image *im, const char *name_to_be_written ) {
|
||||||
/* what is the wanted format
|
/* what is the wanted format
|
||||||
*/
|
*/
|
||||||
if ( name == NULL ) {
|
if ( name == NULL ) {
|
||||||
im->imageFormat = InrimageFormat;
|
im->imageFormat = get_static_inrimageFormat();
|
||||||
} else {
|
} else {
|
||||||
int i,extLength;
|
int i,extLength;
|
||||||
PTRIMAGE_FORMAT f;
|
PTRIMAGE_FORMAT f;
|
||||||
|
|
@ -824,7 +859,7 @@ int _writeImage(_image *im, const char *name_to_be_written ) {
|
||||||
im->imageFormat=NULL;
|
im->imageFormat=NULL;
|
||||||
length=strlen(name);
|
length=strlen(name);
|
||||||
|
|
||||||
for(f=firstFormat;(f!=NULL)&& (im->imageFormat==NULL);f=f->next) {
|
for(f=get_static_firstFormat();(f!=NULL)&& (im->imageFormat==NULL);f=f->next) {
|
||||||
/* scan all extensions for that format */
|
/* scan all extensions for that format */
|
||||||
ptr=&f->fileExtension[0];
|
ptr=&f->fileExtension[0];
|
||||||
|
|
||||||
|
|
@ -857,7 +892,7 @@ int _writeImage(_image *im, const char *name_to_be_written ) {
|
||||||
|
|
||||||
if (!im->imageFormat) {
|
if (!im->imageFormat) {
|
||||||
fprintf(stderr, "_writeImage: warning : unknown extension in %s = assuming Inrimage\n",name);
|
fprintf(stderr, "_writeImage: warning : unknown extension in %s = assuming Inrimage\n",name);
|
||||||
im->imageFormat=InrimageFormat;
|
im->imageFormat=get_static_inrimageFormat();
|
||||||
baseName=strdup(name);
|
baseName=strdup(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -879,7 +914,7 @@ int _writeImage(_image *im, const char *name_to_be_written ) {
|
||||||
if (im->imageFormat) {
|
if (im->imageFormat) {
|
||||||
|
|
||||||
if (im->imageFormat->writeImage==NULL) {
|
if (im->imageFormat->writeImage==NULL) {
|
||||||
im->imageFormat=InrimageFormat;
|
im->imageFormat=get_static_inrimageFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( 0 ) {
|
if ( 0 ) {
|
||||||
|
|
@ -984,7 +1019,7 @@ _image *_readImageHeaderAndGetError( const char *name_to_be_read, int *error )
|
||||||
assume that stdin is inrimage
|
assume that stdin is inrimage
|
||||||
*/
|
*/
|
||||||
if(im->openMode == OM_STD) {
|
if(im->openMode == OM_STD) {
|
||||||
im->imageFormat=InrimageFormat;
|
im->imageFormat=get_static_inrimageFormat();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* get magic string for disk files
|
/* get magic string for disk files
|
||||||
|
|
@ -993,7 +1028,7 @@ _image *_readImageHeaderAndGetError( const char *name_to_be_read, int *error )
|
||||||
magic[4] = '\0';
|
magic[4] = '\0';
|
||||||
ImageIO_seek(im, 0L, SEEK_SET);
|
ImageIO_seek(im, 0L, SEEK_SET);
|
||||||
/** test each format */
|
/** test each format */
|
||||||
for(f=firstFormat;(f!=NULL)&& (im->imageFormat==NULL);f=f->next) {
|
for(f=get_static_firstFormat();(f!=NULL)&& (im->imageFormat==NULL);f=f->next) {
|
||||||
/* test if it is the correct format based on magic and file extension */
|
/* test if it is the correct format based on magic and file extension */
|
||||||
if (((*f->testImageFormat)(magic, name)) >=0) {
|
if (((*f->testImageFormat)(magic, name)) >=0) {
|
||||||
im->imageFormat=f;
|
im->imageFormat=f;
|
||||||
|
|
@ -1377,10 +1412,10 @@ PTRIMAGE_FORMAT imageType(const char *fileName) {
|
||||||
if(fileName) fclose( f );
|
if(fileName) fclose( f );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (firstFormat==NULL)
|
if (get_static_firstFormat()==NULL)
|
||||||
initSupportedFileFormat();
|
initSupportedFileFormat();
|
||||||
|
|
||||||
for(format=firstFormat;(format!=NULL);format=format->next) {
|
for(format=get_static_firstFormat();(format!=NULL);format=format->next) {
|
||||||
/* test if it is the correct header based on magic and file extension */
|
/* test if it is the correct header based on magic and file extension */
|
||||||
if (((*format->testImageFormat)(magic,fileName)) >=0) {
|
if (((*format->testImageFormat)(magic,fileName)) >=0) {
|
||||||
return format;
|
return format;
|
||||||
|
|
@ -1414,8 +1449,8 @@ int addImageFormat( PTRIMAGE_FORMAT format)
|
||||||
(strlen(format->fileExtension)>0) &&
|
(strlen(format->fileExtension)>0) &&
|
||||||
(strlen(format->realName)>0) ) {
|
(strlen(format->realName)>0) ) {
|
||||||
|
|
||||||
format->next=firstFormat;
|
format->next=get_static_firstFormat();
|
||||||
firstFormat=format;
|
get_static_firstFormat()=format;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
@ -1440,11 +1475,11 @@ int addImageFormatAtEnd( PTRIMAGE_FORMAT format)
|
||||||
|
|
||||||
format->next = NULL;
|
format->next = NULL;
|
||||||
|
|
||||||
if (firstFormat == NULL) {
|
if (get_static_firstFormat() == NULL) {
|
||||||
firstFormat=format;
|
get_static_firstFormat()=format;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for(f=firstFormat;(f->next!=NULL);f=f->next)
|
for(f=get_static_firstFormat();(f->next!=NULL);f=f->next)
|
||||||
;
|
;
|
||||||
f->next=format;
|
f->next=format;
|
||||||
}
|
}
|
||||||
|
|
@ -1465,7 +1500,7 @@ CGAL_INLINE_FUNCTION
|
||||||
void initSupportedFileFormat()
|
void initSupportedFileFormat()
|
||||||
{
|
{
|
||||||
PTRIMAGE_FORMAT f;
|
PTRIMAGE_FORMAT f;
|
||||||
if ( InrimageFormat == NULL ) {
|
if ( get_static_inrimageFormat() == NULL ) {
|
||||||
f = createAnalyzeFormat();
|
f = createAnalyzeFormat();
|
||||||
addImageFormatAtEnd( f );
|
addImageFormatAtEnd( f );
|
||||||
f = createBMPFormat();
|
f = createBMPFormat();
|
||||||
|
|
@ -1482,8 +1517,8 @@ void initSupportedFileFormat()
|
||||||
addImageFormatAtEnd( f );
|
addImageFormatAtEnd( f );
|
||||||
f = createPpmFormat();
|
f = createPpmFormat();
|
||||||
addImageFormatAtEnd( f );
|
addImageFormatAtEnd( f );
|
||||||
InrimageFormat = createInrimageFormat();
|
get_static_inrimageFormat() = createInrimageFormat();
|
||||||
addImageFormat( InrimageFormat );
|
addImageFormat( get_static_inrimageFormat() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1491,7 +1526,7 @@ void initSupportedFileFormat()
|
||||||
|
|
||||||
CGAL_INLINE_FUNCTION
|
CGAL_INLINE_FUNCTION
|
||||||
PTRIMAGE_FORMAT firstImageFormat() {
|
PTRIMAGE_FORMAT firstImageFormat() {
|
||||||
return firstFormat;
|
return get_static_firstFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1504,7 +1539,7 @@ void printSupportedFileFormat() {
|
||||||
|
|
||||||
initSupportedFileFormat();
|
initSupportedFileFormat();
|
||||||
|
|
||||||
for(i=0, f=firstFormat;(f!=NULL);i++, f=f->next) {
|
for(i=0, f=get_static_firstFormat();(f!=NULL);i++, f=f->next) {
|
||||||
if ( (f->testImageFormat) &&
|
if ( (f->testImageFormat) &&
|
||||||
(f->readImageHeader) &&
|
(f->readImageHeader) &&
|
||||||
(strlen(f->fileExtension)>0) &&
|
(strlen(f->fileExtension)>0) &&
|
||||||
|
|
@ -1524,14 +1559,14 @@ void printSupportedFileFormat() {
|
||||||
/** remove supported image formats */
|
/** remove supported image formats */
|
||||||
CGAL_INLINE_FUNCTION
|
CGAL_INLINE_FUNCTION
|
||||||
void removeSupportedFileFormat() {
|
void removeSupportedFileFormat() {
|
||||||
PTRIMAGE_FORMAT f=firstFormat;
|
PTRIMAGE_FORMAT f=get_static_firstFormat();
|
||||||
|
|
||||||
while( f != NULL) {
|
while( f != NULL) {
|
||||||
PTRIMAGE_FORMAT f_old = f;
|
PTRIMAGE_FORMAT f_old = f;
|
||||||
f = f->next;
|
f = f->next;
|
||||||
ImageIO_free( f_old);
|
ImageIO_free( f_old);
|
||||||
}
|
}
|
||||||
InrimageFormat=NULL;
|
get_static_inrimageFormat()=NULL;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,9 @@ It can be very useful, e.g. for debugging, to reproduce a sequence of
|
||||||
random numbers. This can be done by either initialising with a fixed
|
random numbers. This can be done by either initialising with a fixed
|
||||||
seed, or by using the state functions as described below.
|
seed, or by using the state functions as described below.
|
||||||
|
|
||||||
|
\note A `Random` object is not deterministic when used by several threads at
|
||||||
|
the same time, even if a fixed seed has been chosen.
|
||||||
|
|
||||||
\cgalHeading{Implementation}
|
\cgalHeading{Implementation}
|
||||||
|
|
||||||
We use the boost random library function `boost::rand48` to generate the random
|
We use the boost random library function `boost::rand48` to generate the random
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue