if (x>maxPoint[0]){ maxPoint[0]=(int)x; }
if (y>maxPoint[1]){ maxPoint[1]=(int)y; }
}
+ minPoint[0]--;
+ minPoint[1]--;
+ maxPoint[0]++;
+ maxPoint[1]++;
//------------------------------------------------------------------------------------------------------
}
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,t;
double x1,y1,z1,x2,y2,z2;
+ double borderX, borderY;
double xx1, yy1,xx2, yy2;
//double delta=( double ) ( np ) / ( double ) ( nps );
manualcontourmodel->UpdateSpline();
// if (np>=2)
// {
// JSTG 26-02-08 ---------------------------------------------------------------------------------------
- nps--;
+// 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<=y1)&&(y>y2)) )
{
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))) || ((xx1>xx2)&&(x<(xx1-d))) ) { result++; }
- } // if
+ 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 verication
+ if ( (x==(int)borderX) && (y==(int)borderY) )
+ {
+ inBorder=true;
+ i=nps;
+ }// if point in border
+
x1=x2; y1=y2; z1=z2;
+
} // for i
// } //if
+
+ if (inBorder==true) { result=1; }
+
return result;
}
maxPoint[1] = -999999;
GetMinMaxPoint_Of_LstManConMod(minPoint,maxPoint);
- for (j=minPoint[1]; j<maxPoint[1]; j++)
+ for (j=minPoint[1]; j<=maxPoint[1]; j++)
{
- for (i=minPoint[0]; i<maxPoint[0]; i++)
+ for (i=minPoint[0]; i<=maxPoint[0]; i++)
{
if (isInside(i,j,_typeOperation)==true)
{
GetMinMaxPoint_Of_LstManConMod(minPoint,maxPoint);
- for (j=minPoint[1]; j<maxPoint[1]; j++)
+ for (j=minPoint[1]; j<=maxPoint[1]; j++)
{
- for (i=minPoint[0]; i<maxPoint[0]; i++)
+ for (i=minPoint[0]; i<=maxPoint[0]; i++)
{
if (isInside(i,j,_typeOperation)==true)
{
}
+//------------------------------------------------------------------------
+void ContourExtractData::InitVolumeStatistics()
+{
+ vol_rCountRange = 0;
+ vol_rsize = 0;
+ vol_minValue = 9999999;
+ vol_maxValue =-9999999;
+ vol_acum_average = 0;
+ vol_acum_standardeviation = 0;
+}
+
+//------------------------------------------------------------------------
+void ContourExtractData::SetVolumeStatistics(int rCountRange,
+ int rsize,
+ double minValue,
+ double maxValue,
+ double acum_average,
+ double acum_standardeviation)
+{
+ vol_rCountRange = vol_rCountRange + rCountRange;
+ vol_rsize = vol_rsize + rsize;
+
+ if (minValue<vol_minValue){ vol_minValue = minValue; }
+ if (maxValue>vol_maxValue){ vol_maxValue = maxValue; }
+
+ vol_acum_average = vol_acum_average + acum_average;
+ vol_acum_standardeviation = vol_acum_standardeviation + acum_standardeviation;
+}
+
+//------------------------------------------------------------------------
+void ContourExtractData::GetVolumeStatistics(int *vol_rCountRange,
+ int *vol_rsize,
+ double *vol_minValue,
+ double *vol_maxValue,
+ double *vol_average,
+ double *vol_standardeviation)
+{
+ *vol_rCountRange = this->vol_rCountRange;
+ *vol_rsize = this->vol_rsize;
+ *vol_minValue = this->vol_minValue;
+ *vol_maxValue = this->vol_maxValue;
+ *vol_average = this->vol_acum_average / this->vol_rsize;
+ *vol_standardeviation = sqrt(this->vol_acum_standardeviation / this->vol_rsize);
+}
+
//------------------------------------------------------------------------
void ContourExtractData::Statistics( std::vector<double> *inputLstValue,
double *rmin,
double *rmax,
double *raverage,
- double *rstandardeviation)
+ double *rstandardeviation
+ )
{
- double min = 0;
- double max = 0;
- double average = 0;
- double standardeviation = 0;
- double acum = 0;
- int size = 0;
- int countRange = 0;
+ double min = 0;
+ double max = 0;
+ double average = 0;
+ double standardeviation = 0;
+ double acum_average = 0;
+ double acum_standardeviation = 0;
+ int size = 0;
+ int countRange = 0;
double ng;
if (inputLstValue!=NULL)
for ( i=0; i<size; i++ )
{
ng=(*inputLstValue)[i];
- acum = acum + ng;
+ acum_average = acum_average + ng;
if (max<ng) max=ng; // Max
if (min>ng) min=ng; // Min
if ((ng>=grayRangeMin) && (ng<=grayRangeMax)) countRange++; // countRange
- }
- average = acum / size;
+ } // for average
+ average = acum_average / size;
// Standar Deviation
- acum=0;
+ acum_standardeviation=0;
double tmp;
for ( i=0; i<size; i++ )
{
tmp = (*inputLstValue)[i] - average;
- acum = acum + tmp*tmp;
- }
- standardeviation = sqrt(acum/size);
-
- }
- }
+ acum_standardeviation = acum_standardeviation + tmp*tmp;
+ } // for standar deviation
+ standardeviation = sqrt(acum_standardeviation/size);
+ SetVolumeStatistics(countRange, size,
+ min,max,
+ acum_average,acum_standardeviation);
+ } // if size
+ } // if NULL
// OUTPUT
*rsize = size;