void WINAPI CIceService::ServiceMain( DWORD dwArgc, LPTSTR* lpszArgv ) { //throw std::exception("The method or operation is not implemented."); ZTools::WriteZToolsLog("Function CIceService::ServiceMain"); ReportStatus(SERVICE_START_PENDING, 1, 1100); Sleep(1000); ReportStatus(SERVICE_RUNNING); try { communicator = InitCommunicator(); Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapterWithEndpoints("PeraNetDiskDaemonService", GetEndPoints()); Ice::ObjectPtr servant = new PeraNetDiskIceI(); adapter->add(servant, communicator->stringToIdentity("PeraNetDiskDaemonService")); adapter->activate(); communicator->waitForShutdown(); communicator->destroy(); } catch(const Ice::Exception& ex) { //cerr << ex << endl; ZTools::WriteZToolsLog( ZTools::FormatString("ice_name:%s\nice_stack:%s", ex.ice_name().c_str(), ex.ice_stackTrace().c_str()) ); if(communicator) { try { communicator->destroy(); } catch(const Ice::Exception& ex) { //cerr << ex << endl; ZTools::WriteZToolsLog( ZTools::FormatString("ice_name:%s\nice_stack:%s", ex.ice_name().c_str(), ex.ice_stackTrace().c_str()) ); } } } //Report to the event log that the service has started successfully //m_EventLogSource.Report(EVENTLOG_INFORMATION_TYPE, CNTS_MSG_SERVICE_STARTED, m_sDisplayName); //The tight loop which constitutes the service // long lOldPause = m_lPaused; // while (!m_lWantStop) // { // //As a demo, we just do a message beep // if (!m_lPaused) // MessageBeep(MB_OK); // // //Wait for the specified time // Sleep(m_dwBeepInternal); // // //SCM has requested a Pause / Continue // if (m_lPaused != lOldPause) // { // if (m_lPaused) // { // ReportStatus(SERVICE_PAUSED); // // //Report to the event log that the service has paused successfully // m_EventLogSource.Report(EVENTLOG_INFORMATION_TYPE, CNTS_MSG_SERVICE_PAUSED, m_sDisplayName); // } // else // { // ReportStatus(SERVICE_RUNNING); // // //Report to the event log that the service has stopped continued // m_EventLogSource.Report(EVENTLOG_INFORMATION_TYPE, CNTS_MSG_SERVICE_CONTINUED, m_sDisplayName); // } // } // // lOldPause = m_lPaused; // } //Pretend that closing down takes some time ReportStatus(SERVICE_STOP_PENDING, 1, 1100); Sleep(1000); //Report to the event log that the service has stopped successfully //m_EventLogSource.Report(EVENTLOG_INFORMATION_TYPE, CNTS_MSG_SERVICE_STOPPED, m_sDisplayName); }
void FilterPoints2::GetPoints() { ofstream F1("c:\\5555.txt", fstream::app); DWORD k = 0; int n; //переводим точки во внутреннюю структуру Lines for (int n = 0; n < Path->curve.n; n++) { if (Path->curve.tag[n] == POTRACE_CURVETO) { PointD startPoint = Path->curve.c[n ? n - 1 : Path->curve.n - 1][2]; PointD UPoint = Path->curve.c[n][0]; PointD WPoint = Path->curve.c[n][1]; PointD endPoint = Path->curve.c[n][2]; Lines.push_back( PotraceLineCPP(startPoint, UPoint)); Lines.push_back( PotraceLineCPP(UPoint, WPoint)); Lines.push_back( PotraceLineCPP(WPoint, endPoint)); } if (Path->curve.tag[n] == POTRACE_CORNER) { PointD startPoint = Path->curve.c[n ? n - 1 : Path->curve.n - 1][2]; PointD vertexPoint = Path->curve.c[n][1]; //срединная точка PointD endPoint = Path->curve.c[n][2]; Lines.push_back( PotraceLineCPP(startPoint, vertexPoint)); Lines.push_back( PotraceLineCPP(vertexPoint, endPoint)); } } //классификация линий //1 - линия параллельна X //2 - линия параллельна Y //0 - линия готова к удалению if (Lines.size() <= 1) return; for (k = 0; k < Lines.size(); k++) { if (isParallelX(Lines[k].Start, Lines[k].End)) Lines[k].tag = 1; else if (isParallelY(Lines[k].Start, Lines[k].End)) Lines[k].tag = 2; } //объединение линиий по классификации DWORD endI; k = 0; while (k < Lines.size()-1) { if (Lines[k].tag != 0) { endI = FindEndParallel(k + 1, Lines[k].tag); if (k != endI) { PotraceLineCPP L = GetEndPoints(Lines[k], Lines[endI]); Lines[k].Start = L.Start; Lines[k].End = L.End; RangeSetType( k + 1, endI, 0); k = endI; } } k++; } //Удаляем линии длины которых меньше указанной for (k = 0; k < Lines.size(); k++) if (Lines[k].tag != 0) if (GetDistance(Lines[k].Start, Lines[k].End) < MinLen) Lines[k].tag = 0; for (k = 0; k < Lines.size(); k++) //if (Lines[k].tag != 0) { //F1 << Lines[k].tag << endl; //F1 << "Lines " << k << " xStart=" << Lines[k].Start.x << endl; //F1 << "Lines " << k << " yStart=" << Lines[k].Start.y << endl; //F1 << "Lines " << k << " xEnd=" << Lines[k].End.x << endl; //F1 << "Lines " << k << " yEnd=" << Lines[k].End.y << endl; F1 << Lines[k].Start.x << ";" << Lines[k].Start.y << ";" << Lines[k].End.x << ";" << Lines[k].End.y<< endl; } //Получаем все точки пересечения двух осей for (DWORD x = 0; x < Lines.size(); x++) if (Lines[x].tag == 1) for (DWORD y = 0; y < Lines.size(); y++) if (Lines[y].tag == 2) { Result.push_back(GetPointD( (Lines[y].Start.x + Lines[y].End.x) / 2, (Lines[x].Start.y + Lines[x].End.y) / 2)); } F1.close(); }
void FilterPoints3::GetPoints() { DWORD k = 0; DWORD m; int n; //переводим точки во внутреннюю структуру Lines for (int n = 0; n < Path->curve.n; n++) { if (Path->curve.tag[n] == POTRACE_CURVETO) { PointD startPoint = Path->curve.c[n ? n - 1 : Path->curve.n - 1][2]; PointD UPoint = Path->curve.c[n][0]; PointD WPoint = Path->curve.c[n][1]; PointD endPoint = Path->curve.c[n][2]; Lines.push_back( PotraceLineCPP(startPoint, UPoint)); Lines.push_back( PotraceLineCPP(UPoint, WPoint)); Lines.push_back( PotraceLineCPP(WPoint, endPoint)); } if (Path->curve.tag[n] == POTRACE_CORNER) { PointD startPoint = Path->curve.c[n ? n - 1 : Path->curve.n - 1][2]; PointD vertexPoint = Path->curve.c[n][1]; //срединная точка PointD endPoint = Path->curve.c[n][2]; Lines.push_back( PotraceLineCPP(startPoint, vertexPoint)); Lines.push_back( PotraceLineCPP(vertexPoint, endPoint)); } } //классификация линий //1 - линия параллельна X //2 - линия параллельна Y //0 - линия готова к удалению if (Lines.size() <= 1) return; for (k = 0; k < Lines.size(); k++) { if (isParallelX(Lines[k].Start, Lines[k].End)) Lines[k].tag = 1; else if (isParallelY(Lines[k].Start, Lines[k].End)) Lines[k].tag = 2; } //объединение линиий по классификации DWORD endI; k = 0; while (k < Lines.size()-1) { if (Lines[k].tag != 0) { endI = FindEndParallel(k + 1, Lines[k].tag); if (k != endI) { PotraceLineCPP L = GetEndPoints(Lines[k], Lines[endI]); Lines[k].Start = L.Start; Lines[k].End = L.End; RangeSetType( k + 1, endI, 0); k = endI; } } k++; } //Удаляем линии длины которых меньше указанной for (k = 0; k < Lines.size(); k++) if (Lines[k].tag != 0) if (GetDistance(Lines[k].Start, Lines[k].End) < MinLen) Lines[k].tag = 0; /*ofstream F0("c:\\999.txt"); for (k = 0; k < Lines.size(); k++) if (Lines[k].tag != 0) { F0 << "tag = " << Lines[k].tag << endl; F0 << "index = " << k << endl; F0 << "Line " << " Start=\t" << Lines[k].Start.x << "\t" << Lines[k].Start.y << endl; F0 << "Line " << " End=\t" << Lines[k].End.x << "\t" << Lines[k].End.y << endl; F0 << "------------------------" << endl; //F0 << Lines[k].Start.x << ";" << Lines[k].Start.y << ";" << Lines[k].End.x << ";" << Lines[k].End.y<< endl; } F0.close(); */ //ищем перегибы в оставшихся линиях (перегиб - виртуальное пересечение линий различных классов) //в массив заносится границы (индексы начала и конца) классов линий IndexRange CurrentRange; CurrentRange.iClass = 0; for (k = 0; k < Lines.size(); k++) { if (Lines[k].tag != 0) { if (CurrentRange.iClass != 0) //если не равно 0 то iBegin заполнен if ((Lines[k].tag != CurrentRange.iClass) || (isChangeRoute(k, CurrentRange.iBegin))) { CurrentRange.iEnd = k; Ranges.push_back(CurrentRange); CurrentRange.iClass = Lines[k].tag; CurrentRange.iBegin = k; } if (CurrentRange.iClass == 0) { CurrentRange.iClass = Lines[k].tag; CurrentRange.iBegin = k; }; } } CurrentRange.iEnd = Lines.size(); //последний диапазон линий всегда будет незавершен, поэтому так Ranges.push_back(CurrentRange); //поиск меток и аппроксимация точек в линию между метками (апроксимация заменена на получение арифм.среднего значения множества точек для соответствующей прямой) for (k = 0; k < Ranges.size(); k++) { //if (Ranges[k].iClass != Ranges[k-1].iClass) Ranges[k].iMediumLine = GetApproxIndexLine(Ranges[k].iBegin, Ranges[k].iEnd); } //имеем Ranges, в котором содержаться индексы усреднённых линий и диапазоны, //строим точки пересечения отрезков for (k = 1; k < Ranges.size(); k++) if (Ranges[k-1].iClass != Ranges[k].iClass) Result.push_back(GetIntersecPoint(Ranges[k-1].iMediumLine, Ranges[k].iMediumLine)); if (Ranges[k-1].iClass != Ranges[k].iClass) Result.push_back(GetIntersecPoint(Ranges[0].iMediumLine, Ranges[Ranges.size() - 1].iMediumLine)); /*ofstream F1("c:\\777.txt"); for (k = 0; k < Result.size(); k++) { F1 << "Result " << k << endl; F1 << "\t" << Result[k].x << "\t" << Result[k].y << endl; } for (k = 0; k < Lines.size(); k++) if (Lines[k].tag != 0) { F1 << "tag = " << Lines[k].tag << endl; F1 << "index = " << k << endl; F1 << "Line " << " Start=\t" << Lines[k].Start.x << "\t" << Lines[k].Start.y << endl; F1 << "Line " << " End=\t" << Lines[k].End.x << "\t" << Lines[k].End.y << endl; F1 << "------------------------" << endl; //F1 << Lines[k].Start.x << ";" << Lines[k].Start.y << ";" << Lines[k].End.x << ";" << Lines[k].End.y<< endl; } F1.close(); */ }