]> Creatis software - creaMaracasVisu.git/commitdiff
#3583 Bug ReadCreaContourFile order points vtk9itk5wx3-macos
authoreduardo.davila@creatis.insa-lyon.fr <eduardo.davila@creatis.insa-lyon.fr>
Sun, 19 Oct 2025 16:26:53 +0000 (18:26 +0200)
committereduardo.davila@creatis.insa-lyon.fr <eduardo.davila@creatis.insa-lyon.fr>
Sun, 19 Oct 2025 16:26:53 +0000 (18:26 +0200)
bbtk/src/bbcreaMaracasVisuReadCreaContourFile.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageView.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageView.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageView.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualBaseModel.cpp
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourModel.cpp

index a22888e7c6a99bb499f4f5d7e3e08ba6525d7d6b..6aea2be219315664237a453066141d07bd70dd3a 100644 (file)
@@ -11,6 +11,10 @@ BBTK_BLACK_BOX_IMPLEMENTATION(ReadCreaContourFile,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 ReadCreaContourFile::Process()
 {
 
@@ -33,7 +37,7 @@ void ReadCreaContourFile::Process()
     std::vector<double> LstX;
     std::vector<double> LstY;
     std::vector<double> LstZ;
-    std::vector<int>     LstIndexs;
+    std::vector<int>    LstIndexs;
 
        if (bbGetInputFileNameRoi().compare("")==0)
        {
@@ -106,7 +110,7 @@ void ReadCreaContourFile::Process()
                                                                LstY.push_back(zz);
                                                                LstZ.push_back( (y*(-1)) + (dimY-1) );
                                                        } // if FromDirection
-                                               } // iControlPoint
+                                               } // for iControlPoint
                                        } // TypeModel
                                        fscanf(ff,"%s",tmp);  // TypeView
                                        fscanf(ff,"%s",tmp);  // 
@@ -118,12 +122,178 @@ void ReadCreaContourFile::Process()
                        } // if --CreaContour--
                } // if ff
        } // if FileNameRoi
