コード例 #1
0
ファイル: qConsole.cpp プロジェクト: qdot/np_boneyard
	bool qConsole::writeMessagesToFile(string strFilename)
	{
		ofstream fOutputFile(strFilename.c_str(), ios::app);
		if(!fOutputFile)
		{
			setMessage(MSG_ERROR, "qConsole", "writeMessagesToFile : Cannot open file '" + strFilename + "' for console output");
			return false;
		}

		/* _ftime stuff ripped out of MSDN entry for time -> getting current */

  		struct __timeb64 timebuffer;
		char *timeline;
		char *test = (char*)malloc(sizeof(char) * 100);
		_ftime64( &timebuffer );
		timeline = _ctime64( & ( timebuffer.time ) );

		sprintf(test, "%.19s.%hu %s", timeline, timebuffer.millitm, &timeline[20] );

		fOutputFile << "qConsole Console Output (Messages/Errors) for run at " << test;
		for(unsigned int i = 0; i < m_vMessageBuffer.size(); ++i)
		{
			fOutputFile << m_vMessageBuffer[i] << endl;
		}
		fOutputFile <<"--------------------------------------------"<<endl;
		free(test);
		fOutputFile.close();
		return true;
	}
コード例 #2
0
ファイル: vpl__time.c プロジェクト: mbin/acer_cloud_wifi_copy
VPLTime_t VPLTime_GetTime(void)
{
    VPLTime_t result;

#if __MSVCRT_VERSION__ >= 0x0601
    struct __timeb64  timebuffer;

    // use 'obsoleted' ftime for ms resolution.
    // gettimeofday is not available on Windows.
# ifdef _MSC_VER
    _ftime64_s(&timebuffer);
# else
    _ftime64(&timebuffer);
# endif
#else
    struct _timeb  timebuffer;

    // use 'obsoleted' ftime for ms resolution.
    // gettimeofday is not available on Windows.
    _ftime(&timebuffer);
#endif
    result =
        ( ((VPLTime_t)(timebuffer.time ) * 1000) +
          (timebuffer.millitm) );
    // Multiply up for microseconds.
    result *= 1000;

    return result;
}
コード例 #3
0
ファイル: robtkapp.c プロジェクト: x42/robtk
static void main_loop(void) {
	struct timespec timeout;
	pthread_mutex_lock (&gui_thread_lock);
	while (client_state != Exit) {
		run_one();

		if (client_state == Exit) break;

#ifdef _WIN32
		//Sleep(1000/UI_UPDATE_FPS);
#if (defined(__MINGW64__) || defined(__MINGW32__)) && __MSVCRT_VERSION__ >= 0x0601
		struct __timeb64 timebuffer;
		_ftime64(&timebuffer);
#else
		struct __timeb32 timebuffer;
		_ftime(&timebuffer);
#endif
		timeout.tv_nsec = timebuffer.millitm * 1000000;
		timeout.tv_sec = timebuffer.time;
#else // POSIX
		clock_gettime(CLOCK_REALTIME, &timeout);
#endif
		timeout.tv_nsec += 1000000000 / (UI_UPDATE_FPS);
		if (timeout.tv_nsec >= 1000000000) {timeout.tv_nsec -= 1000000000; timeout.tv_sec+=1;}
		pthread_cond_timedwait (&data_ready, &gui_thread_lock, &timeout);

	} /* while running */
	pthread_mutex_unlock (&gui_thread_lock);
}
コード例 #4
0
ファイル: VMVupManager.cpp プロジェクト: gfphoenix/tsiu
//#pragma optimize("", off)
void VMVupManager::_UpdateRDVPoint()
{
	RDVPointListIterator it = m_poRDVList.begin();
	while(it != m_poRDVList.end())
	{
		RDVPointInfo& info = (*it).second;
		D_CHECK(info.m_RunningInfo.IsValid());
		f32 fNow = GameEngine::GetGameEngine()->GetClockMod()->GetTotalElapsedSeconds();
		if(info.m_RunningInfo.m_ClientList.size() >= info.m_uiExpectedNum ||
			fNow - info.m_RunningInfo.m_fStartTime >= (f32)info.m_uiTimeOut)
		{
			//Default value
			s32 iDelayOfStartTime = 5000;
			s32 iIntervalOfEachGroup = 0;
			s32 iMaxGroupNum = 1;
			s32 iRunningID = info.m_RunningInfo.m_uiCurrentRunningID;
			RDVPointParameterListIterator itRDVPointParam = m_poRDVParam.find(Protocal::GetRDVPointID(Protocal::GetRDVPointMajor(iRunningID), 0));
			if(itRDVPointParam != m_poRDVParam.end())
			{
				RDVPointParameter& param = (*itRDVPointParam).second;
				iDelayOfStartTime = param.m_iDelayOfStartTime;
				iIntervalOfEachGroup = param.m_iIntervalOfEachGroup;
				iMaxGroupNum = param.m_iGroupNum;
			}
			struct __timeb64 timebuffer;
			_ftime64(&timebuffer);
			__int64 curTime = timebuffer.time * 1000 + timebuffer.millitm;

			for(s32 i = 0; i < info.m_RunningInfo.m_ClientList.size(); ++i)
			{
				VMVup* pVup = FindVup(info.m_RunningInfo.m_ClientList[i]);
				if(!pVup)
					continue;
				if(pVup->GetGroup() >= 0)
				{
					StartTesting(pVup, curTime + iDelayOfStartTime + pVup->GetGroup() * iIntervalOfEachGroup);
				}
			}
			for(s32 i = 0; i < iMaxGroupNum; ++i)
			{
				__int64 nowms = curTime + iDelayOfStartTime + i * iIntervalOfEachGroup;
				__int64 nows = nowms / 1000;
				char timeline[26];
				ctime_s(timeline, 26, &(nows));
				LOG_INFO("RDVPoint(%d,%d)..Group(%d)..Time of starting test: %.19s.%03hu\n", 
					Protocal::GetRDVPointMajor(iRunningID), Protocal::GetRDVPointMinor(iRunningID), i, timeline, nowms % 1000);
			}
			VMSummary::GetPtr()->RemoveRDVPoint(Protocal::GetRDVPointMajor(iRunningID), Protocal::GetRDVPointMinor(iRunningID));
			it = m_poRDVList.erase(it);
		}
		else
		{
			++it;
		}
	}
}	
コード例 #5
0
ファイル: gexpmq_mex.cpp プロジェクト: dgleich/nexpokit
double sf_time()
{
#if defined(_WIN32) || defined(_WIN64)
  struct __timeb64 t; _ftime64(&t);
  return (t.time*1.0 + t.millitm/1000.0);
#else
  struct timeval t; gettimeofday(&t, 0);
  return (t.tv_sec*1.0 + t.tv_usec/1000000.0);
#endif
}
コード例 #6
0
ファイル: compat_win32.c プロジェクト: mcanthony/m4acut
int64_t aa_timer(void)
{
#if HAVE_STRUCT___TIMEB64
    struct __timeb64 tv;
    _ftime64(&tv);
#else
    struct timeb tv;
    ftime(&tv);
#endif
    return (int64_t)tv.time * 1000 + tv.millitm;
}
コード例 #7
0
ファイル: Util.cpp プロジェクト: dprada/pymol-open-source
/**
 * Get a timestamp in seconds since 1970-01-01
 */
