GDCM_NAME_SPACE::Document*doc;
GDCM_NAME_SPACE::File* file = GDCM_NAME_SPACE::File::New();
file->SetLoadMode( GDCM_NAME_SPACE::LD_ALL);
- file->SetFileName(filename.c_str());
+ file->SetFileName( filename );
file->Load();
bool ok = file->IsReadable();
if(!ok)
{
doc = (GDCM_NAME_SPACE::Document*)file;
ok = doc->IsReadable();
- }
+ } // if ok
file->Delete();
return ok;
}
{
vtkImageData* im = 0;
try
- {
- mReader->SetFileName(filename.c_str());
- mReader->Update();
- im = vtkImageData::New();
- im->ShallowCopy(mReader->GetOutput());
- }
- catch (...)
- {
- if (im!=0) im->Delete();
- im = 0;
- }
+ {
+ mReader->SetFileName(filename.c_str());
+ mReader->Update();
+ im = vtkImageData::New();
+ im->ShallowCopy(mReader->GetOutput());
+ } catch (...) {
+ if (im!=0) im->Delete();
+ im = 0;
+ }
return im;
}
const std::string DicomImageReader::GetStringValueFromTag(const gdcm::DataElement& de)
{
+printf("EED DicomImageReader::GetStringValueFromTag Start\n");
static std::string buffer;
buffer = ""; // cleanup previous call
- const gdcm::ByteValue *bv = de.GetByteValue();
- if( bv ) // Can be Type 2
- {
+ const gdcm::ByteValue *bv = de.GetByteValue();
+ if( bv!=NULL ) // Can be Type 2
+ {
buffer = std::string( bv->GetPointer(), bv->GetLength() );
// Will be padded with at least one \0
- }
+ } // if bv
// Since return is a const char* the very first \0 will be considered
+printf("EED DicomImageReader::GetStringValueFromTag END\n");
return buffer.c_str();
}
//=====================================================================
GimmickError("ERROR CREATING '"<<i_locDB<<"'");
}
sqlTreeH->SetAttribute(0,"Name",i_name);
- }
- else
- {
+ } else {
/// Open and test it
GimmickDebugMessage(1,"Opening local database '" <<i_locDB<< "' " << std::endl);
++it)
{
delete it->second;
- }
- }
+ } // for
+ } // if
}
//==============================================================
const std::vector<std::string>& filenames)
{
GimmickMessage(2,"Adding files to '"<<d<<"'"<<std::endl);
-
mImageAdder.SetCurrentDatabase(d);
mImageAdder.SetTreeHandler(GetTreeHandler(d));
mImageAdder.SetSynchronizer(mSynchronizer);
void Gimmick::AddDir(const std::string& d, const std::string& f,
bool recurse)
{
- GimmickMessage(2,"Adding dir '"<<f<<"' to '"<<d<<"' recurse:"
- <<recurse<<std::endl);
-
+ GimmickMessage(2,"Adding dir '"<<f<<"' to '"<<d<<"' recurse:" <<recurse<<std::endl);
TreeHandler * handler=GetTreeHandler(d);
mImageAdder.SetCurrentDatabase(d);
mImageAdder.SetTreeHandler(handler);
{
std::map<std::string, std::string>::iterator it = map_attr.begin();
for(; it != map_attr.end(); it++)
+ {
i_res[it->first] = it->second;
- }
- else
- {
+ } // for
+ } else {
std::vector<std::string>::iterator it = i_attr.inside.begin();
- for(; it != i_attr.inside.end(); it++)
+ for(; it != i_attr.inside.end(); it++)
+ {
i_res[(*it)] = map_attr[(*it)];
- }
- }
+ } // for
+ } // if ALL
+ } // if size
}
{
printf("EED Gimmick::fillVectInfos inside %s\n",(*it).c_str());
infos.inside.push_back((*it));
- }
- else
- {
+ } else {
infos.outside.push_back((*it)); // Need to scan again the files
printf("EED Gimmick::fillVectInfos outside %s\n",(*it).c_str());
- }
- }
+ } // if
+ } // for
}
const std::string Gimmick::getSummary()
/// Destructor
GimmickView::~GimmickView()
{
- printf("EED GimmickView::~GimmickView DESTROCTEUR \n");
GimmickDebugMessage(1,"GimmickView::~GimmickView"
<<std::endl);
}
OutputAttr i_attr, double i_zspc)
{
OutStrGimmick out;
- vtkImageData* first = mReader.GetImage( im.front());
+ vtkImageData* first = mReader.GetImage( im.front() );
out.img = vtkImageData::New();
int ext[6];
//EED 2017-01-01 Migration VTK7
out.img->AllocateScalars(first->GetScalarType(), first->GetNumberOfScalarComponents());
#endif
-
unsigned long imsize = dim[0] * dim[1];
imsize = imsize * dim[2] ; // deal with multiframes here
// differents formats char , short, etc...
//!!!!out.img->SetSpacing(i_zspc);
int slice = 0;
std::vector<std::string>::iterator it;
+
for (it=im.begin(); it!=im.end(); ++it)
{
vtkImageData* cur = mReader.GetImage( (*it) );
memcpy(out.img->GetScalarPointer(0,0,slice), cur->GetScalarPointer(0,0,0), imsize);
slice++;
- }
+ } // for it
getAttributes(im.front(),out.infos, i_attr);
o_output.push_back(out);
//EED UnMosaic step...
//How to verifie if is a mosaic file , with how many images inside??
-
}
//=====================================================================
ImageReader::ImageReader()
:
- mUnreadableImage(0),
+ mUnreadableImage(NULL),
mLastFilename("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&")
{
// std::cout << "#### ImageReader::ImageReader()"<<std::endl;
- if (mUnreadableImage!=0) return;
+ if (mUnreadableImage!=NULL) return;
Register( boost::shared_ptr<AbstractImageReader>(new VtkImageReader(vtkPNGReader::New() , "PNG", ".png")));
#endif
for (int i=0;i<dim[0];i++)
- for (int j=0;j<dim[1];j++)
- mUnreadableImage->SetScalarComponentFromFloat(i,j,0,0,0);
+ {
+ for (int j=0;j<dim[1];j++)
+ {
+ mUnreadableImage->SetScalarComponentFromFloat(i,j,0,0,0);
+ } // for j
+ } // for i
+
for (int i=0;i<dim[0];i++)
- {
- mUnreadableImage->SetScalarComponentFromFloat(i,i,0,0,255);
- mUnreadableImage->SetScalarComponentFromFloat(dim[0]-1-i,i,0,0,255);
- }
+ {
+ mUnreadableImage->SetScalarComponentFromFloat(i,i,0,0,255);
+ mUnreadableImage->SetScalarComponentFromFloat(dim[0]-1-i,i,0,0,255);
+ } // for i
}
//=====================================================================
//delete (*i);
// }
// mReader.clear();
- if (mUnreadableImage!=0)
- {
- mUnreadableImage->Delete();
- mUnreadableImage = 0;
- }
+ if (mUnreadableImage!=NULL)
+ {
+ mUnreadableImage->Delete();
+ mUnreadableImage = NULL;
+ }
}
//=====================================================================
void ImageReader::Register(boost::shared_ptr<AbstractImageReader> r)
{
mReader.push_back(r);
-
}
void ImageReader::UnRegister(const std::string i_val)
std::vector<std::string >::iterator i ;
for (i=mUnReader.begin(); i!=mUnReader.end(); i++)
{
-
if ( (*i).c_str() == filename)
{
ok = false;
// Reads the file (CanRead must be called before : no test here)
vtkImageData* ImageReader::ReadImage( const std::string& filename)
{
- if (mLastFilename!=filename)
- {
- if (!CanRead(filename))
- {
- vtkImageData* im = vtkImageData::New();
- im->ShallowCopy(mUnreadableImage);
- return im;
- }
- }
- vtkImageData* i = mLastReader->ReadImage(mLastFilename);
- if (i==0)
- {
- i = vtkImageData::New();
- i->ShallowCopy(mUnreadableImage);
- }
- return i;
+ if (mLastFilename!=filename)
+ {
+ if (!CanRead(filename))
+ {
+ vtkImageData* im = vtkImageData::New();
+ im->ShallowCopy(mUnreadableImage);
+ return im;
+ } // CanRead
+ } // for mLastFilename
+ vtkImageData* i = mLastReader->ReadImage(mLastFilename);
+ if (i==NULL)
+ {
+ i = vtkImageData::New();
+ i->ShallowCopy(mUnreadableImage);
+ } // i
+ return i;
}
//=====================================================================
// Another function to read attributes for a file
/// in a string to string map
/// On return, the values of the map are the values
/// of the attributes (empty string if not available).
- void ReadAttributes(const std::string& filename,
- tree::AttributeMapType& attr);
+ void ReadAttributes(const std::string& filename, tree::AttributeMapType& attr);
/// Exclude specific readers
/// TO DO...
/// Another function to read attributes for a file
- void getAttributes(const std::string filename,
- std::map <std::string , std::string> &infos, std::vector<std::string> i_attr);
+ void getAttributes(const std::string filename, std::map <std::string , std::string> &infos, std::vector<std::string> i_attr);
-
-
protected:
/// Register a reader
// CTor
Listener::Listener()
{
-
boost::mutex::scoped_lock lock(mMutex);
- GimmickDebugMessage(6,"Listener::Listener"
- <<std::endl);
- mDrive="E:";
- mMounted=false;
- mAddFiles=false;
- mRemoveFiles=true;
-
+ GimmickDebugMessage(6,"Listener::Listener"<<std::endl);
+ mDrive = "E:";
+ mMounted = false;
+ mAddFiles = false;
+ mRemoveFiles = true;
}
//=====================================================================
Listener::~Listener()
{
boost::mutex::scoped_lock lock(mMutex);
- GimmickDebugMessage(6,"Listener::~Listener"
- <<std::endl);
+ GimmickDebugMessage(6,"Listener::~Listener"<<std::endl);
}
//=====================================================================
{
mMounted=true;
}
-
- }
- catch (...)
- {
+ } catch (...) {
if(mMounted && mRemoveFiles)
{
mMounted=false;
mMounted=false;
}
}
-
clock_t endwait;
endwait = clock () + 0.001 * CLOCKS_PER_SEC ;
while (clock() < endwait ) {}
namespace creaImageIO
{
+ class wxThreadEED1
+ {
+ public:
+ void Resume() { printf("EED wxThreadEED1::Resume() \n"); }
+ void Pause() { printf("EED wxThreadEED1::Pause() \n"); }
+ bool TestDestroy() { printf("EED wxThreadEED1::TestDestroy() \n"); return false; }
+ };
- class Listener : public wxThread
+//EED 2018-08-20
+//class Listener : public wxThread
+ class Listener : public wxThreadEED1
{
public:
/// Ctors
#include <wx/utils.h>
#include <creaImageIOSystem.h>
+ #include <creaImageIODicomImageReader.h>
+
+
#include <creaImageIOGimmick.h>
#ifdef _DEBUG
#define new DEBUG_NEW
}
//=====================================================================
+ class wxThreadEED2
+ {
+ public:
+ void Delete() { printf("EED wxThreadEED2::Delete() \n"); }
+ int Run() { printf("EED wxThreadEED2::Run() \n"); return 0;}
+ void Pause() { printf("EED wxThreadEED2::Pause() \n"); }
+ void Create() { printf("EED wxThreadEED2::Create() \n"); }
+ bool IsAlive() { printf("EED wxThreadEED2::IsAlive() \n"); return false; }
+ bool TestDestroy() { printf("EED wxThreadEED2::TestDestroy() \n"); return false; }
+ int GetCurrentId() { printf("EED wxThreadEED2::GetCurrentId() \n"); return -999; }
+ };
+
//=====================================================================
- class ThreadedImageReader: public wxThread
+//EED 2018-08-20
+// class ThreadedImageReader: public wxThread
+ class ThreadedImageReader: public wxThreadEED2
{
public:
ThreadedImageReader(MultiThreadImageReader* tir) :
//=====================================================================
MultiThreadImageReader::MultiThreadImageReader(int number_of_threads)
: //mDoNotSignal(false),
- mReader(0),
+ mReader(NULL),
mTotalMem(0),
mTotalMemMax(1000000)
{
mDone = false;
// Create the threads
-printf("EED MultiThreadImageReader::MultiThreadImageReader %d \n", number_of_threads);
-
for (int i=0; i<number_of_threads; i++)
- {
- //ThreadedImageReader* t = new ThreadedImageReader(this);
- boost::shared_ptr<ThreadedImageReader> t(new ThreadedImageReader(this), ThreadedImageReader::deleter());
- mThreadedImageReaderList.push_back(t);
- std::cout << " ===> Thread "<<i
- <<" successfully added"<< std::endl;
- }
+ {
+ //ThreadedImageReader* t = new ThreadedImageReader(this);
+ boost::shared_ptr<ThreadedImageReader> t(new ThreadedImageReader(this), ThreadedImageReader::deleter());
+ mThreadedImageReaderList.push_back(t);
+ std::cout << " ===> Thread "<<i <<" successfully added"<< std::endl;
+ } // for
mNumberOfThreadedReadersRunning = 0;
// Init the queue
mQueue.set(mComparator);
//=====================================================================
bool MultiThreadImageReader::Start()
{
-printf("EED MultiThreadImageReader::Start Start\n");
// std::cout << "#### MultiThreadImageReader::Start()"
// <<std::endl;
if (mNumberOfThreadedReadersRunning > 0) return true;
wxMutexLocker locker(GetMultiThreadImageReaderUserMutex());
// std::cout << "EO Start : #Threads running = "
// << mNumberOfThreadedReadersRunning<<std::endl;
-printf("EED MultiThreadImageReader::Start Start\n");
return true;
}
//=====================================================================
//=====================================================================
void MultiThreadImageReader::Stop()
{
-printf("EED MultiThreadImageReader::Stop Start\n");
// std::cout << "#### MultiThreadImageReader::Stop()"
// <<std::endl;
// std::cout << "Sending stop order to the threads..."<<std::endl;
while (true);
// std::cout << "All threads stopped : OK "<<std::endl;
- ImageMapType::iterator j;
- for (j =mImages.begin(); j!=mImages.end(); ++j)
- {
- delete j->first;
- } //for
- mImages.clear();
+
+ CleanMImagesMap();
+
mDone = true;
-printf("EED MultiThreadImageReader::Stop End\n");
+
}
//=====================================================================
+
+ void MultiThreadImageReader::CleanMImagesMap()
+ {
+ ImageMapType::iterator j;
+ for (j=mImages.begin(); j!=mImages.end(); ++j)
+ {
+ delete j->first;
+ } //for
+ mImages.clear();
+ }
+
//=====================================================================
MultiThreadImageReader::~MultiThreadImageReader()
{
-printf("EED MultiThreadImageReader::~MultiThreadImageReader Start\n");
// std::cout << "#### MultiThreadImageReader::~MultiThreadImageReader()"
// <<std::endl;
Stop();
if (mReader) delete mReader;
mThreadedImageReaderList.clear();
-printf("EED MultiThreadImageReader::~MultiThreadImageReader End\n");
+
+ CleanMImagesMap();
+
+/*
+ ImageMapType::iterator it;
+ for (it=mImages.begin() ; it!=mImages.end(); it++)
+ {
+ printf("MultiThreadImageReader::~MultiThreadImageReader %s ", it.first->GetFilename() );
+ } // for it
+*/
+
}
//=====================================================================
// if (mNumberOfThreadedReadersRunning==0)
// if (mThreadedImageReaderList.size()==0)
if (true)
- {
+ {
ImageToLoad itl(this,filename);
ImageMapType::iterator i = mImages.find(&itl);
if (i!=mImages.end())
- {
- ImageToLoadPtr pitl = const_cast<ImageToLoadPtr>(i->first);
- // Already inserted
- if (pitl->GetImage() != 0)
- {
- // Already read
- UpdateUnloadPriority(pitl,
- GetMaximalPriorityWithoutLocking()+1);
- return pitl->GetImage();
- }
- }
+ {
+ ImageToLoadPtr pitl = const_cast<ImageToLoadPtr>(i->first);
+ // Already inserted
+ if (pitl->GetImage() != NULL)
+ {
+ // Already read
+ UpdateUnloadPriority( pitl, GetMaximalPriorityWithoutLocking()+1 );
+ return pitl->GetImage();
+ } // if pitl->GetImage()
+ } // if i
+
ImageToLoadPtr pitl = new ImageToLoad(this,filename,0);
- mImages[pitl] = 0;
- pitl->SetImage(mReader->ReadImage(filename));
- UpdateUnloadPriority(pitl,
- GetMaximalPriorityWithoutLocking()+1);
+ mImages[pitl] = NULL;
+ pitl->SetImage( mReader->ReadImage(filename) );
+ UpdateUnloadPriority( pitl, GetMaximalPriorityWithoutLocking()+1 );
return pitl->GetImage();
- }
-
+ } // if true
+
/*
mRequestedFilename = filename;
mRequestedImage = 0;
while (true);
//
*/
+ printf("EED MultiThreadImageReader::GetImage END\n");
+
}
//=====================================================================
std::map<std::string, std::string> getAttributes(const std::vector<std::string> i_attr);
private:
- MultiThreadImageReaderUser* mUser;
- std::string mFilename;
- int mPriority;
- int mIndex;
- int mUnloadIndex;
- vtkImageData* mImage;
+ MultiThreadImageReaderUser *mUser;
+ std::string mFilename;
+ int mPriority;
+ int mIndex;
+ int mUnloadIndex;
+ vtkImageData *mImage;
};
//
/// Type of pointer on an ImageToLoad struct
- typedef ImageToLoad* ImageToLoadPtr;
+ typedef ImageToLoad *ImageToLoadPtr;
/// ImageToLoadPtr comparator on priority (for image queue)
struct ImageToLoadPtrPriorityComparator
/// The callback from threaded readers when an image is read
void SignalImageRead(ImageToLoadPtr p, bool purge);
-
+
+ void CleanMImagesMap();
+
+
+
/// The type of map of images
- typedef std::map<ImageToLoadPtr,vtkImageData*,
- ImageToLoadPtrFilenameComparator> ImageMapType;
+ typedef std::map<ImageToLoadPtr,vtkImageData*, ImageToLoadPtrFilenameComparator> ImageMapType;
/// The map of images
ImageMapType mImages;
/// Comparator for the image to load queue
{
static bool first_time = true;
if (first_time)
- {
- crea::MessageManager::RegisterMessageType("Gimmick!",
- "Gimmick",1);
- crea::MessageManager::RegisterMessageType("Gimmick! DEBUG",
- "Gimmick",0);
- first_time = false;
- }
+ {
+printf("EED === System.h === RegisterGimmickMessageTypes \n");
+ crea::MessageManager::RegisterMessageType("Gimmick!", "Gimmick",1);
+ crea::MessageManager::RegisterMessageType("Gimmick! DEBUG", "Gimmick",0);
+ first_time = false;
+ } // if
}
//==============================================================
inline void SetGimmickMessageLevel(int l)
#define GimmickDebugMessage(LEV,MESS) \
creaDebugMessage("Gimmick! DEBUG",LEV,"[Gimmick!] DEBUG: "<<MESS);
+
#define GimmickError(MESS) \
creaError("[Gimmick!] "<<MESS);
public:
typedef std::map<std::string,std::string> AttributeMapType;
-
/// Ctor with parent
Node(Node* parent);
/// Ctor with parent and attributes map
/// Returns the level of the node in the tree
virtual int GetLevel() const { return mParent->GetLevel()+1; }
-
/// Returns the parent of the node
Node* GetParent() const { return mParent; }
/// Remove the given children from the children list
int RemoveChildrenFromList(Node*);
-
/// Get the Attributes Map
AttributeMapType& GetAttributeMap() { return mAttributeMap; }
mProgressDialog(NULL),
mConstructed(false)
{
+ mViewer=NULL;
GimmickDebugMessage(1,"WxGimmickView::WxGimmickView" <<std::endl);
// Sets the current directory to the home dir
mCurrentDirectory = std2wx(gimmick->GetHomeDirectory());
//==================================================
void WxGimmickView::OnInternalIdle()
{
- if (!mConstructed) return;
+ if (!mConstructed) return;
static bool first_time = true;
+
if (false)
{
first_time = false;
}
// GimmickMessage(1,"WxGimmickView : Refresh viewer"<<std::endl);
// mViewer->StartPlayer();
- if(mViewer)
+ if(mViewer!=NULL)
{
mViewer->RefreshIfNecessary();
}
//==================================================
void WxGimmickView::ClearSelection()
{
-printf("EED WxGimmickView::ClearSelection Start\n");
pointers.clear();
pointers.push_back(boost::shared_ptr<creaImageIO::ImagePointerHolder>(new ImagePointerHolder(GetDefaultImage())));
//pointers.push_back(new ImagePointerHolder(GetDefaultImage()));
mViewer->SetImageVector(pointers);
mViewer->RefreshIfNecessary();
ResetExtent();
-printf("EED WxGimmickView::ClearSelection End\n");
}
//=================================================
//=====================================================================
+ class wxThreadEED3
+ {
+ public:
+ void Delete() { printf("EED wxThreadEED3::Delete() \n"); }
+ int Run() { printf("EED wxThreadEED3::Run() \n"); return 0;}
+ void Pause() { printf("EED wxThreadEED3::Pause() \n"); }
+ void Create() { printf("EED wxThreadEED3::Create() \n"); }
+ bool IsAlive() { printf("EED wxThreadEED3::IsAlive() \n"); return false; }
+ bool TestDestroy() { printf("EED wxThreadEED3::TestDestroy() \n"); return false; }
+ int GetCurrentId() { printf("EED wxThreadEED3::GetCurrentId() \n"); return -999; }
+ };
+
+
//=====================================================================
+//EED 2018-08-20
+// class WxViewerPlayer: public wxThreadEED3
class WxViewerPlayer: public wxThread
{
public:
//================================================================
bool WxViewer::RefreshIfNecessary()
{
- if (mNeedRefresh)
+ if (mNeedRefresh==true)
{
GimmickDebugMessage(10,"WxViewer : Refreshing"<<std::endl);
mInteractor->Render();