Descriptor of the structure of a Tree (number of levels, descriptors of each level, ...). More...
#include <creaImageIOTreeDescriptor.h>
Public Types | |
| typedef std::vector < LevelDescriptor > | LevelDescriptorListType |
| The type of LevelDescriptor container. | |
Public Member Functions | |
| Descriptor () | |
| Ctor : creates the mandatory level 0 descriptor called "Root". | |
| ~Descriptor () | |
| Destructor. | |
| void | LoadXML (const std::string &filename) |
| Loads from a xml description file. | |
| void | CreateDefault () |
| Creates the default descriptor. | |
| unsigned int | GetNumberOfLevels () |
| Returns the number of levels of the tree. | |
| const LevelDescriptor & | GetLevelDescriptor (int level) const |
| Returns the LevelDescriptor of a given level (const ref). | |
| const LevelDescriptor::AttributeDescriptorListType & | GetAttributeDescriptorList (int level, int type=0) const |
| type = 1 without ID and PATIENT_ID | |
| void | CopyAttributeDescriptorList (int level) |
| Copy the AttributeDescriptorList without ID tag. | |
| void | Add (const LevelDescriptor &) |
| Adds a LevelDescriptor at the end of the list. | |
| void | Add (const AttributeDescriptor &, int l) |
| Adds an AttributeDescriptor to level l. | |
| void | BuildAttributeMap (AttributeMapType &) const |
| Builds the key to value map of all the attributes of the tree. | |
| const LevelDescriptorListType & | GetLevelDescriptorList () const |
| Returns the list of tree levels (const). | |
| void | Clear () |
| Clears the Descriptor. | |
| void | createDescriptorfromFile (const std::string &i_file) |
| const std::string | isExist (const std::string i_attr) |
Private Member Functions | |
| void | CreateLevel0Descriptor () |
Private Attributes | |
| LevelDescriptorListType | mLevelDescriptorList |
Descriptor of the structure of a Tree (number of levels, descriptors of each level, ...).
Definition at line 21 of file creaImageIOTreeDescriptor.h.
| typedef std::vector<LevelDescriptor> creaImageIO::tree::Descriptor::LevelDescriptorListType |
The type of LevelDescriptor container.
Definition at line 67 of file creaImageIOTreeDescriptor.h.
| creaImageIO::tree::Descriptor::Descriptor | ( | ) |
Ctor : creates the mandatory level 0 descriptor called "Root".
Definition at line 29 of file creaImageIOTreeDescriptor.cpp.
References CreateLevel0Descriptor().
{
CreateLevel0Descriptor();
}

| creaImageIO::tree::Descriptor::~Descriptor | ( | ) |
| void creaImageIO::tree::Descriptor::Add | ( | const LevelDescriptor & | d | ) |
Adds a LevelDescriptor at the end of the list.
Definition at line 232 of file creaImageIOTreeDescriptor.cpp.
References mLevelDescriptorList.
Referenced by CreateDefault(), createDescriptorfromFile(), CreateLevel0Descriptor(), creaImageIO::SQLiteTreeHandler::DBCreate(), and creaImageIO::SQLiteTreeHandler::DBImportTreeDescription().
{
mLevelDescriptorList.push_back(d);
}

| void creaImageIO::tree::Descriptor::Add | ( | const AttributeDescriptor & | d, | |
| int | l | |||
| ) |
Adds an AttributeDescriptor to level l.
Definition at line 240 of file creaImageIOTreeDescriptor.cpp.
References mLevelDescriptorList.
{
mLevelDescriptorList[l].Add(d);
// TO DO : update DicomTagToName and NameToDicomTag map
}
| void creaImageIO::tree::Descriptor::BuildAttributeMap | ( | AttributeMapType & | ) | const |
Builds the key to value map of all the attributes of the tree.
Referenced by creaImageIO::TreeHandlerImageAdder::AddFile(), creaImageIO::Synchronizer::AttributesMatch(), and creaImageIO::TreeHandlerImageAdder::CheckAttributes().

| void creaImageIO::tree::Descriptor::Clear | ( | ) |
Clears the Descriptor.
Definition at line 249 of file creaImageIOTreeDescriptor.cpp.
References mLevelDescriptorList.
Referenced by CreateDefault(), createDescriptorfromFile(), and creaImageIO::SQLiteTreeHandler::DBImportTreeDescription().
{
mLevelDescriptorList.clear();
}

| void creaImageIO::tree::Descriptor::CopyAttributeDescriptorList | ( | int | level | ) | [inline] |
Copy the AttributeDescriptorList without ID tag.
Definition at line 51 of file creaImageIOTreeDescriptor.h.
Referenced by creaImageIO::tree::Tree::CopyAttributeDescriptorList().
{
mLevelDescriptorList[level].CopyAttributeDescriptorList();
}

