|
SAGA API
v9.6
|
Go to the documentation of this file.
158 bool CSG_Grid::_Memory_Create(
bool bCached)
167 if( bCached || _Cache_Check() )
169 return( _Cache_Create() );
172 return( _Array_Create() );
176 void CSG_Grid::_Memory_Destroy(
void)
182 _Cache_Destroy(
false);
196 bool CSG_Grid::_Array_Create(
void)
202 if( (m_Values = (
void **)
SG_Malloc(
Get_NY() *
sizeof(
void *))) != NULL )
206 char *pLine = (
char *)m_Values[0];
228 void CSG_Grid::_Array_Destroy(
void)
247 #define CACHE_FILE_POS(x, y) (m_Cache_Offset + (m_Cache_bFlip ? Get_NY() - 1 - y : y) * m_nBytes_Line + x * m_nBytes_Value)
250 #if defined(_SAGA_LINUX)
251 #define CACHE_FILE_SEEK fseek
253 #define CACHE_FILE_SEEK _fseeki64
262 || _Cache_Create(m_Cache_File , m_Type, m_Cache_Offset, m_Cache_bSwap, m_Cache_bFlip)
269 return( !
is_Cached() || _Cache_Destroy(
true) );
278 bool CSG_Grid::_Cache_Check(
void)
288 s.
Printf(
"%s\n%s\n%s: %.2fMB",
289 _TL(
"Shall I activate file caching for new grid."),
291 _TL(
"Total memory size"),
317 if( (m_Cache_Stream = fopen(File,
"r+b")) == NULL
318 && (m_Cache_Stream = fopen(File,
"rb" )) == NULL )
324 m_Cache_bTemp =
false;
325 m_Cache_Offset = Offset;
327 m_Cache_bFlip = bFlip;
335 bool CSG_Grid::_Cache_Create(
void)
344 if( (m_Cache_Stream = fopen(File,
"w+b")) == NULL )
350 m_Cache_bTemp =
true;
352 m_Cache_bSwap =
false;
353 m_Cache_bFlip =
false;
359 fwrite(m_Values ? m_Values[y] : Values.Get_Array(), 1,
Get_nLineBytes(), m_Cache_Stream);
370 bool CSG_Grid::_Cache_Destroy(
bool bMemory_Restore)
374 if( bMemory_Restore && _Array_Create() && !
CACHE_FILE_SEEK(m_Cache_Stream, m_Cache_Offset, SEEK_SET) )
382 char *pValue = (
char *)m_Values[y];
395 fclose(m_Cache_Stream);
397 m_Cache_Stream = NULL;
416 void CSG_Grid::_Cache_Set_Value(
int x,
int y,
double Value)
448 double CSG_Grid::_Cache_Get_Value(
int x,
int y)
const
#define SG_FREE_SAFE(PTR)
int Printf(const char *Format,...)
bool SG_UI_Dlg_Continue(const CSG_String &Message, const CSG_String &Caption)
SAGA_API_DLL_EXPORT bool SG_Dir_Exists(const CSG_String &Directory)
int Get_nLineBytes(void) const
SAGA_API_DLL_EXPORT void * SG_Malloc(size_t size)
int Get_nValueBytes(void) const
static int gSG_Grid_Cache_Mode
#define CACHE_FILE_POS(x, y)
SAGA_API_DLL_EXPORT bool SG_File_Delete(const CSG_String &FileName)
SAGA_API_DLL_EXPORT void SG_Free(void *memblock)
SAGA_API_DLL_EXPORT void * SG_Calloc(size_t num, size_t size)
sLong SG_Grid_Cache_Get_Threshold(void)
SAGA_API_DLL_EXPORT bool SG_File_Exists(const CSG_String &FileName)
const SG_Char * Get_Name(bool bShort=true)
void SG_Grid_Cache_Set_Threshold_MB(double nMegabytes)
const SG_Char * Get_File_Name(bool bNative=true) const
void SG_Grid_Cache_Set_Threshold(int nBytes)
static CSG_String Format(const char *Format,...)
void SG_Grid_Cache_Set_Mode(int Mode)
static CSG_String gSG_Grid_Cache_Directory
const SG_Char * SG_Grid_Cache_Get_Directory(void)
bool SG_UI_Process_Set_Progress(int Position, int Range)
bool is_Cached(void) const
double SG_Grid_Cache_Get_Threshold_MB(void)
SAGA_API_DLL_EXPORT CSG_String SG_File_Get_Name_Temp(const CSG_String &Prefix)
SAGA_API_DLL_EXPORT CSG_String SG_File_Make_Path(const CSG_String &Directory, const CSG_String &Name)
void SG_Grid_Cache_Set_Directory(const SG_Char *Directory)
bool SG_UI_Process_Set_Ready(void)
void SG_UI_Msg_Add_Error(const char *Message)
static sLong gSG_Grid_Cache_Threshold
int SG_Grid_Cache_Get_Mode(void)
bool is_Valid(void) const
sLong Get_NCells(void) const