]> Creatis software - creaMaracasVisu.git/commitdiff
no message
authorEduardo Davila <Eduardo.Davila@creatis.insa-lyon.fr>
Tue, 28 Jul 2009 14:17:54 +0000 (14:17 +0000)
committerEduardo Davila <Eduardo.Davila@creatis.insa-lyon.fr>
Tue, 28 Jul 2009 14:17:54 +0000 (14:17 +0000)
lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.cxx
lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourControler.cpp
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewBaseContour.cpp
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewCircle.cpp

index 4604878d8e968e079dbbe8e30d4677c5d2321ddd..974b1680c0bd83937490f92ac71dadefcd7dd8bb 100644 (file)
@@ -89,85 +89,6 @@ void ContourExtractData::GetMinMaxPoint_Of_LstManConMod(     int *minPoint,
        }
 }
 
-//------------------------------------------------------------------------
-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 +111,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 +128,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 +171,6 @@ int ContourExtractData::AnalisisContourInsideV2(int x, int y, int iContour )
                
                if (inBorder==true){ i=nps; }           
        } // for i
-
        
        if (inBorder==true)     { result=1;     }
        
@@ -278,7 +197,6 @@ 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 );
                                if ( (numberLeft % 2) ==1){         numberInside++;  }
                        }
@@ -290,7 +208,6 @@ 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 );
                                if ( (numberLeft % 2) ==1){ result=true;  }
                        }
@@ -300,7 +217,6 @@ bool ContourExtractData::isInside(int x, int y, int typeOperation)
                {
                        for (i=0;i<size;i++)
                        {
-//                             numberLeft = numberLeft + AnalisisContourInside(x,y, lstManConMod[i] );
                                numberLeft = numberLeft + AnalisisContourInsideV2(x,y, i );
                        }
                        if ( numberLeft % 2 ==1){       result = true;  } 
@@ -699,7 +615,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;
index a1d4ddc3ee27679360d2e12e89e763b73363413b..6196303879cbe1d8471acb1815b76daa103f7971 100644 (file)
@@ -64,9 +64,6 @@
        void GetMinMaxPoint_Of_LstManConMod(    int *minPoint, 
                                                                                        int *maxPoint);
 
-       int AnalisisContourInside(      int x, 
-                                                               int y, 
-                                                               manualContourModel *manualcontourmodel );
        int AnalisisContourInsideV2(int x, int y, int iContour );
          
        double GetDataValue(int x, int y, int z);
index 53729c5f13d9b129ea4213e62477ace4a3262165..d16b9c78d5f805fb32407bb0badd118ce27abc53 100644 (file)
@@ -49,9 +49,8 @@ void manualContourControler::MouseClickLeft(int x, int y){
        int size= GetManualViewBaseContour()->GetNumberOfPoints();
 
        // Insert a Control Point with shift+ClickLeft
-       // int tt = GetState();  // JPRx
        vtkRenderWindowInteractor *vtkrenderwindowinteractor = _vtkInteractorStyleBaseView->GetInteractor();
-//EED3131
+
        if( IsEditable() )
        {
                if ( (_vtkInteractorStyleBaseView!=NULL) && (GetState()==0) && ( (vtkrenderwindowinteractor!=NULL) && (vtkrenderwindowinteractor->GetShiftKey()==1) ) )
@@ -65,6 +64,7 @@ void manualContourControler::MouseClickLeft(int x, int y){
                {
                        ok=true;
                        SetState(1);
+                       GetManualContourModel()->SetCloseContour(false);
                        AddPoint(x,y,z);
                }
                // Continuie to Insert Control Points with ClickLeft (After being empty the contour)
index bd08c9298ec887897c26c0698aab9f26eb996dfc..4ab822f8630bbde4369abdf19d404dc2f207b542 100644 (file)
@@ -615,6 +615,7 @@ void manualViewBaseContour::Refresh() // virtual
        if (vri==NULL)
        {
                _wxvtkbaseview->GetRenWin()->Render();
+               printf("EED %p How to optimize manualViewBaseContour::Refresh() \n",this);
        }
 
 }
index 75cba5f5384dd3c7e43d3e97ee9393c6fcdcf42f..879d119773a885879c7af8bf39e56a9c002579e0 100644 (file)
@@ -34,46 +34,6 @@ void manualViewCircle::CopyAttributesTo( manualViewCircle * cloneObject)
 }
 
 
-// ----------------------------------------------------------------------------
-/*
-void manualViewCircle::RefreshContour(){ // virtual
-
-       manualPoint     *mpA,*mpB;
-    unsigned int i, np,nps;
-       double angle,radio;
-       double difX,difY;
-       double XX,YY,ZZ;
-    np = GetNumberOfPoints( );
-       nps = _manContModel->GetNumberOfPointsSpline();
-       double deltaAngle=(3.14159265*2)/(nps-1);
-       if ( np > 0)
-       {
-               if (np==2)
-               {
-                       mpA             = _manContModel->GetManualPoint(0);
-                       mpB             = _manContModel->GetManualPoint(1);
-                       difX    = mpA->GetX() - mpB->GetX();
-                       difY    = mpA->GetY() - mpB->GetY();
-                       radio   = sqrt( difX*difX + difY*difY );
-                       manualContourModelCircle *manContModelCir = (manualContourModelCircle*)_manContModel;
-                       manContModelCir->SetRadio(radio);
-
-                       for( i = 0; i < nps; i++ ) {
-                               manContModelCir->GetSpline_i_Point(i, &XX, &YY, &ZZ);
-//                             angle = deltaAngle*i;
-//                             XX = cos(angle)*radio+mpA->GetX();
-//                             YY = sin(angle)*radio+mpA->GetY();
-                               ZZ = mpA->GetZ();
-                               _pts->SetPoint(i, XX*_spc[0] , YY*_spc[1] , ZZ*_spc[2] );
-                       } //  rof
-               } else {
-                               _pts->SetPoint(0, 0 , 0 , 0);
-                               _pts->SetPoint(1, 0 , 0 , 0);
-               } // if
-       }
-}
-*/
-
 // ----------------------------------------------------------------------------
 int manualViewCircle::GetType() // virtual
 {
@@ -108,43 +68,6 @@ void manualViewCircle::GetMinMax(double &minX,double &minY, double &maxX, double
        }
 }
 
-/*
-// ----------------------------------------------------------------------------
-bool manualViewCircle::ifTouchContour(int x,int y, int z) // virtual
-{
-       bool    result=false;
-       double  px1=99999,py1=99999,px2=-9999,py2=-99999;
-
-       GetMinMax(px1,py1, px2, py2);
-
-       double xx=x;
-       double yy=y;
-       double zz=z;
-       TransfromCoordViewWorld(xx,yy,zz);
-
-       bool ok1=false;
-       bool ok2=false;
-       double ddx=GetRange();
-       double ddy=GetRange();
-
-       if ((xx>px1-ddx)&&(xx<px2+ddx) &&  (yy>py1-ddy)&&(yy<py2+ddy))
-       {
-               ok1=true;
-       }
-
-       if ((xx>px1+ddx)&&(xx<px2-ddx) &&  (yy>py1+ddy)&&(yy<py2-ddy))
-       {
-               ok2=true;
-       }
-
-       if ((ok1==true) && (ok2==false))
-       {
-               result=true;
-       }
-
-       return result;
-}
-*/
 
 // ----------------------------------------------------------------------------