double UtilGetSecondsEpoch()
{
#ifndef _WIN32
  struct timeval tv;
  gettimeofday(&tv,NULL);
  return tv.tv_sec + (tv.tv_usec / 1e6);
#else
   struct __timeb64 timebuffer;
   _ftime64( &timebuffer );
   return timebuffer.time + (timebuffer.millitm / 1e3);
#endif
}
コード例 #8
0
ファイル: getdate.c プロジェクト: leowzukw/scilab-mirror
/*--------------------------------------------------------------------------*/
double *getCurrentDateAsDoubleVector(int *iErr)
{
    double *dVector = (double*) MALLOC(sizeof(double) * NB_ELEMNT_ARRAY_GETDATE);
    *iErr = 1;
    if (dVector)
    {
        struct tm *nowstruct = NULL;
        double milliseconds = 0.;
#ifdef _MSC_VER
        /* manages date  up through 23:59:59, December 31, 3000 */
        /* previous version was limited to  19:14:07 January 18, 2038, UTC. */
        __time64_t long_time;
        struct __timeb64 tstruct;
        _ftime64(&tstruct);
        long_time = tstruct.time;
        nowstruct = _localtime64(&long_time);
#else
        struct timeval timebuffer;
        gettimeofday(&timebuffer, NULL);
        nowstruct = localtime(&timebuffer);
#endif

#ifdef _MSC_VER
        milliseconds = (double)(tstruct.millitm);
#else
        milliseconds = (double)(timebuffer.tv_usec / 1000);  /* micro to ms */
#endif
        if (milliseconds < 0)
        {
            milliseconds = 0.;
        }

        if (nowstruct)
        {
            dVector[YEAR_INDEX] =           (double)(1900 + nowstruct->tm_year);
            dVector[MONTH_INDEX] =          (double)(1    + nowstruct->tm_mon);
            dVector[WEEK_NUMBER_INDEX] =    (double)(week_number(nowstruct));
            dVector[DAY_OF_YEAR_INDEX] =    (double)(1    + nowstruct->tm_yday);
            dVector[WEEKDAY_INDEX] =        (double)(1    + nowstruct->tm_wday);
            dVector[DAY_OF_MONTH_INDEX] =   (double)(nowstruct->tm_mday);
            dVector[HOUR_OF_DAY_INDEX] =    (double)(nowstruct->tm_hour);
            dVector[MINUTE_INDEX] =         (double)(nowstruct->tm_min);
            dVector[SECOND_INDEX] =         (double)(nowstruct->tm_sec);
            dVector[MILLISECOND_INDEX] =    (double)milliseconds;
            *iErr = 0;
        }
    }
    return dVector;
}
コード例 #9
0
ファイル: Log.cpp プロジェクト: roseon/life-marvelous
void PutLog( const char* pszLog)
{
	FILE* pFile;
	pFile = fopen( "patchlog.txt", "a");
	if ( pFile == NULL)
		return;

	char szBuff[128];
	_strtime( szBuff);
	struct __timeb64 tstruct;
	_ftime64( &tstruct);
	fprintf( pFile, "%s:%03d   ", szBuff, tstruct.millitm);

	fprintf( pFile, pszLog);
	fprintf( pFile, "\n");

	fclose( pFile);
}
コード例 #10
0
ファイル: cpr.cpp プロジェクト: oudream/ucommon
int gettimeofday(struct timeval *tv_, void *tz_)
{
    assert(tv_ != NULL);

#if defined(_MSC_VER) && _MSC_VER >= 1300
    struct __timeb64 tb;
    _ftime64(&tb);
#else
# ifndef __BORLANDC__
    struct _timeb tb;
    _ftime(&tb);
# else
    struct timeb tb;
    ftime(&tb);
# endif
#endif
    tv_->tv_sec = (long)tb.time;
    tv_->tv_usec = tb.millitm * 1000;
    return 0;
}
コード例 #11
0
ファイル: getdate.c プロジェクト: leowzukw/scilab-mirror
/*--------------------------------------------------------------------------*/
double getCurrentDateAsUnixTimeConvention(void)
{
    double dValue = 0.;
#ifdef _MSC_VER
    /* manages date  up through 23:59:59, December 31, 3000 */
    /* previous version was limited to  19:14:07 January 18, 2038, UTC. */
    struct __timeb64 tstruct;
    _ftime64(&tstruct);
    dValue = (double)tstruct.time;
#else
    time_t t;
    time(&t);
    dValue = (double)t;
#endif

    if (dValue < 0.)
    {
        dValue = 0.;
    }
    return dValue;
}
コード例 #12
0
ファイル: Utils.cpp プロジェクト: Naturekid/MSVR
/*
* Returns the current time in a string format to be used
* when writing to the log.
*/
char *GetCurTimeForLogging(char *TimeStr)
{
	struct tm *DetailedTime;
	__time64_t SysTime;
	struct __timeb64 SysTime2; 

	_ftime64(&SysTime2); 

	SysTime = (__time64_t) SysTime2.time;
	//_time64(&SysTime);

	DetailedTime = _localtime64(&SysTime);
	sprintf(TimeStr, "%04d-%02d-%02d %02d:%02d:%02d:%03d", 
							(DetailedTime->tm_year + 1900),
							DetailedTime->tm_mon,
							DetailedTime->tm_mday,
							DetailedTime->tm_hour,
							DetailedTime->tm_min,
							DetailedTime->tm_sec,
							SysTime2.millitm);
	return (TimeStr);
}
コード例 #13
0
uint64 DefaultWallclockTimer::read()
{
// POSIX platforms.
#if defined __GNUC__

    timeval tv;
    gettimeofday(&tv, 0);
    return static_cast<uint64>(tv.tv_sec) * 1000000 + static_cast<uint64>(tv.tv_usec);

// Windows.
#elif defined _WIN32

    __timeb64 tb;
    _ftime64(&tb);
    return static_cast<uint64>(tb.time) * 1000 + static_cast<uint64>(tb.millitm);

// Other platforms.
#else

    const time_t seconds = time(0);
    return static_cast<uint64>(seconds);

#endif
}
コード例 #14
0
INLINE 
#endif /* PTW32_BUILD_INLINED */
DWORD
ptw32_relmillisecs (const struct timespec * abstime)
{
  const int64_t NANOSEC_PER_MILLISEC = 1000000;
  const int64_t MILLISEC_PER_SEC = 1000;
  DWORD milliseconds;
  int64_t tmpAbsMilliseconds;
  int64_t tmpCurrMilliseconds;
#if defined(NEED_FTIME)
  struct timespec currSysTime;
  FILETIME ft;
  SYSTEMTIME st;
#else /* ! NEED_FTIME */
#if ( defined(_MSC_VER) && _MSC_VER >= 1300 ) /* MSVC7+ */ || \
    ( defined(PTW32_CONFIG_MINGW) && __MSVCRT_VERSION__ >= 0x0601 )
  struct __timeb64 currSysTime;
#else
  struct _timeb currSysTime;
#endif
#endif /* NEED_FTIME */


  /* 
   * Calculate timeout as milliseconds from current system time. 
   */

  /*
   * subtract current system time from abstime in a way that checks
   * that abstime is never in the past, or is never equivalent to the
   * defined INFINITE value (0xFFFFFFFF).
   *
   * Assume all integers are unsigned, i.e. cannot test if less than 0.
   */
  tmpAbsMilliseconds =  (int64_t)abstime->tv_sec * MILLISEC_PER_SEC;
  tmpAbsMilliseconds += ((int64_t)abstime->tv_nsec + (NANOSEC_PER_MILLISEC/2)) / NANOSEC_PER_MILLISEC;

  /* get current system time */

#if defined(NEED_FTIME)

  GetSystemTime(&st);
  SystemTimeToFileTime(&st, &ft);
  /*
   * GetSystemTimeAsFileTime(&ft); would be faster,
   * but it does not exist on WinCE
   */

  ptw32_filetime_to_timespec(&ft, &currSysTime);

  tmpCurrMilliseconds = (int64_t)currSysTime.tv_sec * MILLISEC_PER_SEC;
  tmpCurrMilliseconds += ((int64_t)currSysTime.tv_nsec + (NANOSEC_PER_MILLISEC/2))
			   / NANOSEC_PER_MILLISEC;

#else /* ! NEED_FTIME */

#if defined(_MSC_VER) && _MSC_VER >= 1400  /* MSVC8+ */
  _ftime64_s(&currSysTime);
#elif ( defined(_MSC_VER) && _MSC_VER >= 1300 ) /* MSVC7+ */ || \
      ( defined(PTW32_CONFIG_MINGW) && __MSVCRT_VERSION__ >= 0x0601 )
  _ftime64(&currSysTime);
#else
  _ftime(&currSysTime);
#endif

  tmpCurrMilliseconds = (int64_t) currSysTime.time * MILLISEC_PER_SEC;
  tmpCurrMilliseconds += (int64_t) currSysTime.millitm;

#endif /* NEED_FTIME */

  if (tmpAbsMilliseconds > tmpCurrMilliseconds)
    {
      milliseconds = (DWORD) (tmpAbsMilliseconds - tmpCurrMilliseconds);
      if (milliseconds == INFINITE)
        {
          /* Timeouts must be finite */
          milliseconds--;
        }
    }
  else
    {
      /* The abstime given is in the past */
      milliseconds = 0;
    }

  return milliseconds;
}
コード例 #15
0
void Ctr2SufManager::ctr2sufProc(vector<vector<Point_3> >& MeshBoundingProfile3D,vector<Point_3>& vecTestPoint)
{
	clock_t   start   =   clock();   
	struct __timeb64 timebuffer;
	char *timeline;
	_ftime64( &timebuffer );
	timeline = _ctime64( & ( timebuffer.time ) );
	printf( "The time is %.19s.%hu %s", timeline, timebuffer.millitm, &timeline[20] );

	//common line case
	//compute the common line
	if( isComnCase )	
	{
		float tempparam[ 8 ];
		for( int i = 0; i < 8; i ++)
		{
			tempparam[ i  ] = pparam[ i ];
		}

		//////////////////////////////////////////////////////////////////////////
		/*for( int i = 0 ; i < 8; i ++ )
		{
			cout<<tempparam[ i ]<<",";
		}
		cout<<endl;*/
		//////////////////////////////////////////////////////////////////////////

		computeComnLine( tempparam, tempparam + 4, comndir, comnpt);
		//////////////////////////////////////////////////////////////////////////
		/*for( int i = 0 ; i < 8; i ++ )
		{
			cout<<tempparam[ i ]<<",";
		}
		cout<<endl;*/
		//////////////////////////////////////////////////////////////////////////
		//////////////////////////////////////////////////////////////////////////
		//writeComnLineDB( tempparam, tempparam + 4, comndir, comnpt);
		//////////////////////////////////////////////////////////////////////////
	}

	//////////////////////////////////////////////////////////////////////////
	/*for( int i = 0; i < planenum + 4; i ++ )
	{
		cout<<pparam[ 4* i ]<<","
			<<pparam[ 4*i + 1]<<","
			<<pparam[ 4*i + 2]<<","
			<<pparam[ 4*i + 3]<<endl;
	}
	cout<<endl;*/
	//////////////////////////////////////////////////////////////////////////

	//preprocess data first
	int** pctrvermark;

	if( !ispreproced || isComnCase)
	{
		pctrvermark = preProcData(isComnCase);
		//reset showcontourvers
		for( int i = 0; i < showplanenum; i ++)
			delete []showctrvers[ i ];
		delete []showctrvers;

		//copy the data from processed data, and reset size
		showplanenum = planenum;
		showctrvers = new float*[ showplanenum ];
		showctredgenum = new int[ showplanenum ];
		showctredges = new int*[ showplanenum ];
		for( int i = 0; i < showplanenum; i++ )
		{
			int versize = pctrvernum[ i ]*3; 
			showctrvers[ i ] = new float[ versize ];
			for( int j = 0 ; j < versize;  j ++ )
				showctrvers[ i ][ j ] = pctrvers[ i ][ j ]*DIM/PROCSIZE;

			showctredgenum[ i ] = pctredgenum[ i ];
			int edgesize = pctredgenum[ i ] * 2;			
			showctredges[ i ] = new int[ edgesize ];
			for( int  j = 0; j < showctredgenum[ i ]; j ++)
			{
				showctredges[ i ][ 2*j ] = pctredges[ i ][ 4*j ];
				showctredges[ i ][ 2*j + 1 ] = pctredges[ i ][ 4*j + 1];
			}
		}

		for( int i = 0; i < planenum; i ++)
		{
			int iVerIndBase=0;
			vector<Point_3> CurrentProfile3D;
			for( int j = 0;j < showctredgenum[ i ]; j++)
			{

				int v1 = showctredges[ i ][ 2*j ];
				int v2 = showctredges[ i ][ 2*j + 1 ];

				CurrentProfile3D.push_back(Point_3(showctrvers[ i ][ v1* 3],
					showctrvers[ i ][ v1* 3+1],
					showctrvers[ i ][ v1* 3+2]));

				if (v2==iVerIndBase)
				{
					iVerIndBase=iVerIndBase+CurrentProfile3D.size();
					MeshBoundingProfile3D.push_back(CurrentProfile3D);
					CurrentProfile3D.clear();
				}
			}
		}
		//for( int i = 0; i < planenum; i ++)
		//{	
		//	vector<Point_3> CurrentProfile3D;
		//	for( int j = 0;j < showctredgenum[ i ]; j++)
		//	{
		//		int v1 = showctredges[ i ][ 2*j ];
		//		glVertex3fv( &showctrvers[ i ][ v1* 3] );
		//		CurrentProfile3D.push_back(Point_3(showctrvers[ i ][ v1* 3],
		//								showctrvers[ i ][ v1* 3+1],
		//								showctrvers[ i ][ v1* 3+2]));
		//	}
		//	MeshBoundingProfile3D.push_back(CurrentProfile3D);
		//}

	}
	//////////////////////////////////////////////////////////////////////////
	//for( int i = 0; i < planenum + 4; i ++ )
	//{
	//	cout<<pparam[ 4* i ]<<","
	//		<<pparam[ 4*i + 1]<<","
	//		<<pparam[ 4*i + 2]<<","
	//		<<pparam[ 4*i + 3]<<endl;
	//}
	//cout<<endl;
	//////////////////////////////////////////////////////////////////////////
	//partition
//	cout<<"------------------ PARTITION ------------------"<<endl;
//	cout<<"Starting............"<<endl;
	partition();	

	///////////////////////////////////////////////////////////B///////////////
	/*writePartitionOut("mmdebug/partition.txt");*/
	//////////////////////////////////////////////////////////////////////////
//	cout<<"DONE!"<<endl<<endl;
	
	//process data
//	cout<<"------------------ PUT CONTOUR INTO FACE ------------------"<<endl;
	putContourIntoFace( pctrvermark );

	//SaveCtr2FaceInfo();


	if( isComnCase )
	{
		for( int i = 0; i < planenum; i ++ )
			delete []pctrvermark[ i ];
		delete []pctrvermark;
	}

	//////////////////////////////////////////////////////////////////////////
//	ContourHandler::writeContourInFace( ssfacenum, ctrfvernum, ctrfverpos, ctrfvertype, 
//		ctrfverval, ctrfedgenum, ctrfedge, ctrfedgetype, ctrfedgeval );	
	//////////////////////////////////////////////////////////////////////////
//	cout<<"DONE!"<<endl<<endl;

	
	//go through each subspace to generate mesh
//	cout<<"-------- GENERATING MESH IN EACH SUBSPACE ------------"<<endl;
	//kw noted: vertices, edges and faces in each subspace
	//stitch them together finally
	floatvector* subMeshVer;
	intvector* subMeshEdge;
	intvector* subMeshFace;
	subMeshVer = new floatvector[ ssspacenum ];
	subMeshEdge = new intvector[ ssspacenum ];
	subMeshFace = new intvector[ ssspacenum ];

	//initialize registration informaiton for stitching
	sverreg = new intvector[ ssvernum ];
	sedgereg = new vector<intvector>[ ssedgenum ];
	sedgesubedgemark = new intvector[ ssedgenum ];
	sfacectrei = new intset[ ssfacenum ];
	sfacespaci = new int[ ssfacenum * 2 ];
	sfaceregface = new vector<intvector>[ ssfacenum ];
	sfaceregver = new intvector[ ssfacenum ];
	sfaceregedgever = new intvector[ ssfacenum ];
	for( int i = 0; i < ssfacenum*2; i ++)
	{
		sfacespaci[ i ] = -1;
	}
	for( int spacei = 0; spacei < ssspacenum; spacei ++)
	{
		for( int facej = 0; facej < ssspacefacenum[ spacei ]; facej ++)
		{
			int facei = ssspace[ spacei ][ facej ];
			if( sfacespaci[ 2 * facei ] == -1)
				sfacespaci[ 2 * facei ] = spacei;
			else
				sfacespaci[ 2*facei + 1 ] = spacei;
		}
	}
	
	//////////////////////////////////////////////////////////////////////////
	/*ancestorlist.resize( ssfacenum * 2 );
	ancestorlist_split.resize( ssfacenum * 2 );*/
	//////////////////////////////////////////////////////////////////////////

	//return;

	dbSpaceNum = ssspacenum; 
	if( dbOneSpaceMode )
	{
		if( dbCurSpace < dbSpaceNum )
		{
			ctr2sufSubspaceProc( dbCurSpace, subMeshVer[ dbCurSpace ], subMeshEdge[ dbCurSpace ], subMeshFace[ dbCurSpace ]);

			//submeshedge is useless for stitching!
			subMeshEdge[ dbCurSpace ].clear();
		}
	}
	//kw: here can use multi-thread to compute each submesh in parallel
	else{
		//	for( int i = 7; i< 8; i ++)

		for( int i = 0; i < ssspacenum; i ++)
			//	for( int i = 2; i < 3; i ++)
			//	for( int i = 54; i < 55; i ++)
			//	for(int i = 0; i < 12; i ++)
			//	for( int i = 14; i < 15; i ++)
		{
					cout<<"--- subspace " << i <<endl;
			ctr2sufSubspaceProc( i, subMeshVer[ i ], subMeshEdge[ i ], subMeshFace[ i ]);

			//submeshedge is useless for stitching!
			subMeshEdge[ i ].clear();
		}
	}

	delete []subMeshEdge;

	//////////////////////////////////////////////////////////////////////////
	//cout<<"before splitting, ancestors:"<<endl;
	//for( int i = 0; i < ssfacenum*2; i +=2 )
	//{
	//	if( ancestorlist[ i ].size() == 0 )
	//	{
	//		if( ancestorlist[ i + 1].size() == 0 )
	//			continue;
	//	}
	//	intset::iterator iter = ancestorlist[ i ].begin();
	////	intset::iterator iter2 = ancestorlist[ i + 1].begin();
	//	while( iter != ancestorlist[ i ].end() )
	//	{
	//		cout<<*iter<<" ";
	//		iter++;
	//	}
	//	cout<<endl;
	//	iter = ancestorlist[ i+1 ].begin();
	//	while( iter != ancestorlist[ i + 1 ].end() )
	//	{
	//		cout<<*iter <<" ";
	//		iter ++;
	//	}
	//	cout<<endl;
	//	cout<<"\n";
	//}
	//cout<<"=============================\n";
	//cout<<"after splitting ancestors:"<<endl;
	//for( int i= 0; i < ssfacenum*2; i += 2 )
	//{
	//	if( ancestorlist_split[ i ].size() == 0 )
	//	{
	//		if( ancestorlist_split[ i + 1].size() == 0)
	//			continue;
	//	}
	//	intset::iterator iter = ancestorlist_split[ i ].begin();
	//	while( iter != ancestorlist_split[ i ].end() )
	//	{
	//		cout<<*iter <<" ";
	//		iter++;
	//	//	cout<<endl;
	//	}
	//	cout<<endl;
	//	iter = ancestorlist_split[ i + 1].begin();
	//	while( iter != ancestorlist_split[ i + 1].end() )
	//	{
	//		cout<<*iter <<" ";
	//		iter ++;
	//	}
	//	cout<<endl<<endl;
	//}


	//////////////////////////////////////////////////////////////////////////
	//cout the faces registered on the contour edges 
	/*for( int i = 0; i < ssfacenum; i ++ )
	{
		int ctrnum = sfaceregface[ i ].size()/2;
		if( ctrnum == 0 )
			continue;
		intset::iterator iter = ancestorlist_split[2* i ].begin();
		for( int j = 0; j < ctrnum; j ++ )
		{
			cout<<"("<<*iter<<":"<<sfaceregface[ i ][ 2*j ] .size()<<","<<
				sfaceregface[ i ][ 2*j +1 ].size()<<")  ";
			iter++;
		}
		cout<<endl;
	}*/
	//////////////////////////////////////////////////////////////////////////

	//for( int i = 0; i < ssfacenum; i ++)
	//{
	//	ancestorlist[ i].clear();
	//	ancestorlist_split[ i ].clear();
	//}
	//ancestorlist_split.clear();
	//ancestorlist.clear();
	//////////////////////////////////////////////////////////////////////////


	//stitch all the subspaces together
	stitchMesh(subMeshVer,subMeshFace);

	clock_t   endt   =   clock();
	cout<<"time difference is:"<<endt - start<<endl;
//	struct __timeb64 timebuffer;
//	char *timeline;
	_ftime64( &timebuffer );
	timeline = _ctime64( & ( timebuffer.time ) );
	printf( "The time is %.19s.%hu %s", timeline, timebuffer.millitm, &timeline[20] );


//	FaceGenerator::writeSubMeshOut( mver, mface, 99);

	//clear all the allocated space
	//for( int i = 0; i < ssspacenum; i ++)
	//{
	//	//subMeshVer[ i ].clear();
	////	subMeshEdge[ i ].clear();
	//	subMeshFace[ i ].clear();
	//}
	////delete []subMeshVer;
	////delete []subMeshEdge;
	//delete []subMeshFace;
	/*subMeshFace = NULL;
	subMeshVer = NULL;*/

	//clear the registration information for subspace vertex, edge and face
	//sverreg
	for( int i = 0; i < ssvernum; i ++)
		sverreg[ i ].clear();
	delete []sverreg;
	sverreg = NULL;

	//sedgereg
	for( int i= 0; i < ssedgenum; i ++)
	{
		for(unsigned int j = 0; j < sedgereg[ i ].size(); j ++)
			sedgereg[ i ][ j ].clear();
		sedgereg[ i ].clear();
	}
	delete []sedgereg;
	sedgereg = NULL;

	//sfacectrei, sfacespaci, sfaceregface, sfaceregver
	for( int i= 0; i < ssfacenum; i ++)
	{
		sfacectrei[ i ].clear();
		
	//	for( int j = 0; j < sfaceregface[ i ].size();  j ++ )
    //       sfaceregface[ i ][ j ].clear();
	//	sfaceregface[ i ].clear();
		sfaceregver[ i ].clear();
	}	
	delete []sfacectrei;
	delete []sfacespaci;
	//delete []sfaceregface;
	delete []sfaceregver;
	sfacectrei = NULL;
	sfacespaci = NULL;
	//sfaceregface = NULL;
	sfaceregver = NULL;

	//set the mesh
	//clear
	if( mesh!= NULL )
		delete mesh;

	//set
	mesh = new Mesh( mver, mface, ctrmedge, 
		center,  unitlen, PROCSIZE );
	
	////kw: get constrained vertices
	//set<int> ConstrVer;
	//for (unsigned int i=0;i<ctrmedge.size();i++)
	//{
	//	ConstrVer.insert(ctrmedge.at(i));
	//}
	//for (set<int>::iterator SetIter=ConstrVer.begin();SetIter!=ConstrVer.end();SetIter++)
	//{
	//	vecTestPoint.push_back(Point_3(mver.at(3*(*SetIter))*DIM/PROCSIZE,mver.at(3*(*SetIter)+1)*DIM/PROCSIZE,
	//		mver.at(3*(*SetIter)+2)*DIM/PROCSIZE));
	//}

	mesh->setGLParam( width, height, nearplane, farplane);

	//clear
	mver.clear();
	mface.clear();
	ctrmedge.clear();
}
コード例 #16
0
/*===========================================================================
* ReadContinuousLogData
*---------------------------------------------------------------------------
* Description: Puts the node in continuous mode, reads the sensor data and
*              prints to the screen and logs data to user file until the user 
*              interrupts.
*
* Return: HANDLE - handle to the opened comport
*===========================================================================*/
void ReadContinuousLogData(int portNum)
{
	int iCount = 0;
	BOOL bStopContinuous = FALSE;
	DWORD dwcharsRead = 0;
	I3dmgx3Set Record;
	BYTE cmd_return;
	int Curs_posY = 0;
	int Curs_posX = 0;
	int status    = 0;
	int error_record = 0;
	int valid_check = 0;
	int valid_count = 0;
	char consoleBuff[60] = {0};
	long valid_rec = 0;
	unsigned char error_cmd;
	char ComLogFile[256]; 
	FILE *m_logFile;
	int LogFlag = 0;
	int error_count = 0;
	int errorCode =0, i=0;
	char fw[20] = {0};
    char sn[20] = {0};
	char mListSep[4];
    char mDecSep[4];
	LANGID langId;
	char szLanguage[256]; /*MAX_PATH]; */
	char idchar[] = {'\x02', '\x00', '\x01', '\x03', '\x04'};
    int m_timerconst = 62500; 
	unsigned long AA_Time_Stamp=0;
	unsigned long AA_s_prev =0;
	float AA_convert = 0.0;
	float AA_prev = 0.0;

	struct __timeb64 timebuffer;
    char *timeline;
    
        _ftime64( &timebuffer );
        timeline = _ctime64( & ( timebuffer.time ) );

	while (LogFlag != 1){
	    printf("Enter Name of LogFile to use:");
		scanf("%s", &ComLogFile); // 255);
		printf("logFile %s\n", ComLogFile);
        if ( ( m_logFile= fopen( ComLogFile, "w")) == NULL){
			printf("File: %s not opened\n", ComLogFile);
			if(++error_count > 2)
				return;
		}else LogFlag = 1;	
	}
	
	fprintf(m_logFile, "[SESSION START TAG]\n");
	fprintf(m_logFile, "Session Start Time:%.19s.%hu \n", timeline, timebuffer.millitm );
	fprintf(m_logFile, "Time Source: HOST\n");
	GetLocaleInfo(LOCALE_SYSTEM_DEFAULT,LOCALE_SLIST,mListSep,4);
	fprintf(m_logFile, "List Separator: %s\n", mListSep);
	GetLocaleInfo(LOCALE_SYSTEM_DEFAULT,LOCALE_SDECIMAL,mDecSep,4);
        fprintf(m_logFile, "Decimal Separator: %s\n", mDecSep);
	langId = GetSystemDefaultLangID (); 
	i = VerLanguageName (langId, szLanguage, 256); //dwSize = MAX_PATH; 
        fprintf(m_logFile, "Language: %s\n", szLanguage);

    while(valid_check == 0)
	{
       errorCode = i3dmgx3_getFirmwareVersion(portNum, &fw[0]);
	   if (errorCode < 0){
		   purge_port(portNum);
               printf("Firmware Error %d\n",errorCode);
		   if (valid_count++ > 6) {
               printf("Please Halt Current Data Display and Retry, count %d\n", valid_count);
		       return;
		   }
	   }else if (errorCode >= 0){
		   valid_check = 1;
	   }
	} 
	
   /*------------------------------------------------------------------
    * 0xEA  get serial information number, model and options (as string) 
    *-----------------------------------------------------------------*/
	valid_count =0;
    for ( i=0; i<4; i++){   //cycles through the valid device options
	
	   errorCode = i3dmgx3_getDeviceIdentiy(portNum, idchar[i], &sn[0]);
	   if (errorCode < 0){
		    purge_port(portNum);
			i--;
			if (valid_count++ >6){
			    printf("Error Read Device Identity: %s\n", explainError(errorCode));
			}
	   } else{
			 switch( i ) {
			       case 0:
					   fprintf(m_logFile, "Device Name: %s\n",sn);
					   break;
				   case 1:
					   fprintf(m_logFile, "Device Model: %s\n",sn);
					   break;
				   case 2:
					   fprintf(m_logFile, "Device FirmWare Version: %s\n", fw);
					   fprintf(m_logFile, "Device Serial Number: %s\n", sn);
					   break;
				   case 3:
					   fprintf(m_logFile, "Device Options: %s\n", sn);
					   break;
				   case 4:
				   default:
					   break;
            }
		 }
	
	} 

	fprintf(m_logFile, "Command C2\n[DATA START TAG]\n\t Time%s Accel X%s Accel Y%s Accel Z%s AngRate X%s AngRate Y%s AngRate Z%s Ticks\n", mListSep, mListSep, mListSep, mListSep, mListSep, mListSep, mListSep);

	//put the node in continuous mode
	status =SetContinuousMode(portNum, 0xC2);
	printf("setcontinuous is %d", status);
	//set up the output for the data
	printf("\n\n");
	printf("Reading streaming data (hit s to Stop streaming).\n");
	printf("C2___________________________Acceleration_______________________________\n");
	printf("            X                       Y                      Z            \n");
	/*  acceleration values go here */
	printf("\n\n\n"); 
	printf("C2____________________________Angular_Rate______________________________\n");
	printf("            X                       Y                      Z            \n");
	/* angle rate values go here  */
	getConXY(&Curs_posX, &Curs_posY); 
	printf("\n\n\n\n");
	
	//continue until the user hits the <s>top key
	while(!bStopContinuous)
	{

		if(ReadNextRecord(portNum, &Record, &cmd_return) != SUCCESS)
			error_record++;
	        if (cmd_return == 0xC2){
                if (AA_s_prev == 0){
	               fprintf(m_logFile, "\t  0.00");
				    AA_s_prev = Record.timer; //AA_Time_Stamp;
		         }
                  else
                {
				  AA_convert = ((float)(Record.timer - AA_s_prev)/m_timerconst); //19660800);
			      AA_s_prev = Record.timer; //AA_Time_Stamp;
				  AA_prev = AA_prev + AA_convert;
			      fprintf(m_logFile, "\t%6.2f", AA_prev);
			    }
			//move to the acceleration position and print the data
            sprintf(consoleBuff, "\t%2.6f\t\t%2.6f\t\t%2.6f", Record.setA[0], Record.setA[1], Record.setA[2]);               
			fprintf(m_logFile, "%s %2.6f%s %2.6f%s %2.6f%s ", mListSep, Record.setA[0],mListSep, Record.setA[1], mListSep, Record.setA[2], mListSep);
            setConXY(Curs_posX, Curs_posY -5, &consoleBuff[0]);
            sprintf(consoleBuff, "\t%2.6f\t\t%2.6f\t\t%2.6f", Record.setB[0], Record.setB[1], Record.setB[2]);
		    fprintf(m_logFile, "%2.6f%s %2.6f%s %2.6f%s %u\n", Record.setB[0], mListSep, Record.setB[1], mListSep, Record.setB[2], mListSep, Record.timer);
			setConXY(Curs_posX, Curs_posY, &consoleBuff[0]);
			valid_rec++;
			}else if (cmd_return != 0xc4){
				if((cmd_return == 0xCB || cmd_return == 0xD3) && error_record == 0)
				    error_cmd = cmd_return;
				else
					error_record++;
			}
			
		
		//check for a key every 50 iterations
		if(iCount++ > 50)	{
			int ch = 0;
			if(ReadCharNoReturn(&ch)){
				bStopContinuous = (ch == 's' || ch == 'S');
			}
			//reset the counter
			iCount = 0;
		}
	}
	printf("\n\n\nStopping Continuous Mode...");
	StopContinuousMode(portNum);
	printf("stopped.\n");
	fclose(m_logFile);
	if (error_record > 0)
	    printf("Number of records received in error were %d and received successfully %d\n", error_record, valid_rec);
	else
		printf("All %d records read successfully.\n", valid_rec);
}