/*========================================================================= Program: vv http://www.creatis.insa-lyon.fr/rio/vv Authors belong to: - University of LYON http://www.universite-lyon.fr/ - Léon Bérard cancer center http://www.centreleonberard.fr - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the copyright notices for more information. It is distributed under dual licence - BSD See included LICENSE.txt file - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html ======================================================================-====*/ //-------------------------------------------------------------------- template clitk::BinaryImageToMeshFilter:: BinaryImageToMeshFilter()//:ProcessObject() { 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); } //-------------------------------------------------------------------- //-------------------------------------------------------------------- /*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; typename ConvertType::Pointer convert = ConvertType::New(); convert->SetInput(im); convert->Update(); vtkImageData * input_vtk = convert->GetOutput(); // Get extend vtkSmartPointer clipper = vtkSmartPointer::New(); clipper->SetInput(input_vtk); 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; for(uint i=0; i squares = vtkSmartPointer::New(); squares->SetInput(input_vtk); 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()); vtkSmartPointer m = squares->GetOutput(); DD(m->GetMaxCellSize()); DD(m->GetNumberOfVerts()); DD(m->GetNumberOfLines()); DD(m->GetNumberOfPolys()); DD(m->GetNumberOfStrips()); // Decimate if (false) { // FIXME 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 if (m->GetNumberOfLines() > 0) { append->AddInput(contours[i]); } } 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"); } //--------------------------------------------------------------------