+        
+    bbSetOutputLstX( LstX );
+    bbSetOutputLstY( LstY );
+    bbSetOutputLstZ( LstZ );
+    bbSetOutputLstIndexs( LstIndexs );
+}
+
+ */
+
+void ReadCreaContourFile::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;
+    
+    std::map<int,  std::vector<double> >  mapX;
+    std::map<int,  std::vector<double> >  mapY;
+    std::map<int,  std::vector<double> >  mapZ;
+
+    if (bbGetInputFileNameRoi().compare("")==0)
+    {
+        printf("EED Warnning!  ReadCreaContourFile::Process  FileNameRoi  EMPTY\n");
+    }  else {
+        char tmp[255];
+        FILE *ff= fopen(bbGetInputFileNameRoi().c_str(),"r");
+        if (ff==NULL)
+        {
+            printf("EED Warnning!  ReadCreaContourFile::Process  Wrong file %s\n", bbGetInputFileNameRoi().c_str() );
+        } else {
+            fscanf(ff,"%s",tmp);  // --CreaContour--
+            std::string tmpStr(tmp);
+            if (tmpStr.compare("--CreaContour--")==0 )
+            {
+                int iContour,iControlPoint;
+                int dimX, dimY,dimZ;
+                int NumberOfContours;
+                double x,y,z,zz;
+                int TypeModel;
+                int NumberOfControlPoints;
+                fscanf(ff,"%s",tmp);      // version
+                fscanf(ff,"%s",tmp);      //
+                fscanf(ff,"%s",tmp);      // ImageDimensions
+                fscanf(ff,"%d",&dimX);  //
+                fscanf(ff,"%d",&dimY);  //
+                fscanf(ff,"%d",&dimZ);  //
+                fscanf(ff,"%s",tmp);      // ImageSpacing
+                fscanf(ff,"%s",tmp);      //
+                fscanf(ff,"%s",tmp);      //
+                fscanf(ff,"%s",tmp);      //
+                fscanf(ff,"%s",tmp);      // NumberOfContours
+                fscanf(ff,"%d",&NumberOfContours);  //
+                for (iContour=0 ; iContour<NumberOfContours ; iContour++)
+                {
+                    std::vector<double> LstX;
+                    std::vector<double> LstY;
+                    std::vector<double> LstZ;
+
+                    fscanf(ff,"%s",tmp);  // Instant
+                    fscanf(ff,"%s",tmp);  //
+                    fscanf(ff,"%s",tmp);  zz=atof(tmp); // zz
+                    fscanf(ff,"%s",tmp);  //
+                    fscanf(ff,"%s",tmp);  //
+                    fscanf(ff,"%s",tmp);  //
+                    fscanf(ff,"%s",tmp);  //
+                    fscanf(ff,"%s",tmp);  // TypeModel
+                    fscanf(ff,"%d",&TypeModel);  //
+                    if ((TypeModel==1) || (TypeModel==6)  )
+                    {
+                        fscanf(ff,"%s",tmp);  // NumberOfControlPoints
+                        fscanf(ff,"%d",&NumberOfControlPoints);  //
+//                        LstIndexs.push_back( NumberOfControlPoints );
+                        for (iControlPoint=0 ;  iControlPoint<NumberOfControlPoints ; iControlPoint++)
+                        {
+                            fscanf(ff,"%s",tmp);  x=atof(tmp); // x
+                            fscanf(ff,"%s",tmp);  y=atof(tmp); // y
+                            fscanf(ff,"%s",tmp);  z=atof(tmp); // z
+                            if (bbGetInputFromDirection()==0)  // XY
+                            {
+                                LstX.push_back(x);
+                                LstY.push_back(y);
+                                LstZ.push_back(zz);
+                            } // if FromDirection
+                            if (bbGetInputFromDirection()==1)  // YZ
+                            {
+                                LstX.push_back(zz);
+                                LstY.push_back(x);
+                                LstZ.push_back(y);
+                            } // if FromDirection
+                            if (bbGetInputFromDirection()==2)  // XZ
+                            {
+                                LstX.push_back(x);
+                                LstY.push_back(zz);
+                                LstZ.push_back( (y*(-1)) + (dimY-1) );
+                            } // if FromDirection
+                        } // for iControlPoint
+                        mapX[zz] = LstX;
+                        mapY[zz] = LstY;
+                        mapZ[zz] = LstZ;
+                    } // TypeModel
+                    fscanf(ff,"%s",tmp);  // TypeView
+                    fscanf(ff,"%s",tmp);  //
+
+                } // for i  NumberOfContours
+                fclose(ff);
+            } else {
+                        printf("EED Warnning!  ReadCreaContourFile::Process  %s is not a creaContour .roi file\n",bbGetInputFileNameRoi().c_str() );
+            } // if --CreaContour--
+        } // if ff
+    } // if FileNameRoi
+    
+    std::vector<double> LstX;
+    std::vector<double> LstY;
+    std::vector<double> LstZ;
+    std::vector<int>    LstIndexs;
+
+    // Order block by zz
+    for( std::map<int, std::vector<double> >::iterator iter = mapX.begin();
+         iter != mapX.end();
+         ++iter )
+    {
+        int i,size = iter->second.size();
+        LstIndexs.push_back( size );
+        for (i=0;i<size;i++)
+        {
+            LstX.push_back( iter->second[i] );
+        } // for i
+    } // for mapX
+
+    for( std::map<int, std::vector<double> >::iterator iter = mapY.begin();
+         iter != mapY.end();
+         ++iter )
+    {
+        int i,size = iter->second.size();
+        for (i=0;i<size;i++)
+        {
+            LstY.push_back( iter->second[i] );
+        } // for i
+    } // for mapY
+
+    for( std::map<int, std::vector<double> >::iterator iter = mapZ.begin();
+         iter != mapZ.end();
+         ++iter )
+    {
+        int i,size = iter->second.size();
+        for (i=0;i<size;i++)
+        {
+            LstZ.push_back( iter->second[i] );
+        } // for i
+    } // for mapZ
+    
     bbSetOutputLstX( LstX );
     bbSetOutputLstY( LstY );
     bbSetOutputLstZ( LstZ );
     bbSetOutputLstIndexs( LstIndexs );
 }
 
 //=====
 // 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)
 //===== 
