Mercurial > hg > orthanc-stone
comparison OrthancStone/UnitTestsSources/ComputationalGeometryTests.cpp @ 2161:e65fe2e50fde dicom-sr tip
integration mainline->dicom-sr
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 27 Sep 2024 22:34:17 +0200 |
parents | 340bde744884 |
children |
comparison
equal
deleted
inserted
replaced
2152:f68f9a8d0d63 | 2161:e65fe2e50fde |
---|---|
536 ASSERT_TRUE(contours.back()[3].IsEqual(OrthancStone::ScenePoint2D(10, 5))); | 536 ASSERT_TRUE(contours.back()[3].IsEqual(OrthancStone::ScenePoint2D(10, 5))); |
537 ASSERT_TRUE(contours.back()[4].IsEqual(OrthancStone::ScenePoint2D(10, 7))); | 537 ASSERT_TRUE(contours.back()[4].IsEqual(OrthancStone::ScenePoint2D(10, 7))); |
538 } | 538 } |
539 } | 539 } |
540 } | 540 } |
541 | |
542 | |
543 #if 0 | |
544 static void SaveSvg(const std::list< std::vector<OrthancStone::ScenePoint2D> >& contours) | |
545 { | |
546 float ww = 15; | |
547 float hh = 13; | |
548 | |
549 FILE* fp = fopen("test.svg", "w"); | |
550 fprintf(fp, "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"); | |
551 fprintf(fp, "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n"); | |
552 fprintf(fp, "<svg width=\"%f\" height=\"%f\" viewBox=\"0 0 %f %f\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n", 100.0f*ww, 100.0f*hh, ww, hh); | |
553 | |
554 // http://thenewcode.com/1068/Making-Arrows-in-SVG | |
555 fprintf(fp, "<defs>\n"); | |
556 fprintf(fp, "<marker id=\"arrowhead\" markerWidth=\"2\" markerHeight=\"3\" \n"); | |
557 fprintf(fp, "refX=\"2\" refY=\"1.5\" orient=\"auto\">\n"); | |
558 fprintf(fp, "<polygon points=\"0 0, 2 1.5, 0 3\" />\n"); | |
559 fprintf(fp, "</marker>\n"); | |
560 fprintf(fp, "</defs>\n"); | |
561 | |
562 fprintf(fp, "<rect fill=\"#fff\" stroke=\"#000\" x=\"0\" y=\"0\" width=\"%f\" height=\"%f\"/>\n", ww, hh); | |
563 | |
564 unsigned int count = 0; | |
565 | |
566 for (std::list< std::vector<OrthancStone::ScenePoint2D> >::const_iterator | |
567 it = contours.begin(); it != contours.end(); ++it, count++) | |
568 { | |
569 std::string color; | |
570 if (count == 0) | |
571 { | |
572 color = "blue"; | |
573 } | |
574 else if (count == 1) | |
575 { | |
576 color = "red"; | |
577 } | |
578 else if (count == 2) | |
579 { | |
580 color = "green"; | |
581 } | |
582 else if (count == 3) | |
583 { | |
584 color = "orange"; | |
585 } | |
586 else | |
587 { | |
588 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); | |
589 } | |
590 | |
591 for (size_t i = 0; i + 1 < it->size(); i++) | |
592 { | |
593 float x1 = (*it)[i].GetX(); | |
594 float x2 = (*it)[i + 1].GetX(); | |
595 float y1 = (*it)[i].GetY(); | |
596 float y2 = (*it)[i + 1].GetY(); | |
597 | |
598 fprintf(fp, "<line x1=\"%f\" y1=\"%f\" x2=\"%f\" y2=\"%f\" stroke=\"%s\" stroke-width=\"0.05\" marker-end=\"url(#arrowhead)\"/>\n", x1, y1, x2, y2, color.c_str()); | |
599 } | |
600 } | |
601 fprintf(fp, "</svg>\n"); | |
602 | |
603 fclose(fp); | |
604 } | |
605 #endif | |
606 | 541 |
607 | 542 |
608 TEST(UnionOfRectangles, EdgeCases) | 543 TEST(UnionOfRectangles, EdgeCases) |
609 { | 544 { |
610 { | 545 { |