//======================================================================
///Reads Images (Non Threaded)
- void GimmickView::ReadImagesNotThreaded(std::vector<vtkImageData*>& s,std::vector<std::string> im, int dimension)
- {
+void GimmickView::ReadImagesNotThreaded(std::vector<vtkImageData*>& s,std::vector<std::string> im, int dimension)
+{
// Create the output data
if (im.size()==1)
- {
-
+ {
// Only one image : give it
vtkImageData* out = vtkImageData::New();
GimmickDebugMessage(3, "State Check: Full Filename: "
<<std::endl);
out->ShallowCopy(mReader.GetImage(im.front()));
s.push_back( out );
- }
-
+ }
else if (im.size()>1)
- {
- vtkImageData* first = mReader.GetImage( im.front());
- 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<std::string>::iterator it;
- for (it=im.begin(); it!=im.end(); ++it)
- {
- //std::cout << "copying slice "<<slice <<std::endl;
- vtkImageData* cur = mReader.GetImage( (*it));
-
- 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++;
- }
- s.push_back(out);
- }
- else
- {
- // n3D
+ {
+ vtkImageData* first = mReader.GetImage( im.front());
+ if (dimension == 2)
+ {
+ // n3D
std::vector<std::string>::iterator it;
- for (it=im.begin(); it!=im.end(); ++it)
- {
- vtkImageData* out = vtkImageData::New();
- out->ShallowCopy(mReader.GetImage(*it));
- s.push_back(out);
- }
- }
- }
-
- }
+ for (it=im.begin(); it!=im.end(); ++it)
+ {
+ vtkImageData* out = vtkImageData::New();
+ out->ShallowCopy(mReader.GetImage(*it));
+ s.push_back(out);
+ }
+ }
+ else
+ {
+ // 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<std::string>::iterator it;
+ for (it=im.begin(); it!=im.end(); ++it)
+ {
+ //std::cout << "copying slice "<<slice <<std::endl;
+ vtkImageData* cur = mReader.GetImage( (*it));
+
+ 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++;
+ }
+ s.push_back(out);
+
+ }
+ }
+}
//======================================================================
//======================================================================
"MultiThreadImageReader event : "<<e<<std::endl);
if (e==ImageLoaded)
{
- if (filename.size()==0)
- {
+ if (filename.size()==0)
+ {
//What to do in this case?
/*
GimmickDebugMessage(5,
"Pushing unknown image in queue"
<<std::endl);
mImageEventQueue.push_back(ImageEventType(image));*/
- return;
- }
- ImageEventTypeMap::iterator i;
- i = mImageEventMap.find(filename);
- if (i!=mImageEventMap.end())
- {
- GimmickDebugMessage(5,
- "Putting image of file '"<<filename<<"' on pointer"
- <<std::endl);
- ImageEventType ie(i->second);
- ie.image = image;
- ie.pointerHolder->Set(ie.image);
- //mImageEventMap.erase(i);
- }
+ return;
+ }
+ ImageEventTypeMap::iterator i;
+//JCP 22-06-2009, test mImageEventMap.size() > 0
+ if(mImageEventMap.size()>0){
+ i = mImageEventMap.find(filename);
+ if (i!=mImageEventMap.end())
+ {
+ GimmickDebugMessage(5,
+ "Putting image of file '"<<filename<<"' on pointer"
+ <<std::endl);
+ ImageEventType ie(i->second);
+ ie.image = image;
+ ie.pointerHolder->Set(ie.image);
+ //mImageEventMap.erase(i);
+ }
+ }
}
else if (e==Error)
{