index af5bf5728820d72348cca8735f42c3ff174ae373..1980892a1e0b82a99929bb91d7caef1e592f3304 100644 (file)
@@ -373,9 +373,8 @@ void ColorLayerImageView::ConfigLookupTable()  // virtual
   
   thresholdTable->SetAlphaRange( 0,1 );
   thresholdTable->SetValueRange( 0,1 );
-
   thresholdTable->SetSaturationRange( 0,0 ); 
-  thresholdTable->SetRampToLinear( );
+    thresholdTable->SetRampToLinear( );
 
   maxColorsThresholdTable = 1000;
   thresholdTable->SetNumberOfTableValues( maxColorsThresholdTable+1 );
@@ -428,9 +427,8 @@ void ColorLayerImageView::ConfigLookupTable()  // virtual
                                end     = GrayLevel_TO_colorTableIndex( GetGreyLevelBoundaries(iColor+1) );  
                        t1              = _transparence_level_boundary[iColor];
                                t2              = _transparence_level_boundary[iColor+1];
-//printf("EED ColorLayerImageView::ConfigLookupTable   Make something with transparence \n");
                                FillColorTable( start,end, r1,g1,b1, r2,g2,b2, t1,t2 );
-                       }// for 
+                       }// for
                } //if                          
   } //  End Of if (!_color_type)
     
index eef06161e20d27f7da595bb953b58bfec5eecd22..757c0bbf523652fe75867b817ac668c933311861 100644 (file)
@@ -59,10 +59,8 @@ class  ColorLayerImageView : public LayerImageBase
           */
          void SetBaseColors(std::vector<double> & base_color);
 
-
          void SetBaseTransparence(std::vector<double> & base_transparence);
 
-
          /** 
           * \brief  Returns the base color for a given index (first coordinate of the first color being 1, second coordinate of the first color being 2, etc.).
           *
@@ -95,15 +93,9 @@ class  ColorLayerImageView : public LayerImageBase
           * \return The number of base colors.
           */
          int GetBaseColorNb();
-
-
-               void    FillColorTable(int start, int end, double r1, double g1, double b1, double r2, double g2, double b2, double t1, double t2);
-
-               int     GrayLevel_TO_colorTableIndex( double VALUE );
-
-
+      void     FillColorTable(int start, int end, double r1, double g1, double b1, double r2, double g2, double b2, double t1, double t2);
+      int      GrayLevel_TO_colorTableIndex( double VALUE );
   private:
-
          int   _x2, _y2, _z2;
          bool  _fix_dynamic;
          void  SetDefaultGreyLevelBoundary();
@@ -111,8 +103,6 @@ class  ColorLayerImageView : public LayerImageBase
          virtual void ConfigLookupTable();
          int   maxColorsThresholdTable;
 
-
-
          //! Base colors for the overlaid image.
          std::vector<double> _base_color;
          //! Grey level boundaries.
index 37df70cfcb1791b9776818fa121983a408d4fb1b..f2eb66bfe79b4cf291bfbc1854add488914d1269 100644 (file)
@@ -446,12 +446,12 @@ void ColorLayerImageViewPanel::onReadImage(wxCommandEvent& event)
 //----------------------------------------------------------------------------
 void ColorLayerImageViewPanel::onThresholdChange(wxCommandEvent& event)
 {
-               if (_thresholdGo)
-               {
-                GetColorLayerImageViewManager()->onThresholdChange();
-                        RefreshView();
-               //std::cout<< "Valor Min: " << minVal << " & Valor Max: " << maxVal  << std::endl;
-          } // _thresholdGo
+    if (_thresholdGo)
+    {
+        GetColorLayerImageViewManager()->onThresholdChange();
+               RefreshView();
+        //std::cout<< "Valor Min: " << minVal << " & Valor Max: " << maxVal  << std::endl;
+    } // _thresholdGo
 }
 
 //----------------------------------------------------------------------------
@@ -566,6 +566,5 @@ void ColorLayerImageViewPanel::SetActive(bool active)
     GetColorLayerImageViewManager()->SetActive( _active );
 }
 
-
 // EOF
 
index 7ec645cf3e01faf470a06957e79682aad98a640d..a8953f0c990c525b517f242164bd2a5d89c16ede 100644 (file)
@@ -78,14 +78,10 @@ private:
        LayerImageBase* _layerimagebase;
 };
 
