X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=itk%2FclitkBinaryImageToMeshFilter.txx;h=b242dcf81d744ae675762389bdb45594b63edcc3;hb=b8e5890d37dfd64409b9694f73c0be164a089e64;hp=9ffe4a204cfd62e5722b0027ec57de3ddbff981a;hpb=6986b996d66273ab7818c12f51cbf5ae049ac04e;p=clitk.git diff --git a/itk/clitkBinaryImageToMeshFilter.txx b/itk/clitkBinaryImageToMeshFilter.txx index 9ffe4a2..b242dcf 100644 --- a/itk/clitkBinaryImageToMeshFilter.txx +++ b/itk/clitkBinaryImageToMeshFilter.txx @@ -20,81 +20,19 @@ //-------------------------------------------------------------------- template clitk::BinaryImageToMeshFilter:: -BinaryImageToMeshFilter()//:ProcessObject() +BinaryImageToMeshFilter():itk::Object() { - DD("BinaryImageToMeshFilter constructor"); - // this->ProcessObject::SetNumberOfRequiredInputs(1); - // this->ProcessObject::SetNumberOfRequiredOutputs(1); - - // //m_OutputMesh = vtkPolyData::New(); - - // this->ProcessObject::SetNumberOfRequiredOutputs(1); - // itk::DataObject::Pointer a = itk::DataObject::New(); - // this->ProcessObject::SetNthOutput( 0, a); + m_ThresholdValue = 0.5; // (for image with 0=background and 1=foreground) } //-------------------------------------------------------------------- -//-------------------------------------------------------------------- -/*template - void - clitk::BinaryImageToMeshFilter:: - GenerateOutputInformation() - { - DD("GenerateOutputInformation"); - // ImagePointer output = this->GetOutput(0); - - // // Set the region to output - // typename ImageType::RegionType m_Region = m_LikeImage->GetLargestPossibleRegion(); - // typename ImageType::SizeType size = m_Region.GetSize(); - // size[0]++; - // size[1]++; - // size[2]++; - // m_Region.SetSize(size); - // output->SetLargestPossibleRegion(m_Region); - // output->SetRequestedRegion(m_Region); - // output->SetBufferedRegion(m_Region); - // output->SetRegions(m_Region); - // output->Allocate(); - } -*/ -//-------------------------------------------------------------------- - - -// template -// void -// clitk::BinaryImageToMeshFilter:: -// SetInput(unsigned int idx, const ImageType *input) -// { -// DD(idx); -// // process object is not const-correct, the const_cast -// // is required here. -// this->ProcessObject::SetNthInput( idx, -// const_cast< ImageType * >( input ) ); -// DD("end"); -// } - -// template -// const ImageType * -// clitk::BinaryImageToMeshFilter:: -// GetInput(unsigned int idx) -// { -// DD("GetInput"); -// DD(idx); -// return dynamic_cast< const ImageType * > -// ( this->ProcessObject::GetInput(idx) ); -// } - - //-------------------------------------------------------------------- template void clitk::BinaryImageToMeshFilter:: Update() -//GenerateOutputInformation() { - DD("Update"); - // Convert itk image into vtk image const ImageType * im = this->GetInput(); typedef itk::ImageToVTKImageFilter ConvertType; @@ -105,90 +43,62 @@ Update() // Get extend vtkSmartPointer clipper = vtkSmartPointer::New(); +#if VTK_MAJOR_VERSION <= 5 clipper->SetInput(input_vtk); +#else + clipper->SetInputData(input_vtk); +#endif int* extent = input_vtk->GetExtent(); - DDV(extent, 6); // Loop on slices vtkSmartPointer append = vtkSmartPointer::New(); uint n = input_vtk->GetDimensions()[2]; - DD(n); - std::vector > contours; + // std::vector > contours; for(uint i=0; i squares = vtkSmartPointer::New(); +#if VTK_MAJOR_VERSION <= 5 squares->SetInput(input_vtk); +#else + squares->SetInputData(input_vtk); +#endif squares->SetImageRange(extent[0], extent[1], extent[2], extent[3], i, i); squares->SetNumberOfContours(1); - squares->SetValue(0, 0.5); // FIXME background (?) - squares->Update(); - // DD(squares->GetNumberOfContours()); - + squares->SetValue(0, m_ThresholdValue); + squares->Update(); vtkSmartPointer m = squares->GetOutput(); - DD(m->GetMaxCellSize()); - DD(m->GetNumberOfVerts()); - DD(m->GetNumberOfLines()); - DD(m->GetNumberOfPolys()); - DD(m->GetNumberOfStrips()); + // Strip (needed) + vtkSmartPointer vs = vtkSmartPointer::New(); +#if VTK_MAJOR_VERSION <= 5 + vs->SetInput(squares->GetOutput()); +#else + vs->SetInputData(squares->GetOutput()); +#endif + vs->Update(); + m = vs->GetOutput(); // Decimate - if (false) { // FIXME + if (false) { // FIXME (do not work) vtkSmartPointer psurface = vtkDecimatePro::New(); psurface->SetInputConnection(squares->GetOutputPort()); psurface->SetTargetReduction(0.5); psurface->Update(); m = psurface->GetOutput(); } - if (true) { - vtkSmartPointer vs = vtkSmartPointer::New(); - vs->SetInput(squares->GetOutput()); - vs->Update(); - m = vs->GetOutput(); - } - - //vtkSmartPointer m = squares->GetOutput(); - contours.push_back(m); - DD(m->GetMaxCellSize()); - DD(m->GetNumberOfVerts()); - DD(m->GetNumberOfLines()); - DD(m->GetNumberOfPolys()); - DD(m->GetNumberOfStrips()); - // m->Print(std::cout); - // FIXME : only add if lines>0 + // only add if lines>0 if (m->GetNumberOfLines() > 0) { - append->AddInput(contours[i]); +#if VTK_MAJOR_VERSION <= 5 + append->AddInput(m);//contours[i]); +#else + append->AddInputData(m);//contours[i]); +#endif } } - DD("done"); - - DD("now append"); - // for(unsigned int i=0; iAddInput(contours[i]); - // } append->Update(); - DD(" copy"); m_OutputMesh = vtkSmartPointer::New(); m_OutputMesh->DeepCopy(append->GetOutput()); - - /* // NO (3D) - vtkSmartPointer pcontour = vtkContourFilter::New(); - pcontour->SetValue(0, 0.5); - pcontour->SetInput(input_vtk); - pcontour->Update(); - // vtkAlgorithmOutput *data = pcontour->GetOutputPort(); - // vtkSmartPointer skinMapper = vtkPolyDataMapper::New(); - // skinMapper->SetInputConnection(data); //psurface->GetOutputPort() - // skinMapper->ScalarVisibilityOff(); - m_OutputMesh = pcontour->GetOutput();//data - */ - - DD("end"); - int a=12; - DD("erelre"); } //--------------------------------------------------------------------