//=====
// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
//=====
+
+
+/*
void ManualPaint_Model::Process()
{
if (bbGetInputByImagePoints()!=NULL)
{
- int i,j,k;
+ int i,ii=0;
+// int i,j,k;
// int ia,ja,ka;
// int ii,jj,kk;
int ext[6];
int dimX=ext[1]-ext[0]+1;
int dimY=ext[3]-ext[2]+1;
int dimZ=ext[5]-ext[4]+1;
+// char *pByImagePoints = bbGetInputByImagePoints->GetScalarComponent(i,j,k,0);
+// int sizeData;
+//#pragma omp parallel for
for (i=0;i<dimX;i++)
{
- if (i%20==0)
+ int j,k;
+ ii++;
+ if (ii%10==0)
{
- printf("ManualPaint_Model %d%\n", (int)(i*100.0/dimX) );
+ printf("ManualPaint_Model %d%\n", (int)(ii*100.0/dimX) );
}
for (j=0;j<dimY;j++)
{
bbSetOutputOut( NULL );
}
}
+*/
+
+
+
+void ManualPaint_Model::Process()
+{
+
+// THE MAIN PROCESSING METHOD BODY
+// Here we simply set the input 'In' value to the output 'Out'
+// And print out the output value
+// INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
+// void bbSet{Input|Output}NAME(const TYPE&)
+// const TYPE& bbGet{Input|Output}NAME() const
+// Where :
+// * NAME is the name of the input/output
+// (the one provided in the attribute 'name' of the tag 'input')
+// * TYPE is the C++ type of the input/output
+// (the one provided in the attribute 'type' of the tag 'input')
+// bbSetOutputOut( bbGetInputIn() );
+// std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
+
+ if (bbGetInputImage()!=NULL)
+ {
+ manualpaintmodel->SetActive( bbGetInputActive() );
+ manualpaintmodel->SetTool( bbGetInputTool() );
+ manualpaintmodel->Set2D3D( bbGetInput2D3D() );
+ manualpaintmodel->SetImages( bbGetInputImage(),bbGetInputImage2() );
+ manualpaintmodel->SetGrayLevel( bbGetInputGrayLevel() );
+ manualpaintmodel->SetDirection( bbGetInputDirection() );
+ manualpaintmodel->SetBrushSize( bbGetInputBrushSize() );
+ manualpaintmodel->SetBrushForm( bbGetInputBrushForm() );
+ manualpaintmodel->SetToleranceFill( bbGetInputToleranceFill() );
+ manualpaintmodel->SetDistanceFill( bbGetInputDistanceFill() );
+ manualpaintmodel->SetRangeMin( bbGetInputRange()[0] );
+ manualpaintmodel->SetRangeMax( bbGetInputRange()[1] );
+ if (bbGetInputPoint().size()==3)
+ {
+ manualpaintmodel->PaintImage( bbGetInputPoint()[0] , bbGetInputPoint()[1] , bbGetInputPoint()[2] );
+ } // if Points
+
+ if ( bbGetInputByLstPointsX().size()!=0 )
+ {
+ int i,size = bbGetInputByLstPointsX().size();
+ for (i=0;i<size;i++)
+ {
+ manualpaintmodel->PaintImage( bbGetInputByLstPointsX()[i] , bbGetInputByLstPointsY()[i] , bbGetInputByLstPointsZ()[i] );
+ } // for
+ }// if ByLstPointsX
+
+ if (bbGetInputByImagePoints()!=NULL)
+ {
+// int ia,ja,ka;
+// int ii,jj,kk;
+ int ext[6];
+ bbGetInputByImagePoints()->GetWholeExtent(ext);
+ int dimX=ext[1]-ext[0]+1;
+ int dimY=ext[3]-ext[2]+1;
+ int dimZ=ext[5]-ext[4]+1;
+
+ DEFINEPOINTERIMAGE_MANUALPAINT(vBIP,sSBIP,pBIP,sTBIP,bbGetInputByImagePoints());
+ DEFINEPOINTERIMAGE_MANUALPAINT(vI2,sSI2,pI2,sTI2,bbGetInputImage2());
+
+//#pragma omp parallel for
+
+ int i,j,k;
+ for (k=0;k<dimZ;k++)
+ {
+ if (k%50==0)
+ {
+ printf("ManualPaint_Model %d%\n", (int)(k*100.0/dimZ) );
+ }
+ for (j=0;j<dimY;j++)
+ {
+ for (i=0;i<dimX;i++)
+ {
+ GETVALUE_MANUALPAINT(vBIP,pBIP,sTBIP)
+ if (vBIP>0)
+ {
+ GETVALUE_MANUALPAINT(vI2,pI2,sTI2)
+ if (vI2==0)
+ {
+ manualpaintmodel->PaintImage(i,j,k);
+ } // vI2
+ } // vBIP
+ pBIP = pBIP + sSBIP;
+ pI2 = pI2 + sSI2;
+ }// for i
+ }// for j
+ }// for k
+
+ printf("ManualPaint_Model %d%\n", 100 );
+ } // if ByImagePoints
+ } else {
+ printf("EED Warning: Image not set. Box creaMaracasVisu::ManualPaint_Model (BBTK) \n");
+ } // if
+
+ if (bbGetInputImage2()!=NULL)
+ {
+ bbSetOutputOut( bbGetInputImage2() );
+ } else if (bbGetInputImage()!=NULL) {
+ bbSetOutputOut( bbGetInputImage() );
+ } else {
+ bbSetOutputOut( NULL );
+ }
+}
//=====
// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
//=====
_distancefill = 500;
_limitRecursionFill = 50000;
_auxImageFill = NULL;
+ _maxXback = 0;
+ _maxYback = 0;
+ _maxZback = 0;
}
//---------------------------------------------------------------------------
void FillFilter::SetImages(vtkImageData *image,vtkImageData *image2) // virtual
{
baseFilterManualPaint::SetImages(image,image2);
- if (_auxImageFill != NULL)
+
+ if ((_maxX!=_maxXback) || (_maxY!=_maxYback) || (_maxZ!=_maxZback))
{
- _auxImageFill->Delete();
+ if (_auxImageFill != NULL)
+ {
+ _auxImageFill->Delete();
+ }
+ _auxImageFill = vtkImageData::New();
+ _auxImageFill->SetDimensions(_maxX + 1, _maxY + 1, _maxZ + 1);
+ _auxImageFill->SetOrigin(0, 0, 0);
+ _auxImageFill->SetExtent(0, _maxX, 0, _maxY, 0, _maxZ);
+ _auxImageFill->SetWholeExtent(0, _maxX, 0, _maxY, 0, _maxZ);
+ _auxImageFill->SetScalarTypeToUnsignedChar();
+ _auxImageFill->AllocateScalars();
+ _ptrAuxImageFill = (unsigned char *)_auxImageFill->GetScalarPointer();
+ memset(_ptrAuxImageFill, 0, (_maxX+1) * (_maxY+1) * (_maxZ+1) );
}
- _auxImageFill = vtkImageData::New();
- _auxImageFill->SetDimensions(_maxX + 1, _maxY + 1, _maxZ + 1);
- _auxImageFill->SetOrigin(0, 0, 0);
- _auxImageFill->SetExtent(0, _maxX, 0, _maxY, 0, _maxZ);
- _auxImageFill->SetWholeExtent(0, _maxX, 0, _maxY, 0, _maxZ);
- _auxImageFill->SetScalarTypeToUnsignedChar();
- _auxImageFill->AllocateScalars();
+ _maxXback=_maxX;
+ _maxYback=_maxY;
+ _maxYback=_maxZ;
}
+
//---------------------------------------------------------------------------
void FillFilter::Run() // virtual
{
+ long int ivi;
if ((_px >= _minX) && (_px <= _maxX) && (_py >= _minY) && (_py <= _maxY)
- && (_pz >= _minZ) && (_pz <= _maxZ)) {
- _graylevelbasefill = _image->GetScalarComponentAsDouble(_px, _py, _pz,
- 0);
- _pxfill = _px;
- _pyfill = _py;
- _pzfill = _pz;
- _distbasefill = _distancefill * _distancefill;
- _countRecursiveFill = 0;
- _countRecursiveFillProblem = 0;
- _countProgressingFill = 0;
- unsigned char *pImage =
- (unsigned char *) _auxImageFill->GetScalarPointer();
- _usingAuxImageFill = false;
- memset(pImage, 0, _maxX * _maxY * _maxZ);
-
- FillToolRecursive(_px, _py, _pz);
-// printf("--\n");
-
+ && (_pz >= _minZ) && (_pz <= _maxZ))
+ {
+ _graylevelbasefill = _image->GetScalarComponentAsDouble(_px, _py, _pz,0);
+ _pxfill = _px;
+ _pyfill = _py;
+ _pzfill = _pz;
+ _distbasefill = _distancefill * _distancefill;
+ _countRecursiveFill = 0;
+ _countRecursiveFillProblem = 0;
+ _countProgressingFill = 0;
+ _usingAuxImageFill = false;
+ ivi = _px + _py*(_maxX+1) + _pz*(_maxX+1)*(_maxY+1); // index vector image
+//EED01
+// FillToolRecursive(_px, _py, _pz);
+ FillToolRecursive(_px, _py, _pz, ivi);
+
+ unsigned char *pImage;
+ pImage = (unsigned char *) _auxImageFill->GetScalarPointer();
int ii, jj, kk;
- while (_countRecursiveFillProblem != 0) {
- _countRecursiveFillProblem = 0;
- _usingAuxImageFill = true;
- for (ii = 0; ii <= _maxX; ii++) {
- for (jj = 0; jj <= _maxY; jj++) {
- for (kk = 0; kk <= _maxZ; kk++) {
- pImage =
- (unsigned char *) _auxImageFill->GetScalarPointer(
- ii, jj, kk);
- if ((*pImage) == 1) {
- FillToolRecursive(ii, jj, kk);
- }
- } // for kk
+ ivi = 0;
+ while (_countRecursiveFillProblem != 0)
+ {
+ _countRecursiveFillProblem = 0;
+ _usingAuxImageFill = true;
+ for (kk = 0; kk <= _maxZ; kk++)
+ {
+ for (jj = 0; jj <= _maxY; jj++)
+ {
+ for (ii = 0; ii <= _maxX; ii++)
+ {
+ if (pImage[ivi] == 1)
+ {
+//EED01
+// FillToolRecursive(ii, jj, kk);
+ FillToolRecursive(ii, jj, kk, ivi);
+ } // if
+ ivi++;
+ } // for ii
} // for jj
- } //for ii
+ } //for kk
// printf("-\n");
} // while
-
} //if _minX _maxX _minY _maxY _minZ _maxZ
}
//---------------------------------------------------------------------------
-void FillFilter::FillToolRecursive(int px, int py, int pz)
+void FillFilter::FillToolRecursive(int px, int py, int pz,long int ivi)
{
- _countRecursiveFill++;
+DEFINEPOINTERIMAGE_MANUALPAINT(v_image,ss_image,p_image,st_image,_image)
+DEFINEPOINTERIMAGE_MANUALPAINT(v_image2,ss_image2,p_image2,st_image2,_image2)
+ _countRecursiveFill++;
_countProgressingFill++;
if (_countProgressingFill > 200000)
{
if (_usingAuxImageFill == true)
{
this->_IMManager->AddModifiedPixel(px, py, pz); //DFCH
- _auxImageFill->SetScalarComponentFromFloat(px, py, pz, 0, 0);
+//EED01
+// _auxImageFill->SetScalarComponentFromFloat(px, py, pz, 0, 0);
+ _ptrAuxImageFill[ ivi ]=0;
}
- _tmpDistfill = (px - _pxfill) * (px - _pxfill)
- + (py - _pyfill) * (py - _pyfill)
- + (pz - _pzfill) * (pz - _pzfill);
- _tmpiglfill = _image->GetScalarComponentAsDouble(px, py, pz, 0);
+ _tmpDistfill = (px-_pxfill)*(px-_pxfill)
+ + (py-_pyfill)*(py-_pyfill)
+ + (pz-_pzfill)*(pz-_pzfill);
+
+//if (_countRecursiveFill >1 )
+//{
+// printf(" -> %d %d %d cr=%ld r=%f\n", px,py,pz,_countRecursiveFill , _tmpDistfill);
+//}
+
+
+//EED01
+// _tmpiglfill = _image->GetScalarComponentAsDouble(px, py, pz, 0);
+GETVALUE2_MANUALPAINT(_tmpiglfill,p_image,st_image,ivi)
if (_image2!=NULL)
{
- _tmpiglfill2 = _image2->GetScalarComponentAsDouble(px, py, pz, 0);
+//EED01
+// _tmpiglfill2 = _image2->GetScalarComponentAsDouble(px, py, pz, 0);
+GETVALUE2_MANUALPAINT(_tmpiglfill2,p_image2,st_image2,ivi)
} else {
_tmpiglfill2 = _tmpiglfill;
}
- float grayLBFMTOL = _graylevelbasefill - _tolerancefill;
- float grayLBFPTOL = _graylevelbasefill + _tolerancefill;
- bool isInRange = false;
+ float grayLBFMTOL = _graylevelbasefill - _tolerancefill;
+ float grayLBFPTOL = _graylevelbasefill + _tolerancefill;
+ bool isInRange = false;
//DFCH
if (_RangeMin <= grayLBFMTOL && _RangeMax >= grayLBFPTOL) {
- isInRange = true;
+ isInRange = true;
} //fi esle
else if (_RangeMin > grayLBFMTOL && _RangeMax >= grayLBFPTOL) {
- grayLBFMTOL = _RangeMin;
- isInRange = true;
+ grayLBFMTOL = _RangeMin;
+ isInRange = true;
} //fi esle
else if (_RangeMin <= grayLBFMTOL && _RangeMax < grayLBFPTOL) {
- grayLBFPTOL = _RangeMax;
- isInRange = true;
- } //fi esle
- else if ((_RangeMin <= _graylevelbasefill)
- && (_graylevelbasefill <= _RangeMax)) {
- grayLBFMTOL = _RangeMin;
- grayLBFPTOL = _RangeMax;
- isInRange = true;
+ grayLBFPTOL = _RangeMax;
+ isInRange = true;
} //fi esle
+ else if ((_RangeMin <= _graylevelbasefill) && (_graylevelbasefill <= _RangeMax)) {
+ grayLBFMTOL = _RangeMin;
+ grayLBFPTOL = _RangeMax;
+ isInRange = true;
+ } //fi Range
if (isInRange)
{
this->_IMManager->AddModifiedPixel(px, py, pz); //DFCH
if (_image2!=NULL)
{
- _image2->SetScalarComponentFromFloat(px, py, pz, 0,(float) _graylevel);
+//EED01
+// _image2->SetScalarComponentFromFloat(px, py, pz, 0,(float) _graylevel);
+SETVALUE2_MANUALPAINT(_graylevel,p_image2,st_image2,ivi)
} else {
- _image->SetScalarComponentFromFloat(px, py, pz, 0,(float) _graylevel);
+//EED01
+// _image->SetScalarComponentFromFloat(px, py, pz, 0,(float) _graylevel);
+SETVALUE2_MANUALPAINT(_graylevel,p_image,st_image,ivi)
}
if (_countRecursiveFill < _limitRecursionFill)
{
//FillToolRecursive(px+1,py,pz);
//FillToolRecursive(px-1,py,pz);
- FillToolRecursive(px, py + 1, pz);
- FillToolRecursive(px, py - 1, pz);
- FillToolRecursive(px, py, pz - 1);
- FillToolRecursive(px, py, pz + 1);
+ FillToolRecursive(px, py + 1, pz, ivi+_OneLine );
+ FillToolRecursive(px, py - 1, pz, ivi-_OneLine );
+ FillToolRecursive(px, py, pz - 1, ivi-_OnePlane );
+ FillToolRecursive(px, py, pz + 1, ivi+_OnePlane );
}
if (_direction == 1) // XZ
{
- FillToolRecursive(px + 1, py, pz);
- FillToolRecursive(px - 1, py, pz);
+ FillToolRecursive(px + 1, py, pz, ivi+_OneColumn);
+ FillToolRecursive(px - 1, py, pz, ivi-_OneColumn);
//FillToolRecursive(px,py+1,pz);
//FillToolRecursive(px,py-1,pz);
- FillToolRecursive(px, py, pz - 1);
- FillToolRecursive(px, py, pz + 1);
+ FillToolRecursive(px, py, pz - 1, ivi-_OnePlane );
+ FillToolRecursive(px, py, pz + 1, ivi+_OnePlane );
}
if (_direction == 2) // XY
{
- FillToolRecursive(px + 1, py, pz);
- FillToolRecursive(px, py + 1, pz);
- FillToolRecursive(px - 1, py, pz);
- FillToolRecursive(px, py - 1, pz);
+ FillToolRecursive(px + 1, py, pz, ivi+_OneColumn);
+ FillToolRecursive(px, py + 1, pz, ivi+_OneLine);
+ FillToolRecursive(px - 1, py, pz, ivi-_OneColumn);
+ FillToolRecursive(px, py - 1, pz, ivi-_OneLine);
//FillToolRecursive(px,py,pz-1);
//FillToolRecursive(px,py,pz+1);
}
} else { // 3D
-
- FillToolRecursive(px + 1, py, pz);
- FillToolRecursive(px - 1, py, pz);
- FillToolRecursive(px, py + 1, pz);
- FillToolRecursive(px, py - 1, pz);
- FillToolRecursive(px, py, pz - 1);
- FillToolRecursive(px, py, pz + 1);
+ FillToolRecursive(px + 1, py, pz, ivi+_OneColumn );
+ FillToolRecursive(px - 1, py, pz, ivi-_OneColumn );
+ FillToolRecursive(px, py + 1, pz, ivi+_OneLine );
+ FillToolRecursive(px, py - 1, pz, ivi-_OneLine );
+ FillToolRecursive(px, py, pz - 1, ivi-_OnePlane );
+ FillToolRecursive(px, py, pz + 1, ivi+_OnePlane );
} // 2D 3D
} //_countRecursiveFill
} // _graylevel
- if ((_auxGrayLevelValidationFill == true)
- && (_countRecursiveFill >= _limitRecursionFill))
+ if ((_auxGrayLevelValidationFill == true) && (_countRecursiveFill >= _limitRecursionFill))
{
_countRecursiveFillProblem++;
-
if (_2D3D == 0) //2D
- {
+ {
if (_direction == 0) // YZ
- {
+ {
//SetAuxImageFill(px+1,py,pz);
//SetAuxImageFill(px-1,py,pz);
- SetAuxImageFill(px, py + 1, pz);
- SetAuxImageFill(px, py - 1, pz);
- SetAuxImageFill(px, py, pz - 1);
- SetAuxImageFill(px, py, pz + 1);
+ SetAuxImageFill(px, py + 1, pz,ivi+_OneLine);
+ SetAuxImageFill(px, py - 1, pz,ivi-_OneLine);
+ SetAuxImageFill(px, py, pz - 1,ivi-_OnePlane);
+ SetAuxImageFill(px, py, pz + 1,ivi+_OnePlane);
}
if (_direction == 1) // XZ
- {
- SetAuxImageFill(px + 1, py, pz);
- SetAuxImageFill(px - 1, py, pz);
+ {
+ SetAuxImageFill(px + 1, py, pz,ivi+_OneColumn);
+ SetAuxImageFill(px - 1, py, pz,ivi-_OneColumn);
//SetAuxImageFill(px,py+1,pz);
//SetAuxImageFill(px,py-1,pz);
- SetAuxImageFill(px, py, pz - 1);
- SetAuxImageFill(px, py, pz + 1);
+ SetAuxImageFill(px, py, pz - 1,ivi-_OnePlane);
+ SetAuxImageFill(px, py, pz + 1,ivi+_OnePlane);
}
if (_direction == 2) // XY
- {
- SetAuxImageFill(px + 1, py, pz);
- SetAuxImageFill(px - 1, py, pz);
- SetAuxImageFill(px, py + 1, pz);
- SetAuxImageFill(px, py - 1, pz);
+ {
+ SetAuxImageFill(px + 1, py, pz,ivi+_OneColumn);
+ SetAuxImageFill(px - 1, py, pz,ivi-_OneColumn);
+ SetAuxImageFill(px, py + 1, pz,ivi+_OneLine);
+ SetAuxImageFill(px, py - 1, pz,ivi-_OneLine);
//SetAuxImageFill(px,py,pz-1);
//SetAuxImageFill(px,py,pz+1);
}
} else { // 3D
-
- SetAuxImageFill(px + 1, py, pz);
- SetAuxImageFill(px - 1, py, pz);
- SetAuxImageFill(px, py + 1, pz);
- SetAuxImageFill(px, py - 1, pz);
- SetAuxImageFill(px, py, pz - 1);
- SetAuxImageFill(px, py, pz + 1);
+ SetAuxImageFill(px + 1, py, pz,ivi+_OneColumn);
+ SetAuxImageFill(px - 1, py, pz,ivi-_OneColumn);
+ SetAuxImageFill(px, py + 1, pz,ivi+_OneLine);
+ SetAuxImageFill(px, py - 1, pz,ivi-_OneLine);
+ SetAuxImageFill(px, py, pz - 1,ivi-_OnePlane);
+ SetAuxImageFill(px, py, pz + 1,ivi+_OnePlane);
} // 2D 3D
} // _graylevel //_limitRecursionFill
} //if _minX _maxX _minY _maxY _minZ _maxZ
-
_countRecursiveFill--;
-
}
//---------------------------------------------------------------------------
-void FillFilter::SetAuxImageFill(int px, int py, int pz)
+void FillFilter::SetAuxImageFill(int px, int py, int pz, long int ivi)
{
if ((px >= _minX) && (px <= _maxX) && (py >= _minY) && (py <= _maxY)
- && (pz >= _minZ) && (pz <= _maxZ)) {
+ && (pz >= _minZ) && (pz <= _maxZ))
+ {
this->_IMManager->AddModifiedPixel(px, py, pz); //DFCH
- _auxImageFill->SetScalarComponentFromFloat(px, py, pz, 0, 1);
- }
+//EED01
+// _auxImageFill->SetScalarComponentFromFloat(px, py, pz, 0, 1);
+ _ptrAuxImageFill[ ivi ]=1;
+ } // if px py pz
}
//---------------------------------------------------------------------------