}
}
-//------------------------------------------------------------------------
-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 )
y1=_lstlstlstVecY1[iContour][y][i];
x2=_lstlstlstVecX2[iContour][y][i];
y2=_lstlstlstVecY2[iContour][y][i];
-
+
borderX=x1;
borderY=y1;
// 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)
{
if (inBorder==true){ i=nps; }
} // for i
-
if (inBorder==true) { result=1; }
{
for (i=0;i<size;i++)
{
-// numberLeft = AnalisisContourInside(x,y, lstManConMod[i] );
numberLeft = AnalisisContourInsideV2(x,y, i );
if ( (numberLeft % 2) ==1){ numberInside++; }
}
{
for (i=0;i<size;i++)
{
-// numberLeft = AnalisisContourInside(x,y, lstManConMod[i] );
numberLeft = AnalisisContourInsideV2(x,y, i );
if ( (numberLeft % 2) ==1){ result=true; }
}
{
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; }
{
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;
}
-// ----------------------------------------------------------------------------
-/*
-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
{
}
}
-/*
-// ----------------------------------------------------------------------------
-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;
-}
-*/
// ----------------------------------------------------------------------------