X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvMesh.cxx;h=e7045f58d84a19889f0f8abd97a4698587b237bb;hb=8dc75d1449323b08bf7378cded6f0bec24b2016f;hp=72ed60da872019c2021457befad5b9aa216b335f;hpb=573d80d0f7a17607d2ee883c21c940c0ba020282;p=clitk.git diff --git a/vv/vvMesh.cxx b/vv/vvMesh.cxx index 72ed60d..e7045f5 100644 --- a/vv/vvMesh.cxx +++ b/vv/vvMesh.cxx @@ -31,6 +31,7 @@ #include // vtk +#include #include #include #include @@ -135,12 +136,14 @@ void vvMesh::ComputeMasks(vtkImageData* sample,bool extrude) double *bounds=mesh->GetBounds(); vtkSmartPointer binary_image=vtkSmartPointer::New(); +#if VTK_MAJOR_VERSION <= 5 binary_image->SetScalarTypeToUnsignedChar(); ///Use the smallest mask in which the mesh fits // Add two voxels on each side to make sure the mesh fits double * samp_origin=sample->GetOrigin(); double * spacing=sample->GetSpacing(); binary_image->SetSpacing(spacing); + /// Put the origin on a voxel to avoid small skips binary_image->SetOrigin(floor((bounds[0]-samp_origin[0])/spacing[0]-2)*spacing[0]+samp_origin[0], floor((bounds[2]-samp_origin[1])/spacing[1]-2)*spacing[1]+samp_origin[1], @@ -150,6 +153,23 @@ void vvMesh::ComputeMasks(vtkImageData* sample,bool extrude) 0,ceil((bounds[3]-origin[1])/spacing[1]+4), 0,ceil((bounds[5]-origin[2])/spacing[2])+4); binary_image->AllocateScalars(); +#else + ///Use the smallest mask in which the mesh fits + // Add two voxels on each side to make sure the mesh fits + double * samp_origin=sample->GetOrigin(); + double * spacing=sample->GetSpacing(); + binary_image->SetSpacing(spacing); + + /// Put the origin on a voxel to avoid small skips + binary_image->SetOrigin(floor((bounds[0]-samp_origin[0])/spacing[0]-2)*spacing[0]+samp_origin[0], + floor((bounds[2]-samp_origin[1])/spacing[1]-2)*spacing[1]+samp_origin[1], + floor((bounds[4]-samp_origin[2])/spacing[2]-2)*spacing[2]+samp_origin[2]); + double * origin=binary_image->GetOrigin(); + binary_image->SetExtent(0,ceil((bounds[1]-origin[0])/spacing[0]+4), + 0,ceil((bounds[3]-origin[1])/spacing[1]+4), + 0,ceil((bounds[5]-origin[2])/spacing[2])+4); + binary_image->AllocateScalars(VTK_UNSIGNED_CHAR, 1); +#endif memset(binary_image->GetScalarPointer(),0,binary_image->GetDimensions()[0]*binary_image->GetDimensions()[1]*binary_image->GetDimensions()[2]*sizeof(unsigned char)); @@ -161,22 +181,43 @@ void vvMesh::ComputeMasks(vtkImageData* sample,bool extrude) if (extrude) { vtkSmartPointer extrude=vtkSmartPointer::New(); +#if VTK_MAJOR_VERSION <= 5 extrude->SetInput(mesh); +#else + extrude->SetInputData(mesh); +#endif ///We extrude in the -slice_spacing direction to respect the FOCAL convention extrude->SetVector(0, 0, -slice_spacing); +#if VTK_MAJOR_VERSION <= 5 sts->SetInput(extrude->GetOutput()); - } else +#else + sts->SetInputConnection(extrude->GetOutputPort()); +#endif + } else { +#if VTK_MAJOR_VERSION <= 5 sts->SetInput(mesh); +#else + sts->SetInputData(mesh); +#endif + } vtkSmartPointer stencil=vtkSmartPointer::New(); +#if VTK_MAJOR_VERSION <= 5 stencil->SetStencil(sts->GetOutput()); stencil->SetInput(binary_image); +#else + stencil->SetStencilData(sts->GetOutput()); + stencil->SetInputData(binary_image); +#endif stencil->Update(); this->AddMask(stencil->GetOutput()); - //vtkSmartPointer w = vtkSmartPointer::New(); - //w->SetInput(stencil->GetOutput()); - //w->SetFileName("binary.mhd"); - //w->Write(); + + /* + vtkSmartPointer w = vtkSmartPointer::New(); + w->SetInput(stencil->GetOutput()); + w->SetFileName("binary.mhd"); + w->Write(); + */ } } @@ -185,7 +226,11 @@ void vvMesh::ComputeMeshes() this->RemoveMeshes(); for (std::vector::iterator i=masks.begin(); i!=masks.end(); i++) { vtkSmartPointer marching = vtkSmartPointer::New(); +#if VTK_MAJOR_VERSION <= 5 marching->SetInput(*i); +#else + marching->SetInputData(*i); +#endif marching->SetValue(0,0.5); marching->Update(); this->AddMesh(marching->GetOutput());