FillFilter::FillFilter()
{
_tolerancefill = 125;
- _distancefill = 5;
- _auxImageFill = NULL;
- _maxXback = 0;
- _maxYback = 0;
- _maxZback = 0;
+
+//EED 2020-04-28 BORRAME Change to local variables to use with openmp
+// _auxImageFill = NULL;
+// _maxXback = 0;
+// _maxYback = 0;
+// _maxZback = 0;
+ SetDistanceFill(5);
}
//---------------------------------------------------------------------------
FillFilter::~FillFilter()
{
+/*//EED 2020-04-28 BORRAME Change to local variables to use with openmp
if (_auxImageFill != NULL)
{
_auxImageFill->Delete();
}//_auxImageFill
+*/
}
//---------------------------------------------------------------------------
void FillFilter::SetImages(vtkImageData *image,vtkImageData *image2) // virtual
{
baseFilterManualPaint::SetImages(image,image2);
+
+/* //EED 2020-04-28 BORRAME Change to local variables to use with openmp
if ((_maxX!=_maxXback) || (_maxY!=_maxYback) || (_maxZ!=_maxZback))
{
if (_auxImageFill != NULL)
}
unsigned char * ptrAuxImageFill = (unsigned char *)_auxImageFill->GetScalarPointer();
memset(ptrAuxImageFill, 0, (_maxX+1) * (_maxY+1) * (_maxZ+1) );
- _maxXback=_maxX;
- _maxYback=_maxY;
- _maxZback=_maxZ;
+ _maxXback = _maxX;
+ _maxYback = _maxY;
+ _maxZback = _maxZ;
+*/
+
}
void FillFilter::Run() // virtual
{
long int ivi;
- if ((_px >= _minX) && (_px <= _maxX) && (_py >= _minY) && (_py <= _maxY)
- && (_pz >= _minZ) && (_pz <= _maxZ))
+ if ((_px >= _minX) && (_px < _dimX) && (_py >= _minY) && (_py < _dimY)
+ && (_pz >= _minZ) && (_pz < _dimZ))
{
this->_IMManager->BaseInitialPoint(_px, _py ,_pz);
- _graylevelbasefill = _image->GetScalarComponentAsDouble(_px, _py, _pz,0);
- _distbasefill = _distancefill * _distancefill;
- ivi = _px + _py*(_maxX+1) + _pz*(_maxX+1)*(_maxY+1); // index vector image
- FillToolLoop(_px, _py, _pz, ivi);
+ FillToolLoop(_px, _py, _pz);
} //if _minX _maxX _minY _maxY _minZ _maxZ
}
+
//---------------------------------------------------------------------------
-void FillFilter::FillToolLoop(int px, int py, int pz,long int iviA)
+vtkImageData* FillFilter::GenerateAuxImageFill( long int &OneColumnAux, long int &OneLineAux , long int &OnePlaneAux,
+ int px,int py,int pz,
+ int &pxAux, int &pyAux, int &pzAux )
{
+ // _2D3D = 1 3D
+
+ int minXAux = px-_distancefill; if (minXAux>=0) { pxAux=px-minXAux; } else { pxAux=px; minXAux=0; }
+ int minYAux = py-_distancefill; if (minYAux>=0) { pyAux=py-minYAux; } else { pyAux=py; minYAux=0; }
+ int minZAux = pz-_distancefill; if (minZAux>=0) { pzAux=pz-minZAux; } else { pzAux=pz; minZAux=0; }
+
+ int maxXAux = px+_distancefill; if (maxXAux>_dimX) { maxXAux=_dimX; }
+ int maxYAux = py+_distancefill; if (maxYAux>_dimY) { maxYAux=_dimY; }
+ int maxZAux = pz+_distancefill; if (maxZAux>_dimZ) { maxZAux=_dimZ; }
+
+
+ int auxDimX = maxXAux-minXAux+1;
+ int auxDimY = maxYAux-minYAux+1;
+ int auxDimZ = maxZAux-minZAux+1;
+
+ // new vtkImageData
+ if (_2D3D==0) // 2D
+ {
+ if (_direction==0) // YZ
+ {
+ auxDimX = 1;
+ }
+ if (_direction==1) // XZ
+ {
+ auxDimY = 1;
+ }
+ if (_direction==2) // XY
+ {
+ auxDimZ = 1;
+ }
+ } // if 2D
+
+ OneColumnAux = 1;
+ OneLineAux = auxDimX;
+ OnePlaneAux = auxDimX*auxDimY;
+
+ vtkImageData *auxImageFill;
+ auxImageFill = vtkImageData::New();
+ auxImageFill->SetDimensions(auxDimX, auxDimY, auxDimZ);
+ auxImageFill->SetOrigin(0, 0, 0);
+ auxImageFill->SetExtent(0, auxDimX, 0, auxDimY, 0, auxDimZ);
+ auxImageFill->AllocateScalars(VTK_UNSIGNED_CHAR,1);
+ unsigned char * ptrAuxImageFill = (unsigned char *)auxImageFill->GetScalarPointer();
+ memset( ptrAuxImageFill, 0, auxDimX*auxDimY*auxDimZ );
+ return auxImageFill;
+}
+
+
+
+//---------------------------------------------------------------------------
+void FillFilter::FillToolLoop(int px, int py, int pz)
+{
+ _distbasefill = _distancefill * _distancefill;
double difX,difY,difZ,_tmpDistfill;
std::vector<int> lstX;
std::vector<int> lstY;
std::vector<int> lstZ;
- std::vector<long long int> lstivi;
lstX.push_back(px);
lstY.push_back(py);
lstZ.push_back(pz);
- lstivi.push_back( iviA );
+ std::vector<long long int> lstivi;
+ lstivi.push_back( px + py*_OneLine+ pz*_OnePlane );
+
+ long int OneColumnAux, OneLineAux, OnePlaneAux;
+ int pxAux, pyAux, pzAux;
+ vtkImageData* auxImageFill = GenerateAuxImageFill( OneColumnAux,OneLineAux,OnePlaneAux,
+ px,py,pz,
+ pxAux,pyAux,pzAux );
+ std::vector<long long int> lstiviAux;
+ lstiviAux.push_back( pxAux + pyAux*OneLineAux + pzAux*OnePlaneAux );
+
DEF_POINTER_IMAGE_VTK_CREA_set(v_image,ss_image,p_image,st_image,_image)
if (_image2!=NULL)
DEF_POINTER_IMAGE_VTK_CREA_set(v_image2,ss_image2,p_image2,st_image2,_image2)
} // if _image2
- DEF_POINTER_IMAGE_VTK_CREA(v_auxImageFill,ss_auxImageFill,p_auxImageFill,st_auxImageFill,_auxImageFill)
+ GETVALUE2_VTK_CREA(_graylevelbasefill,p_image,st_image,lstivi[0])
+
+//EED 2020-04-28 BORRAME Change to local variables to use with openmp
+// DEF_POINTER_IMAGE_VTK_CREA(v_auxImageFill,ss_auxImageFill,p_auxImageFill,st_auxImageFill,_auxImageFill)
+ DEF_POINTER_IMAGE_VTK_CREA(vAuxImageFill,ssAuxImageFill,pAuxImageFill,stAuxImageFill,auxImageFill)
+
while ( lstX.size()!=0 )
{
// if point inside image
- if ((lstX[0] >= _minX) && (lstX[0] <= _maxX) && (lstY[0] >= _minY) && (lstY[0] <= _maxY) && (lstZ[0] >= _minZ) && (lstZ[0] <= _maxZ))
+ if ((lstX[0] >= _minX) && (lstX[0] < _dimX) && (lstY[0] >= _minY) && (lstY[0] < _dimY) && (lstZ[0] >= _minZ) && (lstZ[0] < _dimZ))
{
difX = px-lstX[0];
difY = py-lstY[0];
if (_tmpDistfill<=_distbasefill)
{
// if point not visited
- GETVALUE2_VTK_CREA(v_auxImageFill,p_auxImageFill,st_auxImageFill,lstivi[0] );
- if (v_auxImageFill==0)
+ GETVALUE2_VTK_CREA(vAuxImageFill,pAuxImageFill,stAuxImageFill,lstiviAux[0] );
+ if (vAuxImageFill==0)
{
// If Gray Level valid
if (isInRange)
{
- _auxGrayLevelValidationFill = (_tmpiglfill != _graylevel)
- && (_tmpiglfill2 != _graylevel)
- && (_tmpiglfill >= grayLBFMTOL)
- && (_tmpiglfill <= grayLBFPTOL)
- && (_tmpDistfill <= _distbasefill); //DFCH
+ _auxGrayLevelValidationFill = (_tmpiglfill != _graylevel) &&
+ (_tmpiglfill2 != _graylevel) &&
+ (_tmpiglfill >= grayLBFMTOL) &&
+ (_tmpiglfill <= grayLBFPTOL) &&
+ (_tmpDistfill <= _distbasefill) ; //DFCH
} else {
_auxGrayLevelValidationFill = false;
} // if isInRange
- if (_auxGrayLevelValidationFill)
+ if (_auxGrayLevelValidationFill==true)
{
-
this->_IMManager->AddModifiedPixel(lstX[0], lstY[0], lstZ[0]); //DFCH
-
// Modifie image
if (_image2!=NULL)
{
} // if _image2
// Add neighborhood points in the list
+
+ // Add point to already visited
+ SETVALUE2_VTK_CREA(1,pAuxImageFill,stAuxImageFill,lstiviAux[0]);
+
if (_2D3D == 0) //2D
{
if (_direction == 0) // YZ
{
- //lstX.push_back(lstX[0]+1); lstY.push_back(lstY[0] ); lstZ.push_back(lstZ[0] ); lstivi.push_back( lstivi[0]+_OneColumn);
- //lstX.push_back(lstX[0]-1); lstY.push_back(lstY[0] ); lstZ.push_back(lstZ[0] ); lstivi.push_back( lstivi[0]-_OneColumn);
- lstX.push_back(lstX[0] ); lstY.push_back(lstY[0]+1); lstZ.push_back(lstZ[0] ); lstivi.push_back( lstivi[0]+_OneLine);
- lstX.push_back(lstX[0] ); lstY.push_back(lstY[0]-1); lstZ.push_back(lstZ[0] ); lstivi.push_back( lstivi[0]-_OneLine);
- lstX.push_back(lstX[0] ); lstY.push_back(lstY[0] ); lstZ.push_back(lstZ[0]+1); lstivi.push_back( lstivi[0]+_OnePlane);
- lstX.push_back(lstX[0] ); lstY.push_back(lstY[0] ); lstZ.push_back(lstZ[0]-1); lstivi.push_back( lstivi[0]-_OnePlane);
+//lstX.push_back(lstX[0]+1); lstY.push_back(lstY[0]); lstZ.push_back(lstZ[0]); lstivi.push_back(lstivi[0]+_OneColumn); lstiviAux.push_back(lstiviAux[0]+OneColumnAux);
+//lstX.push_back(lstX[0]-1); lstY.push_back(lstY[0]); lstZ.push_back(lstZ[0]); lstivi.push_back(lstivi[0]-_OneColumn); lstiviAux.push_back(lstiviAux[0]-OneColumnAux);
+ lstX.push_back(lstX[0] ); lstY.push_back(lstY[0]+1); lstZ.push_back(lstZ[0] ); lstivi.push_back(lstivi[0]+_OneLine); lstiviAux.push_back(lstiviAux[0]+OneLineAux);
+ lstX.push_back(lstX[0] ); lstY.push_back(lstY[0]-1); lstZ.push_back(lstZ[0] ); lstivi.push_back(lstivi[0]-_OneLine); lstiviAux.push_back(lstiviAux[0]-OneLineAux);
+ lstX.push_back(lstX[0] ); lstY.push_back(lstY[0] ); lstZ.push_back(lstZ[0]+1); lstivi.push_back(lstivi[0]+_OnePlane); lstiviAux.push_back(lstiviAux[0]+OnePlaneAux);
+ lstX.push_back(lstX[0] ); lstY.push_back(lstY[0] ); lstZ.push_back(lstZ[0]-1); lstivi.push_back(lstivi[0]-_OnePlane); lstiviAux.push_back(lstiviAux[0]-OnePlaneAux);
}
if (_direction == 1) // XZ
{
- lstX.push_back(lstX[0]+1); lstY.push_back(lstY[0] ); lstZ.push_back(lstZ[0] ); lstivi.push_back( lstivi[0]+_OneColumn);
- lstX.push_back(lstX[0]-1); lstY.push_back(lstY[0] ); lstZ.push_back(lstZ[0] ); lstivi.push_back( lstivi[0]-_OneColumn);
- // lstX.push_back(lstX[0] ); lstY.push_back(lstY[0]+1); lstZ.push_back(lstZ[0] ); lstivi.push_back( lstivi[0]+_OneLine);
- // lstX.push_back(lstX[0] ); lstY.push_back(lstY[0]-1); lstZ.push_back(lstZ[0] ); lstivi.push_back( lstivi[0]-_OneLine);
- lstX.push_back(lstX[0] ); lstY.push_back(lstY[0] ); lstZ.push_back(lstZ[0]+1); lstivi.push_back( lstivi[0]+_OnePlane);
- lstX.push_back(lstX[0] ); lstY.push_back(lstY[0] ); lstZ.push_back(lstZ[0]-1); lstivi.push_back( lstivi[0]-_OnePlane);
+ lstX.push_back(lstX[0]+1); lstY.push_back(lstY[0]); lstZ.push_back(lstZ[0]); lstivi.push_back(lstivi[0]+_OneColumn); lstiviAux.push_back(lstiviAux[0]+OneColumnAux);
+ lstX.push_back(lstX[0]-1); lstY.push_back(lstY[0]); lstZ.push_back(lstZ[0]); lstivi.push_back(lstivi[0]-_OneColumn); lstiviAux.push_back(lstiviAux[0]-OneColumnAux);
+// lstX.push_back(lstX[0] ); lstY.push_back(lstY[0]+1); lstZ.push_back(lstZ[0] ); lstivi.push_back(lstivi[0]+_OneLine); lstiviAux.push_back(lstiviAux[0]+OneLineAux);
+// lstX.push_back(lstX[0] ); lstY.push_back(lstY[0]-1); lstZ.push_back(lstZ[0] ); lstivi.push_back(lstivi[0]-_OneLine); lstiviAux.push_back(lstiviAux[0]-OneLineAux);
+ lstX.push_back(lstX[0] ); lstY.push_back(lstY[0] ); lstZ.push_back(lstZ[0]+1); lstivi.push_back(lstivi[0]+_OnePlane); lstiviAux.push_back(lstiviAux[0]+OnePlaneAux);
+ lstX.push_back(lstX[0] ); lstY.push_back(lstY[0] ); lstZ.push_back(lstZ[0]-1); lstivi.push_back(lstivi[0]-_OnePlane); lstiviAux.push_back(lstiviAux[0]-OnePlaneAux);
}
if (_direction == 2) // XY
{
- lstX.push_back(lstX[0]+1); lstY.push_back(lstY[0] ); lstZ.push_back(lstZ[0] ); lstivi.push_back( lstivi[0]+_OneColumn);
- lstX.push_back(lstX[0]-1); lstY.push_back(lstY[0] ); lstZ.push_back(lstZ[0] ); lstivi.push_back( lstivi[0]-_OneColumn);
- lstX.push_back(lstX[0] ); lstY.push_back(lstY[0]+1); lstZ.push_back(lstZ[0] ); lstivi.push_back( lstivi[0]+_OneLine);
- lstX.push_back(lstX[0] ); lstY.push_back(lstY[0]-1); lstZ.push_back(lstZ[0] ); lstivi.push_back( lstivi[0]-_OneLine);
- //lstX.push_back(lstX[0] ); lstY.push_back(lstY[0] ); lstZ.push_back(lstZ[0]+1); lstivi.push_back( lstivi[0]+_OnePlane);
- //lstX.push_back(lstX[0] ); lstY.push_back(lstY[0] ); lstZ.push_back(lstZ[0]-1); lstivi.push_back( lstivi[0]-_OnePlane);
+lstX.push_back(lstX[0]+1); lstY.push_back(lstY[0]); lstZ.push_back(lstZ[0]); lstivi.push_back(lstivi[0]+_OneColumn); lstiviAux.push_back(lstiviAux[0]+OneColumnAux);
+lstX.push_back(lstX[0]-1); lstY.push_back(lstY[0]); lstZ.push_back(lstZ[0]); lstivi.push_back(lstivi[0]-_OneColumn); lstiviAux.push_back(lstiviAux[0]-OneColumnAux);
+ lstX.push_back(lstX[0] ); lstY.push_back(lstY[0]+1); lstZ.push_back(lstZ[0] ); lstivi.push_back(lstivi[0]+_OneLine); lstiviAux.push_back(lstiviAux[0]+OneLineAux);
+ lstX.push_back(lstX[0] ); lstY.push_back(lstY[0]-1); lstZ.push_back(lstZ[0] ); lstivi.push_back(lstivi[0]-_OneLine); lstiviAux.push_back(lstiviAux[0]-OneLineAux);
+//lstX.push_back(lstX[0] ); lstY.push_back(lstY[0] ); lstZ.push_back(lstZ[0]+1); lstivi.push_back(lstivi[0]+_OnePlane); lstiviAux.push_back(lstiviAux[0]+OnePlaneAux);
+//lstX.push_back(lstX[0] ); lstY.push_back(lstY[0] ); lstZ.push_back(lstZ[0]-1); lstivi.push_back(lstivi[0]-_OnePlane); lstiviAux.push_back(lstiviAux[0]-OnePlaneAux);
}
} else { // 3D
- lstX.push_back(lstX[0]+1); lstY.push_back(lstY[0] ); lstZ.push_back(lstZ[0] ); lstivi.push_back( lstivi[0]+_OneColumn);
- lstX.push_back(lstX[0]-1); lstY.push_back(lstY[0] ); lstZ.push_back(lstZ[0] ); lstivi.push_back( lstivi[0]-_OneColumn);
- lstX.push_back(lstX[0] ); lstY.push_back(lstY[0]+1); lstZ.push_back(lstZ[0] ); lstivi.push_back( lstivi[0]+_OneLine);
- lstX.push_back(lstX[0] ); lstY.push_back(lstY[0]-1); lstZ.push_back(lstZ[0] ); lstivi.push_back( lstivi[0]-_OneLine);
- lstX.push_back(lstX[0] ); lstY.push_back(lstY[0] ); lstZ.push_back(lstZ[0]+1); lstivi.push_back( lstivi[0]+_OnePlane);
- lstX.push_back(lstX[0] ); lstY.push_back(lstY[0] ); lstZ.push_back(lstZ[0]-1); lstivi.push_back( lstivi[0]-_OnePlane);
+ lstX.push_back(lstX[0]+1); lstY.push_back(lstY[0]); lstZ.push_back(lstZ[0]); lstivi.push_back(lstivi[0]+_OneColumn); lstiviAux.push_back(lstiviAux[0]+OneColumnAux);
+ lstX.push_back(lstX[0]-1); lstY.push_back(lstY[0]); lstZ.push_back(lstZ[0]); lstivi.push_back(lstivi[0]-_OneColumn); lstiviAux.push_back(lstiviAux[0]-OneColumnAux);
+ lstX.push_back(lstX[0] ); lstY.push_back(lstY[0]+1); lstZ.push_back(lstZ[0] ); lstivi.push_back(lstivi[0]+_OneLine); lstiviAux.push_back(lstiviAux[0]+OneLineAux);
+ lstX.push_back(lstX[0] ); lstY.push_back(lstY[0]-1); lstZ.push_back(lstZ[0] ); lstivi.push_back(lstivi[0]-_OneLine); lstiviAux.push_back(lstiviAux[0]-OneLineAux);
+ lstX.push_back(lstX[0] ); lstY.push_back(lstY[0] ); lstZ.push_back(lstZ[0]+1); lstivi.push_back(lstivi[0]+_OnePlane); lstiviAux.push_back(lstiviAux[0]+OnePlaneAux);
+ lstX.push_back(lstX[0] ); lstY.push_back(lstY[0] ); lstZ.push_back(lstZ[0]-1); lstivi.push_back(lstivi[0]-_OnePlane); lstiviAux.push_back(lstiviAux[0]-OnePlaneAux);
} // 2D 3D
} // if gray level valid _auxGrayLevelValidationFill
} // if point not visited
- // Add point to already visited
- SETVALUE2_VTK_CREA(1,p_auxImageFill,st_auxImageFill,lstivi[0]);
} // if distance of center point
} // if point inside image
// Remove point from the list
lstY.erase( lstY.begin() );
lstZ.erase( lstZ.begin() );
lstivi.erase( lstivi.begin() );
+ lstiviAux.erase( lstiviAux.begin() );
} // while _lstX.size
+ auxImageFill->Delete();
}
//---------------------------------------------------------------------------
_distancefill = distancefill;
}
+/*//EED 2020-04-28 BORRAME Change to local variables to use with openmp
//---------------------------------------------------------------------------
vtkImageData* FillFilter::GetAuxImageFill()
{
return _auxImageFill;
}
-
-
+*/