// stdafx.cpp : 只包括标准包含文件的源文件 // Vcs-Client.pch 将作为预编译头 // stdafx.obj 将包含预编译类型信息 #include "stdafx.h" #define MIN_XYZ_VALUE (-999999) float* g_xys = new float[3000 * 3000 * 2]; int g_xyz_flag = 0; #define Q_R 1500 #define X0 1500 #define Y0 1500 inline float abs_m(float lf) { if (lf < 0) lf *= -1; return lf; } // 以c为基准, 计算两个向量的夹角 float getAngelOfTwoVector(Point2f &pt1, Point2f &pt2, Point2f &c) { float theta = atan2(pt1.y - c.y, pt1.x - c.x) - atan2(pt2.y - c.y, pt2.x - c.x); if (theta > CV_PI) theta -= 2 * CV_PI; if (theta < -CV_PI) theta += 2 * CV_PI; theta = -1*theta * 180.0 / CV_PI; return theta; } //字符串分割 void splitString(const string& s, vector& v, const string& c) { string::size_type pos1, pos2; pos2 = s.find(c); pos1 = 0; while (string::npos != pos2) { v.push_back(s.substr(pos1, pos2 - pos1)); pos1 = pos2 + c.size(); pos2 = s.find(c, pos1); } if (pos1 != s.length()) v.push_back(s.substr(pos1)); } CString g_strSavePath = ""; CString g_strCurTime = ""; void LogOutToFile(const char* fmt, ...) { static CRITICAL_SECTION stCritical; static BOOL bInit = FALSE; static CString strLogPath; if (FALSE == bInit) { bInit = TRUE; GetModuleFileName(NULL, strLogPath.GetBuffer(2048), 2047); strLogPath.ReleaseBuffer(); strLogPath = strLogPath.Left(strLogPath.ReverseFind('\\')); strLogPath += "\\log\\runtime.log"; InitializeCriticalSection(&stCritical); } EnterCriticalSection(&stCritical); va_list ap; va_start(ap, fmt); char pBuffer[800] = ""; if (vsnprintf_s(pBuffer, 796, _TRUNCATE, fmt, ap) > 0) { if (strlen(pBuffer) == 0 || pBuffer[strlen(pBuffer) - 1] != '\n') { pBuffer[strlen(pBuffer) + 1] = '\0';//最后再追加一个结束符,因为原结束符需要修改为换行符 pBuffer[strlen(pBuffer)] = '\n'; } } va_end(ap); TRACE("%s\n", pBuffer); FILE* pFile = NULL; fopen_s(&pFile, strLogPath.GetBuffer(), "ab+"); if (NULL != pFile) { char acTime[32] = { 0 }; SYSTEMTIME stTime; GetLocalTime(&stTime); sprintf_s(acTime, 32, "[%02d-%02d %02d:%02d:%02d.%03d] ", stTime.wMonth, stTime.wDay, stTime.wHour, stTime.wMinute, stTime.wSecond, stTime.wMilliseconds); fwrite(acTime, 1, strlen(acTime), pFile); fwrite(pBuffer, 1, strlen(pBuffer), pFile); fwrite("\r\n", 1, strlen("\r\n"), pFile); fclose(pFile); } LeaveCriticalSection(&stCritical); }