<commit_before>//
// vtTiledGeom: Renders tiled heightfields using Roettger's libMini library
//
// Copyright (c) 2005-2007 Virtual Terrain Project
// Free for all uses, see license.txt for details.
//

#include "vtlib/vtlib.h"
#include "vtdata/FilePath.h"
#include "vtdata/vtLog.h"
#include "TiledGeom.h"

#include "mini.h"
#include "miniload.h"
#include "minicache.h"
#include "datacloud.h"
#include "miniOGL.h"

// If we use a threading library, we can support multithreading
#define SUPPORT_THREADING	1
#define USE_PTHREADS		0
#define USE_OPENTHREADS		1

// Set this to use the 'minicache' OpenGL primitive cache.
//  Actually, we depend on it for adaptive resolution, so leave it at 1.
#define USE_VERTEX_CACHE	1

#define WE_OWN_BUFFERS		0

#define LOG_TILE_LOADS		0

/////////////
// singleton; TODO: get rid of this to allow multiple instances
static vtTiledGeom *s_pTiledGeom = NULL;

#if USE_PTHREADS
  #include <pthread.h>
  #ifdef _MSC_VER
	#pragma message( "Adding link with pthreadVC2.lib" )
	#pragma comment( lib, "pthreadVC2.lib" )
  #endif
   const int numthreads = 1;
   pthread_t pthread[numthreads];
   pthread_mutex_t mutex,iomutex;
   pthread_attr_t attr;

   void threadinit()
      {
      pthread_mutex_init(&mutex,NULL);
	  pthread_mutex_init(&iomutex,NULL);

      pthread_attr_init(&attr);
      pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_JOINABLE);
      }

   void threadexit()
      {
      pthread_mutex_destroy(&mutex);
	  pthread_mutex_destroy(&iomutex);
      pthread_attr_destroy(&attr);
      }

   void startthread(void *(*thread)(void *background),backarrayelem *background,
	   void *data)
      {
	  pthread_create(&pthread[background->background-1],&attr,thread,background);
      }

   void jointhread(backarrayelem *background,void *data)
      {
      void *status;
      pthread_join(pthread[background->background-1],&status);
      }

   void lock_cs(void *data)
      {pthread_mutex_lock(&mutex);}

   void unlock_cs(void *data)
      {pthread_mutex_unlock(&mutex);}

	void lock_io(void *data)
	  {pthread_mutex_lock(&iomutex);}

	void unlock_io(void *data)
	  {pthread_mutex_unlock(&iomutex);}
#endif

#if USE_OPENTHREADS
  #include "OpenThreads/Thread"
  #include "OpenThreads/Mutex"
  #ifdef _MSC_VER
	#pragma message( "Adding link with OpenThreads.lib" )
	#pragma comment( lib, "OpenThreads.lib" )
  #endif
	const int numthreads = 1;
	class MyThread : public OpenThreads::Thread
	{
	public:
		void run()
		{
			m_to_call(m_background);
		}
		void *(*m_to_call)(void *background);
		backarrayelem *m_background;
	};
	MyThread *pthread[numthreads];
	OpenThreads::Mutex mutex, iomutex;

	void threadinit()
	{
		for (int i = 0; i < numthreads; i++)
		{
			MyThread *th = new MyThread;
			pthread[i] = th;
		}
	}

	void threadexit()
	{
		for (int i = 0; i < numthreads; i++)
		{
			delete pthread[i];
		}
	}

	void startthread(void *(*thread)(void *background),backarrayelem *background,void *data)
	{
		pthread[background->background-1]->m_to_call = thread;
		pthread[background->background-1]->m_background = background;
		pthread[background->background-1]->start();
	}

	void jointhread(backarrayelem *background,void *data)
	{
		pthread[background->background-1]->join();
	}

	void lock_cs(void *data)
	{mutex.lock();}

	void unlock_cs(void *data)
	{mutex.unlock();}

	void lock_io(void *data)
	{iomutex.lock();}

	void unlock_io(void *data)
	{iomutex.unlock();}
#endif

#ifndef DOXYGEN_SHOULD_SKIP_THIS
///////////////////////////////////////////////////////////////////////
// class TiledDatasetDescription implementation

