From: Eduardo DAVILA Date: Thu, 23 Dec 2021 15:53:45 +0000 (+0100) Subject: #3478 ContourExtractData X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=1ca79dd44497ce974fe1d6cae0f912c511725705;p=creaMaracasVisu.git #3478 ContourExtractData --- diff --git a/bbtk/src/bbcreaMaracasVisuContourControlPoints.cxx b/bbtk/src/bbcreaMaracasVisuContourControlPoints.cxx index 3fd817c..8e79b7a 100644 --- a/bbtk/src/bbcreaMaracasVisuContourControlPoints.cxx +++ b/bbtk/src/bbcreaMaracasVisuContourControlPoints.cxx @@ -4,7 +4,6 @@ #include "bbcreaMaracasVisuContourControlPoints.h" #include "bbcreaMaracasVisuPackage.h" - namespace bbcreaMaracasVisu { @@ -37,39 +36,29 @@ void ContourControlPoints::Process() { if (_manContourControl_1==NULL) { - _manContourControl_1 = new manualContourControler(); + _manContourControl_1 = new manualContourControler(); _mContourModel_1 = new manualContourModel(); _mViewContour_1 = new manualViewContour(); - _mContourModel_1 -> SetCloseContour( bbGetInputOpenClose() ); - _mViewContour_1->SetModel( _mContourModel_1 ); _mViewContour_1->SetWxVtkBaseView( bbGetInputwxVtkBaseView() ); _mViewContour_1->SetRange( 2 ); _mViewContour_1->SetZ( 1000 ); - //JSTG 18-06-07 _mContourModel_1->SetNumberOfPointsSpline(100); - - //EED 3 oct 2006 double spc[3]; bbGetInputwxVtkBaseView()->GetSpacing(spc); _mViewContour_1->SetSpacing(spc); - - //EED 3 oct 2006 _mViewContour_1->SetColorNormalContour(0, 0, 1); _mViewContour_1->SetColorEditContour(0.5, 0.5, 0.5); - - _manContourControl_1->SetModelView( _mContourModel_1 , _mViewContour_1 ); ((vtkInteractorStyleBaseView*)bbGetInputwxVtkBaseView()->GetInteractorStyleBaseView())->AddInteractorStyleMaracas( _manContourControl_1 ); _manContourControl_1->CreateNewManualContour(); _manContourControl_1->SetActive( bbGetInputActive() ); _mViewContour_1->RefreshContour(); } // _manContourControl_1 - _mContourModel_1 -> SetCloseContour( bbGetInputOpenClose() ); _manContourControl_1->SetActive( bbGetInputActive() ); if ( bbGetInputVisible() == true) @@ -78,10 +67,11 @@ void ContourControlPoints::Process() } else { _mViewContour_1->RemoveCompleteContourActor (); } + double width = bbGetInputWidthLine(); + _mViewContour_1->SetWidthLine( width ); + _mViewContour_1->SetRange( 2*width ); _mViewContour_1->RefreshContour(); - bbSetOutputManualBaseModel( _mContourModel_1 ); - } // wxVtkBaseView } @@ -97,7 +87,8 @@ void ContourControlPoints::bbUserSetDefaultValues() bbSetInputVisible(true); bbSetInputOpenClose(true); bbSetInputwxVtkBaseView(NULL); - _manContourControl_1 = NULL; + bbSetInputWidthLine(1); + _manContourControl_1 = NULL; _mContourModel_1 = NULL; _mViewContour_1 = NULL; diff --git a/bbtk/src/bbcreaMaracasVisuContourControlPoints.h b/bbtk/src/bbcreaMaracasVisuContourControlPoints.h index 1f1dd37..5d62a24 100644 --- a/bbtk/src/bbcreaMaracasVisuContourControlPoints.h +++ b/bbtk/src/bbcreaMaracasVisuContourControlPoints.h @@ -23,14 +23,15 @@ class bbcreaMaracasVisu_EXPORT ContourControlPoints //===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) //===== - BBTK_DECLARE_INPUT(Active,bool); - BBTK_DECLARE_INPUT(Visible,bool); - BBTK_DECLARE_INPUT(Type,int); - BBTK_DECLARE_INPUT(OpenClose,bool); - BBTK_DECLARE_INPUT(wxVtkBaseView,wxVtkBaseView*); - BBTK_DECLARE_OUTPUT(ManualBaseModel,manualBaseModel*); - BBTK_PROCESS(Process); - void Process(); + BBTK_DECLARE_INPUT(Active,bool); + BBTK_DECLARE_INPUT(Visible,bool); + BBTK_DECLARE_INPUT(Type,int); + BBTK_DECLARE_INPUT(OpenClose,bool); + BBTK_DECLARE_INPUT(wxVtkBaseView,wxVtkBaseView*); + BBTK_DECLARE_INPUT(WidthLine,double); + BBTK_DECLARE_OUTPUT(ManualBaseModel,manualBaseModel*); + BBTK_PROCESS(Process); + void Process(); manualContourControler *_manContourControl_1; manualContourModel *_mContourModel_1; @@ -43,17 +44,18 @@ class bbcreaMaracasVisu_EXPORT ContourControlPoints }; BBTK_BEGIN_DESCRIBE_BLACK_BOX(ContourControlPoints,bbtk::AtomicBlackBox); - BBTK_NAME("ContourControlPoints"); - BBTK_AUTHOR("Info-Dev Creatis"); - BBTK_DESCRIPTION("No Description."); - BBTK_CATEGORY("empty"); + BBTK_NAME("ContourControlPoints"); + BBTK_AUTHOR("Info-Dev Creatis"); + BBTK_DESCRIPTION("No Description."); + BBTK_CATEGORY("empty"); - BBTK_INPUT(ContourControlPoints,Active,"Active (default false) ",bool,""); - BBTK_INPUT(ContourControlPoints,Type,"(0 Default) 0=Spline, ... .",int,""); - BBTK_INPUT(ContourControlPoints,OpenClose,"Open=true or Close=false contour (default false)",bool,""); - BBTK_INPUT(ContourControlPoints,Visible,"Visible (default true)",bool,""); - BBTK_INPUT(ContourControlPoints,wxVtkBaseView,"wxVtkBaseView",wxVtkBaseView*,""); - BBTK_OUTPUT(ContourControlPoints,ManualBaseModel,"manualBaseModel",manualBaseModel*,""); + BBTK_INPUT(ContourControlPoints,Active,"Active (default false) ",bool,""); + BBTK_INPUT(ContourControlPoints,Type,"(0 Default) 0=Spline, ... .",int,""); + BBTK_INPUT(ContourControlPoints,OpenClose,"Open=true or Close=false contour (default false)",bool,""); + BBTK_INPUT(ContourControlPoints,Visible,"Visible (default true)",bool,""); + BBTK_INPUT(ContourControlPoints,wxVtkBaseView,"wxVtkBaseView",wxVtkBaseView*,""); + BBTK_INPUT(ContourControlPoints,WidthLine,"(1 Default) Line and Control points Width",double,""); + BBTK_OUTPUT(ContourControlPoints,ManualBaseModel,"manualBaseModel",manualBaseModel*,""); BBTK_END_DESCRIBE_BLACK_BOX(ContourControlPoints); //===== diff --git a/bbtk/src/bbcreaMaracasVisuContourExtractDataBox.cxx b/bbtk/src/bbcreaMaracasVisuContourExtractDataBox.cxx new file mode 100644 index 0000000..f4ca2df --- /dev/null +++ b/bbtk/src/bbcreaMaracasVisuContourExtractDataBox.cxx @@ -0,0 +1,178 @@ +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +#include "bbcreaMaracasVisuContourExtractDataBox.h" +#include "bbcreaMaracasVisuPackage.h" + +#include "ContourExtractData.h" + + + + +namespace bbcreaMaracasVisu +{ + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ContourExtractDataBox) +BBTK_BLACK_BOX_IMPLEMENTATION(ContourExtractDataBox,bbtk::AtomicBlackBox); +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +void ContourExtractDataBox::Process() +{ + +// THE MAIN PROCESSING METHOD BODY +// Here we simply set the input 'In' value to the output 'Out' +// And print out the output value +// INPUT/OUTPUT ACCESSORS ARE OF THE FORM : +// void bbSet{Input|Output}NAME(const TYPE&) +// const TYPE& bbGet{Input|Output}NAME() const +// Where : +// * NAME is the name of the input/output +// (the one provided in the attribute 'name' of the tag 'input') +// * TYPE is the C++ type of the input/output +// (the one provided in the attribute 'type' of the tag 'input') + // bbSetOutputOut( bbGetInputIn() ); + // std::cout << "Output value = " <SetImage( bbGetInputReferenceImage() ); + if (bbGetInputRange().size()==2) + { + contourextractdata->SetScalarRange( bbGetInputRange()[0] , bbGetInputRange()[1] ); + } // if Range + + // _contourextractdata ->SetTypeOperation( typeContourGroup % 3 ); + contourextractdata->InitVolumeStatistics(); + std::vector lstManConMod; + lstManConMod.push_back( bbGetInputManualBaseModel() ); + contourextractdata->SetLstManualContourModel( lstManConMod ); + + contourextractdata->ResetImageResult( bbGetInputZ() ); + // for ( z=minZ ; z<=maxZ ; z++ ) + // { + contourextractdata->SetZtoBeAnalys( bbGetInputZ() ); + contourextractdata->CalculateImageResult(); + // } // for + + + std::vector LstValue; + std::vector LstValuePosX; + std::vector LstValuePosY; + std::vector LstValuePosZ; + int numberOfPixels=0; + LstValue.clear(); + LstValuePosX.clear(); + LstValuePosY.clear(); + LstValuePosZ.clear(); + + contourextractdata->GetValuesInsideCrown( &numberOfPixels, + &LstValue, + &LstValuePosX, + &LstValuePosY, + &LstValuePosZ); + + // int grayRangeMin; + // int grayRangeMax; + + int resultSize; + int resultGrayRangeCount; + double resultMin; + double resultMax; + double resultAverage; + double resultStandarDeviation; + + // resultSize=numberOfPixels; + + if (bbGetInputRange().size()==2) + { + // Statistics of each slice. + contourextractdata->Statistics( &LstValue, + bbGetInputRange()[0], + bbGetInputRange()[1], + &resultGrayRangeCount, + &resultSize, + &resultMin, + &resultMax, + &resultAverage, + &resultStandarDeviation); + bbSetOutputResultGrayRangeCount( (double)resultGrayRangeCount ); + bbSetOutputResultSize( (double)resultSize ); + bbSetOutputResultMin( resultMin ); + bbSetOutputResultMax( resultMax ); + bbSetOutputResultAverage( resultAverage ); + bbSetOutputResultStandarDeviation( resultStandarDeviation ); + } // if Range + + vtkImageData *imageValues = contourextractdata->GetVtkImageValueResult(); + vtkImageData *imageMask = contourextractdata->GetVtkImageMaskResult(); + bbSetOutputValues( imageValues ); + bbSetOutputMask( imageMask ); + bbSetOutputNumberOfPixels( (double)numberOfPixels ); + bbSetOutputLstValue( LstValue ); + bbSetOutputLstValuePosX( LstValuePosX ); + bbSetOutputLstValuePosX( LstValuePosY ); + bbSetOutputLstValuePosX( LstValuePosZ ); + + // int vol_rCountRange; + // int vol_rsize; + // double vol_minValue; + // double vol_maxValue; + // double vol_average; + // double vol_standardeviation; + + // _contourextractdata->GetVolumeStatistics(&vol_rCountRange, &vol_rsize, + // &vol_minValue, &vol_maxValue, + // &vol_average, &vol_standardeviation); +} + +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +void ContourExtractDataBox::bbUserSetDefaultValues() +{ +// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX +// Here we initialize the input 'In' to 0 + bbSetInputManualBaseModel(NULL); + bbSetInputReferenceImage(NULL); + bbSetInputZ(0); + std::vector rangeMinMax; + rangeMinMax.push_back(-10000); + rangeMinMax.push_back(10000); + bbSetInputRange(rangeMinMax); + bbSetOutputMask(NULL); + bbSetOutputValues(NULL); + + bbSetOutputResultGrayRangeCount( -1 ); + bbSetOutputResultSize( -1 ); + bbSetOutputResultMin( -1 ); + bbSetOutputResultMax( -1 ); + bbSetOutputResultAverage( -1 ); + bbSetOutputResultStandarDeviation( -1 ); + +} + +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +void ContourExtractDataBox::bbUserInitializeProcessing() +{ +// THE INITIALIZATION METHOD BODY : +// Here does nothing +// but this is where you should allocate the internal/output pointers +// if any +} + +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +void ContourExtractDataBox::bbUserFinalizeProcessing() +{ +// THE FINALIZATION METHOD BODY : +// Here does nothing +// but this is where you should desallocate the internal/output pointers +// if any +} + +}// EO namespace bbcreaMaracasVisu + + diff --git a/bbtk/src/bbcreaMaracasVisuContourExtractDataBox.h b/bbtk/src/bbcreaMaracasVisuContourExtractDataBox.h new file mode 100644 index 0000000..618be6e --- /dev/null +++ b/bbtk/src/bbcreaMaracasVisuContourExtractDataBox.h @@ -0,0 +1,85 @@ +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +#ifndef __bbcreaMaracasVisuContourExtractDataBox_h_INCLUDED__ +#define __bbcreaMaracasVisuContourExtractDataBox_h_INCLUDED__ + +#include "bbcreaMaracasVisu_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "iostream" + +#include +#include "manualContourModel.h" + + +namespace bbcreaMaracasVisu +{ + +class bbcreaMaracasVisu_EXPORT ContourExtractDataBox + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(ContourExtractDataBox,bbtk::AtomicBlackBox); +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== + BBTK_DECLARE_INPUT(ReferenceImage , vtkImageData*); + BBTK_DECLARE_INPUT(ManualBaseModel , manualBaseModel*); + BBTK_DECLARE_INPUT(Z , int); + BBTK_DECLARE_INPUT(Range , std::vector); + BBTK_DECLARE_OUTPUT(Mask , vtkImageData*); + BBTK_DECLARE_OUTPUT(Values , vtkImageData*); + + BBTK_DECLARE_OUTPUT(NumberOfPixels , double ); + BBTK_DECLARE_OUTPUT(LstValue , std::vector ); + BBTK_DECLARE_OUTPUT(LstValuePosX , std::vector ); + BBTK_DECLARE_OUTPUT(LstValuePosY , std::vector ); + BBTK_DECLARE_OUTPUT(LstValuePosZ , std::vector ); + + BBTK_DECLARE_OUTPUT(ResultGrayRangeCount , double ); + BBTK_DECLARE_OUTPUT(ResultSize , double ); + BBTK_DECLARE_OUTPUT(ResultMin , double ); + BBTK_DECLARE_OUTPUT(ResultMax , double ); + BBTK_DECLARE_OUTPUT(ResultAverage , double ); + BBTK_DECLARE_OUTPUT(ResultStandarDeviation , double ); + BBTK_PROCESS(Process); + void Process(); +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +}; + +BBTK_BEGIN_DESCRIBE_BLACK_BOX(ContourExtractDataBox,bbtk::AtomicBlackBox); + BBTK_NAME("ContourExtractDataBox"); + BBTK_AUTHOR("Info-Dev"); + BBTK_DESCRIPTION("No Description."); + BBTK_CATEGORY("empty"); + BBTK_INPUT(ContourExtractDataBox,ReferenceImage,"Reference Image",vtkImageData*,""); + BBTK_INPUT(ContourExtractDataBox,ManualBaseModel,"ManualBaseModel",manualBaseModel*,""); + BBTK_INPUT(ContourExtractDataBox,Z,"(0 default) slice Z to be extracted",int,""); + BBTK_INPUT(ContourExtractDataBox,Range,"([-10000 10000] Gray level range [min max]",std::vector,""); + + BBTK_OUTPUT(ContourExtractDataBox,Mask,"Mask image",vtkImageData*,""); + BBTK_OUTPUT(ContourExtractDataBox,Values,"Values image",vtkImageData*,""); + BBTK_OUTPUT(ContourExtractDataBox,NumberOfPixels,"Number of pixels (this value can be big)",double,""); + BBTK_OUTPUT(ContourExtractDataBox,LstValue,"List of values inside the mask and in the range",std::vector,""); + BBTK_OUTPUT(ContourExtractDataBox,LstValuePosX,"List of px of the values inside the mask and in the range",std::vector,""); + BBTK_OUTPUT(ContourExtractDataBox,LstValuePosY,"List of py of the values inside the mask and in the range",std::vector,""); + BBTK_OUTPUT(ContourExtractDataBox,LstValuePosZ,"List of pz of the values inside the mask and in the range",std::vector,""); + + BBTK_OUTPUT(ContourExtractDataBox,ResultGrayRangeCount,"ResultGrayRangeCount",double,""); + BBTK_OUTPUT(ContourExtractDataBox,ResultSize,"ResultSize",double,""); + BBTK_OUTPUT(ContourExtractDataBox,ResultMin,"ResultMin",double,""); + BBTK_OUTPUT(ContourExtractDataBox,ResultMax,"ResultMax",double,""); + BBTK_OUTPUT(ContourExtractDataBox,ResultAverage,"ResultAverage",double,""); + BBTK_OUTPUT(ContourExtractDataBox,ResultStandarDeviation,"ResultStandarDeviation",double,""); + +BBTK_END_DESCRIBE_BLACK_BOX(ContourExtractDataBox); +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +} +// EO namespace bbcreaMaracasVisu + +#endif // __bbcreaMaracasVisuContourExtractDataBox_h_INCLUDED__ + diff --git a/lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.cxx b/lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.cxx index da3d19b..948e37d 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.cxx @@ -67,16 +67,14 @@ void ContourExtractData::SetImage( vtkImageData* imagedata) //---------------------------------------------------------------------- void ContourExtractData::SetZtoBeAnalys( int z ) { - this->zImage = z; + this->zImage = z; } //------------------------------------------------------------------------ void ContourExtractData::SetLstManualContourModel( std::vector lstManConMod) { - this->lstManConMod = lstManConMod; + this->lstManConMod = lstManConMod; } - - //------------------------------------------------------------------------ void ContourExtractData::GetMinMaxPoint(int *minPoint, int *maxPoint, diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewPoint.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewPoint.h index 84e2b95..7da674e 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewPoint.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewPoint.h @@ -58,8 +58,8 @@ public: manualViewPoint(wxVtkBaseView *wxvtkbaseview); virtual ~manualViewPoint(); - virtual manualViewPoint * Clone(); - void CopyAttributesTo( manualViewPoint *cloneObject ); + virtual manualViewPoint * Clone(); + void CopyAttributesTo( manualViewPoint *cloneObject ); void SetSelected(bool selected); void SetPosibleSelected(bool posibleSelected); bool GetSelected();