/**
  * Decode the PDU
  * 
  * @param CDicomStreamReader $stream_reader The stream reader
  *  
  * @return null
  */
 function decodePDU(CDicomStreamReader $stream_reader)
 {
     $this->pdvs = array();
     $stream_reader->setStreamLength($this->getTotalLength());
     while ($stream_reader->getPos() < $stream_reader->getStreamLength()) {
         $pdv_length = $stream_reader->readUInt32();
         // + 4;
         //$stream_reader->seek(-4);
         $pdv_content = $stream_reader->read($pdv_length);
         $pdv_handle = fopen('php://temp', 'w+');
         fwrite($pdv_handle, $pdv_content, $pdv_length);
         $pdv_stream = new CDicomStreamReader($pdv_handle);
         $pdv_stream->rewind();
         $pdv = new CDicomPDV(array("presentation_contexts" => $this->presentation_contexts, "length" => $pdv_length));
         $pdv->decode($pdv_stream);
         $this->pdvs[] = $pdv;
     }
 }
 /**
  * Decode the SOP class common extended negociation item
  * 
  * @param CDicomStreamReader $stream_reader The stream reader
  * 
  * @return null
  */
 function decodeItem(CDicomStreamReader $stream_reader)
 {
     $this->sop_uid_length = $stream_reader->readUInt16();
     $this->sop_class_uid = $stream_reader->readUID($this->sop_uid_length);
     $this->service_uid_length = $stream_reader->readUInt16();
     $this->service_class_uid = $stream_reader->readUID($this->service_uid_length);
     $this->related_sop_classes_id_length = $stream_reader->readUInt16();
     if ($this->related_sop_classes_id_length > 0) {
         $related_sop_classes_content = $stream_reader->read($this->related_sop_classes_id_length);
         $handle = fopen("php://temp", "w+");
         fwrite($handle, $related_sop_classes_content);
         $related_sop_classes_stream = new CDicomStreamReader($handle);
         $this->related_sop_classes_id = array();
         while ($related_sop_classes_stream->tell() <= $this->related_sop_classes_id_length) {
             $related_sop_class_id = new CDicomSubFieldRelatedSopClassIdentification();
             $related_sop_class_id->decodeField($related_sop_classes_stream);
         }
     }
 }
Exemple #3
0
 /**
  * Decode the PDV
  * 
  * @param CDicomStreamReader $stream_reader The stream reader
  * 
  * @return null
  */
 function decode(CDicomStreamReader $stream_reader)
 {
     // On fait un stream temp pour le message
     //$this->length = $stream_reader->readUInt32();
     $this->pres_context_id = $stream_reader->readUInt8();
     $this->message_control_header = $stream_reader->readUInt8();
     $message_length = $this->length - 2;
     $message_content = $stream_reader->read($message_length);
     $handle = fopen("php://temp", "w+");
     fwrite($handle, $message_content);
     $message_stream = new CDicomStreamReader($handle);
     $message_stream->rewind();
     $message_stream->setStreamLength($message_length);
     if (!($this->transfer_syntax = $this->getTransferSyntax())) {
         /** @todo throw exception **/
     }
     $this->message = CDicomMessageFactory::decodeMessage($message_stream, $this->message_control_header, $this->transfer_syntax);
     $message_stream->close();
     $content = substr($stream_reader->buf, 13) . $message_stream->buf;
     $this->setBinaryContent($content);
 }