Logo Search packages:      
Sourcecode: dcmtk version File versions

OFBool DVPSStoredPrint::printSCPCreate ( DVConfiguration cfg,
const char *  cfgname,
DcmDataset rqDataset,
T_DIMSE_Message &  rsp,
DcmDataset *&  rspDataset,
OFBool  presentationLUTnegotiated,
DVPSPresentationLUT_PList globalPresentationLUTList,
const char *  filmSessionUID,
DcmUniqueIdentifier study,
DcmUniqueIdentifier psSeries,
DcmUniqueIdentifier imgSeries 
)

performs a Print SCP Basic Film Box N-CREATE operation on a newly created instance of this class. The results of the operation are stored in the objects passed as rsp, rspDataset and globalPresentationLUTList.

Parameters:
cfg config file facility
cfgname symbolic printer name in config file
rqDataset N-CREATE request dataset, may be NULL
rsp N-CREATE response message
rspDataset N-CREATE response dataset passed back in this parameter
presentationLUTnegotiated OFTrue if support for the Presentation LUT SOP class has been negotiated at association negotiation and is supported on Basic Film Box level
globalPresentationLUTList list of presentation LUTs managed by the Print SCP. If a SCP default Presentation LUT needs to be created as the result of the N-CREATE operation, it is stored in this list.
filmSessionUID SOP instance UID of the Basic Film Session object
study study UID to be used when storing Stored Print or image objects
psSeries series UID to be used when storing Stored Print objects
imgSeries series UID to be used when storing image objects (Hardcopy Grayscale)
Returns:
OFTrue if N-CREATE was successful, OFFalse otherwise.

Definition at line 2029 of file dvpssp.cc.

References addPresentationLUTReference(), borderDensity, OFString::c_str(), OFString::clear(), DcmStack::clear(), configurationInformation, currentNumCols, currentNumRows, currentValuesValid, emptyImageDensity, filmBoxInstanceUID, filmOrientation, filmSizeID, DVPSPresentationLUT_PList::findPresentationLUT(), DVPSPresentationLUT::getAlignment(), getFilmOrientation(), DcmElement::getLength(), DcmByteString::getLength(), DVConfiguration::getNetworkAETitle(), DcmByteString::getOFString(), DcmShortText::getOFString(), DcmCodeString::getOFString(), DcmShortText::getOFStringArray(), DVConfiguration::getTargetPrinterBorderDensity(), DVConfiguration::getTargetPrinterConfigurationSetting(), DVConfiguration::getTargetPrinterEmptyImageDensity(), DVConfiguration::getTargetPrinterFilmSizeID(), DVConfiguration::getTargetPrinterMagnificationType(), DVConfiguration::getTargetPrinterMaxDensity(), DVConfiguration::getTargetPrinterMinDensity(), DVConfiguration::getTargetPrinterNumberOfBorderDensities(), DVConfiguration::getTargetPrinterNumberOfConfigurationSettings(), DVConfiguration::getTargetPrinterNumberOfEmptyImageDensities(), DVConfiguration::getTargetPrinterNumberOfFilmSizeIDs(), DVConfiguration::getTargetPrinterNumberOfMagnificationTypes(), DVConfiguration::getTargetPrinterNumberOfMaxDensities(), DVConfiguration::getTargetPrinterNumberOfMinDensities(), DVConfiguration::getTargetPrinterNumberOfPortraitDisplayFormats(), DVConfiguration::getTargetPrinterNumberOfPrinterResolutionIDs(), DVConfiguration::getTargetPrinterNumberOfSmoothingTypes(), DVConfiguration::getTargetPrinterPortraitDisplayFormatColumns(), DVConfiguration::getTargetPrinterPortraitDisplayFormatRows(), DVConfiguration::getTargetPrinterResolutionID(), DVConfiguration::getTargetPrinterSmoothingType(), DVConfiguration::getTargetPrinterSupportsTrim(), illumination, imageBoxContentList, imageDisplayFormat, imageSeriesInstanceUID, DVPSPresentationLUT_PList::insert(), DcmItem::insert(), OFConsole::lockCerr(), logstream, magnificationType, maxDensity, minDensity, DcmItem::nextObject(), DCMTypes::PF_shortenLongTagValues, presentationLUTInstanceUID, DVPSImageBoxContent_PList::printSCPCreate(), DcmUniqueIdentifier::putString(), DcmByteString::putString(), DcmUnsignedShort::putUint16(), referencedPresentationLUTAlignment, referencedPresentationLUTInstanceUID, reflectedAmbientLight, requestedResolutionID, DcmItem::search(), seriesInstanceUID, setMaxDensity(), setMinDensity(), DVPSPresentationLUT::setSOPInstanceUID(), DVPSPresentationLUT::setType(), smoothingType, studyInstanceUID, DcmStack::top(), trim, OFConsole::unlockCerr(), updateCache(), verboseMode, and DVPSImageBoxContent_PList::writeReferencedImageBoxSQ().

