void nDimensions::Process()
{
- double **vectx = 0, **vecty = 0, **vectz = 0;
- std::vector< void * > vectortemp;
- std::vector<int> size;
- vtkImageData **mask = 0, **value = 0;
- vtkImageData* img = bbGetInputIn();
- std::vector<vtkImageData*> selectedimages;
- if(img!=NULL && currentimg!=img)
- {
- wxContourMainFrame::getInstance()->ShowToolsPanel(true);
- currentimg=img;
- selectedimages.push_back(img);
- wxContourMainFrame::getInstance()->configure(selectedimages);
- } // if img
-
- if(currentimg != NULL)
- {
- int contourtype = bbGetInputContourType();
- //wxContourMainFrame::getInstance()->getValuesXYZ(vectx, vecty, vectz, &size);
- //wxContourMainFrame::getInstance()->getMaskValue(mask, value, contourtype);
- } // if currentimg
+// double **vectx = 0, **vecty = 0, **vectz = 0;
+// std::vector< void * > vectortemp;
+// std::vector<int> size;
+// vtkImageData **mask = 0, **value = 0;
+
+ if (firsttime==true)
+ {
+ firsttime=false;
+ std::vector<vtkImageData*> selectedimages;
+ if(bbGetInputIn()!=NULL)
+ {
+ currentimg = bbGetInputIn();
+ selectedimages.push_back( bbGetInputIn() );
+ wxContourMainFrame::getInstance()->ShowToolsPanel(true);
+ wxContourMainFrame::getInstance()->configure(selectedimages);
+ } // if In
+ } else{
+
+ //wxContourMainFrame::getInstance()->getValuesXYZ(vectx, vecty, vectz, &size);
+ //wxContourMainFrame::getInstance()->getMaskValue(mask, value, contourtype);
+
+ if ( currentimg!=bbGetInputIn() )
+ {
+ wxContourMainFrame::getInstance()->changeImage(0, bbGetInputIn() );
+ currentimg=bbGetInputIn();
+ } // if currentimg!=In
+
+
+ } // if firsttime
wxContourMainFrame::getInstance()->RefreshInterface();
bbSetOutputwxContourMainFrame( wxContourMainFrame::getInstance() );
// bbSetOutputX(vectx);
//-----------------------------------------------------------------
void nDimensions::bbUserSetDefaultValues()
{
- currentimg=NULL;
+ firsttime = true;
+ currentimg = NULL;
bbSetInputContourType(0);
bbSetInputIn(NULL);
}
private:
//wxContourMainFrame* frame;
vtkImageData* currentimg;
+ bool firsttime;
//wxContourEventHandler * eventHandler;
};
_contourextractdata = NULL;
}
+
+void wxContourMainFrame::changeImage(int id, vtkImageData *img)
+{
+ if ( id<_images.size() ) _images[id]=img;
+ kernelManager->changeImage(id,img);
+ _theViewPanel->changeImage(img);
+// updateInstantImageData();
+
+}
+
void wxContourMainFrame::configure(std::vector<vtkImageData*> imgs)
{
_images = imgs;
{
std::vector<int> inst;
_instantPanel->getInstant(inst);
-
vtkImageData* img = kernelManager->getImageAtInstant(inst);
if(img!=NULL)
{
sizeLstNameThings = lstNameThings.size();
for (i=0 ; i<sizeLstNameThings ; i++)
{
-printf("EED wxContourMainFrame::SetZForAllContours contour=%d \n", i );
manualBaseModel * manualModel = kernelManager->getOutlineByKeyName(lstNameThings[i]);
sizeLstPoints = manualModel->GetSizeLstPoints();
for (ii=0 ; ii<sizeLstPoints ; ii++)
fprintf(pFileData,"--CreaContour--\n");
fprintf(pFileData,"Version %s\n", "1.0.3" );
fprintf(pFileData,"OnePixelSize %f\n", _onePixelSize);
-
//------------------------------------------------------------------------------------------------------------
-
vtkImageData *image = _images[0];
-
int dimRange[3];
image->GetDimensions(dimRange);
-
fprintf(pFile,"ImageDimensions %d %d %d\n", dimRange[0], dimRange[1], dimRange[2] );
-
double spaRange[3];
image->GetSpacing(spaRange);
-
fprintf(pFile,"ImageSpacing %f %f %f\n", spaRange[0], spaRange[1], spaRange[2] );
-
// Normal Contours
-
lstNameThings = kernelManager->GetLstNameThings();
sizeLstNameThings = lstNameThings.size();
fprintf(pFile,"NumberOfContours %d\n", sizeLstNameThings );
-
//CMRU 03-09-09-----------------------------------------------------------------------------------------------
fprintf(pFileData,"NumberOfContours %d\n", sizeLstNameThings );
//------------------------------------------------------------------------------------------------------------
-
-
// EED 2017-05-30
double spc[3];
spc[0]=1;
spc[1]=1;
- spc[2]=1;
-
+ spc[2]=1;
for (i=0 ; i<sizeLstNameThings ; i++)
{
//CMRU 03-09-09-----------------------------------------------------------------------------------------------
manualBaseModel * manualModel = kernelManager->getOutlineByKeyName(lstNameThings[i]);
-
// EED 2017-05-30
// double sizeInPixel = manualModel ->GetPathSize( );
double sizeInPixel = manualModel ->GetPathSize( spc );
-
double realContourSize = sizeInPixel*_onePixelSize;
manualModel ->SetRealSize(realContourSize);
//------------------------------------------------------------------------------------------------------------
-
//int size= kernelManager->GetLstNameThings().size();
-
kernelManager->SaveThingName( pFile, pFileData, lstNameThings[i] );
_theViewPanel->getSceneManager()->SaveThingName( pFile, lstNameThings[i] );
}// for i
-
//-- Static Contours
-
// fprintf(pFile,"ImageDimensions %d %d %d\n", dimRange[0], dimRange[1], dimRange[2] );
// fprintf(pFile,"ImageSpacing %f %f %f\n", spaRange[0], spaRange[1], spaRange[2] );
-
lstNameThings = kernelManager->GetLstNameThingsStatic();
sizeLstNameThings = lstNameThings.size();
fprintf(pFile,"NumberOfContoursStatic %d\n", sizeLstNameThings );
-
//CMRU 03-09-09-----------------------------------------------------------------------------------------------
fprintf(pFileData,"NumberOfContoursStatic %d\n", sizeLstNameThings );
//------------------------------------------------------------------------------------------------------------
-
for (i=0 ; i<sizeLstNameThings ; i++)
{
kernelManager->SaveThingName( pFile, pFileData, lstNameThings[i] );
void wxContourMainFrame::SegmentationOneSlice( int x, int y, int z, int isovalue, int sampling, int method )
{
-
-//printf("EED wxContourMainFrame::SegmentationOneSlice Start=%d %d\n",sampling,method );
-//printf("EED wxContourMainFrame::SegmentationOneSlice %d %d %d \n",x,y,z );
-
int typeofcontour = 1;
//--Extracting Contour
vtkImageData *imagedata = getImageData();
void wxContourMainFrame::onBrigthnessColorWindowLevel(int colorwindow,int windowlevel)
{
_theViewPanel->onBrigthnessColorWindowLevel(colorwindow, windowlevel);
-
RefreshInterface();
}
void wxContourMainFrame::saveFileWithContoursAutomatique()
{
-printf("EED wxContourMainFrame::saveFileWithContoursAutomatique \n");
std::string filename = kernelManager->getCurrentFileName();
if(filename.compare("")!=0){
saveFileWithContours(filename);
onSave();
}
}
+
void wxContourMainFrame::ShowToolsPanel(bool show)
{
_pannew->Show(show);
}
-
-
void wxContourMainFrame::SetContourGroup(int contourGroup)
{
_contourGroup = contourGroup;
}
-
wxPanel *wxContourMainFrame::getMaskImageViewPanel(wxWindow *parent)
{
-
if (_viewMaskImagePanel==NULL)
{
_contourextractdata = new ContourExtractData(true);
//------------------------------------------------------------------------------------------------------------
// Creational and initialization methods
//------------------------------------------------------------------------------------------------------------
- void configure(std::vector<vtkImageData*> imgs);
+ void changeImage(int id, vtkImageData *img);
+ void configure(std::vector<vtkImageData*> imgs);
bool configurePanels( );
bool addNewPanel(wxPanel* panel);
wxAuiNotebook * createNotebook();
numViews->push_back(0);
theViewPanel = new wxMaracas_N_ViewersWidget( this, showingVID, numViews );
SetVisibleAxis(false);
-
theViewPanel->SetBackgroundColour(wxColour(0,0,0));
-
theViewPanel->SetSize(800,600);
theViewPanel->GetWindow(1)->SetSize(800,600);
-
}
//------------------------------------------------------------------------------------------------------------
- void wxContourViewPanel::changeImage(vtkImageData* img){
-
+ void wxContourViewPanel::changeImage(vtkImageData* img)
+ {
theViewPanel->SetImage(img);
-
}
+
wxVtkMPR2DView * wxContourViewPanel::GetwxVtkMPR2DView()
{
return (wxVtkMPR2DView *) (theViewPanel->GetwxVtkBaseView(1));
double last_spacing[3];
bool _useVerticalBar;
bool _useHorizontalBar;
-
wxEvtHandler *_eventHandler;
bool _showBeforeContour;
bool _showAfterContour;
//EED
-
//------------------------------------------------------------------------------------------------------------
// Private methods
//------------------------------------------------------------------------------------------------------------
-
-
-
wxVtkMPR2DView *GetwxVtkMPR2DView();
-
-
// DECLARE_CLASS(wxContourViewPanel)
// any class wishing to process wxWindows events must use this macro
//DECLARE_EVENT_TABLE()
-
};
#endif // __wxContour_ViewPanel__
return vectimages;
}
+void KernelManagerContour::changeImage(int id, vtkImageData *img)
+{
+ if ( id<vectimages.size() )
+ {
+ vectimages[id]=img;
+ }
+ double spc[3];
+ std::vector<double> vectspc;
+ img->GetSpacing(spc);
+ vectspc.push_back(spc[0]);
+ vectspc.push_back(spc[1]);
+ vectspc.push_back(spc[2]);
+ vectimagesSpacing[id]=vectspc;
+ std::string imgstring = "Source Image "+intToString(id+1);
+ ImageSourceThing *imagesourcething = modelManager->getImageSourceThingByKeyName( imgstring );
+ imagesourcething->setSourceImage( img );
+}
void KernelManagerContour::setVectImages(std::vector<vtkImageData*> vectimg)
{
modelManager-> getConceptsInformation(conceptNameVect, conceptSizeVect);
}
-
vtkImageData* KernelManagerContour::getImageAtInstant(std::vector<int> inst)
{
int index = inst[5]-1;
-
if(index < (int)(vectimages.size())&&index!=_currentIndex)
{
- _currentIndex=index;
+ _currentIndex = index;
return vectimages[index];
}
return NULL;
std::string KernelManagerContour::parseOsirixFile(std::string filename)
{
-
-
#ifdef ParserOsirix_BUILD
vtkImageData* sourceimage;
std::string xsdfile;
-
xsdfile = _datadir;
-
xsdfile.append("\\XML\\osirixschema.xsd");
-
sourceimage = getSourceImage();
OsirixParser p(xsdfile.c_str(), sourceimage->GetSpacing(), sourceimage->GetExtent());
-
- if(p.ParseFile(filename.c_str())!= 0){
-
+ if(p.ParseFile(filename.c_str())!= 0)
+ {
}
-
return p.getContoursFileName();
#else
return "";
#endif
-
-
}
// Constructors & Destructors
//------------------------------------------------------------------------------------------------------------
public:
-
/**
** With this constructor the setVectImages and initialize environment must be called
**/
**/
KernelManagerContour(std::vector<vtkImageData*> images,std::string datadir,std::string tmpdir);
~KernelManagerContour();
-
std::vector<vtkImageData*> getVectImages();
- void setVectImages(std::vector<vtkImageData*> vectimg);
-
+ void changeImage(int id, vtkImageData *img);
+ void setVectImages(std::vector<vtkImageData*> vectimg);
void GetSpacing(double *vecspc, int iImage);
-
-
/**
** This method returns the source of the image data selected by the user.
*/
vtkImageData* getSourceImage();
-
-
-
void initializeEnvironment(std::string datadir);
-
-
/**
** This methods connect the event in the class interfNewContourMenu with the world of the appli
**/
-
std::string createOutline(manualBaseModel * manModelContour,std::vector<int> instantVector);
/////////////////////////////////
-
std::string intToString(int num);
-
std::vector<std::string> GetLstNameThingsStatic();
-
void SaveThingName(FILE* pFile, FILE *pFileData, std::string name );
-
std::vector<std::string> GetLstNameThings();
-
bool IsPartOfStaticList(std::string keyName );
-
void deleteCModel(std::string theKeyName);
-
void removeAllOutlines();
-
//void setInstance(theInstant);
-
std::vector<NameWrapper *> getActualInstantOutlines();
-
int getNamesWrappingSize();
-
std::string getNameWrapping(int i);
-
void setInstant(Instant* theInstant);
void setInstant(std::vector<int> vectInstant);
std::string createCopyContourOf ( std::string anExistingKName, std::vector<int> &instantNoTouchData);
-
Instant * getCurrentInstant();
-
manualBaseModel* getOutlineByKeyName(std::string cloneName);
-
bool onRedo(std::string& filename);
-
bool onUndo(std::string& filename);
-
bool onUndoSaveFile(std::string& filename);
-
std::string saveState();
-
void changeContourOfManager(std::string keyName, Instant *instant);
-
void resetAppend();
-
std::string onSpreadAdd( std::vector<double> *vecX, std::vector<double> *vecY, std::vector<double> *vecZ, std::vector<int> instants);
-
void getMaxMinZ(double *minZ,double *maxZ);
-
manualBaseModel* GetPoints(int z,int type, std::vector<double>* vecCtrlPointX,std::vector<double>* vecCtrlPointY,std::vector<double>* vecCtrlPointZ, std::string& theName,int typeofcontour, std::vector<int> tempVector);
-
//
// Method which creates the model associated with the type in parameter. The possible contour types are:
// 0-spline
// @param typeContour - int
// @return manualBaseModel - Model created based on the type
manualBaseModel* factoryManualContourModel(int typeContour);
-
void CalculeSplinePropagation();
-
std::vector<std::string> getOutlinesNameAtInstant(std::vector<int> tempvector);
-
std::vector<ContourThing**> getOutlinesAtInstant(Instant* instant );
-
std::vector<manualBaseModel*> ExploseEachModel( std::vector<manualBaseModel*> lstManConMod );
-
-
void getConceptsInformation(std::vector<std::string>& conceptNameVect, std::vector<int>& conceptSizeVect);
-
vtkImageData* getImageAtInstant(std::vector<int> inst);
//------------------------------------------------------------------------------------------------------------
void setCurrentFileName(std::string filenam);
std::string getCurrentFileName();
-
std::string parseOsirixFile(std::string filename);
private:
//------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------
std::vector<vtkImageData*> vectimages;
std::vector<std::vector<double> > vectimagesSpacing;
-
ImageSourceThing *imageSource;
-
//Instant * _actualInstant;
//Temporary attribute should be removed
OutlineModelManager *modelManager;
-
std::string filename;
-
int inredo;
int inundo;
int _currentIndex;
std::string stundoredo;
std::string _datadir;
-
ContourPropagation *_contourPropagation;
-
OutlineModelManager *getOutlineModelManager();
};
#endif