sizeZ = 1;
vtkImageData *newImage = vtkImageData::New();
newImage->Initialize();
- newImage->SetScalarTypeToUnsignedChar();
newImage->SetSpacing( 1,1,1 );
newImage->SetDimensions( sizeX,sizeY,sizeZ );
- newImage->SetWholeExtent(0, sizeX-1,0,sizeY-1,0,sizeZ-1 );
newImage->SetExtent(0, sizeX-1,0,sizeY-1,0,sizeZ-1 );
+
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
+ newImage->SetWholeExtent(0, sizeX-1,0,sizeY-1,0,sizeZ-1 );
+ newImage->SetScalarTypeToUnsignedChar();
newImage->SetNumberOfScalarComponents(1);
newImage->AllocateScalars();
newImage->Update();
+#else
+ newImage->AllocateScalars(VTK_UNSIGNED_CHAR,1);
+#endif
+
memset ( (void*)newImage->GetScalarPointer(), 0, sizeX*sizeY*1 );
for (i=0; i<sizeX; i++)
{
f->SetFileName( bbGetInputIn()[0] );
} else {
f->SetFileName( "" );
- }
+ } // if
bool res = f->Load();
if ( !res )
f->Delete();
bbSetOutputOut( CreateDefaultImage() );
return;
- }
+ } // if res
// Get info from the first image file
int i;
std::vector<double> v_iop;
for(i=0; i< 6; i++)
{
v_iop.push_back(iop[i]);
- }
+ } // for i
bbSetOutputIOP(v_iop );
std::vector<double> v_ipp;
for(i=0; i< 3; i++)
{
v_ipp.push_back(ipp[i]);
- }
+ } // for i
bbSetOutputIPP(v_ipp );
// Add *all the files* to the SerieHelper
++it)
{
sh->AddFileName(*it);
- }
+ } //for vector
GDCM_NAME_SPACE::FileList::const_iterator it;
// Should only contain one!
l = sh->GetFirstSingleSerieUIDFileSet();
- int nbFiles;
- double zspacing = 0.;
- nbFiles = l->size() ;
+ double zspacing = 0.;
sh->OrderFileList(l); // this one should compute the *actual* Z Spacing!
- zspacing = sh->GetZSpacing();
+ zspacing = sh->GetZSpacing();
std::vector<double> v_pixelspacing;
v_pixelspacing.push_back( f->GetXSpacing() );
v_pixelspacing.push_back( f->GetYSpacing() );
// v_pixelspacing.push_back(f->GetZSpacing());
// }
bbSetOutputPixelSpacing(v_pixelspacing);
+
+ VectorMapInfoDicom vectormapinfodicom;
+ uint16_t group;
+ uint16_t elem;
+ std::string key;
+ std::string strTagValue; // read on disc
+ int iTag,sizeDicomTagsVector=bbGetInputDicomTags().size();
+ GDCM_NAME_SPACE::FileList::const_iterator iitt = l->begin();
+ //iitt ++;
+ for ( ; iitt != l->end(); ++iitt)
+ {
+ MapInfoDicom mapinfodicom;
+
+ for (iTag=0; iTag<sizeDicomTagsVector; iTag++)
+ {
+ key = bbGetInputDicomTags()[iTag];
+ group = elem = 0;
+ if ( (key.size()==10) && (key[0] == 'D') && (key[5] == '_') )
+ {
+ sscanf(key.c_str(),"D%04hx_%04hx ",&group,&elem);
+ }// if key
+ strTagValue = (*iitt)->GetEntryString(group,elem);
+ mapinfodicom.insert ( std::pair<std::string,std::string>(key,strTagValue) );
+ } // for iTag
+
+ vectormapinfodicom.push_back( mapinfodicom );
+ } // for iitt
+ bbSetOutputDicomInfo( vectormapinfodicom );
+
if (reader!=NULL)
{
reader->Delete();
- reader=NULL;
+ reader = NULL;
}
reader = vtkGdcmReader::New();
-
//EED 21 mars 2012 FLIP probleme ..PLOP..
reader->SetFlipY(false);
-
-
//reader->SetFileName( bbGetInputIn().c_str() );
reader->SetCoherentFileList(l);
reader->Update();
- printf("EED GetXCoherentInfoGdcmReader::Process \n");
+ reader->GetOutput();
+
bbSetOutputOut( reader->GetOutput() );
}
#endif
gdcm::Element<gdcm::VR::DS,gdcm::VM::VM6> iop;
iop.Read( ss );
for(i=0; i< 6; i++)
- v_iop.push_back((float)(iop[i]));
+ {
+ v_iop.push_back((float)(iop[i]));
+ }
bbSetOutputIOP(v_iop );
std::vector<double> v_ipp;
deIpp.GetValue().Print(ss);
gdcm::Element<gdcm::VR::DS,gdcm::VM::VM3> ipp;
ipp.Read( ss );
- for(i=0; i< 3; i++)
+ for(i=0; i< 3; i++)
+ {
v_ipp.push_back((float)(ipp[i]));
+ } // for 3
bbSetOutputIPP(v_ipp );
// Add *all the files* to the IPPsorter
void GetXCoherentInfoGdcmReader::bbUserFinalizeProcessing()
{
if(reader)
+ {
reader->Delete();
+ } // if reader
if(f)
+ {
f->Delete();
+ } // if f
if(sh)
+ {
sh->Delete();
+ } // if sh
}
#endif
void GetXCoherentInfoGdcmReader::bbUserFinalizeProcessing()
{
if(reader)
+ {
reader->Delete();
+ }
}
#endif
// * TYPE is the C++ type of the input/output
// (the one provided in the attribute 'type' of the tag 'input')
- double spc[6];
+ double spc[3];
int dim[3];
int outputformat = VTK_UNSIGNED_SHORT;
+
if (bbGetInputOutputFormat()=="VTK_BIT") outputformat = VTK_BIT; // 1
else if (bbGetInputOutputFormat()=="VTK_CHAR") outputformat = VTK_CHAR; // 2
else if (bbGetInputOutputFormat()=="MET_CHAR") outputformat = VTK_CHAR; // 2
else if (bbGetInputOutputFormat()=="MET_FLOAT") outputformat = VTK_FLOAT; // 10
else if (bbGetInputOutputFormat()=="VTK_DOUBLE") outputformat = VTK_DOUBLE; // 11
else if (bbGetInputOutputFormat()=="MET_DOUBLE") outputformat = VTK_DOUBLE; // 11
-
+
spc[0] = bbGetInputSpacing()[0];
spc[1] = bbGetInputSpacing()[1];
spc[2] = bbGetInputSpacing()[2];
-
dim[0] = bbGetInputDimensions()[0];
dim[1] = bbGetInputDimensions()[1];
dim[2] = bbGetInputDimensions()[2];
-
+ if ((dim[0]<=0)||(dim[1]<=0)||(dim[2]<=0))
+ {
+ dim[0]=1;
+ dim[1]=1;
+ dim[2]=1;
+ }
+ if ((spc[0]<=0)||(spc[1]<=0)||(spc[2]<=0))
+ {
+ spc[0]=1;
+ spc[1]=1;
+ spc[2]=1;
+ }
+ //EED 2017-12-7
+ if (imageoutput!=NULL)
+ {
+ imageoutput->Delete();
+ }
+ imageoutput = vtkImageData::New();
imageoutput->Initialize();
- imageoutput->SetScalarType( outputformat );
imageoutput->SetSpacing( spc );
imageoutput->SetDimensions( dim[0], dim[1], dim[2] );
+
+//EED 2017-01-01 Migration VTK7
+#if (VTK_MAJOR_VERSION <= 5)
+ imageoutput->SetScalarType( outputformat );
imageoutput->AllocateScalars();
-
+#endif
+#if (VTK_MAJOR_VERSION >= 6)
+ imageoutput->AllocateScalars( outputformat,1 );
+#endif
+
int i,j,k;
long sizeBlock;
+
for (i=0; i<dim[0]; i++)
{
imageoutput->SetScalarComponentFromDouble(i,0,0, 0, bbGetInputInitialValue() );
- }
+ } // for i
+
sizeBlock= dim[0] * imageoutput->GetScalarSize();
- for (j=1; j<dim[1]; j++)
+ for (j=1; j<dim[1]; j++)
{
memcpy( imageoutput->GetScalarPointer(0,j,0), imageoutput->GetScalarPointer() , sizeBlock );
- }
+ } // for j
+
sizeBlock= dim[0] * dim[1] * imageoutput->GetScalarSize();
for (k=0; k<dim[2]; k++)
{
memcpy( imageoutput->GetScalarPointer(0,0,k) ,imageoutput->GetScalarPointer() , sizeBlock );
} // for k
-
++
+
+//EED 2017-01-01 Migration VTK7
+#if (VTK_MAJOR_VERSION <= 5)
imageoutput->Update();
+#endif
+#if (VTK_MAJOR_VERSION >= 6)
+ // ..
+#endif
+
imageoutput->Modified();
bbSetOutputOut(imageoutput);
}
// but this is where you should allocate the internal/output pointers
// if any
- imageoutput = vtkImageData::New();
+ //EED 2017-12-7 imageoutput = vtkImageData::New();
}
//=====
#include "bbvtkImageBoundaries.h"
#include "bbvtkPackage.h"
+ #include "creaVtk_MACROS.h"
+
+ #include <omp.h>
namespace bbvtk
{
//=====
void ImageBoundaries::Process()
{
- if (bbGetInputIn()!=NULL)
- {
- int ext[6];
+ printf("bbtk:vtk::ImageBoundaries::Process start\n");
+ if (bbGetInputIn()!=NULL){
+ int i,j,k;
+ int ext[6];
+ double value;
+
+//EED 2017-01-01 Migration VTK7
+#if (VTK_MAJOR_VERSION <= 5)
bbGetInputIn()->GetWholeExtent(ext);
+#endif
+#if (VTK_MAJOR_VERSION >= 6)
+ bbGetInputIn()->GetExtent(ext);
+#endif
+
int maxX = ext[1]-ext[0]+1;
int maxY = ext[3]-ext[2]+1;
int maxZ = ext[5]-ext[4]+1;
-
int bXMax = 0;
int bYMax = 0;
int bZMax = 0;
int bYMin = maxY-1;
int bZMin = maxZ-1;
- for (i=0 ; i<maxX ; i++)
+ /*
+ #pragma omp parallel for
+ for (int i=0 ; i<maxX ; i++)
{
+ int j;
+ int k;
for (j=0 ; j<maxY ; j++)
{
for (k=0 ; k<maxZ ; k++)
{
- value = bbGetInputIn()->GetScalarComponentAsDouble(i, j, k,0);
+ double value = bbGetInputIn()->GetScalarComponentAsDouble(i, j, k,0);
if ( (value>=bbGetInputLowerValue()) && (value<=bbGetInputUpperValue()) )
{
if (i<bXMin) bXMin=i;
} // for k
} // for j
} // i
-
+ */
+
+ DEF_POINTER_IMAGE_VTK_CREA(vI,ssI,pI,stI,bbGetInputIn())
+ int i;
+ int j;
+ long int index=0;
+ for (int k=0 ; k<maxZ ; k++)
+ {
+ for (j=0 ; j<maxY ; j++)
+ {
+ for (i=0 ; i<maxX ; i++)
+ {
+ // double value = bbGetInputIn()->GetScalarComponentAsDouble(i, j, k,0);
+ GETVALUE2_VTK_CREA(vI,pI,stI,index)
+ index++;
+ if ( (vI>=bbGetInputLowerValue()) && (vI<=bbGetInputUpperValue()) )
+ {
+ if (i<bXMin) bXMin=i;
+ if (j<bYMin) bYMin=j;
+ if (k<bZMin) bZMin=k;
+ if (i>bXMax) bXMax=i;
+ if (j>bYMax) bYMax=j;
+ if (k>bZMax) bZMax=k;
+ }
+ } // for k
+ } // for j
+ } // i
std::vector<int> tmpIndex;
std::vector<int> tmpSize;
-
if (bXMin>bXMax){
tmpIndex.push_back(0);
tmpIndex.push_back(0);
tmpSize.push_back(bYMax-bYMin+1);
tmpSize.push_back(bZMax-bZMin+1);
}
-
bbSetOutputIndex(tmpIndex);
bbSetOutputSize(tmpSize);
} else {
printf("bbtk warnning: bbtk:vtk:ImageBoundaries box, Input image (In) not initialized..\n");
}
- printf("bbtk:vtk::ImageBoundaries::Process end\n");
}
//=====
// 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 ImagePlanes::bbUserSetDefaultValues()
{
- bbSetOutputPlaneX(0);
- bbSetOutputPlaneY(0);
- bbSetOutputPlaneZ(0);
- bbSetOutputImageX(0);
- bbSetOutputImageY(0);
- bbSetOutputImageZ(0);
- bbSetInputIn(0);
+ bbSetOutputPlaneX(NULL);
+ bbSetOutputPlaneY(NULL);
+ bbSetOutputPlaneZ(NULL);
+ bbSetOutputImageX(NULL);
+ bbSetOutputImageY(NULL);
+ bbSetOutputImageZ(NULL);
+ bbSetInputIn(NULL);
std::vector<double> vect;
vect.push_back(0);
vect.push_back(0);
// EED MPR view orientation correction..
vtkImageFlip *flipYFilter = vtkImageFlip::New();
flipYFilter->SetFilteredAxis(1); // flip y axis
+
+//EED 2017-01-01 Migration VTK7
+#if (VTK_MAJOR_VERSION <= 5)
flipYFilter->SetInput( planeWidgetX->GetResliceOutput() );
+#endif
+#if (VTK_MAJOR_VERSION >= 6)
+ flipYFilter->SetInputData( planeWidgetX->GetResliceOutput() );
+#endif
+
flipYFilter->Update();
vtkImageChangeInformation *image = vtkImageChangeInformation::New();
+
+//EED 2017-01-01 Migration VTK7
+#if (VTK_MAJOR_VERSION <= 5)
image->SetInput( planeWidgetY->GetResliceOutput() );
+#endif
+#if (VTK_MAJOR_VERSION >= 6)
+ image->SetInputData( planeWidgetY->GetResliceOutput() );
+#endif
+
image->SetOutputSpacing( 1,1,1 );
image->CenterImageOn();
image->Update();
_imageTransform = vtkTransform::New();
vtkImageReslice *slicer =vtkImageReslice::New();
+
+//EED 2017-01-01 Migration VTK7
+#if (VTK_MAJOR_VERSION <= 5)
slicer->SetInput( image->GetOutput() );
+#endif
+#if (VTK_MAJOR_VERSION >= 6)
+ slicer->SetInputData( image->GetOutput() );
+#endif
+
slicer->SetInformationInput( image->GetOutput() );
slicer->SetResliceTransform( _imageTransform );
slicer->SetOutputOrigin(0 , 0 , 0 );
slicer->SetInterpolationModeToNearestNeighbor();
slicer->Update();
vtkImageChangeInformation *imageResult = vtkImageChangeInformation::New();
+
+//EED 2017-01-01 Migration VTK7
+#if (VTK_MAJOR_VERSION <= 5)
imageResult->SetInput( slicer->GetOutput() );
+#endif
+#if (VTK_MAJOR_VERSION >= 6)
+ imageResult->SetInputData( slicer->GetOutput() );
+#endif
+
double spc[3];
planeWidgetY->GetResliceOutput()->GetSpacing(spc);
imageResult->SetOutputSpacing( spc[1], spc[0], spc[2] );
//bbSetOutputImage3Pts(planeWidget3Pts->GetResliceOutput());
if(picker != 0)
+ {
picker->UnRegister(NULL);
-
+ }
+
mVtkCallback = VtkCallbackType::New();
mVtkCallback->SetBlackBox(this);
planeWidgetX->AddObserver(vtkCommand::InteractionEvent,mVtkCallback);
{
int dim[3];
int ext[6];
+//EED 2017-01-01 Migration VTK7
+#if (VTK_MAJOR_VERSION <= 5)
bbGetOutputPlaneX()->GetResliceOutput()->GetWholeExtent(ext);
+#endif
+#if (VTK_MAJOR_VERSION >= 6)
+ bbGetOutputPlaneX()->GetResliceOutput()->GetExtent(ext);
+#endif
+
dim[0] = ext[1]-ext[0]+1;
dim[1] = ext[3]-ext[2]+1;
dim[2] = ext[5]-ext[4]+1;
double xSpacing, ySpacing, zSpacing;
bbGetInputIn()->GetSpacing(xSpacing, ySpacing, zSpacing);
+//EED 2017-01-01 Migration VTK7
+#if (VTK_MAJOR_VERSION <= 5)
bbGetOutputPlaneX()->SetInput(bbGetInputIn());
+#endif
+#if (VTK_MAJOR_VERSION >= 6)
+ bbGetOutputPlaneX()->SetInputData(bbGetInputIn());
+#endif
+
bbGetOutputPlaneX()->SetPlaneOrientationToXAxes();
bbGetOutputPlaneX()->SetSlicePosition((xMax+xMin)/2.*xSpacing);
// bbGetOutputPlaneX()->SetPoint1( 0*xSpacing, 146*ySpacing, 186*zSpacing);
// bbGetOutputPlaneX()->SetPoint2( 126*xSpacing, 146*ySpacing, 0*zSpacing);
+//EED 2017-01-01 Migration VTK7
+#if (VTK_MAJOR_VERSION <= 5)
bbGetOutputPlaneY()->SetInput(bbGetInputIn());
+#endif
+#if (VTK_MAJOR_VERSION >= 6)
+ bbGetOutputPlaneY()->SetInputData(bbGetInputIn());
+#endif
+
bbGetOutputPlaneY()->SetPlaneOrientationToYAxes();
bbGetOutputPlaneY()->SetSlicePosition((yMax+yMin)/2.*ySpacing);
+//EED 2017-01-01 Migration VTK7
+#if (VTK_MAJOR_VERSION <= 5)
bbGetOutputPlaneZ()->SetInput(bbGetInputIn());
+#endif
+#if (VTK_MAJOR_VERSION >= 6)
+ bbGetOutputPlaneZ()->SetInputData(bbGetInputIn());
+#endif
+
bbGetOutputPlaneZ()->SetPlaneOrientationToZAxes();
bbGetOutputPlaneZ()->SetSlicePosition((zMax+zMin)/2.*zSpacing);
bbGetOutputPlaneZ()->SetResliceInterpolate( bbGetInputInterpolation() );
+//EED 2017-01-01 Migration VTK7
+#if (VTK_MAJOR_VERSION <= 5)
bbGetOutputPlaneX()->GetResliceOutput()->Update();
bbGetOutputPlaneY()->GetResliceOutput()->Update();
bbGetOutputPlaneZ()->GetResliceOutput()->Update();
+#endif
+#if (VTK_MAJOR_VERSION >= 6)
+ // ...
+#endif
std::vector<int> pointsx = bbGetInputPointsX();
std::vector<int> pointsy = bbGetInputPointsY();
//Get the corresponding three points out of the vectors
double origin[3];
- origin[0] = pointsx[0];
- origin[1] = pointsy[0];
- origin[2] = pointsz[0];
+ origin[0] = pointsx[0];
+ origin[1] = pointsy[0];
+ origin[2] = pointsz[0];
double point1[3];
- point1[0] = pointsx[1];
- point1[1] = pointsy[1];
- point1[2] = pointsz[1];
+ point1[0] = pointsx[1];
+ point1[1] = pointsy[1];
+ point1[2] = pointsz[1];
double point2[3];
- point2[0]= pointsx[2];
- point2[1]= pointsy[2];
- point2[2]= pointsz[2];
+ point2[0] = pointsx[2];
+ point2[1] = pointsy[2];
+ point2[2] = pointsz[2];
//With the three points we create the corresponding X, Y and Z vectors all orthogonal to each other
- double* vect1= getNormal(makeVector(origin, point1));
- double* vect2= getNormal(makeVector(origin, point2));
- double* crossp = getCrossProduct(vect1, vect2);
+ double* vect1 = getNormal(makeVector(origin, point1));
+ double* vect2 = getNormal(makeVector(origin, point2));
+ double* crossp = getCrossProduct(vect1, vect2);
- double *newx = getCrossProduct(vect2, crossp);
+ double *newx = getCrossProduct(vect2, crossp);
- int ext[6],factor=0;
+ int ext[6],factor = 0;
bbGetInputIn()->GetExtent(ext);
factor = ext[0]<ext[3]? ext[3] : ext[0];
//for the plane widgets
vtkImagePlaneWidget* plane3pts = (vtkImagePlaneWidget*)bbGetOutputPlane3Pts();
+
+//EED 2017-01-01 Migration VTK7
+#if (VTK_MAJOR_VERSION <= 5)
plane3pts->SetInput(bbGetInputIn());
+#endif
+#if (VTK_MAJOR_VERSION >= 6)
+ plane3pts->SetInputData(bbGetInputIn());
+#endif
+
double xSpacing, ySpacing, zSpacing;
bbGetInputIn()->GetSpacing(xSpacing, ySpacing, zSpacing);
plane3pts->SetOrigin(pointsx[0]*xSpacing,pointsy[0]*ySpacing,pointsz[0]*zSpacing);
plane3pts->SetPoint2((origin[0]+vect2[0]*factor)*xSpacing,
(origin[1]+vect2[1]*factor)*ySpacing,
(origin[2]+vect2[2]*factor)*zSpacing);
+
+//EED 2017-01-01 Migration VTK7
+#if (VTK_MAJOR_VERSION <= 5)
plane3pts->GetResliceOutput()->Update();
+#endif
+#if (VTK_MAJOR_VERSION >= 6)
+ // ..
+#endif
+
//To get the slice of image out of the selected volume
- if (_imageReslicer==NULL){
+ if (_imageReslicer==NULL)
+ {
_imageReslicer = vtkImageReslice::New();
_imageReslicer->SetOutputDimensionality(2);
_transform = vtkTransform::New();
_matrix = vtkMatrix4x4::New();
- }
+ } // if
_imageReslicer->SetInterpolationMode( bbGetInputInterpolation() );
+
+//EED 2017-01-01 Migration VTK7
+#if (VTK_MAJOR_VERSION <= 5)
_imageReslicer->SetInput( bbGetInputIn() );
+#endif
+#if (VTK_MAJOR_VERSION >= 6)
+ _imageReslicer->SetInputData( bbGetInputIn() );
+#endif
+
+
_imageReslicer->SetInformationInput(bbGetInputIn());
//fill out the information with the created vectors and using the spacing of the image
_imageReslicer->SetResliceAxesDirectionCosines(newx[0]*xSpacing,newx[1]*xSpacing,newx[2]*xSpacing,
vect2[0]*ySpacing,vect2[1]*ySpacing,vect2[2]*ySpacing,
crossp[0]*zSpacing,crossp[1]*zSpacing,crossp[2]*zSpacing);
_imageReslicer->SetResliceAxesOrigin(origin[0]*xSpacing,origin[1]*ySpacing,origin[2]*zSpacing);
+
+
+//EED 2017-01-01 Migration VTK7
+#if (VTK_MAJOR_VERSION <= 5)
_imageReslicer->GetOutput()->Update();
_imageReslicer->GetOutput()->UpdateInformation();
+#endif
+#if (VTK_MAJOR_VERSION >= 6)
+ _imageReslicer->Update();
+#endif
+
+
bbSetOutputImage3Pts(_imageReslicer->GetOutput());
} // bbGetInputIn
}
- void ImagePlanes::updateInteractor(){
-
- vtkRenderWindowInteractor* interactor = bbGetInputInteractor();
-
- if(interactor){
- bbGetOutputPlaneX()->SetInteractor(interactor);
- bbGetOutputPlaneX()->EnabledOn();
- bbGetOutputPlaneY()->SetInteractor(interactor);
- bbGetOutputPlaneY()->EnabledOn();
- bbGetOutputPlaneZ()->SetInteractor(interactor);
- bbGetOutputPlaneZ()->EnabledOn();
- bbGetOutputPlane3Pts()->SetInteractor(interactor);
- bbGetOutputPlane3Pts()->EnabledOn();
- }
- }
+ void ImagePlanes::updateInteractor()
+ {
+ vtkRenderWindowInteractor* interactor = bbGetInputInteractor();
+ if(interactor)
+ {
+ bbGetOutputPlaneX()->SetInteractor(interactor);
+ bbGetOutputPlaneX()->EnabledOn();
+ bbGetOutputPlaneY()->SetInteractor(interactor);
+ bbGetOutputPlaneY()->EnabledOn();
+ bbGetOutputPlaneZ()->SetInteractor(interactor);
+ bbGetOutputPlaneZ()->EnabledOn();
+ bbGetOutputPlane3Pts()->SetInteractor(interactor);
+ bbGetOutputPlane3Pts()->EnabledOn();
+ } // if
+ }
+
//-----------------------------------------------------------------
- void vtkImageDataPointerRelay::bbUserSetDefaultValues()
+ void vtkImageDataPointerRelay::bbUserSetDefaultValues()
{
}
//=====
void ImageVtkProperties::Process()
{
- unsigned int dim;
- int ext[6];
- double spc[3];
- double range[2];
- std::string nametype;
- int numberoOfComponents;
- std::vector<int> vsize;
- std::vector<float> vspacing;
- std::vector<float> vrange;
+ unsigned int dim;
+ int ext[6];
+ double spc[3];
+ double range[2];
+ double origin[3];
+ std::string nametype;
+ int numberoOfComponents;
+ std::vector<int> vsize;
+ std::vector<double> vspacing;
+ std::vector<double> vrange;
+ std::vector<double> vorigin;
if ( bbGetInputIn() )
{
bbGetInputIn()->Modified();
-
+//EED 2017-01-01 Migration VTK7
+#if (VTK_MAJOR_VERSION <= 5)
bbGetInputIn()->Update();
bbGetInputIn()->GetWholeExtent(ext);
+#endif
+#if (VTK_MAJOR_VERSION >= 6)
+ bbGetInputIn()->GetExtent(ext);
+#endif
+
vsize.push_back(ext[1]-ext[0]+1);
vsize.push_back(ext[3]-ext[2]+1);
vsize.push_back(ext[5]-ext[4]+1);
-
dim = 0;
if (vsize[0]>1) dim++;
if (vsize[1]>1) dim++;
if (vsize[2]>1) dim++;
-
bbGetInputIn()->GetScalarRange(range);
+ bbGetInputIn()->GetOrigin(origin);
numberoOfComponents=bbGetInputIn()->GetNumberOfScalarComponents();
-
bbGetInputIn()->GetSpacing(spc);
for (unsigned int i=0;i<dim;++i)
{
- vspacing.push_back((float)spc[i]);
+ vspacing.push_back( (double)spc[i] );
+ vorigin.push_back( (double)origin[i] );
}
-
- vrange.push_back((float)range[0]);
- vrange.push_back((float)range[1]);
-
+ vrange.push_back((double)range[0]);
+ vrange.push_back((double)range[1]);
if (bbGetInputIn()->GetScalarType()==VTK_BIT) nametype="VTK_BIT"; // 1
if (bbGetInputIn()->GetScalarType()==VTK_CHAR) nametype="VTK_CHAR"; // 2
if (bbGetInputIn()->GetScalarType()==VTK_SIGNED_CHAR) nametype="VTK_SIGNED_CHAR"; // 15
vrange.push_back(0);
nametype = "VOID";
}
- bbSetOutputDimension( dim );
- bbSetOutputSize( vsize );
- bbSetOutputSpacing( vspacing );
- bbSetOutputMinMax( vrange );
- bbSetOutputTypeName( nametype );
- bbSetOutputComponents( numberoOfComponents );
-
+ bbSetOutputDimension ( dim );
+ bbSetOutputOrigin ( vorigin );
+ bbSetOutputSize ( vsize );
+ bbSetOutputSpacing ( vspacing );
+ bbSetOutputMinMax ( vrange );
+ bbSetOutputTypeName ( nametype );
+ bbSetOutputComponents ( numberoOfComponents );
}
//=====
// 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)
// * TYPE is the C++ type of the input/output
// (the one provided in the attribute 'type' of the tag 'input')
- if ((bbGetInputImageFix()!=NULL) && (bbGetInputImageMove()!=NULL) )
- {
- if ( bbGetInputImageFix()->GetScalarType()==bbGetInputImageMove()->GetScalarType() )
- {
- // Creating Image
- int dim[3];
- int ext[6];
+ if (bbGetInputActive()==true)
+ {
+ if ( (bbGetInputImageFix()!=NULL) && (bbGetInputImageMove()!=NULL) )
+ {
+ if ( bbGetInputImageFix()->GetScalarType()==bbGetInputImageMove()->GetScalarType() )
+ {
+ // Creating Image
+ int dim[3];
+ int ext[6];
- bbGetInputImageFix()->GetWholeExtent(ext);
- dim[0]= ext[1]-ext[0]+1;
- dim[1]= ext[3]-ext[2]+1;
- dim[2]= ext[5]-ext[4]+1;
+//EED 2017-01-01 Migration VTK7
+#if (VTK_MAJOR_VERSION <= 5)
+ bbGetInputImageFix()->GetWholeExtent(ext);
+#endif
+#if (VTK_MAJOR_VERSION >= 6)
+ bbGetInputImageFix()->GetExtent(ext);
+#endif
+ dim[0]= ext[1]-ext[0]+1;
+ dim[1]= ext[3]-ext[2]+1;
+ dim[2]= ext[5]-ext[4]+1;
- if (bbGetInputType()==0)
+ if (bbGetInputType()==0)
+ {
+ _imageoutput = vtkImageData::New();
+ _imageoutput->Initialize();
+ _imageoutput->SetSpacing( bbGetInputImageFix()->GetSpacing() );
+ _imageoutput->SetDimensions( dim[0], dim[1], dim[2] );
+//EED 2017-01-01 Migration VTK7
+#if (VTK_MAJOR_VERSION <= 5)
+ _imageoutput->SetScalarType( bbGetInputImageFix()->GetScalarType() );
+ _imageoutput->AllocateScalars();
+#endif
+#if (VTK_MAJOR_VERSION >= 6)
+ _imageoutput->AllocateScalars(bbGetInputImageFix()->GetScalarType() , 1);
+#endif
+ }
+ if (bbGetInputType()==1)
+ {
+ _imageoutput=bbGetInputImageFix();
+ }
+
+
+ // Duplicating Fix Image
+ long sizeimage = dim[0]*dim[1]*dim[2]*bbGetInputImageFix()->GetScalarSize();
+ memcpy( _imageoutput->GetScalarPointer() , bbGetInputImageFix()->GetScalarPointer() , sizeimage);
+
+ // Copy the Move Image
+ int j,k;
+ int px,py,pz;
+
+//EED 2017-01-01 Migration VTK7
+#if (VTK_MAJOR_VERSION <= 5)
+ bbGetInputImageMove()->GetWholeExtent(ext);
+#endif
+#if (VTK_MAJOR_VERSION >= 6)
+ bbGetInputImageMove()->GetExtent(ext);
+#endif
+
+ int dimMoveX = ext[1]-ext[0]+1;
+ int dimMoveY = ext[3]-ext[2]+1;
+ int dimMoveZ = ext[5]-ext[4]+1;
+
+ int spxM=0; // start px MoveImage
+ int sizeXM=0; // sizeX MoveImage
+
+ px=bbGetInputOrigin()[0];
+ spxM=0;
+ if (px<=0)
+ {
+ spxM=px*(-1);
+ px=0;
+ }
+ sizeXM = dimMoveX-spxM;
+ if (px+sizeXM>=dim[0]) sizeXM=dim[0]-px;
+
+ sizeXM=sizeXM*bbGetInputImageFix()->GetScalarSize();
+ for (k=0; k<dimMoveZ; k++)
+ {
+ for (j=0; j<dimMoveY; j++)
+ {
+ py=j+bbGetInputOrigin()[1];
+ pz=k+bbGetInputOrigin()[2];
+
+ if ( (py<dim[1]) && (pz<dim[2]) &&
+ (py>=0) && (pz>=0) &&
+ (sizeXM>0) )
{
- memcpy( _imageoutput->GetScalarPointer(px,py,pz) , bbGetInputImageMove()->GetScalarPointer(spxM,j,k) , sizeXM );
+ _imageoutput = vtkImageData::New();
+ _imageoutput->Initialize();
+ _imageoutput->SetScalarType( bbGetInputImageFix()->GetScalarType() );
+ _imageoutput->SetSpacing( bbGetInputImageFix()->GetSpacing() );
+ _imageoutput->SetDimensions( dim[0], dim[1], dim[2] );
+ _imageoutput->AllocateScalars();
+ // Duplicating Fix Image
+ long sizeimage = dim[0]*dim[1]*dim[2]*bbGetInputImageFix()->GetScalarSize();
+ memcpy( _imageoutput->GetScalarPointer() , bbGetInputImageFix()->GetScalarPointer() , sizeimage);
+ }
+ if (bbGetInputType()==1)
+ {
+ _imageoutput=bbGetInputImageFix();
}
- } // for j
- } // for k
- _imageoutput->Modified();
- } // If Image Fixe Move the same GetScalarType
- else {
- printf ("ERROR: InversCrop both ImageFixe and ImageMove need the same format.\n");
- }
- } // If Image Fixe Move != NULL
- else {
- printf ("ERROR: InversCrop need ImageFixe and ImageMove to run.\n");
- }
- bbSetOutputOut(_imageoutput);
+
+
+ // Copy the Move Image
+ int j,k;
+ int px,py,pz;
+
+ bbGetInputImageMove()->GetWholeExtent(ext);
+ int dimMoveX = ext[1]-ext[0]+1;
+ int dimMoveY = ext[3]-ext[2]+1;
+ int dimMoveZ = ext[5]-ext[4]+1;
+
+ int spxM = 0; // start px MoveImage
+ int sizeXM = 0; // sizeX MoveImage
+
+ px = bbGetInputOrigin()[0];
+ spxM = 0;
+ if (px<0)
+ {
+ spxM=px*(-1);
+ px=0;
+ }
+ sizeXM = dimMoveX-spxM;
+ if (px+sizeXM>=dim[0]) sizeXM=dim[0]-px;
+ sizeXM=sizeXM*bbGetInputImageFix()->GetScalarSize();
+ for (k=0; k<dimMoveZ; k++)
+ {
+ for (j=0; j<dimMoveY; j++)
+ {
+ py=j+bbGetInputOrigin()[1];
+ pz=k+bbGetInputOrigin()[2];
+ if ( (py<dim[1]) && (pz<dim[2]) &&
+ (py>=0) && (pz>=0) &&
+ (sizeXM>0) )
+ {
+ memcpy( _imageoutput->GetScalarPointer(px,py,pz) , bbGetInputImageMove()->GetScalarPointer(spxM,j,k) , sizeXM );
+ }
+
+ } // for j
+ } // for k
+ _imageoutput->Modified();
+ } // If Image Fixe Move the same GetScalarType
+ else {
+ printf ("ERROR: InversCrop both ImageFixe and ImageMove need the same format.\n");
+ printf (" type ImageFix:%d type ImageMove:%d\n", bbGetInputImageFix()->GetScalarType(), bbGetInputImageMove()->GetScalarType() );
+
+ }
+ } // If Image Fixe Move != NULL
+ else {
+ printf ("ERROR: InversCrop need ImageFixe and ImageMove to run.\n");
+ }
+ bbSetOutputOut(_imageoutput);
+
+ } // if Active
+
}
//=====
//=====
void InversCrop::bbUserSetDefaultValues()
{
-
// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
// Here we initialize the input 'In' to 0
+ bbSetInputActive(true);
bbSetInputType(0);
bbSetInputImageFix(NULL);
bbSetInputImageMove(NULL);
-
std::vector<int> origin;
origin.push_back(0);
origin.push_back(0);
origin.push_back(0);
bbSetInputOrigin(origin);
-
_imageoutput=NULL;
}
//=====
#include "bbvtkPolyDataToActor.h"
#include "bbvtkPackage.h"
+
namespace bbvtk
{
BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,PolyDataToActor)
colour.push_back(1.0);
colour.push_back(0.5);
bbSetInputColour(colour);
-
bbSetInputActive(true);
bbSetInputIn(NULL);
bbSetInputRenderer(NULL);
bbSetInputRepresentation(2);
bbSetInputLineWidth(1);
bbSetInputScalarVisibility(false);
-
polydatamapper = NULL;
vtkactor = NULL;
}
if (bbGetInputActive()==true)
{
- polydatamapper->SetInput( bbGetInputIn() );
- vtkactor->GetProperty()->SetRepresentation( bbGetInputRepresentation() );
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
+ polydatamapper->SetInput( bbGetInputIn() );
+#else
+ polydatamapper->SetInputData( bbGetInputIn() );
+#endif
+
+ vtkactor->GetProperty()->SetRepresentation( bbGetInputRepresentation() );
++
+ if (bbGetInputRepresentation()==1)
+ {
+ vtkactor->GetProperty()->SetAmbient(1);
+ vtkactor->GetProperty()->SetDiffuse(1);
+ vtkactor->GetProperty()->SetSpecular(0);
+ } else {
+ printf("EED WARNNING! PolyDataToActor::DoProcess which is the default values of Ambient, Diffuse, Specular ? \n");
+ }
+
-
vtkactor->GetProperty()->SetLineWidth( bbGetInputLineWidth() );
vtkactor->GetProperty()->SetColor( bbGetInputColour()[0],
bbGetInputColour()[2] );
vtkactor->GetProperty()->SetOpacity( bbGetInputOpacity() );
+
if ( bbGetInputTransform()!=NULL )
{
BBTK_BLACK_BOX_IMPLEMENTATION(SliceImage,bbtk::AtomicBlackBox);
void SliceImage::Process()
{
+
+ printf("EED ********************************** bbtk-box vtk:SliceImage (Deprecated)\n");
+ printf("EED ********************************** >> use bbtk-box creaMaracasVisu:SliceImage \n");
vtkImageData* original = bbGetInputIn();
if (original == NULL)
final = vtkImageData::New();
final->SetSpacing(space);
final->SetDimensions(newDim);
+
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
final->SetScalarType(scalar_type);
final->AllocateScalars();
final->Update();
+#else
+ final->AllocateScalars(scalar_type,1);
+#endif
+
}
bbSetOutputMax(max_z);
}
caster = vtkImageCast::New();
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
caster->SetInput(final);
+#else
+ caster->SetInputData(final);
+#endif
+
caster->SetOutputScalarTypeToShort();
caster->Update();
#include "bbvtkPackage.h"
#include <vtkPointData.h>
-
+ #include <vtkMath.h>
namespace bbvtk
{
int ext[6];
bbGetInputImage()->GetSpacing(spc);
bbGetInputImage()->GetScalarRange(range);
+
+
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
bbGetInputImage()->GetWholeExtent(ext);
+#else
+ bbGetInputImage()->GetExtent(ext);
+#endif
+
int maxX = ext[1]-ext[0]+1;
int maxY = ext[3]-ext[2]+1;
int maxZ = ext[5]-ext[4]+1;
colorLookupTable->SetTableValue( iLookTable , rgba2[0],rgba2[1],rgba2[2],rgba2[3]);
} // for iLookTable
+ //EED 2018-06-8 ***********************ARDS Projet***********************************************
+ if (bbGetInputColorType()==2)
+ {
+ int tableSize=256;
+ colorLookupTable = vtkLookupTable::New();
+ // colorLookupTable->SetNumberOfTableValues(tableSize);
+ colorLookupTable->SetTableRange(range[0],range[1]);
+ // colorLookupTable->SetTableRange(0,11);
+ colorLookupTable->Build();
+
+ /*
+ for (unsigned int i = 0; i < tableSize; ++i)
+ {
+ colorLookupTable->SetTableValue(i,
+ vtkMath::Random(.25, 1.0),
+ vtkMath::Random(.25, 1.0),
+ vtkMath::Random(.25, 1.0),
+ 1.0);
+ }
+ */
+
+ double rgba1[4];
+ double rgba2[4];
+ int i,j;
+ for (int iLookTable = 0; iLookTable<tableSize*3; iLookTable++)
+ {
+ i=rand() % tableSize;
+ j=rand() % tableSize;
+ colorLookupTable->GetTableValue(i, rgba1);
+ colorLookupTable->GetTableValue(j, rgba2);
+
+ colorLookupTable->SetTableValue(j, rgba1[0],rgba1[1],rgba1[2],rgba1[3]);
+ colorLookupTable->SetTableValue(i, rgba2[0],rgba2[1],rgba2[2],rgba2[3]);
+ } // for iLookTable
+
+ } // type 2
+
+
+ if (bbGetInputColorType()==3)
+ {
+ int tableSize=13;
+ colorLookupTable = vtkLookupTable::New();
+ colorLookupTable->SetNumberOfTableValues(tableSize);
+ colorLookupTable->SetTableRange(6,range[1]);
+ colorLookupTable->Build();
+
+ colorLookupTable->SetTableValue(0, 1 ,1 ,1 ,1);
+ colorLookupTable->SetTableValue(1, 1 ,0 ,0 ,1);
+ colorLookupTable->SetTableValue(2, 0 ,1 ,0 ,1);
+ colorLookupTable->SetTableValue(3, 0 ,0 ,1 ,1);
+ colorLookupTable->SetTableValue(4, 0 ,1 ,1 ,1);
+ colorLookupTable->SetTableValue(5, 1 ,1 ,0 ,1);
+ colorLookupTable->SetTableValue(6, 1 ,0 ,1 ,1);
+
+ colorLookupTable->SetTableValue(7, 0.5,1 ,1 ,1);
+ colorLookupTable->SetTableValue(8, 1 ,0.5,1 ,1);
+ colorLookupTable->SetTableValue(9, 1 ,1 ,0.5,1);
+
+ colorLookupTable->SetTableValue(10,1 ,0.5,0.5,1);
+ colorLookupTable->SetTableValue(11,0.5,0.5,1 ,1);
+
+ } // type 2
+
+
+
+
}
bbGetInputMesh()->GetPointData()->SetScalars(colors);