Referenced by DVPSPrintSCP::filmBoxNCreate().

{
  studyInstanceUID = study;
  seriesInstanceUID = psSeries;
  imageSeriesInstanceUID = imgSeries;

  OFBool result = OFTrue;
  DcmStack stack;
  filmBoxInstanceUID = rsp.msg.NCreateRSP.AffectedSOPInstanceUID;

  // filmOrientation
  if (result)
  {
    READ_FROM_PDATASET(DcmCodeString, filmOrientation)
    if (filmOrientation.getLength() == 0) filmOrientation.putString(DEFAULT_filmOrientation);
    else
    {
      OFString aString;
      filmOrientation.getOFString(aString, 0, OFTrue);
      if ((aString != "PORTRAIT")&&(aString != "LANDSCAPE"))
      {
        if (verboseMode)
        {
          logstream->lockCerr() << "cannot create Basic Film Box: illegal film orientation: '" << aString.c_str() << "'" << endl;
          logstream->unlockCerr();
        }
        rsp.msg.NCreateRSP.DimseStatus = STATUS_N_InvalidAttributeValue;
        result = OFFalse;
      }
    }
  }
    
  // imageDisplayFormat
  if (result)
  {
    READ_FROM_PDATASET(DcmShortText, imageDisplayFormat)
    if (imageDisplayFormat.getLength() == 0) 
    {
        if (verboseMode)
        {
          logstream->lockCerr() << "cannot create Basic Film Box: image display format missing or empty" << endl;
          logstream->unlockCerr();
        }
        rsp.msg.NCreateRSP.DimseStatus = STATUS_N_MissingAttribute; 
        result = OFFalse;
    } else {
      currentValuesValid = OFFalse;
      updateCache(); // evaluates image display format and computes number of columns and rows
      if (currentValuesValid)
      {
        // now we check whether this is a supported layout as per the config file
        Uint32 numPortraitDisplayFormats = cfg.getTargetPrinterNumberOfPortraitDisplayFormats(cfgname);
        if (numPortraitDisplayFormats > 0)
        {
          OFBool found = OFFalse;
          DVPSFilmOrientation orientation = getFilmOrientation();
          Uint32 col=0;
          Uint32 row=0;
          for (Uint32 i=0; i<numPortraitDisplayFormats; i++)
          {
             col=cfg.getTargetPrinterPortraitDisplayFormatColumns(cfgname,i);
             row=cfg.getTargetPrinterPortraitDisplayFormatRows(cfgname,i);
             if (orientation == DVPSF_landscape)
             {
               if ((col==currentNumRows)&&(row==currentNumCols))
               {
                 found = OFTrue;
                 break;
               }        
             } else {
               if ((col==currentNumCols)&&(row==currentNumRows))
               {
                 found = OFTrue;
                 break;
               }        
             }        
          }
          if (! found)
          {
            OFString aString;
            imageDisplayFormat.getOFStringArray(aString);
            if (verboseMode)
            {
              logstream->lockCerr() << "cannot create Basic Film Box: unsupported image display format: '" << aString.c_str() << "'" << endl;
              logstream->unlockCerr();
            }
            rsp.msg.NCreateRSP.DimseStatus = STATUS_N_InvalidAttributeValue;
            result = OFFalse;
          }
        }
      } else {
        OFString aString;
        imageDisplayFormat.getOFStringArray(aString);
        if (verboseMode)
        {
          logstream->lockCerr() << "cannot create Basic Film Box: illegal image display format: '" << aString.c_str() << "'" << endl;
          logstream->unlockCerr();
        }
        rsp.msg.NCreateRSP.DimseStatus = STATUS_N_InvalidAttributeValue;
        result = OFFalse;
      }
    }
  }

  // filmSizeID
  if (result)
  {
    Uint32 numFilmSizes = cfg.getTargetPrinterNumberOfFilmSizeIDs(cfgname);     
    READ_FROM_PDATASET(DcmCodeString, filmSizeID)
    if (filmSizeID.getLength() == 0) 
    {
      if (numFilmSizes > 0)
      {
        OFString aString;
        cfg.getTargetPrinterFilmSizeID(cfgname, 0, aString);            
        filmSizeID.putString(aString.c_str());
      } else {
        filmSizeID.putString(DEFAULT_filmSizeID);
      }
    } else {
      // check whether we can accept the proposed medium type
      OFString theSizeID;
      OFString aString;
      OFBool found = OFFalse;
      filmSizeID.getOFString(theSizeID, 0, OFTrue);
      for (Uint32 i=0; i<numFilmSizes; i++)
      {
        cfg.getTargetPrinterFilmSizeID(cfgname, i, aString);
        if (theSizeID == aString) 
        {
          found = OFTrue;
          break;
        }       
      }
      if (! found)
      {
        if (verboseMode)
        {
          logstream->lockCerr() << "cannot create Basic Film Box: illegal film size ID: '" << theSizeID.c_str() << "'" << endl;
          logstream->unlockCerr();
        }
        rsp.msg.NCreateRSP.DimseStatus = STATUS_N_InvalidAttributeValue;
        result = OFFalse;
      }
    }
  }

  // magnificationType
  if (result)
  {
    Uint32 numMagnifications = cfg.getTargetPrinterNumberOfMagnificationTypes(cfgname);         
    READ_FROM_PDATASET(DcmCodeString, magnificationType)
    if (magnificationType.getLength() == 0) 
    {
      if (numMagnifications > 0)
      {
        OFString aString;
        cfg.getTargetPrinterMagnificationType(cfgname, 0, aString);             
        magnificationType.putString(aString.c_str());
      } else {
        magnificationType.putString(DEFAULT_magnificationType);
      }
    } else {
      // check whether we can accept the proposed medium type
      OFString theMagnification;
      OFString aString;
      OFBool found = OFFalse;
      magnificationType.getOFString(theMagnification, 0, OFTrue);
      for (Uint32 i=0; i<numMagnifications; i++)
      {
        cfg.getTargetPrinterMagnificationType(cfgname, i, aString);
        if (theMagnification == aString) 
        {
          found = OFTrue;
          break;
        }       
      }
      if (! found)
      {
        if (verboseMode)
        {
          logstream->lockCerr() << "cannot create Basic Film Box: illegal magnification type: '" << theMagnification.c_str() << "'" << endl;
          logstream->unlockCerr();
        }
        rsp.msg.NCreateRSP.DimseStatus = STATUS_N_InvalidAttributeValue;
        result = OFFalse;
      }
    }
  }

  // smoothingType
  if (result)
  {
    Uint32 numSmoothings = cfg.getTargetPrinterNumberOfSmoothingTypes(cfgname);         
    READ_FROM_PDATASET(DcmCodeString, smoothingType)
    if (smoothingType.getLength() == 0) 
    {
      if (numSmoothings > 0)
      {
        OFString aString;
        cfg.getTargetPrinterSmoothingType(cfgname, 0, aString);         
        smoothingType.putString(aString.c_str());
      }
    } else {
      // check whether we can accept the proposed smoothing type
      OFString theSmoothing;
      OFString aString;
      OFBool found = OFFalse;
      smoothingType.getOFString(theSmoothing, 0, OFTrue);
      for (Uint32 i=0; i<numSmoothings; i++)
      {
        cfg.getTargetPrinterSmoothingType(cfgname, i, aString);
        if (theSmoothing == aString) 
        {
          found = OFTrue;
          break;
        }       
      }
      if (numSmoothings == 0)
      {
        if (verboseMode)
        {
          logstream->lockCerr() << "cannot create Basic Film Box: smoothing type requested but not supported." << endl;
          logstream->unlockCerr();
        }
        rsp.msg.NCreateRSP.DimseStatus = STATUS_N_NoSuchAttribute;
        result = OFFalse;
      } 
      else if (! found)
      {
        if (verboseMode)
        {
          logstream->lockCerr() << "cannot create Basic Film Box: illegal smoothing type: '" << theSmoothing.c_str() << "'" << endl;
          logstream->unlockCerr();
        }
        rsp.msg.NCreateRSP.DimseStatus = STATUS_N_InvalidAttributeValue;
        result = OFFalse;
      }
    }
  }


  // borderDensity
  if (result)
  {
    Uint32 numBorderDensities = cfg.getTargetPrinterNumberOfBorderDensities(cfgname);   
    READ_FROM_PDATASET(DcmCodeString, borderDensity)
    if (borderDensity.getLength() == 0) 
    {
      if (numBorderDensities > 0)
      {
        OFString aString;
        cfg.getTargetPrinterBorderDensity(cfgname, 0, aString);         
        borderDensity.putString(aString.c_str());
      }
    } else {
      // check whether we can accept the proposed border density
      if (numBorderDensities == 0) // we don't support border density
      {
        if (verboseMode)
        {
          logstream->lockCerr() << "cannot create Basic Film Box: border density requested but not supported." << endl;
          logstream->unlockCerr();
        }
        rsp.msg.NCreateRSP.DimseStatus = STATUS_N_NoSuchAttribute;        
        result = OFFalse;
      } else {
        OFString theBorderDensity;
        OFString aString;
        OFBool found = OFFalse;
        OFBool supportsNumericDensity = OFFalse;
        unsigned long l;
        borderDensity.getOFString(theBorderDensity, 0, OFTrue);
        for (Uint32 i=0; i<numBorderDensities; i++)
        {
          cfg.getTargetPrinterBorderDensity(cfgname, i, aString);
          if (theBorderDensity == aString) 
          {
            found = OFTrue;
            break;
          } else {
            if (1 == sscanf(aString.c_str(), "%lu", &l)) supportsNumericDensity = OFTrue;
          }
        }
        if ((! found) && supportsNumericDensity)
        {
          // the density was not found in the list; check whether it is numerical
          if (1 == sscanf(theBorderDensity.c_str(), "%lu", &l)) found = OFTrue;
        }
          
        if (! found)
        {
          if (verboseMode)
          {
            logstream->lockCerr() << "cannot create Basic Film Box: illegal border density: '" << theBorderDensity.c_str() << "'" << endl;
            logstream->unlockCerr();
          }
          rsp.msg.NCreateRSP.DimseStatus = STATUS_N_InvalidAttributeValue;
          result = OFFalse;
        }        
      }
    }
  }

  // emptyImageDensity
  if (result)
  {
    Uint32 numEmptyImageDensities = cfg.getTargetPrinterNumberOfEmptyImageDensities(cfgname);   
    READ_FROM_PDATASET(DcmCodeString, emptyImageDensity)
    if (emptyImageDensity.getLength() == 0) 
    {
      if (numEmptyImageDensities > 0)
      {
        OFString aString;
        cfg.getTargetPrinterEmptyImageDensity(cfgname, 0, aString);         
        emptyImageDensity.putString(aString.c_str());
      }
    } else {
      // check whether we can accept the proposed empty image density
      if (numEmptyImageDensities == 0) // we don't support empty image density
      {
        if (verboseMode)
        {
          logstream->lockCerr() << "cannot create Basic Film Box: empty image density requested but not supported." << endl;
          logstream->unlockCerr();
        }
        rsp.msg.NCreateRSP.DimseStatus = STATUS_N_NoSuchAttribute;        
        result = OFFalse;
      } else {
        OFString theEIDensity;
        OFString aString;
        OFBool found = OFFalse;
        OFBool supportsNumericDensity = OFFalse;
        unsigned long l;
        emptyImageDensity.getOFString(theEIDensity, 0, OFTrue);
        for (Uint32 i=0; i<numEmptyImageDensities; i++)
        {
          cfg.getTargetPrinterEmptyImageDensity(cfgname, i, aString);
          if (theEIDensity == aString) 
          {
            found = OFTrue;
            break;
          } else {
            if (1 == sscanf(aString.c_str(), "%lu", &l)) supportsNumericDensity = OFTrue;
          }
        }
        if ((! found) && supportsNumericDensity)
        {
          // the density was not found in the list; check whether it is numerical
          if (1 == sscanf(theEIDensity.c_str(), "%lu", &l)) found = OFTrue;
        }
          
        if (! found)
        {
          if (verboseMode)
          {
            logstream->lockCerr() << "cannot create Basic Film Box: illegal empty image density: '" << theEIDensity.c_str() << "'" << endl;
            logstream->unlockCerr();
          }
          rsp.msg.NCreateRSP.DimseStatus = STATUS_N_InvalidAttributeValue;
          result = OFFalse;
        }        
      }
    }
  }

  // maxDensity
  if (result)
  {
    Uint32 numMaxDensities = cfg.getTargetPrinterNumberOfMaxDensities(cfgname);   
    READ_FROM_PDATASET(DcmUnsignedShort, maxDensity)
    if (maxDensity.getLength() == 0) 
    {
      if (numMaxDensities > 0)
      {
        OFString aString;
        cfg.getTargetPrinterMaxDensity(cfgname, 0, aString);         
        if (EC_Normal != setMaxDensity(aString.c_str())) maxDensity.putUint16(DEFAULT_maxDensity, 0);
      }
    } // we don't check a max density set by the user (for now)
  }

  // minDensity
  if (result)
  {
    Uint32 numMinDensities = cfg.getTargetPrinterNumberOfMinDensities(cfgname);   
    READ_FROM_PDATASET(DcmUnsignedShort, minDensity)
    if (minDensity.getLength() == 0) 
    {
      if (numMinDensities > 0)
      {
        OFString aString;
        cfg.getTargetPrinterMinDensity(cfgname, 0, aString);         
        if (EC_Normal != setMinDensity(aString.c_str())) minDensity.putUint16(DEFAULT_minDensity, 0);
      }
    } else {
      if (numMinDensities == 0) // we don't support min density
      {
        if (verboseMode)
        {
          logstream->lockCerr() << "cannot create Basic Film Box: min density requested but not supported." << endl;
          logstream->unlockCerr();
        }
        rsp.msg.NCreateRSP.DimseStatus = STATUS_N_NoSuchAttribute;        
        result = OFFalse;
      }
      // we don't check a min density set by the user (for now)
    }
  }

  // trim
  if (result)
  {
    READ_FROM_PDATASET(DcmCodeString, trim)
    if (trim.getLength() == 0) 
    {
      if (cfg.getTargetPrinterSupportsTrim(cfgname)) trim.putString(DEFAULT_trim);
    }
    else
    {
      if (cfg.getTargetPrinterSupportsTrim(cfgname))
      {
        OFString aString;
        trim.getOFString(aString, 0, OFTrue);
        if ((aString != "YES")&&(aString != "NO"))
        {
          if (verboseMode)
          {
            logstream->lockCerr() << "cannot create Basic Film Box: illegal trim: '" << aString.c_str() << "'" << endl;
            logstream->unlockCerr();
          }
          rsp.msg.NCreateRSP.DimseStatus = STATUS_N_InvalidAttributeValue;
          result = OFFalse;
        }
      } else {
        if (verboseMode)
        {
          logstream->lockCerr() << "cannot create Basic Film Box: trim requested but not supported." << endl;
          logstream->unlockCerr();
        }
        rsp.msg.NCreateRSP.DimseStatus = STATUS_N_NoSuchAttribute;        
        result = OFFalse;
      }
    }
  }

  // configurationInformation
  if (result)
  {
    READ_FROM_PDATASET(DcmShortText, configurationInformation)
    if (configurationInformation.getLength() > 0) 
    {
      // check whether we can accept the proposed configuration information
      Uint32 numConfigurationInformation = cfg.getTargetPrinterNumberOfConfigurationSettings(cfgname);   
      if (numConfigurationInformation == 0) // we don't support configuration information
      {
        if (verboseMode)
        {
          logstream->lockCerr() << "cannot create Basic Film Box: configuration information requested but not supported." << endl;
          logstream->unlockCerr();
        }
        rsp.msg.NCreateRSP.DimseStatus = STATUS_N_NoSuchAttribute;        
        result = OFFalse;
      } else {
        OFString theConfiguration;
        OFBool found = OFFalse;
        configurationInformation.getOFString(theConfiguration, 0, OFTrue);
        for (Uint32 i=0; i<numConfigurationInformation; i++)
        {
          if (theConfiguration == cfg.getTargetPrinterConfigurationSetting(cfgname, i)) 
          {
            found = OFTrue;
            break;
          }
        }          
        if (! found)
        {
          if (verboseMode)
          {
            logstream->lockCerr() << "cannot create Basic Film Box: illegal configuration information: '" << theConfiguration.c_str() << "'" << endl;
            logstream->unlockCerr();
          }
          rsp.msg.NCreateRSP.DimseStatus = STATUS_N_InvalidAttributeValue;
          result = OFFalse;
        }        
      }
    }
  }

  // requestedResolutionID
  if (result)
  {
    Uint32 numResolutionIDs = cfg.getTargetPrinterNumberOfPrinterResolutionIDs(cfgname);   
    READ_FROM_PDATASET(DcmCodeString, requestedResolutionID)
    if (requestedResolutionID.getLength() == 0) 
    {
      if (numResolutionIDs > 0)
      {
        OFString aString;
        cfg.getTargetPrinterResolutionID(cfgname, 0, aString);         
        requestedResolutionID.putString(aString.c_str());
      }
    } else {
      // check whether we can accept the requested resolution ID
      if (numResolutionIDs == 0) // we don't support requested resolution ID
      {
        if (verboseMode)
        {
          logstream->lockCerr() << "cannot create Basic Film Box: requested resolution ID present but not supported." << endl;
          logstream->unlockCerr();
        }
        rsp.msg.NCreateRSP.DimseStatus = STATUS_N_NoSuchAttribute;        
        result = OFFalse;
      } else {
        OFString theResolutionID;
        OFString aString;
        OFBool found = OFFalse;
        requestedResolutionID.getOFString(theResolutionID, 0, OFTrue);
        for (Uint32 i=0; i<numResolutionIDs; i++)
        {
          cfg.getTargetPrinterResolutionID(cfgname, i, aString);
          if (theResolutionID == aString) 
          {
            found = OFTrue;
            break;
          }
        }          
        if (! found)
        {
          if (verboseMode)
          {
            logstream->lockCerr() << "cannot create Basic Film Box: illegal requested resolution ID: '" << theResolutionID.c_str() << "'" << endl;
            logstream->unlockCerr();
          }
          rsp.msg.NCreateRSP.DimseStatus = STATUS_N_InvalidAttributeValue;
          result = OFFalse;
        }        
      }
    }
  }

  if (presentationLUTnegotiated)
  {

    // illumination
    if (result)
    {
      READ_FROM_PDATASET(DcmUnsignedShort, illumination)
      if (illumination.getLength() == 0) illumination.putUint16(DEFAULT_illumination, 0);
      // we don't check illumination set by the user (for now)
    }

    // reflectedAmbientLight
    if (result)
    {
      READ_FROM_PDATASET(DcmUnsignedShort, reflectedAmbientLight)
      if (reflectedAmbientLight.getLength() == 0) illumination.putUint16(DEFAULT_reflectedAmbientLight, 0);
      // we don't check reflected ambient light set by the user (for now)
    }

    // referenced presentation LUT sequence
    if (result)
    {
      stack.clear();

      if (rqDataset && (EC_Normal == rqDataset->search(DCM_ReferencedPresentationLUTSequence, stack, ESM_fromHere, OFFalse)))
      {
        DcmSequenceOfItems *seq=(DcmSequenceOfItems *)stack.top();
        if (seq->card() ==1)
        {
           OFString aString;
           DcmItem *item = seq->getItem(0);
           stack.clear();
           READ_FROM_DATASET2(DcmUniqueIdentifier, referencedPresentationLUTInstanceUID)           
           if (referencedPresentationLUTInstanceUID.getLength() > 0)
           {
             referencedPresentationLUTInstanceUID.getOFString(aString,0);
             DVPSPresentationLUT *currentPLUT = globalPresentationLUTList.findPresentationLUT(aString.c_str());
             if (NULL == currentPLUT)
             {
               if (verboseMode)
               {
                 logstream->lockCerr() << "cannot create Basic Film Box: presentation LUT reference cannot be resolved" << endl;
                 logstream->unlockCerr();
               }
               rsp.msg.NCreateRSP.DimseStatus = STATUS_N_InvalidAttributeValue;
               result = OFFalse;
             } else {
               // check referenced SOP class UID
               DcmUniqueIdentifier refClassUID(DCM_ReferencedSOPClassUID);
               stack.clear();
               READ_FROM_DATASET2(DcmUniqueIdentifier, refClassUID)
               if (refClassUID.getLength() > 0)
               {     
                  aString.clear();
                  refClassUID.getOFString(aString,0, OFTrue);
                  if (aString != UID_PresentationLUTSOPClass)
                  {
                    if (verboseMode)
                    {
                      ostream &mycerr = logstream->lockCerr();
                      mycerr << "cannot create Basic Film Box: referenced SOP class UID in referenced presentation LUT sequence incorrect:" << endl;
                      (stack.top())->print(mycerr, DCMTypes::PF_shortenLongTagValues);
                      logstream->unlockCerr();            
                    }
                    rsp.msg.NCreateRSP.DimseStatus = STATUS_N_InvalidAttributeValue;
                    result = OFFalse;
                  } else {
                    // referenced presentation LUT sequence is OK
                    // synchronize presentationLUTInstanceUID and referencedPresentationLUTInstanceUID
                    presentationLUTInstanceUID.clear();
                    referencedPresentationLUTInstanceUID.getOFString(presentationLUTInstanceUID,0);             
                    referencedPresentationLUTAlignment = currentPLUT->getAlignment();
                  }
               } else {
                  if (verboseMode)
                  {
                    logstream->lockCerr() << "cannot create Basic Film Box: no referenced SOP class UID in referenced presentation LUT sequence" << endl;
                    logstream->unlockCerr();
                  }
                  rsp.msg.NCreateRSP.DimseStatus = STATUS_N_InvalidAttributeValue;
                  result = OFFalse;
               }
             }
           } else {
             if (verboseMode)
             {
               logstream->lockCerr() << "cannot create Basic Film Box: no referenced SOP instance UID in referenced presentation LUT sequence" << endl;
               logstream->unlockCerr();
             }
             rsp.msg.NCreateRSP.DimseStatus = STATUS_N_InvalidAttributeValue;
             result = OFFalse;
           }
        } else {
          if (verboseMode)
          {
            logstream->lockCerr() << "cannot create Basic Film Box: referenced presentation LUT sequence number of items != 1" << endl;
            logstream->unlockCerr();
          }
          rsp.msg.NCreateRSP.DimseStatus = STATUS_N_InvalidAttributeValue;
          result = OFFalse;
        }
      }
    }    
    
  } /* if presentationLUTnegotiated */

  DcmSequenceOfItems *refFilmSessionSequence = NULL;
  
  // referenced film session sequence
  if (result)
  {
    stack.clear();

    if (rqDataset && (EC_Normal == rqDataset->search(DCM_ReferencedFilmSessionSequence, stack, ESM_fromHere, OFFalse)))
    {
      DcmUniqueIdentifier classUID(DCM_ReferencedSOPClassUID);
      DcmUniqueIdentifier instanceUID(DCM_ReferencedSOPInstanceUID);
      refFilmSessionSequence =(DcmSequenceOfItems *)stack.top();
      if (refFilmSessionSequence->card() ==1)
      {
         OFString aString;
         DcmItem *item = refFilmSessionSequence->getItem(0);
         stack.clear();
         READ_FROM_DATASET2(DcmUniqueIdentifier, instanceUID)
         if (instanceUID.getLength() > 0)
         {
           instanceUID.getOFString(aString,0);
           if (aString != filmSessionUID)
           {
             if (verboseMode)
             {
               logstream->lockCerr() << "cannot create Basic Film Box: referenced film session instance UID incorrect" << endl;
               logstream->unlockCerr();
             }
             rsp.msg.NCreateRSP.DimseStatus = STATUS_N_InvalidAttributeValue;
             result = OFFalse;
           } else {
             // check referenced SOP class UID
             stack.clear();
             READ_FROM_DATASET2(DcmUniqueIdentifier, classUID)
             if (classUID.getLength() > 0)
             {     
                aString.clear();
                classUID.getOFString(aString,0, OFTrue);
                if (aString != UID_BasicFilmSessionSOPClass)
                {
                  if (verboseMode)
                  {
                    ostream &mycerr = logstream->lockCerr();
                    mycerr << "cannot create Basic Film Box: referenced SOP class UID in referenced film session sequence incorrect:" << endl;
                    (stack.top())->print(mycerr, DCMTypes::PF_shortenLongTagValues);
                    logstream->unlockCerr();            
                  }
                  rsp.msg.NCreateRSP.DimseStatus = STATUS_N_InvalidAttributeValue;
                  result = OFFalse;
                }
             } else {
                if (verboseMode)
                {
                  logstream->lockCerr() << "cannot create Basic Film Box: no referenced SOP class UID in referenced film session sequence" << endl;
                  logstream->unlockCerr();
                }
                rsp.msg.NCreateRSP.DimseStatus = STATUS_N_InvalidAttributeValue;
                result = OFFalse;
             }
           }
         } else {
           if (verboseMode)
           {
             logstream->lockCerr() << "cannot create Basic Film Box: no referenced SOP instance UID in referenced film session sequence" << endl;
             logstream->unlockCerr();
           }
           rsp.msg.NCreateRSP.DimseStatus = STATUS_N_InvalidAttributeValue;
           result = OFFalse;
         }
      } else {
        if (verboseMode)
        {
          logstream->lockCerr() << "cannot create Basic Film Box: referenced film session sequence number of items != 1" << endl;
          logstream->unlockCerr();
        }
        rsp.msg.NCreateRSP.DimseStatus = STATUS_N_InvalidAttributeValue;
        result = OFFalse;
      }
    } else {
      if (verboseMode)
      {
        logstream->lockCerr() << "cannot create Basic Film Box: referenced film session sequence absent" << endl;
        logstream->unlockCerr();
      }
      rsp.msg.NCreateRSP.DimseStatus = STATUS_N_MissingAttribute; 
      result = OFFalse;
    }
  }    

  // browse through rqDataset and check for unsupported attributes
  if (result && rqDataset)
  {
    OFBool intoSub = OFTrue;
    stack.clear();
    while (EC_Normal == rqDataset->nextObject(stack, intoSub))
    {
      intoSub = OFFalse;
      const DcmTagKey& currentTag = (stack.top())->getTag();
      if (currentTag.getElement() == 0x0000) /* group length */ ;
      else if (currentTag == DCM_ImageDisplayFormat) /* OK */ ;
      else if (currentTag == DCM_FilmOrientation) /* OK */ ;
      else if (currentTag == DCM_FilmSizeID) /* OK */ ;
      else if (currentTag == DCM_MagnificationType) /* OK */ ;
      else if (currentTag == DCM_SmoothingType) /* OK */ ;
      else if (currentTag == DCM_BorderDensity) /* OK */ ;
      else if (currentTag == DCM_EmptyImageDensity) /* OK */ ;
      else if (currentTag == DCM_MinDensity) /* OK */ ;
      else if (currentTag == DCM_MaxDensity) /* OK */ ;
      else if (currentTag == DCM_Trim) /* OK */ ;
      else if (currentTag == DCM_ConfigurationInformation) /* OK */ ;
      else if (currentTag == DCM_RequestedResolutionID) /* OK */ ;
      else if (currentTag == DCM_ReferencedFilmSessionSequence) /* OK */ ;
      else if (currentTag == DCM_Illumination)
      {
        if (! presentationLUTnegotiated)
        {
          if (verboseMode)
          {
            ostream &mycerr = logstream->lockCerr();
            mycerr << "cannot create Basic Film Box: illumination received:" << endl;
            (stack.top())->print(mycerr, DCMTypes::PF_shortenLongTagValues);
            logstream->unlockCerr();
          }
          rsp.msg.NCreateRSP.DimseStatus = STATUS_N_NoSuchAttribute;          
          result = OFFalse;
        }
      }
      else if (currentTag == DCM_ReflectedAmbientLight)
      {
        if (! presentationLUTnegotiated)
        {
          if (verboseMode)
          {
            ostream &mycerr = logstream->lockCerr();
            mycerr << "cannot create Basic Film Box: reflected ambient light received:" << endl;
            (stack.top())->print(mycerr, DCMTypes::PF_shortenLongTagValues);
            logstream->unlockCerr();
          }
          rsp.msg.NCreateRSP.DimseStatus = STATUS_N_NoSuchAttribute;          
          result = OFFalse;
        }
      }
      else if (currentTag == DCM_ReferencedPresentationLUTSequence)
      {
        if (! presentationLUTnegotiated)
        {
          if (verboseMode)
          {
            ostream &mycerr = logstream->lockCerr();
            mycerr << "cannot create Basic Film Box: referenced presentation LUT sequence received:" << endl;
            (stack.top())->print(mycerr, DCMTypes::PF_shortenLongTagValues);
            logstream->unlockCerr();
          }
          rsp.msg.NCreateRSP.DimseStatus = STATUS_N_NoSuchAttribute;          
          result = OFFalse;
        }
      }
      else
      {
        if (verboseMode)
        {
          ostream &mycerr = logstream->lockCerr();
          mycerr << "cannot create Basic Film Box: unsupported attribute received:" << endl;
          (stack.top())->print(mycerr, DCMTypes::PF_shortenLongTagValues);
          logstream->unlockCerr();
        }
        rsp.msg.NCreateRSP.DimseStatus = STATUS_N_NoSuchAttribute;
        result = OFFalse;
      }
    }
  }
  
  // if n-create was successful, create response dataset
  if (result)
  {
    rspDataset = new DcmDataset;    
    if (rspDataset)
    {
      OFCondition writeresult = EC_Normal;
      DcmElement *delem = NULL;

      if (refFilmSessionSequence) // should never be NULL if we get this far
      {      
        DcmSequenceOfItems *newRefFilmSessionSequence = new DcmSequenceOfItems(*refFilmSessionSequence);
        if (newRefFilmSessionSequence) rspDataset->insert(newRefFilmSessionSequence, OFTrue /*replaceOld*/);
        else writeresult = EC_MemoryExhausted;
      }

      ADD_TO_PDATASET(DcmShortText, imageDisplayFormat)
      ADD_TO_PDATASET(DcmCodeString, filmOrientation)
      ADD_TO_PDATASET(DcmCodeString, filmSizeID)
      ADD_TO_PDATASET(DcmCodeString, magnificationType)
      ADD_TO_PDATASET(DcmUnsignedShort, maxDensity)     
      ADD_TO_PDATASET(DcmShortText, configurationInformation)
      if (smoothingType.getLength() > 0) { ADD_TO_PDATASET(DcmCodeString, smoothingType) }
      if (borderDensity.getLength() > 0) { ADD_TO_PDATASET(DcmCodeString, borderDensity) }
      if (emptyImageDensity.getLength() > 0) { ADD_TO_PDATASET(DcmCodeString, emptyImageDensity) }
      if (minDensity.getLength() > 0) { ADD_TO_PDATASET(DcmUnsignedShort, minDensity) }
      if (trim.getLength() > 0) { ADD_TO_PDATASET(DcmCodeString, trim) }
      if (requestedResolutionID.getLength() > 0) { ADD_TO_PDATASET(DcmCodeString, requestedResolutionID) }

      if (presentationLUTnegotiated)
      {
        if (referencedPresentationLUTInstanceUID.getLength() == 0)
        {
          referencedPresentationLUTInstanceUID.putString(WELLKNOWN_IDENTITY_PLUT_UID);
          if (NULL == globalPresentationLUTList.findPresentationLUT(WELLKNOWN_IDENTITY_PLUT_UID))
          {
            DVPSPresentationLUT *wellknownlut = new DVPSPresentationLUT();
            if (wellknownlut)
            {
              writeresult = wellknownlut->setType(DVPSP_identity);
              if (EC_Normal == writeresult) writeresult = wellknownlut->setSOPInstanceUID(WELLKNOWN_IDENTITY_PLUT_UID);
              if (EC_Normal == writeresult) globalPresentationLUTList.insert(wellknownlut);              
            } else writeresult = EC_MemoryExhausted;
          }
        }
        if (EC_Normal == writeresult) writeresult = addPresentationLUTReference(*rspDataset);
      }

      // create image boxes and referenced image box sequence
      if (imageBoxContentList.printSCPCreate(currentNumRows * currentNumCols, studyInstanceUID, imageSeriesInstanceUID, cfg.getNetworkAETitle()))
      {
        if (EC_Normal == writeresult) writeresult = imageBoxContentList.writeReferencedImageBoxSQ(*rspDataset);         
      } else writeresult = EC_MemoryExhausted;
            
      if (EC_Normal == writeresult)
      {
        rsp.msg.NCreateRSP.DataSetType = DIMSE_DATASET_PRESENT;
      } else {
        delete rspDataset;
        rspDataset = NULL;
        rsp.msg.NCreateRSP.DimseStatus = STATUS_N_ProcessingFailure;
        result = OFFalse;
      }     
    } else {
      rsp.msg.NCreateRSP.DimseStatus = STATUS_N_ProcessingFailure;
      result = OFFalse;
    }
  }
  return result;
}


Generated by  Doxygen 1.6.0   Back to index