DCM_ATTRIBUTE_CLASS* DCM_ATTRIBUTE_GROUP_CLASS::setAttribute(UINT32 tag, ATTR_VR_ENUM vr) // DESCRIPTION : Ensure that the attribute is present in the group. // PRECONDITIONS : // POSTCONDITIONS : // EXCEPTIONS : // NOTES : Return NULL if the given VR does not match the attribute VR. //<<=========================================================================== { // get the attribute with the given tag DCM_ATTRIBUTE_CLASS *attribute_ptr = GetAttributeByTag(tag); if (attribute_ptr == NULL) { // if not present // - instantiate a new attribute attribute_ptr = new DCM_ATTRIBUTE_CLASS(tag, vr); attribute_ptr->SetType(ATTR_TYPE_1); // now add the attribute to the DICOM object addAttribute(attribute_ptr); } // check that the attribute VR matches that given if (attribute_ptr->GetVR() != vr) { attribute_ptr = NULL; } // return attribute return attribute_ptr; }
void DCM_ATTRIBUTE_GROUP_CLASS::updatePixelData() // DESCRIPTION : Check for Pixel Data and update the lengths based on // : the image being a color. // PRECONDITIONS : // POSTCONDITIONS : // EXCEPTIONS : // NOTES : //<<=========================================================================== { DCM_ATTRIBUTE_CLASS *bitsAllocated_ptr = GetAttributeByTag(TAG_BITS_ALLOCATED); DCM_ATTRIBUTE_CLASS *samplesPerPixel_ptr = GetAttributeByTag(TAG_SAMPLES_PER_PIXEL); DCM_ATTRIBUTE_CLASS *planarConfiguration_ptr = GetAttributeByTag(TAG_PLANAR_CONFIGURATION); DCM_ATTRIBUTE_CLASS *pixelData_ptr = GetAttributeByTag(TAG_PIXEL_DATA); UINT16 bitsAllocated = 8; UINT16 samplesPerPixel = 1; UINT16 planarConfiguration = FRAME_INTERLEAVE; BASE_VALUE_CLASS *value_ptr; // try and get the bits allocated if ((bitsAllocated_ptr) && (bitsAllocated_ptr->GetVR() == ATTR_VR_US) && (bitsAllocated_ptr->GetNrValues())) { value_ptr = bitsAllocated_ptr->GetValue(0); if (value_ptr) { value_ptr->Get(bitsAllocated); } } // try and get the planar configuration if ((planarConfiguration_ptr) && (planarConfiguration_ptr->GetVR() == ATTR_VR_US) && (planarConfiguration_ptr->GetNrValues())) { value_ptr = planarConfiguration_ptr->GetValue(0); if (value_ptr) { value_ptr->Get(planarConfiguration); } } // try and get the samples per pixel if ((samplesPerPixel_ptr) && (samplesPerPixel_ptr->GetVR() == ATTR_VR_US) && (samplesPerPixel_ptr->GetNrValues())) { value_ptr = samplesPerPixel_ptr->GetValue(0); if (value_ptr) { value_ptr->Get(samplesPerPixel); } } if ((pixelData_ptr) && ((pixelData_ptr->GetVR() == ATTR_VR_OB) || (pixelData_ptr->GetVR() == ATTR_VR_OF) || (pixelData_ptr->GetVR() == ATTR_VR_OW)) && (pixelData_ptr->GetNrValues())) { OTHER_VALUE_CLASS *otherValue_ptr = static_cast<OTHER_VALUE_CLASS*>(pixelData_ptr->GetValue(0)); if (otherValue_ptr == NULL) return; // should not happen // update the other data for the Bits Allocated, Samples Per Pixel and Planar Configuration otherValue_ptr->SetBitsAllocated(bitsAllocated); otherValue_ptr->SetSamplesPerPixel(samplesPerPixel); otherValue_ptr->SetPlanarConfiguration(planarConfiguration); } }