- }
- else if (data->GetDicomNode()->GetType()==DicomNode::Series)
- {
- DicomNode::ChildrenListType::iterator j;
- for (j =data->GetDicomNode()->GetChildrenList().begin();
- j!=data->GetDicomNode()->GetChildrenList().end();
- j++)
- {
- im.push_back ( *j );
- }
- }
- }
- }
- // Create the output data
- if (im.size()==1)
- {
- // Only one image : give it
- vtkImageData* out = vtkImageData::New();
- out->ShallowCopy(mReader.GetImage(im.front()->ImageGetFullFileName()));
- f.push_back( out );
- }
- else if (im.size()>1)
- {
- vtkImageData* first = mReader.GetImage( im.front()->ImageGetFullFileName() );
- if (first->GetDataDimension()==2)
- {
- // n2D to 3D
- vtkImageData* out = vtkImageData::New();
- out->CopyStructure(first);
- out->SetScalarType(first->GetScalarType());
- int ext[6];
- first->GetExtent(ext);
- ext[5] = im.size();
- out->SetExtent(ext);
- // LG : TODO : Z Spacing ?
-
- out->AllocateScalars();
-
- //first->Print(std::cout);
- // out->Print(std::cout);
-
- int dim[3];
- first->GetDimensions(dim);
- unsigned long imsize =
- ( (unsigned long)first->GetScalarPointer(0,1,0)
- - (unsigned long)first->GetScalarPointer(0,0,0))
- *dim[1];
-
- int slice = 0;
- std::vector<DicomNode*>::iterator it;
- for (it=im.begin(); it!=im.end(); ++it)
- {
- //std::cout << "copying slice "<<slice <<std::endl;
- vtkImageData* cur = mReader.GetImage( (*it)->ImageGetFullFileName() );
-
- void* src = cur->GetScalarPointer(0,0,0);
- void* dst = out->GetScalarPointer(0,0,slice);
- // std::cout << "src="<<src<<std::endl;
- // std::cout << "dst="<<dst<<std::endl;
- // std::cout << "siz="<<imsize<<std::endl;
- memcpy(dst,src,imsize);
-
- slice++;
- }
- f.push_back(out);
- }
- else
- {
- // n3D
- std::vector<DicomNode*>::iterator it;
- for (it=im.begin(); it!=im.end(); ++it)
- {
- vtkImageData* out = vtkImageData::New();
- out->ShallowCopy(mReader.GetImage((*it)->ImageGetFullFileName()));
- f.push_back(out);
- }
- }
- }
- */
- return NULL;