📄 dcitem.h
字号:
/** looks up the given sequence in the current dataset and returns the given item. * If either the sequence or the item do not exist, they are created. If necessary, * multiple empty items are inserted. Only the top-most level of the dataset/item * is examined (i.e. no deep-search is performed). * Applicable to the following VRs: SQ, (pixelSQ) * @param seqTag DICOM tag specifying the sequence attribute to be searched for or * to be create respectively * @param item variable in which the reference to the sequence item is stored * @param itemNum number of the item to be searched for (0..n-1, -1 for last, * -2 for append new) * @return EC_Normal upon success, an error otherwise. */ OFCondition findOrCreateSequenceItem(const DcmTag &seqTag, DcmItem *&item, const signed long itemNum = 0); /* --- findAndXXX functions: find an element and do something with it --- */ /** find element, remove it from the dataset and free the associated memory. * Applicable to all DICOM value representations (VR). * @param tagKey DICOM tag specifying the attribute to be searched for * @param allOccurrences flag indicating whether to delete all occurrences of the * attribute tag or the first one only (implies 'searchIntoSub' to be true) * @param searchIntoSub flag indicating whether to search into sequences or not * @return EC_Normal upon success, an error code otherwise. */ OFCondition findAndDeleteElement(const DcmTagKey &tagKey, const OFBool allOccurrences = OFFalse, const OFBool searchIntoSub = OFFalse); /** find element, and create a copy of it. * Applicable to all DICOM value representations (VR). * @param tagKey DICOM tag specifying the attribute to be searched for * @param newElement stores pointer to the new element copy (NULL in case of error). * This element is not inserted into the dataset/item and must, therefore, be * deleted by the caller. * @param searchIntoSub flag indicating whether to search into sequences or not * @return EC_Normal upon success, an error code otherwise. */ OFCondition findAndCopyElement(const DcmTagKey &tagKey, DcmElement *&newElement, const OFBool searchIntoSub = OFFalse); /* --- putAndInsert functions: put value and insert new element --- */ /** create a new element, put specified value to it and insert the element into the dataset/item. * Applicable to the following VRs: AE, AS, AT, CS, DA, DS, DT, FL, FD, IS, LO, LT, OB, OF, OW, * PN, SH, SL, SS, ST, TM, UI, UL, US, UT * @param tag DICOM tag specifying the attribute to be created * @param value value to be set for the new element (might be empty or NULL) * @param replaceOld flag indicating whether to replace an existing element or not * @return EC_Normal upon success, an error code otherwise. */ OFCondition putAndInsertString(const DcmTag &tag, const char *value, const OFBool replaceOld = OFTrue); /** create a new element, put specified value to it and insert the element into the dataset/item. * Applicable to the following VRs: AE, AS, CS, DA, DS, DT, IS, LO, LT, PN, SH, ST, TM, UI, UT * @param tag DICOM tag specifying the attribute to be created * @param value value to be set for the new element (might be empty) * @param replaceOld flag indicating whether to replace an existing element or not * @return EC_Normal upon success, an error code otherwise. */ OFCondition putAndInsertOFStringArray(const DcmTag &tag, const OFString &value, const OFBool replaceOld = OFTrue); /** create a new element, put specified value to it and insert the element into the dataset/item. * Applicable to the following VRs: OB, ox (polymorph OB/OW or pixel data) * @param tag DICOM tag specifying the attribute to be created * @param value value to be set for the new element (might be NULL) * @param count number of values (= bytes in this case) to be copied from 'value' * @param replaceOld flag indicating whether to replace an existing element or not * @return EC_Normal upon success, an error code otherwise. */ OFCondition putAndInsertUint8Array(const DcmTag &tag, const Uint8 *value, const unsigned long count, const OFBool replaceOld = OFTrue); /** create a new element, put specified value to it and insert the element into the dataset/item. * Applicable to the following VRs: US, xs (US or SS) * @param tag DICOM tag specifying the attribute to be created * @param value value to be set for the new element * @param pos index of the value to be set (0..vm-1) * @param replaceOld flag indicating whether to replace an existing element or not * @return EC_Normal upon success, an error code otherwise. */ OFCondition putAndInsertUint16(const DcmTag &tag, const Uint16 value, const unsigned long pos = 0, const OFBool replaceOld = OFTrue); /** create a new element, put specified value to it and insert the element into the dataset/item. * Applicable to the following VRs: AT, OW, US, ox (polymorph OB/OW or pixel data), xs (US or SS) * @param tag DICOM tag specifying the attribute to be created * @param value value to be set for the new element (might be NULL) * @param count number of values (not bytes!) to be copied from 'value' * @param replaceOld flag indicating whether to replace an existing element or not * @return EC_Normal upon success, an error code otherwise. */ OFCondition putAndInsertUint16Array(const DcmTag &tag, const Uint16 *value, const unsigned long count, const OFBool replaceOld = OFTrue); /** create a new element, put specified value to it and insert the element into the dataset/item. * Applicable to the following VRs: SS, xs (US or SS) * @param tag DICOM tag specifying the attribute to be created * @param value value to be set for the new element * @param pos index of the value to be set (0..vm-1) * @param replaceOld flag indicating whether to replace an existing element or not * @return EC_Normal upon success, an error code otherwise. */ OFCondition putAndInsertSint16(const DcmTag &tag, const Sint16 value, const unsigned long pos = 0, const OFBool replaceOld = OFTrue); /** create a new element, put specified value to it and insert the element into the dataset/item. * Applicable to the following VRs: SS, xs (US or SS) * @param tag DICOM tag specifying the attribute to be created * @param value value to be set for the new element * @param count number of values (not bytes!) to be copied from 'value' * @param replaceOld flag indicating whether to replace an existing element or not * @return EC_Normal upon success, an error code otherwise. */ OFCondition putAndInsertSint16Array(const DcmTag &tag, const Sint16 *value, const unsigned long count, const OFBool replaceOld = OFTrue); /** create a new element, put specified value to it and insert the element into the dataset/item. * Applicable to the following VRs: UL * @param tag DICOM tag specifying the attribute to be created * @param value value to be set for the new element * @param pos index of the value to be set (0..vm-1) * @param replaceOld flag indicating whether to replace an existing element or not * @return EC_Normal upon success, an error code otherwise. */ OFCondition putAndInsertUint32(const DcmTag &tag, const Uint32 value, const unsigned long pos = 0, const OFBool replaceOld = OFTrue); /** create a new element, put specified value to it and insert the element into the dataset/item. * Applicable to the following VRs: SL * @param tag DICOM tag specifying the attribute to be created * @param value value to be set for the new element * @param pos index of the value to be set (0..vm-1) * @param replaceOld flag indicating whether to replace an existing element or not * @return EC_Normal upon success, an error code otherwise. */ OFCondition putAndInsertSint32(const DcmTag &tag, const Sint32 value, const unsigned long pos = 0, const OFBool replaceOld = OFTrue); /** create a new element, put specified value to it and insert the element into the dataset/item. * Applicable to the following VRs: FL, OF * @param tag DICOM tag specifying the attribute to be created * @param value value to be set for the new element * @param pos index of the value to be set (0..vm-1) * @param replaceOld flag indicating whether to replace an existing element or not * @return EC_Normal upon success, an error code otherwise. */ OFCondition putAndInsertFloat32(const DcmTag &tag, const Float32 value, const unsigned long pos = 0, const OFBool replaceOld = OFTrue); /** create a new element, put specified value to it and insert the element into the dataset/item. * Applicable to the following VRs: FD * @param tag DICOM tag specifying the attribute to be created * @param value value to be set for the new element * @param pos index of the value to be set (0..vm-1) * @param replaceOld flag indicating whether to replace an existing element or not * @return EC_Normal upon success, an error code otherwise. */ OFCondition putAndInsertFloat64(const DcmTag &tag, const Float64 value, const unsigned long pos = 0, const OFBool replaceOld = OFTrue); /** create a new element (with no value) and insert it into the dataset/item. * Applicable to the following VRs: AE, AS, AT, CS, DA, DS, DT, FL, FD, IS, LO, OB, OF, OW, LT, * PN, SH, SQ, ST, TM, UI, UT * @param tag DICOM tag specifying the attribute to be created * @param replaceOld flag indicating whether to replace an existing element or not * @return EC_Normal upon success, an error code otherwise. */ OFCondition insertEmptyElement(const DcmTag &tag, const OFBool replaceOld = OFTrue); protected: /// the list of elements maintained by this object DcmList *elementList; /** flag used during suspended I/O. Indicates whether the last element * was completely or only partially read/written during the last call * to read/write. */ OFBool lastElementComplete; /** used during reading. Contains the position in the stream where * the item started (needed for calculating the remaining number of * bytes available for a fixed-length item). */ Uint32 fStartPosition; /** This function reads tag and length information from inStream and * returns this information to the caller. When reading information, * the transfer syntax which was passed is accounted for. If the * transfer syntax shows an explicit value representation, the data * type of this object is also read from the stream. In general, this * function follows the rules which are specified in the DICOM standard * (see DICOM standard (year 2000) part 5, section 7) (or the corresponding * section in a later version of the standard) concerning the encoding * of a dataset. * @param inStream The stream which contains the information. * @param xfer The transfer syntax which was used to encode the * information in inStream. * @param tag Contains in the end the tag that was read. * @param length Contains in the end the length value that was read. * @param bytesRead Contains in the end the amount of bytes which were * read from inStream. * @return status, EC_Normal if successful, an error code otherwise */ OFCondition readTagAndLength(DcmInputStream &inStream, // inout const E_TransferSyntax xfer, // in DcmTag &tag, // out Uint32 &length, // out Uint32 &bytesRead); // out /** This function creates a new DcmElement object on the basis of the newTag * and newLength information which was passed, inserts this new element into * elementList, reads the actual data value which belongs to this element * (attribute) from the inStream and also assigns this information to the * object which was created at the beginning. * @param inStream The stream which contains the information. * @param newTag The tag of the element of which the information is * being read. * @param newLength The length of the information which is being read. * @param xfer The transfer syntax which was used to encode the * information in inStream. * @param glenc Encoding type for group length. Specifies what will * be done with group length tags. * @param maxReadLength Maximum read length for reading the attribute value. * @return status, EC_Normal if successful, an error code otherwise */ OFCondition readSubElement(DcmInputStream &inStream, // inout DcmTag &newTag, // inout const Uint32 newLength, // in const E_TransferSyntax xfer, // in const E_GrpLenEncoding glenc, // in const Uint32 maxReadLength = DCM_MaxReadLength); /** This function reads the first 6 bytes from the input stream and determines * the transfer syntax which was used to code the information in the stream. * The decision is based on two questions: a) Did we encounter a valid tag? * and b) Do the last 2 bytes which were read from the stream represent a valid * VR? In certain special cases, where the transfer syntax cannot be determined * without doubt, we want to guess the most likely transfer syntax (see code). * @param inStream The stream which contains the coded information. * @return The transfer syntax which was determined. */ E_TransferSyntax checkTransferSyntax(DcmInputStream &inStream); private: /// private unimplemented copy assignment operator DcmItem &operator=(const DcmItem &); OFCondition searchSubFromHere(const DcmTagKey &tag, // in DcmStack &resultStack, // inout OFBool searchIntoSub ); // in OFBool foundVR(char *atposition); /// cache for private creator tags and names DcmPrivateTagCache privateCreatorCache;};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -