bool DCM_COMMAND_CLASS::updateWid(BASE_WAREHOUSE_ITEM_DATA_CLASS *wid_ptr) // DESCRIPTION : Update this command with the contents of the command given. // PRECONDITIONS : // POSTCONDITIONS : // EXCEPTIONS : // NOTES : //<<=========================================================================== { bool result = false; // // ensure update WID is a command // if (wid_ptr->getWidType() == widTypeM) { DCM_COMMAND_CLASS *updateCommand_ptr = static_cast<DCM_COMMAND_CLASS*>(wid_ptr); // // we can perform the update by merging the update command into this // merge(updateCommand_ptr); // // sort attributes after update // SortAttributes(); // // result is OK // result = true; } return result; }
bool DCM_COMMAND_CLASS::encode(DATA_TF_CLASS& dataTransfer) // DESCRIPTION : encode DICOM command to dataTransfer stream. // PRECONDITIONS : // POSTCONDITIONS : // EXCEPTIONS : // NOTES : //<<=========================================================================== { // check if we need to add the group length attributes if (defineGroupLengthsM) { // add group length(s) - attributes sorted here addGroupLengths(); // update group length(s) setGroupLengths(dataTransfer.getTsCode()); } else { // sort the DICOM command attributes into ascending order SortAttributes(); } // set the transfer VR - used by the logger if (dataTransfer.isExplicitVR()) { // set to explicit setTransferVR(TRANSFER_ATTR_VR_EXPLICIT); } else { // set to implicit setTransferVR(TRANSFER_ATTR_VR_IMPLICIT); } // encode the command attributes return DCM_ATTRIBUTE_GROUP_CLASS::encode(dataTransfer); }
void DCM_ATTRIBUTE_GROUP_CLASS::addGroupLengths() // DESCRIPTION : Method to add the Group Length attributes to the // DICOM object. They are initially filled in with a zero // length. The actual lengths need to be computed when // when the sequence lengths are known. // PRECONDITIONS : // POSTCONDITIONS : // EXCEPTIONS : // NOTES : //<<=========================================================================== { UINT32 thisGroup = 0xFFFF; // sort attributes before adding group lengths SortAttributes(); // run through all Attributes - they may not have been sorted yet for (int i = 0; i < GetNrAttributes(); i++) { DCM_ATTRIBUTE_CLASS *attribute_ptr = GetAttribute(i); if (attribute_ptr->GetGroup() != thisGroup) { // we are in a new group and must check to see if a group length should be added if (attribute_ptr->GetElement() != LENGTH_ELEMENT) { // set the Group Length value UINT32 length = 0; DCM_VALUE_UL_CLASS *value_ptr = new DCM_VALUE_UL_CLASS(); value_ptr->Set(length); // allocate the Group Length attribute DCM_ATTRIBUTE_CLASS *groupLengthAttribute_ptr = new DCM_ATTRIBUTE_CLASS(attribute_ptr->GetGroup(), LENGTH_ELEMENT); groupLengthAttribute_ptr->SetVR(ATTR_VR_UL); // make Group Length mandatory to ensure it is encoded groupLengthAttribute_ptr->SetType(ATTR_TYPE_1); // set EnsureEvenAttributeValueLength groupLengthAttribute_ptr->setEnsureEvenAttributeValueLength(ensureEvenAttributeValueLengthM); // add Value to Attribute groupLengthAttribute_ptr->AddValue(value_ptr); // add Attribute to Object addAttribute(groupLengthAttribute_ptr); } else { // check if a value has been defined if (attribute_ptr->GetNrValues() == 0) { // set the Group Length value UINT32 length = 0; DCM_VALUE_UL_CLASS *value_ptr = new DCM_VALUE_UL_CLASS; value_ptr->Set(length); // make Group Length mandatory to ensure it is encoded attribute_ptr->SetType(ATTR_TYPE_1); // add Value to Attribute attribute_ptr->AddValue(value_ptr); } } thisGroup = attribute_ptr->GetGroup(); } // recurse through the sequence items if (attribute_ptr->GetVR() == ATTR_VR_SQ) { // only interested if one SQ value available if (attribute_ptr->GetNrValues() == 1) { // get SQ value DCM_VALUE_SQ_CLASS *sqValue_ptr = static_cast<DCM_VALUE_SQ_CLASS*>(attribute_ptr->GetValue(0)); // set the group lengths sqValue_ptr->addGroupLengths(); } } } // having added the Group Length - we must sort the object again SortAttributes(); }