MCPcopy Create free account
hub / github.com/MITK/MITK / PropertyNameToDICOMTagPath

Function PropertyNameToDICOMTagPath

Modules/DICOM/src/mitkDICOMTagPath.cpp:628–727  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

626
627
628 DICOMTagPath
629 PropertyNameToDICOMTagPath(const std::string& propertyName)
630 {
631 DICOMTagPath result;
632
633 std::istringstream f(propertyName);
634 std::string subStr;
635
636 if (getline(f, subStr, '.'))
637 {
638 if (subStr != "DICOM")
639 {
640 return DICOMTagPath();
641 }
642
643 unsigned int nrCount = 0;
644 unsigned long group = 0;
645 unsigned long element = 0;
646
647 while (getline(f, subStr, '.'))
648 {
649 if (subStr == "*")
650 {
651 if (nrCount == 2)
652 { //add last element
653 result.AddElement(group, element);
654 nrCount = 0;
655 }
656 else if (nrCount != 0)
657 { //invalid path
658 return DICOMTagPath();
659 }
660
661 result.AddAnyElement();
662 }
663 else
664 {
665 std::regex reg_element("([A-Fa-f\\d]{4})");
666 std::regex reg_anySelection("\\[\\*\\]");
667 std::regex reg_Selection("\\[(\\d+)\\]");
668 std::smatch sm;
669 if (std::regex_match(subStr, sm, reg_anySelection))
670 {
671 if (nrCount == 2)
672 {
673 result.AddAnySelection(group, element);
674 nrCount = 0;
675 }
676 else
677 { //invalid path
678 return DICOMTagPath();
679 }
680 }
681 else if (std::regex_match(subStr, sm, reg_Selection))
682 {
683 if (nrCount == 2)
684 {
685 result.AddSelection(group, element, std::stoi(sm[1]));

Calls 1

AddElementMethod · 0.80

Tested by 1