<process>
<PRE>
-
+
+
+
creaImageIO::WxSimpleDlg dlg(0,crea::std2wx(bbGetInputTitle()),"localdatabase_Descriptor.dscp","Local Database");
dlg.SetAttrDicomTags( bbGetInputDicomTags() );
dlg.ShowModal();
bbSetOutputDicomInfo( dlg.getDicomInfoImagesSelected() );
- if (dlg.getImagesSelected().size()!=0){
- bbSetOutputFileName( std::string( dlg.getInfoImage().mb_str() ) );
+ if (dlg.getImagesSelected().size()!=0)
+ {
+ bbSetOutputFileName( std::string( dlg.getInfoImage().mb_str() ) );
+ bbSetOutputOut( dlg.getVolumeSelected() );
+
+/*
if(dlg.getImagesSelected().size() ==1)
{
bbSetOutputOut( dlg.getImagesSelected()[0] );
bbSetOutputOut(first);
} // dim
}
+*/
+
} else {
- bbSetOutputOut( NULL );
+ bbSetOutputOut( NULL );
} // dlg.getImagesSelected().size()!=0
+
+
+
bbSetOutputOutImages( dlg.getImagesSelected());
printf("EED creaImageIOWxSimpleDlg 5 \n");
</PRE>
std::vector<vtkImageData*> images;
creaImageIO::WxSimpleDlg w(0,_T("Select your image"),"creaContours_Descriptor.dscp","creatisContours DB");
w.ShowModal();
+
+ vtkImageData *result=NULL;
+
if(w.GetReturnCode() == wxID_OK)
{
- std::vector<std::string> s;
- images = w.getImagesSelected();
- infoImage = w.getInfoImage();
+// images = w.getImagesSelected();
+// infoImage = w.getInfoImage();
+ result=w.getVolumeSelected();
+
} // if
- vtkImageData *result=NULL;
- if (images.size()>0)
- {
- result=images[0];
- }
+// EED 2016/02/16
+// if (images.size()>0)
+// {
+// result=images[0];
+// }
return result;
}
EndModal( dlg.GetReturnCode() );
}
+//-----------------------------------------------------------------------------
wxString WxSimpleDlg::getInfoImage()
{
return infoimage;
return m_results;
}
+//-----------------------------------------------------------------------------
std::vector< std::map<std::string, std::string> > WxSimpleDlg::getDicomInfoImagesSelected()
{
return m_resultsDicomAtr;
}
+//-----------------------------------------------------------------------------
void WxSimpleDlg::SetAttrDicomTags( std::vector<std::string> attr )
{
m_attrDicomTags=attr;
}
+//-----------------------------------------------------------------------------
+ vtkImageData* WxSimpleDlg::getVolumeSelected()
+ {
+ vtkImageData *result;
+
+// creaImageIO::WxSimpleDlg dlg(0,crea::std2wx(bbGetInputTitle()),"localdatabase_Descriptor.dscp","Local Database");
+// dlg.SetAttrDicomTags( bbGetInputDicomTags() );
+// dlg.ShowModal();
+// bbSetOutputDicomInfo( dlg.getDicomInfoImagesSelected() );
+
+ if (getImagesSelected().size()!=0){
+// bbSetOutputFileName( std::string( dlg.getInfoImage().mb_str() ) );
+ if(getImagesSelected().size() ==1)
+ {
+ result = getImagesSelected()[0] ;
+ } else {
+ // FCY: it will be a big problem if we have several kind of data in the same folder.
+ // creation of a huge vtkImageData!!!!
+ vtkImageData* first = getImagesSelected()[0];
+ int dim[3];
+ first->GetDimensions(dim);
+ if (dim[2]==1)
+ {
+ vtkImageData *out;
+ out = vtkImageData::New();
+ out->SetScalarType(first->GetScalarType());
+ out->SetNumberOfScalarComponents(first->GetNumberOfScalarComponents());
+ int ext[6];
+ first->GetWholeExtent(ext);
+ if(ext[5] == 0)
+ {
+ ext[5] = getImagesSelected().size()-1;
+ } else {
+ ext[5] = ext[5] * getImagesSelected().size()-1; // to deal with multiframes
+ } // ext
+ out->SetExtent(ext);
+ double spac[3];
+ first->GetDimensions(dim);
+ first->GetSpacing(spac);
+ if (spac[0]==spac[1])
+ {
+ spac[2]=spac[0];
+ }
+ out->SetSpacing(spac);
+ out->SetDimensions(dim[0], dim[1], getImagesSelected().size() );
+ out->AllocateScalars();
+ out->Update();
+ unsigned long imsize = dim[0] * dim[1];
+ imsize = imsize * dim[2]; // deal with multiframes here
+ // differents formats char , short, etc...
+ // differents components 1..3 ex. jpg ->RGB 3
+ imsize = imsize * first->GetScalarSize() * first->GetNumberOfScalarComponents();
+ int slice,sizeImageVector=getImagesSelected().size();
+ for (slice=0 ; slice<sizeImageVector ; slice++)
+ {
+ vtkImageData *img = getImagesSelected()[slice];
+ memcpy(out->GetScalarPointer(0,0,slice), img->GetScalarPointer(0,0,0), imsize);
+ //img->Delete();
+ } // for slice
+
+//EED This is NOT working. The iteration over the pointer vtkImageData
+// int slice=0;
+// std::vector<vtkImageData*>::iterator it;
+// for (it=dlg.getImagesSelected().begin(); it!=dlg.getImagesSelected().end(); ++it)
+// {
+// memcpy(out->GetScalarPointer(0,0,slice), (*it)->GetScalarPointer(0,0,0), imsize);
+// slice++;
+// }
+// //for (it=dlg.getImagesSelected().begin(); it!=dlg.getImagesSelected().end(); ++it)
+// //{
+// // (*it)->Delete();
+// //}
+
+ result =out;
+
+ } else {
+ result = first;
+ } // dim
+ } // if getImagesSelected size
+ } else {
+ result = NULL;
+ } // getImagesSelected().size()!=0
+
+
+ return result;
+
+ }
+
+
-}
+} // namespace creaImageIO