TiledDatasetDescription::TiledDatasetDescription()
{
	cols = rows = lod0size = 0;<commit_msg>tweak changed member names<commit_after>//
// vtTiledGeom: Renders tiled heightfields using Roettger's libMini library
//
// Copyright (c) 2005-2007 Virtual Terrain Project
// Free for all uses, see license.txt for details.
//

#include "vtlib/vtlib.h"
#include "vtdata/FilePath.h"
#include "vtdata/vtLog.h"
#include "TiledGeom.h"

#include "mini.h"
#include "miniload.h"
#include "minicache.h"
#include "datacloud.h"
#include "miniOGL.h"

// If we use a threading library, we can support multithreading
#define SUPPORT_THREADING	1
#define USE_PTHREADS		0
#define USE_OPENTHREADS		1

// Set this to use the 'minicache' OpenGL primitive cache.
//  Actually, we depend on it for adaptive resolution, so leave it at 1.
#define USE_VERTEX_CACHE	1

#define WE_OWN_BUFFERS		0

#define LOG_TILE_LOADS		0

/////////////
// singleton; TODO: get rid of this to allow multiple instances
static vtTiledGeom *s_pTiledGeom = NULL;

#if USE_PTHREADS
  #include <pthread.h>
  #ifdef _MSC_VER
	#pragma message( "Adding link with pthreadVC2.lib" )
	#pragma comment( lib, "pthreadVC2.lib" )
  #endif
   const int numthreads = 1;
   pthread_t pthread[numthreads];
   pthread_mutex_t mutex,iomutex;
   pthread_attr_t attr;

   void threadinit()
      {
      pthread_mutex_init(&mutex,NULL);
	  pthread_mutex_init(&iomutex,NULL);

      pthread_attr_init(&attr);
      pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_JOINABLE);
      }

   void threadexit()
      {
      pthread_mutex_destroy(&mutex);
	  pthread_mutex_destroy(&iomutex);
      pthread_attr_destroy(&attr);
      }

   void startthread(void *(*thread)(void *background),backarrayelem *background,
	   void *data)
      {
	  pthread_create(&pthread[background->background-1],&attr,thread,background);
      }

   void jointhread(backarrayelem *background,void *data)
      {
      void *status;
      pthread_join(pthread[background->background-1],&status);
      }

   void lock_cs(void *data)
      {pthread_mutex_lock(&mutex);}

   void unlock_cs(void *data)
      {pthread_mutex_unlock(&mutex);}

	void lock_io(void *data)
	  {pthread_mutex_lock(&iomutex);}

	void unlock_io(void *data)
	  {pthread_mutex_unlock(&iomutex);}
#endif

#if USE_OPENTHREADS
  #include "OpenThreads/Thread"
  #include "OpenThreads/Mutex"
  #ifdef _MSC_VER
	#pragma message( "Adding link with OpenThreads.lib" )
	#pragma comment( lib, "OpenThreads.lib" )
  #endif
	const int numthreads = 1;
	class MyThread : public OpenThreads::Thread
	{
	public:
		void run()
		{
			void *result = m_function(m_param);
		}
		void *(*m_function)(void *background);
		backarrayelem *m_param;
	};
	MyThread *pthread[numthreads];
	OpenThreads::Mutex mutex, iomutex;

	void threadinit()
	{
		for (int i = 0; i < numthreads; i++)
		{
			MyThread *th = new MyThread;
			pthread[i] = th;
		}
	}

	void threadexit()
	{
		for (int i = 0; i < numthreads; i++)
			delete pthread[i];
	}

	void startthread(void *(*thread)(void *background),backarrayelem *background,void *data)
	{
		pthread[background->background-1]->m_function = thread;
		pthread[background->background-1]->m_param = background;
		pthread[background->background-1]->start();
	}

	void jointhread(backarrayelem *background,void *data)
	{
		pthread[background->background-1]->join();
	}

	void lock_cs(void *data)
	{mutex.lock();}

	void unlock_cs(void *data)
	{mutex.unlock();}

	void lock_io(void *data)
	{iomutex.lock();}

	void unlock_io(void *data)
	{iomutex.unlock();}
#endif

#ifndef DOXYGEN_SHOULD_SKIP_THIS
///////////////////////////////////////////////////////////////////////
// class TiledDatasetDescription implementation

TiledDatasetDescription::TiledDatasetDescription()
{
	cols = rows = lod0size = 0;
{'fraction_non_alphanumeric': 0.14351726012503396, 'fraction_numerical': 0.007882576787170427, 'mean_word_length': 3.8129496402877696, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3610619', 'n_tokens_mistral': 2725, 'n_tokens_neox': 2595, 'n_words': 574}