X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src2%2FcreaImageIOGimmickView.cpp;h=49297e9be755c074c127bafa89adf24931ddb479;hb=d9ba01af864b9f8a9a2268c535e8f6994d47346a;hp=c391d4a4a6136f96c005234df1908f78b3d2d3ab;hpb=79be5edd158476cd0f21d3146223594234ef06fc;p=creaImageIO.git diff --git a/src2/creaImageIOGimmickView.cpp b/src2/creaImageIOGimmickView.cpp index c391d4a..49297e9 100644 --- a/src2/creaImageIOGimmickView.cpp +++ b/src2/creaImageIOGimmickView.cpp @@ -3,35 +3,46 @@ namespace creaImageIO { + //====================================================================== // CTor - GimmickView::GimmickView(Gimmick* gimmick) - : mGimmick(gimmick) + GimmickView::GimmickView(Gimmick* gimmick, int threads) + : mGimmick(gimmick), + mReader(threads) { GimmickDebugMessage(1,"GimmickView::GimmickView" <CreateTreeView(i->second); } } + //====================================================================== + + //====================================================================== + /// Updates the TreeView of given name from level l to bottom + /// (calls the virtual method TreeView::Update()) + void GimmickView::UpdateTreeViewLevel(const std::string& t, int l) + { + TreeViewMapType::iterator i; + i = GetTreeViewMap().find(t); + if ( i == GetTreeViewMap().end() ) + { + GimmickError("INTERNAL ERROR : GimmickView::UpdateTreeView : '" + <second->UpdateLevel(l); + } + //====================================================================== + ///Validates the dimension compliance of the images with the maximum and + ///minimum given, and between their sizes + bool GimmickView::ValidateSelected (std::vector& sel, int min_dim, int max_dim) + { + GimmickMessage(2,"Validating selected"<0) + { + std::vector::iterator i; + std::string row; + std::string col; + std::string plane; + + //Validation between image sizes + for (i=sel.begin(); i!=sel.end() && valid; ++i) + { + if(i==sel.begin()) + { + row=(*i)->GetAttribute("D0028_0010"); + col=(*i)->GetAttribute("D0028_0011"); + plane=(*i)->GetAttribute("D0028_0012"); + level=(*i)->GetLevel(); + + } + else + { + if(((*i)->GetAttribute("D0028_0010"))!=row || + ((*i)->GetAttribute("D0028_0011"))!=col || + ((*i)->GetAttribute("D0028_0012"))!=plane) + { + mMessage="The selected images are not compatible."; + valid=false; + } + } + } + + //Dimention validation + //Compatibility with maximum + if(valid) + { + + int rows; + int cols; + int planes; + std::string s; + std::istringstream t(s); + s=row; + t >> rows; + if(row==""){rows=1;} + s=col; + t >> cols; + if(col==""){cols=1;} + s=plane; + t >> planes; + if(plane==""){planes=1;} + + int dim = 0; + if (planes>1) dim=3; + else if (cols>1) dim=2; + else if (rows>1) dim=1; + + if (dim == 0) + { + mMessage="Unknown image dimension : cannot select !"; + valid= false; + } + else if (dim>max_dim) + { + mMessage="Selecting "; + mMessage+=dim; + mMessage+="D images is not allowed !"; + valid= false; + } + if ( dim == max_dim ) + { + mMessage="Cannot add this image to selection : would result in a "; + mMessage+=(dim+1); + mMessage+="D image!"; + + valid= false; + } + if ( dim < min_dim && sel.size()<2 ) + { + GimmickDebugMessage(2, "State Check: Dim: " + <& s,std::vector im, int dimension) + { + + // Create the output data + if (im.size()==1) + { + + // Only one image : give it + vtkImageData* out = vtkImageData::New(); + GimmickMessage(1, "State Check: Full Filename: " + <GetAttribute("FullFileName") + <ShallowCopy(mReader.GetImage(im.front()->GetAttribute("FullFileName"))); + s.push_back( out ); + } + + else if (im.size()>1) + { + vtkImageData* first = mReader.GetImage( im.front()->GetAttribute("FullFileName")); + if (dimension==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::iterator it; + for (it=im.begin(); it!=im.end(); ++it) + { + //std::cout << "copying slice "<GetAttribute("FullFileName")); + + void* src = cur->GetScalarPointer(0,0,0); + void* dst = out->GetScalarPointer(0,0,slice); + // std::cout << "src="<