| void creaImageIO::tree::Descriptor::CreateDefault | ( | ) |
Creates the default descriptor.
Definition at line 50 of file creaImageIOTreeDescriptor.cpp.
References Add(), Clear(), CreateLevel0Descriptor(), creaImageIO::tree::AttributeDescriptor::IDENTIFIER, and creaImageIO::tree::AttributeDescriptor::LABEL.
{
// clears the existing one
Clear();
// Creates the level 0 descriptor
CreateLevel0Descriptor();
// Creates the attribute "Name"
Add(AttributeDescriptor("Name","Name",
AttributeDescriptor::LABEL),0);
// Patient level
Add(LevelDescriptor("Patient"));
Add(AttributeDescriptor("NumberOfChildren","#Series",0),1); // Number of Series
Add(AttributeDescriptor(0x0010,0x0010, // Patient name
AttributeDescriptor::LABEL),1);
Add(AttributeDescriptor(0x0010,0x0040),1); // Patient sex
Add(AttributeDescriptor(0x0010,0x0030),1); // Patient birthday
Add(AttributeDescriptor(0x0010,0x0020, // Patient ID
AttributeDescriptor::IDENTIFIER),1);
// Study-series level
Add(LevelDescriptor("Series"));
Add(AttributeDescriptor("NumberOfChildren","#Images",0),2); // Number of images
Add(AttributeDescriptor(0x0008,0x0060, // Modality
AttributeDescriptor::LABEL),2);
Add(AttributeDescriptor(0x0008,0x1030),2); // Study Description
Add(AttributeDescriptor(0x0008,0x103E),2); // Description
Add(AttributeDescriptor(0x0008,0x0080),2); // Institution Name
Add(AttributeDescriptor(0x0008,0x0081),2); // Institution Adress
Add(AttributeDescriptor(0x0008,0x1010),2); // Station Name
Add(AttributeDescriptor(0x0008,0x1048),2); // Physician of Record
Add(AttributeDescriptor(0x0008,0x1050),2); // Performing Physician's Name
Add(AttributeDescriptor(0x0018,0x1030),2); // Protocol Name
Add(AttributeDescriptor(0x0020,0x0010),2); // Study ID
Add(AttributeDescriptor(0x0008,0x0020),2); // Study Date
Add(AttributeDescriptor(0x0008,0x0030),2); // Study Time
Add(AttributeDescriptor(0x0008,0x0050),2); // Study Accession Number
Add(AttributeDescriptor(0x0008,0x0005),2); // Specific character set
Add(AttributeDescriptor(0x0008,0x0021),2); // Series Date
Add(AttributeDescriptor(0x0008,0x0031),2); // Series time
Add(AttributeDescriptor(0x0020,0x000D // Study Instance UID
),2);//AttributeDescriptor::IDENTIFIER),2);
Add(AttributeDescriptor(0x0020,0x000E, // Series Instance UID
AttributeDescriptor::IDENTIFIER),2);
// |
// AttributeDescriptor::LABEL),2);
// Image level
Add(LevelDescriptor("Image"));
Add(AttributeDescriptor(0x0020,0x0013),3); // Image Number
Add(AttributeDescriptor(0x0028,0x0010),3); // Rows
Add(AttributeDescriptor(0x0028,0x0011),3); // Columns
Add(AttributeDescriptor(0x0028,0x0012),3); // Planes
Add(AttributeDescriptor(0x0028,0x0002),3); // Sample per pixels
Add(AttributeDescriptor(0x0028,0x0008),3); // Number of Frames
Add(AttributeDescriptor(0x0028,0x0004),3); // Photometric Interpretation
Add(AttributeDescriptor(0x0028,0x0103),3); // Pixel Representation
Add(AttributeDescriptor(0x0020,0x0032),3); // Image Position Patient
Add(AttributeDescriptor(0x0020,0x0037),3); // Image Orientation Patient
Add(AttributeDescriptor(0x0020,0x1041),3); // Slice Location
Add(AttributeDescriptor(0x0028,0x0006),3); // Planar Configuration
Add(AttributeDescriptor(0x0028,0x0030),3); // Pixel Spacing
Add(AttributeDescriptor(0x0028,0x0100),3); // AlocatedBits
Add(AttributeDescriptor(0x0028,0x0101),3); // StoredBits
Add(AttributeDescriptor(0x0008,0x0008),3); // Image Type
Add(AttributeDescriptor(0x0008,0x0023),3); // Content Date
Add(AttributeDescriptor(0x0008,0x0033),3); // Content Time
Add(AttributeDescriptor(0x0020,0x4000),3); // Image Comments
Add(AttributeDescriptor(0x0004,0x1500, // File Name
AttributeDescriptor::LABEL),3);
Add(AttributeDescriptor(0x0028,0x1052),3); // Rescale Intercept
Add(AttributeDescriptor(0x0028,0x1053),3); // Rescale Slope
Add(AttributeDescriptor(0x0050,0x0004),3); // Calibration Image
Add(AttributeDescriptor(0x0020,0x0052 // Frame Reference UID
),3);
Add(AttributeDescriptor(0x0008,0x0016),3); // SOP Class UID
Add(AttributeDescriptor("FullFileName", // Full file name
"Full file name",
AttributeDescriptor::IDENTIFIER),3);
}

