MeVisLabToolboxReference
|
00001 //----------------------------------------------------------------------------- 00002 // **InsertLicense** code 00003 //----------------------------------------------------------------------------- 00005 00010 //----------------------------------------------------------------------------- 00011 00012 #ifndef CLASS_DCMTREE_STRUCTUREDMF 00013 #define CLASS_DCMTREE_STRUCTUREDMF 00014 00015 #include "DCMTree_Lib.h" 00016 #include "DCMTree_TagId.h" 00017 00018 #ifdef _MSC_VER 00019 #pragma warning (push) 00020 #pragma warning (disable : 4251) 00021 #endif 00022 00023 namespace DCMTree 00024 { 00048 class DCMTREE_EXPORT StructuredMF 00049 { 00050 public: 00051 00053 typedef std::vector<unsigned int> IndexVector; 00054 00056 static std::string privateCreator; /* = "MeVis StructuredMF data" */ 00057 00058 // Private group and element id constants used for storing the StructuredMF info 00059 enum { 00060 privateGroupId = 0x0041, 00061 00062 dimensionsOffset = 1, 00063 dimensionSequenceOffset = 2, 00064 frameIndexOffset = 3 00065 }; 00066 00067 00072 StructuredMF( Const_TreePtr tree ); 00073 00077 StructuredMF( TreePtr tree ); 00078 00082 StructuredMF( TreePtr sharedTagTree, const IndexVector &gridExtent ); 00083 StructuredMF( TreePtr sharedTagTree, unsigned int depth, 00084 unsigned int timePoints = 0, unsigned int u1Size = 0); 00085 00086 00088 Const_TreePtr tagTree() const; 00090 TreePtr tagTree(); 00091 00092 00094 00097 TagPtr sharedTag_rw( TagId tagId ); 00099 Const_TagPtr sharedTag( TagId tagId ) const; 00101 Const_TagPtr sharedTag( TagId tagId, const std::string& privateCreator, Vr privateVr=UN ) const; 00102 00104 TreePtr extractSharedTagTree() const; 00106 00108 void setSharedTags( TreePtr tree, bool handleFuncGroups = true ); 00109 00110 00112 00115 Const_TagPtr tagForGridPosition( TagId tagId, IndexVector gridPosition ) const; 00116 Const_TagPtr tagForGridPosition( TagId tagId, unsigned int z, unsigned int t = 0, unsigned int u1 = 0 ) const; 00117 00121 Const_TagPtr tagForGridPosition( TagId tagId, IndexVector gridPosition, const std::string& privateCreator, Vr privateVr=UN ) const; 00122 Const_TagPtr tagForGridPosition( TagId tagId, const std::string& privateCreator, Vr privateVr, unsigned int z, unsigned int t = 0, unsigned int u1 = 0 ) const; 00123 00126 int frameIndexForGridPosition( const IndexVector &gridPosition ) const; 00127 int frameIndexForGridPosition( unsigned int z, unsigned int t = 0, unsigned int u1 = 0 ) const; 00128 00130 typedef enum { 00131 ExtractSharedAndSpecific, 00132 ExtractSpecific, 00133 ExtractSpecificWithSharedParent 00134 } ExtractMode; 00135 00138 TreePtr extractTagTreeForGridPosition( IndexVector gridPosition, ExtractMode mode = ExtractSharedAndSpecific ) const; 00139 TreePtr extractTagTreeForGridPosition( unsigned int z, unsigned int t = 0, unsigned int u1 = 0, 00140 ExtractMode mode = ExtractSharedAndSpecific ) const; 00141 00145 void setTagForGridPosition( TagPtr tag, const IndexVector &gridPosition, const std::string& privateCreator = "", bool skipInvalidPrivateTags = true ); 00146 void setTagForGridPosition( TagPtr tag, unsigned int z, unsigned int t = 0, unsigned int u1 = 0, const std::string& privateCreator = "" ); 00147 00151 void setGridPositionSpecificTags( TreePtr tree, const IndexVector &gridPosition, bool skipInvalidPrivateTags = true ); 00152 void setGridPositionSpecificTags( TreePtr tree, unsigned int z, unsigned int t = 0, unsigned int u1 = 0 ); 00153 00156 void setFrameIndexForGridPosition( unsigned int frameIndex, const IndexVector &gridPosition ); 00157 void setFrameIndexForGridPosition( unsigned int frameIndex, unsigned int z, unsigned int t = 0, unsigned int u1 = 0 ); 00159 00160 00162 00163 00165 enum StatusCode { 00166 OK = 0, 00167 NO_PER_FRAME_TAGS, 00168 AMBIGUOUS_TAG, 00169 00170 INCONSISTENT_PER_FRAME_TAGS, 00171 00172 NUM_STATUS_CODES 00173 }; 00174 00179 void normalizeTagStructure( double tolerance = 0.0, bool compress = true ); 00181 00182 00184 00185 00192 00193 boost::uint32_t getGridDimension() const; 00194 00196 const IndexVector& getGridExtent() const; 00197 00199 unsigned int getNumberOfFrames() const; 00200 00202 bool frameExists( const IndexVector& position ) const; 00203 00206 void getEmptyFrames (std::vector<IndexVector> &positions) const; 00208 00209 00210 private: 00212 bool initPrivateTagIds (bool create); 00214 void clearPrivateTags(); 00216 bool isPrivateTagId (const TagId &tagId) const; 00218 TagInfo dimensionsTagInfo(); 00221 TagInfo dimensionGroupTagInfo(); 00223 TagInfo frameIndexTagInfo(); 00225 TagInfo defaultCreatorTagInfo(); 00228 void normalizeTagStructure( TreePtr dimTree, double tolerance, bool compress ); 00231 TreePtr gridPositionTagTree( IndexVector gridPosition ); 00233 Const_TreePtr gridPositionTagTree( IndexVector gridPosition ) const; 00235 void createDimensionSubtree( TagPtr parentSeq, int index); 00237 void setDimensionsTag(); 00238 00240 IndexVector indexVectorFromIndexes( unsigned int z, unsigned int t, unsigned int u1 ) const; 00241 00246 bool checkGridPosition( const IndexVector &gridPosition ) const; 00247 00248 00250 TreePtr _treePtr; 00252 Const_TreePtr _constTreePtr; 00254 IndexVector _gridExtent; 00255 00257 TagId _creatorId, _privateBaseId, _dimensionsId, _dimensionSequenceId, _frameIndexId; 00258 }; 00259 } 00260 00261 #ifdef _MSC_VER 00262 #pragma warning (pop) 00263 #endif 00264 00265 #endif