-//------------------------------------------------------------------------
-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;
-}
-