)
{
int i;
- int np = manualcontourmodel->GetSizeLstPoints( ); // number of control points
+ //int np = manualcontourmodel->GetSizeLstPoints( ); // number of control points // JPRx
// JSTG 26-02-08 ---------------------------------------------------------------------------------------
//int nps = manualviewbaseecontour->GetNumberOfPointsSpline(); // number of points in the spline
if (x>maxPoint[0]){ maxPoint[0]=(int)x; }
if (y>maxPoint[1]){ maxPoint[1]=(int)y; }
}
+ minPoint[0]--;
+ minPoint[1]--;
+ maxPoint[0]++;
+ maxPoint[1]++;
//------------------------------------------------------------------------------------------------------
}
//------------------------------------------------------------------------
int ContourExtractData::AnalisisContourInside(int x,
- int y,
- manualContourModel *manualcontourmodel
- )
+ int y,
+ manualContourModel *manualcontourmodel
+ )
{
+ bool inBorder=false;
int result = 0;
int i;
- int np = manualcontourmodel->GetSizeLstPoints( ); // number of control points
+ //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;
}
void *p;
p = imagedata->GetScalarPointer(x,y,z);
- if (imagedata->GetScalarType()==VTK_UNSIGNED_CHAR)
- { unsigned char *pp = (unsigned char*)p;
+ if (imagedata->GetScalarType()==VTK_CHAR)
+ {
+ char *pp = (char*)p;
+ result = (double)(*pp);
+ }
+ else if (imagedata->GetScalarType()==VTK_SIGNED_CHAR)
+ {
+ signed char *pp = (signed char*)p;
+ result = (double)(*pp);
+ }
+ else if (imagedata->GetScalarType()==VTK_UNSIGNED_CHAR)
+ {
+ unsigned char *pp = (unsigned char*)p;
+ result = (double)(*pp);
+ }
+ else if (imagedata->GetScalarType()==VTK_SHORT)
+ {
+ short *pp = (short*)p;
+ result = (double)(*pp);
+ }
+ else if (imagedata->GetScalarType()==VTK_UNSIGNED_SHORT)
+ {
+ unsigned short *pp = (unsigned short*)p;
+ result = (double)(*pp);
+ }
+ else if (imagedata->GetScalarType()==VTK_INT)
+ {
+ int *pp = (int*)p;
+ result = (double)(*pp);
+ }
+ else if (imagedata->GetScalarType()==VTK_UNSIGNED_INT)
+ {
+ unsigned int *pp = (unsigned int*)p;
result = (double)(*pp);
}
- if (imagedata->GetScalarType()==VTK_FLOAT)
- { float *pp = (float*)p;
+ else if (imagedata->GetScalarType()==VTK_LONG)
+ {
+ long *pp = (long*)p;
result = (double)(*pp);
}
- if (imagedata->GetScalarType()==VTK_SHORT)
- { short *pp = (short*)p;
+ else if (imagedata->GetScalarType()==VTK_UNSIGNED_LONG)
+ {
+ unsigned long *pp = (unsigned long*)p;
result = (double)(*pp);
}
- if (imagedata->GetScalarType()==VTK_UNSIGNED_SHORT)
- { unsigned short *pp = (unsigned short*)p;
+ else if (imagedata->GetScalarType()==VTK_FLOAT)
+ {
+ float *pp = (float*)p;
result = (double)(*pp);
}
+ else if (imagedata->GetScalarType()==VTK_DOUBLE)
+ {
+ double *pp = (double*)p;
+ result = (double)(*pp);
+ }
+
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)
{