]> Creatis software - creaMaracasVisu.git/commitdiff
#3478 ContourExtractData
authorEduardo DAVILA <davila@creatis.insa-lyon.fr>
Thu, 23 Dec 2021 15:53:45 +0000 (16:53 +0100)
committerEduardo DAVILA <davila@creatis.insa-lyon.fr>
Thu, 23 Dec 2021 15:53:45 +0000 (16:53 +0100)
bbtk/src/bbcreaMaracasVisuContourControlPoints.cxx
bbtk/src/bbcreaMaracasVisuContourControlPoints.h
bbtk/src/bbcreaMaracasVisuContourExtractDataBox.cxx [new file with mode: 0644]
bbtk/src/bbcreaMaracasVisuContourExtractDataBox.h [new file with mode: 0644]
lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewPoint.h

index 3fd817c778e0ca0ec86e9a657207cf1759aaaf75..8e79b7a100a2264c125d7577f28b8f2d945eea6e 100644 (file)
@@ -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;
   
index 1f1dd37ff3a6fe51f66ff2052c2b75f6d498f171..5d62a24fff9e2c5f7ff8197e486e5fe7cc09c02a 100644 (file)
@@ -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 (file)
index 0000000..f4ca2df
--- /dev/null
@@ -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 = " <<bbGetOutputOut() << std::endl;
+
+        ContourExtractData *contourextractdata = new ContourExtractData(true);
+        contourextractdata->SetImage( bbGetInputReferenceImage() );
+        if (bbGetInputRange().size()==2)
+        {
+            contourextractdata->SetScalarRange( bbGetInputRange()[0] , bbGetInputRange()[1] );
+        } // if Range
+    
+     //   _contourextractdata ->SetTypeOperation( typeContourGroup % 3 );
+        contourextractdata->InitVolumeStatistics();
+        std::vector<manualBaseModel*> 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<double> LstValue;
+        std::vector<double> LstValuePosX;
+        std::vector<double> LstValuePosY;
+        std::vector<double> 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<double> 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 (file)
index 0000000..618be6e
--- /dev/null
@@ -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 <vtkImageData.h>
+#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<double>);
+    BBTK_DECLARE_OUTPUT(Mask                    , vtkImageData*);
+    BBTK_DECLARE_OUTPUT(Values                  , vtkImageData*);
+    
+    BBTK_DECLARE_OUTPUT(NumberOfPixels          , double );
+    BBTK_DECLARE_OUTPUT(LstValue                , std::vector<double> );
+    BBTK_DECLARE_OUTPUT(LstValuePosX            , std::vector<double> );
+    BBTK_DECLARE_OUTPUT(LstValuePosY            , std::vector<double> );
+    BBTK_DECLARE_OUTPUT(LstValuePosZ            , std::vector<double> );
+
+    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<double>,"");
+
+    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<double>,"");
+    BBTK_OUTPUT(ContourExtractDataBox,LstValuePosX,"List of px of the values inside the mask and in the range",std::vector<double>,"");
+    BBTK_OUTPUT(ContourExtractDataBox,LstValuePosY,"List of py of the values inside the mask and in the range",std::vector<double>,"");
+    BBTK_OUTPUT(ContourExtractDataBox,LstValuePosZ,"List of pz of the values inside the mask and in the range",std::vector<double>,"");
+
+    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__
+
index da3d19b816e7aab56e211799800c3660d91ba27c..948e37d08519851ba0c749085951f265831ae475 100644 (file)
@@ -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<manualBaseModel*> lstManConMod)
 {
-       this->lstManConMod = lstManConMod;
+       this->lstManConMod  = lstManConMod;
 }
-
-
 //------------------------------------------------------------------------
 void ContourExtractData::GetMinMaxPoint(int *minPoint, 
                                                                                int *maxPoint, 
index 84e2b95e6d2e71780d51e460cc0e5e8751f6f5cd..7da674e1c0a0249a056d9f32d02c09538864809e 100644 (file)
@@ -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();