| void creaImageIO::tree::Descriptor::createDescriptorfromFile | ( | const std::string & | i_file | ) |
Definition at line 150 of file creaImageIOTreeDescriptor.cpp.
References Add(), and Clear().
Referenced by creaImageIO::Gimmick::createDB().
{
Clear();
// read file and put in buffer
std::ifstream i_file(i_name.c_str());
std::stringstream buffer;
buffer << i_file.rdbuf();
std::string line;
bool bname;
int ilevel = -1;
while(std::getline(buffer, line))
{
if(line =="<level>")
{ //increment levels.
ilevel++;
bname = true;
}
else if(bname)
{
// For each level, a name to describe it
Add(LevelDescriptor(line));
bname = false;
}
else if(line.empty()) // to avoid end line
{
return;
}
else
{
// split line to find all tags
std::vector<std::string> descriptors;
std::string separator = " ";
std::string::size_type last_pos = line.find_first_not_of(separator);
//find first separator
std::string::size_type pos = line.find_first_of(separator, last_pos);
while(std::string::npos != pos || std::string::npos != last_pos)
{
descriptors.push_back(line.substr(last_pos, pos - last_pos));
last_pos = line.find_first_not_of(separator, pos);
pos = line.find_first_of(separator, last_pos);
}
// By default, the last tag is at zero and not recorded but if take in count
unsigned int flag = 0;
if(descriptors.size() == 4)
{
std::stringstream val;
val << std::dec << descriptors[3];
val>> flag;
}
// if Dicom tag, use "group" and "element" descriptor
if(descriptors[0] == "D")
{ std::stringstream val, val2;
unsigned short group;
unsigned short element;
val << std::dec << descriptors[1] ;
val >> std::hex >> group;
val2 << std::dec << descriptors[2];
val2 >> std::hex >> element;
Add(AttributeDescriptor( group,element,flag), ilevel);
}
else if(descriptors[0].find("#") != -1)
{
// commented line continue to next line
}
else
{ boost::algorithm::replace_all(descriptors[2],"_"," ");
Add(AttributeDescriptor( descriptors[1].c_str(),descriptors[2].c_str(),flag), ilevel);
}
}
}
}


| void creaImageIO::tree::Descriptor::CreateLevel0Descriptor | ( | ) | [private] |
Creates the mandatory level 0 descriptor called "Root" (assumes the list is empty)
Definition at line 42 of file creaImageIOTreeDescriptor.cpp.
References Add().
Referenced by CreateDefault(), and Descriptor().
{
Add(LevelDescriptor("Root"));
}


| const LevelDescriptor::AttributeDescriptorListType& creaImageIO::tree::Descriptor::GetAttributeDescriptorList | ( | int | level, | |
| int | type = 0 | |||
| ) | const [inline] |
type = 1 without ID and PATIENT_ID
Returns the AttributeDescriptorList of a given level (const ref) type = 0 all attributes
Definition at line 46 of file creaImageIOTreeDescriptor.h.
Referenced by creaImageIO::tree::Tree::GetAttributeDescriptorList().
{ return mLevelDescriptorList[level].GetAttributeDescriptorList(type); }

| const LevelDescriptor& creaImageIO::tree::Descriptor::GetLevelDescriptor | ( | int | level | ) | const [inline] |
Returns the LevelDescriptor of a given level (const ref).
Definition at line 39 of file creaImageIOTreeDescriptor.h.
Referenced by creaImageIO::tree::Tree::GetLevelDescriptor().
{ return mLevelDescriptorList[level]; }

| const LevelDescriptorListType& creaImageIO::tree::Descriptor::GetLevelDescriptorList | ( | ) | const [inline] |
Returns the list of tree levels (const).
Definition at line 70 of file creaImageIOTreeDescriptor.h.
Referenced by isExist().
{ return mLevelDescriptorList; }

| unsigned int creaImageIO::tree::Descriptor::GetNumberOfLevels | ( | ) | [inline] |
Returns the number of levels of the tree.
Definition at line 35 of file creaImageIOTreeDescriptor.h.
Referenced by creaImageIO::tree::Tree::GetNumberOfLevels().
{ return mLevelDescriptorList.size(); }

| const std::string creaImageIO::tree::Descriptor::isExist | ( | const std::string | i_attr | ) |
test if an attribute is present in DescriptionList return level's name
Definition at line 280 of file creaImageIOTreeDescriptor.cpp.
References GetLevelDescriptorList().
Referenced by creaImageIO::tree::Tree::isAttributeExist().
{
std::string name = "";
LevelDescriptorListType::const_iterator l = GetLevelDescriptorList().begin();
for (; l!= GetLevelDescriptorList().end(); ++l)
{
LevelDescriptor::AttributeDescriptorListType::const_iterator a = l->GetAttributeDescriptorList().begin();
for(;a!= l->GetAttributeDescriptorList().end(); ++a)
{
if (a->GetKey() == i_attr)
{
name = l->GetName();
break;
}
}
}
return name.c_str();
}


| void creaImageIO::tree::Descriptor::LoadXML | ( | const std::string & | filename | ) |
Loads from a xml description file.
Definition at line 84 of file creaImageIOTreeDescriptor.h.
1.7.1