-
-
 //---------------------------------------------------------------------------------------------
 //---------------------------------------------------------------------------------------------
 //---------------------------------------------------------------------------------------------
 
-
-
 LayerImageBase::LayerImageBase()
 {
        _actorPresent                   =       false;
@@ -598,7 +594,7 @@ void LayerImageBase::onThreshold()
                _thresholdActor->SetInputData( _thresholdMapper->GetOutput() );
 #endif
 
-               _thresholdActor->SetOpacity(_opacity);
+               _thresholdActor->SetOpacity(_opacity*2);
                _scalarbarActor->SetLookupTable( _thresholdTable );
 //             _scalarbarActor->SetLookupTable( _thresholdMapper->GetLookupTable() );
                _scalarbarActor->SetTitle("Value");
@@ -640,7 +636,7 @@ void LayerImageBase::onThresholdChangeOpacity (int opacity)
                _thresholdActor->SetOpacity(opacity/100.0);
        }
 // EED 2017-12-17
-       _opacity = (double)opacity/100.0;
+       _opacity = (double)opacity/100.0;    
 }
 
 //----------------------------------------------------------------------------
index 0ab4c87e8ac3ac985eb3566b10f14905967a4724..e1d0cd57a99dcd506449376de69da9647454e922 100644 (file)
@@ -85,7 +85,7 @@ void ThresholdImageView::ConfigLookupTable()  // virtual
        thresholdTable->SetNumberOfTableValues( (maxTot-minTot) );
        thresholdTable->SetAlphaRange(0, 1);
        thresholdTable->SetValueRange(0, 1);
-       thresholdTable->SetSaturationRange(0, 0); 
+       thresholdTable->SetSaturationRange(0, 1); 
        thresholdTable->SetRampToLinear( );
 
        //Assign a fake color for the upper image, and set the white as transparent
index 647c6f4f701097bbd16fa1a1b432e29d41826565..fa9360b417c56597917bbf8af58ca63d80dc076e 100644 (file)
@@ -163,7 +163,6 @@ int  manualBaseModel::GetIdPoint(double x, double y, double z, int i_range,int t
                xx=mp->GetX();
                yy=mp->GetY();
                zz=mp->GetZ();
-
                if (type==-1)
                {
                        if ((fabs(xx-x)<range) && (fabs(yy-y)<range) && (fabs(zz-z)<range)) {
@@ -173,7 +172,7 @@ int  manualBaseModel::GetIdPoint(double x, double y, double z, int i_range,int t
                                   ibak=i;
                           }
                        }
-               }
+               } // if type  -1
                if (type==0)
                {
                        if ((fabs(yy-y)<range) && (fabs(zz-z)<range)) {
@@ -183,7 +182,7 @@ int  manualBaseModel::GetIdPoint(double x, double y, double z, int i_range,int t
                                   ibak=i;
                           }
                        }
-               }
+               } // if type 0
                if (type==1)
                {
                        if ((fabs(xx-x)<range) && (fabs(zz-z)<range)) {
@@ -193,7 +192,7 @@ int  manualBaseModel::GetIdPoint(double x, double y, double z, int i_range,int t
                                   ibak=i;
                           }
                        }
-               }
+               } // if type 1
                if (type==2)
                {
                        if ((fabs(xx-x)<range) && (fabs(yy-y)<range) ) {
@@ -203,8 +202,8 @@ int  manualBaseModel::GetIdPoint(double x, double y, double z, int i_range,int t
                                   ibak=i;
                           }
                        }
-               }
-       }
+               } // if type 2
+       } // for
        return ibak;
 }
 // ----------------------------------------------------------------------------
index 3d194cf312d164ec858474f1a44bfdf264961f91..433e1dacd011b16f80e960cae4581fb6b335d4bc 100644 (file)
@@ -216,7 +216,7 @@ int  manualContourModel::GetIdPoint(double x, double y, double z, int i_range,in
                yy=mp->GetY();
                zz=mp->GetZ();
 
-               if (type==-1)
+        if (type==-1)
                {
                        if ((fabs(xx-x)<range) && (fabs(yy-y)<range) && (fabs(zz-z)<range)) {
                           dd=sqrt(   (xx-x)*(xx-x) + (yy-y)*(yy-y) + (zz-z)*(zz-z) );