void main(void) { AdjacencyWDigraph<int> G(5); int n = 5; int **kay; int **c; Make2DArray(c,n+1,n+1); Make2DArray(kay,n+1,n+1); cout << "Enter number of edges of 5 vertex weighted digraph" << endl; int e, u, v, w; cin >> e; for (int i = 1; i <= e; i++) { cout << "enter edge " << i << endl; cin >> u >> v >> w; G.Add(u,v,w);} cout << "The weighted digraph is" << endl; G.Output(); G.AllPairs(c,kay); cout << "cost matrix is" << endl; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) cout << c[i][j] << ' '; cout << endl;} cout << "kay matrix is" << endl; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) cout << kay[i][j] << ' '; cout << endl;} OutputPath(c,kay,0,1,5); }
void main(void) { welcome(); InputMaze(); if (FindPath()) OutputPath(); else cout << "No path" << endl; }
void TestSparsePerformance(bool outputMap) { int cellSize = 16; int w = 40; int h = 100; double map = CreateSparseMap(w*cellSize,h*cellSize,cellSize); //map = CreateMap(w*cellSize,h*cellSize,cellSize); SetCellMap(map, 4*cellSize, 4*cellSize, 1); SetCellMap(map, 5*cellSize, 4*cellSize, 1); SetCellMap(map, 5*cellSize, 5*cellSize, 1); SetCellMap(map, 5*cellSize, 6*cellSize, 1); SetCellMap(map, 5*cellSize, 7*cellSize, 1); SetCellMap(map, 4*cellSize, 7*cellSize, 1); SetCellMapRegion(map, (w/2)*cellSize, 0*cellSize, 2*cellSize, (h*0.75)*cellSize, 1); //SetCellMapRegion(map, (w/2)*cellSize, (h/2+1)*cellSize, 2*cellSize, (h/2-2)*cellSize, 1); #ifndef _DEBUG double pathFinder = CreatePathFinder(map); #else double mapDebug = CreateMap(w*cellSize,h*cellSize,cellSize); double pathFinder = CreatePathFinderDebug(map, mapDebug); #endif double path = FindPath(pathFinder, 2.0*cellSize, 8.0*cellSize, (w-2)*cellSize, 2.0*cellSize); if (outputMap) { OutputPath(map, path); } DestroyMap(map); DestroyPathFinder(pathFinder); DestroyPath(path); #ifdef _DEBUG DestroyMap(mapDebug); #endif }
FX_BOOL CFX_PSRenderer::DrawPath(const CFX_PathData* pPathData, const CFX_AffineMatrix* pObject2Device, const CFX_GraphStateData* pGraphState, FX_DWORD fill_color, FX_DWORD stroke_color, int fill_mode, int alpha_flag, void* pIccTransform ) { StartRendering(); int fill_alpha = FXGETFLAG_COLORTYPE(alpha_flag) ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXARGB_A(fill_color); int stroke_alpha = FXGETFLAG_COLORTYPE(alpha_flag) ? FXGETFLAG_ALPHA_STROKE(alpha_flag) : FXARGB_A(stroke_color); if (fill_alpha && fill_alpha < 255) { return FALSE; } if (stroke_alpha && stroke_alpha < 255) { return FALSE; } if (fill_alpha == 0 && stroke_alpha == 0) { return FALSE; } if (stroke_alpha) { SetGraphState(pGraphState); if (pObject2Device) { CFX_ByteTextBuf buf; buf << FX_BSTRC("mx Cm [") << pObject2Device->a << FX_BSTRC(" ") << pObject2Device->b << FX_BSTRC(" ") << pObject2Device->c << FX_BSTRC(" ") << pObject2Device->d << FX_BSTRC(" ") << pObject2Device->e << FX_BSTRC(" ") << pObject2Device->f << FX_BSTRC("]cm "); m_pOutput->OutputPS((FX_LPCSTR)buf.GetBuffer(), buf.GetSize()); } } OutputPath(pPathData, stroke_alpha ? NULL : pObject2Device); if (fill_mode && fill_alpha) { SetColor(fill_color, alpha_flag, pIccTransform); if ((fill_mode & 3) == FXFILL_WINDING) { if (stroke_alpha) { OUTPUT_PS("q f Q "); } else { OUTPUT_PS("f"); } } else if ((fill_mode & 3) == FXFILL_ALTERNATE) { if (stroke_alpha) { OUTPUT_PS("q F Q "); } else { OUTPUT_PS("F"); } } } if (stroke_alpha) { SetColor(stroke_color, alpha_flag, pIccTransform); if (pObject2Device) { OUTPUT_PS("s sm"); } else { OUTPUT_PS("s"); } } OUTPUT_PS("\n"); return TRUE; }
void main(void) { Position s,f, *p; int l; InputGrid(s,f); if (FindPath(s,f,l,p)) OutputPath(l,p); else cout << "No path" << endl; }
void FindPathTest(double map, double pathFinder, int w, int h, int cellSize, bool outputMap) { double path = FindPath(pathFinder, 2.0*cellSize, 8.0*cellSize, (w-2)*cellSize, 2.0*cellSize); //double path = FindPath(pathFinder, (w-2)*cellSize, 2.0*cellSize, 2.0*cellSize, 8.0*cellSize); if (outputMap) { OutputPath(map, path); } DestroyPath(path); }
int main() { struct around start; s.top = 0; printf("input: (0-7)\nX:"); scanf("%d",&start.x); printf("Y:"); scanf("%d",&start.y); setweight(); setmap(); HorsePath(start); OutputPath(); //ShanShuo(); return 0; }
void CFX_PSRenderer::SetClip_PathFill(const CFX_PathData* pPathData, const CFX_AffineMatrix* pObject2Device, int fill_mode ) { StartRendering(); OutputPath(pPathData, pObject2Device); CFX_FloatRect rect = pPathData->GetBoundingBox(); if (pObject2Device) { rect.Transform(pObject2Device); } m_ClipBox.Intersect(rect.GetOutterRect()); if ((fill_mode & 3) == FXFILL_WINDING) { OUTPUT_PS("W n\n"); } else { OUTPUT_PS("W* n\n"); } }
FPDF_EXPORT void FPDF_CALLCONV FPDFPage_InsertClipPath(FPDF_PAGE page, FPDF_CLIPPATH clipPath) { CPDF_Page* pPage = CPDFPageFromFPDFPage(page); if (!pPage) return; CPDF_Dictionary* pPageDict = pPage->GetDict(); CPDF_Object* pContentObj = GetPageContent(pPageDict); if (!pContentObj) return; std::ostringstream strClip; CPDF_ClipPath* pClipPath = CPDFClipPathFromFPDFClipPath(clipPath); for (size_t i = 0; i < pClipPath->GetPathCount(); ++i) { CPDF_Path path = pClipPath->GetPath(i); if (path.GetPoints().empty()) { // Empty clipping (totally clipped out) strClip << "0 0 m W n "; } else { OutputPath(strClip, path); if (pClipPath->GetClipType(i) == FXFILL_WINDING) strClip << "W n\n"; else strClip << "W* n\n"; } } CPDF_Document* pDoc = pPage->GetDocument(); if (!pDoc) return; CPDF_Stream* pStream = pDoc->NewIndirect<CPDF_Stream>(nullptr, 0, pDoc->New<CPDF_Dictionary>()); pStream->SetDataFromStringstream(&strClip); if (CPDF_Array* pArray = ToArray(pContentObj)) { pArray->InsertAt(0, pStream->MakeReference(pDoc)); } else if (pContentObj->IsStream() && !pContentObj->IsInline()) { CPDF_Array* pContentArray = pDoc->NewIndirect<CPDF_Array>(); pContentArray->Add(pStream->MakeReference(pDoc)); pContentArray->Add(pContentObj->MakeReference(pDoc)); pPageDict->SetFor(pdfium::page_object::kContents, pContentArray->MakeReference(pDoc)); } }
void CFX_PSRenderer::SetClip_PathStroke(const CFX_PathData* pPathData, const CFX_AffineMatrix* pObject2Device, const CFX_GraphStateData* pGraphState ) { StartRendering(); SetGraphState(pGraphState); if (pObject2Device) { CFX_ByteTextBuf buf; buf << FX_BSTRC("mx Cm [") << pObject2Device->a << FX_BSTRC(" ") << pObject2Device->b << FX_BSTRC(" ") << pObject2Device->c << FX_BSTRC(" ") << pObject2Device->d << FX_BSTRC(" ") << pObject2Device->e << FX_BSTRC(" ") << pObject2Device->f << FX_BSTRC("]cm "); m_pOutput->OutputPS((FX_LPCSTR)buf.GetBuffer(), buf.GetSize()); } OutputPath(pPathData, NULL); CFX_FloatRect rect = pPathData->GetBoundingBox(pGraphState->m_LineWidth, pGraphState->m_MiterLimit); rect.Transform(pObject2Device); m_ClipBox.Intersect(rect.GetOutterRect()); if (pObject2Device) { OUTPUT_PS("strokepath W n sm\n"); } else { OUTPUT_PS("strokepath W n\n"); } }
DLLEXPORT void STDCALL FPDFPage_InsertClipPath(FPDF_PAGE page, FPDF_CLIPPATH clipPath) { CPDF_Page* pPage = CPDFPageFromFPDFPage(page); if (!pPage) return; CPDF_Dictionary* pPageDic = pPage->m_pFormDict; CPDF_Object* pContentObj = pPageDic ? pPageDic->GetElement("Contents") : nullptr; if (!pContentObj) pContentObj = pPageDic ? pPageDic->GetArrayBy("Contents") : nullptr; if (!pContentObj) return; CFX_ByteTextBuf strClip; CPDF_ClipPath* pClipPath = (CPDF_ClipPath*)clipPath; FX_DWORD i; for (i = 0; i < pClipPath->GetPathCount(); i++) { CPDF_Path path = pClipPath->GetPath(i); int iClipType = pClipPath->GetClipType(i); if (path.GetPointCount() == 0) { // Empty clipping (totally clipped out) strClip << "0 0 m W n "; } else { OutputPath(strClip, path); if (iClipType == FXFILL_WINDING) strClip << "W n\n"; else strClip << "W* n\n"; } } CPDF_Dictionary* pDic = new CPDF_Dictionary; CPDF_Stream* pStream = new CPDF_Stream(nullptr, 0, pDic); pStream->SetData(strClip.GetBuffer(), strClip.GetSize(), FALSE, FALSE); CPDF_Document* pDoc = pPage->m_pDocument; if (!pDoc) return; pDoc->AddIndirectObject(pStream); CPDF_Array* pContentArray = nullptr; if (CPDF_Array* pArray = ToArray(pContentObj)) { pContentArray = pArray; CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum()); pContentArray->InsertAt(0, pRef); } else if (CPDF_Reference* pReference = ToReference(pContentObj)) { CPDF_Object* pDirectObj = pReference->GetDirect(); if (pDirectObj) { if (CPDF_Array* pArray = pDirectObj->AsArray()) { pContentArray = pArray; CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum()); pContentArray->InsertAt(0, pRef); } else if (pDirectObj->IsStream()) { pContentArray = new CPDF_Array(); pContentArray->AddReference(pDoc, pStream->GetObjNum()); pContentArray->AddReference(pDoc, pDirectObj->GetObjNum()); pPageDic->SetAtReference("Contents", pDoc, pDoc->AddIndirectObject(pContentArray)); } } } }
DLLEXPORT void STDCALL FPDFPage_InsertClipPath(FPDF_PAGE page,FPDF_CLIPPATH clipPath) { if(!page) return; CPDF_Page* pPage = (CPDF_Page*)page; CPDF_Dictionary* pPageDic = pPage->m_pFormDict; CPDF_Object* pContentObj = pPageDic->GetElement("Contents"); if(!pContentObj) pContentObj = pPageDic->GetArray("Contents"); if(!pContentObj) return; CFX_ByteTextBuf strClip; CPDF_ClipPath* pClipPath = (CPDF_ClipPath*)clipPath; FX_DWORD i; for (i = 0; i < pClipPath->GetPathCount(); i ++) { CPDF_Path path = pClipPath->GetPath(i); int iClipType = pClipPath->GetClipType(i); if (path.GetPointCount() == 0) { // Empty clipping (totally clipped out) strClip << "0 0 m W n "; } else { OutputPath(strClip, path); if (iClipType == FXFILL_WINDING) strClip << "W n\n"; else strClip << "W* n\n"; } } CPDF_Dictionary* pDic = FX_NEW CPDF_Dictionary; CPDF_Stream* pStream = FX_NEW CPDF_Stream(NULL,0, pDic); pStream->SetData(strClip.GetBuffer(), strClip.GetSize(), FALSE, FALSE); CPDF_Document* pDoc = pPage->m_pDocument; if(!pDoc) return; pDoc->AddIndirectObject(pStream); CPDF_Array* pContentArray = NULL; if (pContentObj && pContentObj->GetType() == PDFOBJ_ARRAY) { pContentArray = (CPDF_Array*)pContentObj; CPDF_Reference* pRef = FX_NEW CPDF_Reference(pDoc, pStream->GetObjNum()); pContentArray->InsertAt(0, pRef); } else if(pContentObj && pContentObj->GetType() == PDFOBJ_REFERENCE) { CPDF_Reference* pReference = (CPDF_Reference*)pContentObj; CPDF_Object* pDirectObj = pReference->GetDirect(); if(pDirectObj != NULL) { if(pDirectObj->GetType() == PDFOBJ_ARRAY) { pContentArray = (CPDF_Array*)pDirectObj; CPDF_Reference* pRef = FX_NEW CPDF_Reference(pDoc, pStream->GetObjNum()); pContentArray->InsertAt(0, pRef); } else if(pDirectObj->GetType() == PDFOBJ_STREAM) { pContentArray = FX_NEW CPDF_Array(); pContentArray->AddReference(pDoc,pStream->GetObjNum()); pContentArray->AddReference(pDoc,pDirectObj->GetObjNum()); pPageDic->SetAtReference("Contents", pDoc, pDoc->AddIndirectObject(pContentArray)); } } } }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); ui->phaseAtery->setChecked(true); ui->phaseEquil->setChecked(true); ui->phaseNonEnhance->setChecked(true); ui->phaseHepaticPortal->setChecked(true); ui->thickLess100->setChecked(true); ui->thick100to200->setChecked(true); ui->thick200to400->setChecked(true); ui->thickMore400->setChecked(true); ui->tumorNo->setChecked(true); ui->tumorMinor->setChecked(true); ui->tumorCritical->setChecked(true); ui->qualityPoor->setChecked(true); ui->qualityGood->setChecked(true); ui->qualityNormal->setChecked(true); ui->segOK->setChecked(true); ui->segError->setChecked(true); rmbMenu = new QMenu(this); dcmFinderAction = new QAction(this); dcmFinderAction->setText("在Finder中显示Dicom路径"); mhdFinderAction = new QAction(this); mhdFinderAction->setText("在Finder中显示mhd路径"); rmbMenu->addAction(dcmFinderAction); rmbMenu->addAction(mhdFinderAction); ui->databaseWidget->setContextMenuPolicy(Qt::CustomContextMenu); ui->outputNameEdit->setText("点此输入路径集名"); connect(ui->loadDBButton, SIGNAL(clicked()), this, SLOT(ReadDBFromFile())); connect(ui->phaseAtery, SIGNAL(stateChanged(int)), this, SLOT(UpdateFilters(int))); connect(ui->phaseEquil, SIGNAL(stateChanged(int)), this, SLOT(UpdateFilters(int))); connect(ui->phaseNonEnhance, SIGNAL(stateChanged(int)), this, SLOT(UpdateFilters(int))); connect(ui->phaseHepaticPortal, SIGNAL(stateChanged(int)), this, SLOT(UpdateFilters(int))); connect(ui->thickLess100, SIGNAL(stateChanged(int)), this, SLOT(UpdateFilters(int))); connect(ui->thick200to400, SIGNAL(stateChanged(int)), this, SLOT(UpdateFilters(int))); connect(ui->thickMore400, SIGNAL(stateChanged(int)), this, SLOT(UpdateFilters(int))); connect(ui->thick100to200, SIGNAL(stateChanged(int)), this, SLOT(UpdateFilters(int))); connect(ui->tumorNo, SIGNAL(stateChanged(int)), this, SLOT(UpdateFilters(int))); connect(ui->tumorMinor, SIGNAL(stateChanged(int)), this, SLOT(UpdateFilters(int))); connect(ui->tumorCritical, SIGNAL(stateChanged(int)), this, SLOT(UpdateFilters(int))); connect(ui->qualityNormal, SIGNAL(stateChanged(int)), this, SLOT(UpdateFilters(int))); connect(ui->qualityGood, SIGNAL(stateChanged(int)), this, SLOT(UpdateFilters(int))); connect(ui->qualityPoor, SIGNAL(stateChanged(int)), this, SLOT(UpdateFilters(int))); connect(ui->segError, SIGNAL(stateChanged(int)), this, SLOT(UpdateFilters(int))); connect(ui->segOK, SIGNAL(stateChanged(int)), this, SLOT(UpdateFilters(int))); connect(ui->userdefFilter, SIGNAL(textChanged()), this, SLOT(DummyReceiver())); connect(ui->databaseWidget, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(ctmExec(const QPoint &))); connect(dcmFinderAction, SIGNAL(triggered()), this, SLOT(ShowDcmInFinder())); connect(mhdFinderAction, SIGNAL(triggered()), this, SLOT(ShowMhdInFinder())); connect(ui->savePathButton, SIGNAL(clicked()), this, SLOT(OutputPath())); Reset(); SetupDB(); }
DLLEXPORT void STDCALL FPDFPage_InsertClipPath(FPDF_PAGE page, FPDF_CLIPPATH clipPath) { CPDF_Page* pPage = CPDFPageFromFPDFPage(page); if (!pPage) return; CPDF_Dictionary* pPageDic = pPage->m_pFormDict; CPDF_Object* pContentObj = pPageDic ? pPageDic->GetObjectFor("Contents") : nullptr; if (!pContentObj) pContentObj = pPageDic ? pPageDic->GetArrayFor("Contents") : nullptr; if (!pContentObj) return; CFX_ByteTextBuf strClip; CPDF_ClipPath* pClipPath = (CPDF_ClipPath*)clipPath; uint32_t i; for (i = 0; i < pClipPath->GetPathCount(); i++) { CPDF_Path path = pClipPath->GetPath(i); int iClipType = pClipPath->GetClipType(i); if (path.GetPoints().empty()) { // Empty clipping (totally clipped out) strClip << "0 0 m W n "; } else { OutputPath(strClip, path); if (iClipType == FXFILL_WINDING) strClip << "W n\n"; else strClip << "W* n\n"; } } CPDF_Document* pDoc = pPage->m_pDocument; if (!pDoc) return; CPDF_Stream* pStream = pDoc->NewIndirect<CPDF_Stream>( nullptr, 0, pdfium::MakeUnique<CPDF_Dictionary>(pDoc->GetByteStringPool())); pStream->SetData(strClip.GetBuffer(), strClip.GetSize()); CPDF_Array* pArray = ToArray(pContentObj); if (pArray) { pArray->InsertNewAt<CPDF_Reference>(0, pDoc, pStream->GetObjNum()); return; } CPDF_Reference* pReference = ToReference(pContentObj); if (!pReference) return; CPDF_Object* pDirectObj = pReference->GetDirect(); if (!pDirectObj) return; CPDF_Array* pObjArray = pDirectObj->AsArray(); if (pObjArray) { pObjArray->InsertNewAt<CPDF_Reference>(0, pDoc, pStream->GetObjNum()); return; } if (pDirectObj->IsStream()) { CPDF_Array* pContentArray = pDoc->NewIndirect<CPDF_Array>(); pContentArray->AddNew<CPDF_Reference>(pDoc, pStream->GetObjNum()); pContentArray->AddNew<CPDF_Reference>(pDoc, pDirectObj->GetObjNum()); pPageDic->SetNewFor<CPDF_Reference>("Contents", pDoc, pContentArray->GetObjNum()); } }
void MainWindow::OnGenerateLicenseClicked() { QDate StartDate = ui->dt_StartDate->date(); QDate EndDate = ui->dt_EndDate->date(); //is date format valid ? if(EndDate<=StartDate) { QMessageBox Msgbox; Msgbox.setText("License duration is too small"); Msgbox.exec(); return; } //does fingerprint file exists ? QString FingerprintFilePath = ui->t_LicenseSeedPath->toPlainText(); if(fileExists(FingerprintFilePath)== false) { QMessageBox Msgbox; Msgbox.setText("Could not find license seed file"); Msgbox.exec(); } int GraceDuration = ui->t_GraceDuration->toPlainText().toInt(); if(GraceDuration > 31) { QMessageBox Msgbox; Msgbox.setText("Max Grace duration is 31 days"); Msgbox.exec(); GraceDuration = 31; // this limitation comes from inside licenseDLL. Can be extended, but needs a rebuild } GraceDuration = GraceDuration * 24 * 60 * 60; //calculate start and duration QDateTime StartDateTime(StartDate); StartDateTime.setTimeSpec(Qt::UTC); QDateTime EndDateTime(EndDate); EndDateTime.setTimeSpec(Qt::UTC); int LicenseDuration = EndDateTime.toTime_t() - StartDateTime.toTime_t(); time_t LicenseStart = StartDateTime.toTime_t(); int er, ers = 0; //create a license License *TestLicense = new License; er = TestLicense->SetDuration(LicenseStart, LicenseDuration, GraceDuration); if( er != 0 ) { QMessageBox Msgbox; Msgbox.setText("There was an error setting license duration"); Msgbox.exec(); } ers += er; //iterate through the table and add rows 1 by 1 int RowCount = ui->table_LicenseContent->rowCount(); for( int row = 0; row<RowCount; row++) { QString ProductName = ui->table_LicenseContent->item(row,0)->text(); QString FeatureName = ui->table_LicenseContent->item(row,1)->text(); er = TestLicense->AddProjectFeature( ProductName.toStdString().c_str(), FeatureName.toStdString().c_str()); if( er != 0 ) { QMessageBox Msgbox; Msgbox.setText("There was an error adding activation key to the license"); Msgbox.exec(); } ers += er; } //where to save the output QString OutputPath(QDir(FingerprintFilePath).currentPath()); OutputPath += "/"; OutputPath += LICENSE_FILE_CONSTANT_NAME; er = TestLicense->SaveToFile(OutputPath.toStdString().c_str(),FingerprintFilePath.toStdString().c_str()); if( er != 0 ) { QMessageBox Msgbox; Msgbox.setText("There was an error saving the license"); Msgbox.exec(); } ers += er; delete TestLicense; if( ers == 0 ) { QMessageBox Msgbox; Msgbox.setText("License successfully generated"); Msgbox.exec(); } else { QMessageBox Msgbox; Msgbox.setText("There was an error generating the license"); Msgbox.exec(); } }