]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.cxx
*** empty log message ***
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / Contour / ContourExtractData.cxx
index 4604878d8e968e079dbbe8e30d4677c5d2321ddd..10e04156dc251ce1914f30ecb440173da28a4e72 100644 (file)
@@ -34,7 +34,7 @@ void ContourExtractData::SetZtoBeAnalys( int z )
   }
 
 //------------------------------------------------------------------------
-  void ContourExtractData::SetLstManualContourModel( std::vector<manualContourModel*> lstManConMod)
+  void ContourExtractData::SetLstManualContourModel( std::vector<manualBaseModel*> lstManConMod)
   {
          this->lstManConMod = lstManConMod;
   }
@@ -43,12 +43,12 @@ void ContourExtractData::SetZtoBeAnalys( int z )
 //------------------------------------------------------------------------
 void ContourExtractData::GetMinMaxPoint(int *minPoint, 
                                                                                  int *maxPoint, 
-                                                                                 manualContourModel *manualcontourmodel
+                                                                                 manualBaseModel *manualcontourmodel
                                                                                  )
 {
        int i;
        //int   np              = manualcontourmodel->GetSizeLstPoints( );  // number of control points // JPRx
-
+               
 // JSTG 26-02-08 ---------------------------------------------------------------------------------------
        //int nps = manualviewbaseecontour->GetNumberOfPointsSpline(); // number of points in the spline
        int nps = manualcontourmodel->GetNumberOfPointsSpline(); // number of points in the spline
@@ -83,91 +83,13 @@ void ContourExtractData::GetMinMaxPoint_Of_LstManConMod(    int *minPoint,
 
 {
        int i,size = lstManConMod.size();
+
        for(i=0 ; i<size ; i++)
        {
                GetMinMaxPoint(minPoint,maxPoint,lstManConMod[i]);
        }
 }
 
-//------------------------------------------------------------------------
-int ContourExtractData::AnalisisContourInside(int x, 
-                                           int y, 
-                                           manualContourModel *manualcontourmodel
-                                           )
-{
-       bool inBorder=false;
-       int result      = 0;
-       int i;
-       //int   np              = manualcontourmodel->GetSizeLstPoints( );  // number of control points // JPRx
-
-// JSTG 26-02-08 ---------------------------------------------------------------------------------------
-       //int nps = manualviewbaseecontour->GetNumberOfPointsSpline(); // number of points in the spline
-       int nps = manualcontourmodel->GetNumberOfPointsSpline(); // number of points in the spline
-       double x1,y1,z1,x2,y2,z2;
-       double borderX, borderY;
-       double xx1, yy1,xx2, yy2;
-       //double delta=( double ) ( np  ) / ( double ) ( nps  );
-       manualcontourmodel->UpdateSpline();
-//------------------------------------------------------------------------------------------------------
-       double d;
-       bool ok;
-//     if (np>=2)
-//     {
-// JSTG 26-02-08 ---------------------------------------------------------------------------------------
-//             nps--;
-               //manualcontourmodel->GetSplinePoint(0,x1,y1,z1);
-               manualcontourmodel->GetSpline_i_Point(0,&x1,&y1,&z1);
-           x1=x1+0.5; y1=y1+0.5;
-               for (i=1; i<=nps; i++)
-               {
-                       borderX=x1;
-                       borderY=y1;
-                       
-                       ok=false;
-                       //t= delta * (double)(i%nps);
-                       //manualcontourmodel->GetSplinePoint(t,x2,y2,z2);
-                       manualcontourmodel->GetSpline_i_Point(i,&x2,&y2,&z2);
-                       x2=x2+0.5; y2=y2+0.5;
-//------------------------------------------------------------------------------------------------------
-
-                       //by triangle similarity
-                       if ( ((y1<y2)&&(y>=y1)&&(y<y2)) || ((y1>y2)&&(y>=y2)&&(y<y1)) )
-                       {
-                               if (y1<y2) { xx1=x1; yy1=y1; xx2=x2; yy2=y2;} else { xx1=x2; yy1=y2; xx2=x1; yy2=y1; } 
-                               
-                               d = ( fabs(xx2-xx1)*(y-yy1) ) / (yy2-yy1) ;
-                               if ( (xx1<xx2)&&(x<(xx1+d)) )   
-                               { 
-                                       result++; 
-                                       borderX=xx1+d;
-                                       borderY=y;
-                               } 
-                               if ( (xx1>xx2)&&(x<(xx1-d)) )  { 
-                                       result++; 
-                                       borderX=xx1-d;
-                                       borderY=y;
-                               } 
-                       } // if point inside contour 
-                       
-                       //Border verification
-                       if (   (x==(int)borderX) && (y==(int)borderY)   )  { inBorder=true; }// if point in border
-                       
-                       // Verification : border in horizontal line 
-                       if ( ((int)y1==(int)y2)  &&  ((int)y1==y) && (x1<x2) && (x>=x1) && (x<=x2))             { inBorder=true;        }
-                       if ( ((int)y1==(int)y2)  &&  ((int)y1==y) && (x2<x1) && (x>=x2) && (x<=x1))             { inBorder=true;        }
-
-                       if (inBorder==true){ i=nps; }
-                       
-                       x1=x2; y1=y2; z1=z2;
-                       
-               } // for i
-//     } //if
-       
-       if (inBorder==true)     { result=1;     }
-       
-       return result;
-}
-
 
 //------------------------------------------------------------------------
 int ContourExtractData::AnalisisContourInsideV2(int x, int y, int iContour )
@@ -190,7 +112,7 @@ int ContourExtractData::AnalisisContourInsideV2(int x, int y, int iContour )
                y1=_lstlstlstVecY1[iContour][y][i];
                x2=_lstlstlstVecX2[iContour][y][i];
                y2=_lstlstlstVecY2[iContour][y][i];
-               
+
                borderX=x1;
                borderY=y1;
                
@@ -207,11 +129,10 @@ int ContourExtractData::AnalisisContourInsideV2(int x, int y, int iContour )
                // Finding border looking in vertical direction  AND  verifing if pixel is at right of the line 
                if  ( (yy>=yy1)&&(yy<=yy2) ) 
                {
-                               
                        //by triangle similarity
                        d = ( fabs(xx2-xx1)*(yy-yy1) ) / (yy2-yy1) ;
-                       if ( (xx1<xx2)&&(x<(xx1+d)) )  { result++; }
-                       if ( (xx1>xx2)&&(x<(xx1-d)) )  { result++; } 
+                       if ( (xx1<=xx2)&&(x<(xx1+d)) )  {       result++;       }
+                       if ( (xx1>xx2)&&(x<(xx1-d)) )   {       result++;       } 
                        
                        if ( (yy2-yy1)/difxx2xx1 >= 1.0)
                        {
@@ -251,7 +172,6 @@ int ContourExtractData::AnalisisContourInsideV2(int x, int y, int iContour )
                
                if (inBorder==true){ i=nps; }           
        } // for i
-
        
        if (inBorder==true)     { result=1;     }
        
@@ -278,30 +198,71 @@ bool ContourExtractData::isInside(int x, int y, int typeOperation)
                {
                        for (i=0;i<size;i++)
                        {
-//                             numberLeft =  AnalisisContourInside(x,y, lstManConMod[i] );
-                               numberLeft =  AnalisisContourInsideV2(x,y, i );
+                               // To process the statistics of the Points contour the procedure is different
+                               // RaC 19-09-09
+                               manualBaseModel *mbm = lstManConMod[i];
+                               if(mbm->GetTypeModel()==7)
+                               {
+                                       if(mbm->IsPoint(x,y)==true)
+                                       {
+                                               numberLeft=1;
+                                       }
+                               }//if
+                               else
+                               {
+                                       numberLeft =  AnalisisContourInsideV2(x,y, i );
+                               }//else
+
                                if ( (numberLeft % 2) ==1){         numberInside++;  }
                        }
                        if ( numberInside == (size) ){ result=true; }
                } // AND  Intersection
 
+               numberLeft=0;
 
                if (typeOperation==1)  // OR  All
                {
                        for (i=0;i<size;i++)
                        {
-//                             numberLeft =  AnalisisContourInside(x,y, lstManConMod[i] );
-                               numberLeft =  AnalisisContourInsideV2(x,y, i );
+                               // To process the statistics of the Points contour the procedure is different
+                               // RaC 19-09-09
+                               manualBaseModel *mbm = lstManConMod[i];
+                               if(mbm->GetTypeModel()==7)
+                               {
+                                       if(mbm->IsPoint(x,y)==true)
+                                       {
+                                               numberLeft=1;
+                                       }
+                               }//if
+                               else
+                               {
+                                       numberLeft =  AnalisisContourInsideV2(x,y, i );
+                               }//else
                                if ( (numberLeft % 2) ==1){ result=true;  }
                        }
                } // OR  All
 
+               numberLeft=0;
+
                if (typeOperation==2)  // XOR  crown
                {
                        for (i=0;i<size;i++)
                        {
-//                             numberLeft = numberLeft + AnalisisContourInside(x,y, lstManConMod[i] );
-                               numberLeft = numberLeft + AnalisisContourInsideV2(x,y, i );
+                               // To process the statistics of the Points contour the procedure is different
+                               // RaC 19-09-09
+                               manualBaseModel *mbm = lstManConMod[i];
+                               if(mbm->GetTypeModel()==7)
+                               {
+                                       if(mbm->IsPoint(x,y)==true)
+                                       {
+                                               numberLeft=1;
+                                       }
+                               }//if
+                               else
+                               {
+                                       numberLeft =  numberLeft + AnalisisContourInsideV2(x,y, i );
+                               }//else
+                               
                        }
                        if ( numberLeft % 2 ==1){       result = true;  } 
                }// XOR  crown
@@ -509,7 +470,6 @@ void ContourExtractData::GetValuesInsideCrown(std::vector<double> *pLstValue,
                } // for
        } // for
 
-
 // Borrame
 //     if (this->okImagesResults==true){
 //             imagedataValueResult->Modified();
@@ -690,7 +650,7 @@ void ContourExtractData::Fill_lstlstlstVecXY(int iContour, int sizeY)
 {
        int i,y;
        double x1,y1,z1,x2,y2,z2;
-       manualContourModel *manualcontourmodel= lstManConMod[iContour]; 
+       manualBaseModel *manualcontourmodel= lstManConMod[iContour];    
        int nps = manualcontourmodel->GetNumberOfPointsSpline(); // number of points in the spline
        manualcontourmodel->UpdateSpline();
        //------------------------------------------------------------------------------------------------------
@@ -699,7 +659,7 @@ void ContourExtractData::Fill_lstlstlstVecXY(int iContour, int sizeY)
        {
                manualcontourmodel->GetSpline_i_Point(0,&x1,&y1,&z1);
                x1=x1+0.5; y1=y1+0.5;
-               for (i=1; i<=nps; i++)
+               for (i=1; i<nps; i++)
                {
                        manualcontourmodel->GetSpline_i_Point(i,&x2,&y2,&z2);
                        x2=x2+0.5; y2=y2+0.5;