#include #include #include // ------------------------------------------------------------------------- cpExtensions::IO::MementoState::MementoState() { m_Id = 0; }; // ------------------------------------------------------------------------- //cpExtensions::IO::MementoState::MementoState(long id, TPluginImage* _img) //{ // SetToMemento(_img); //} // //bool //cpExtensions::IO::MementoState::SetToMemento(TPluginObject * _do) //{ // char base[] = "state"; // std::ostringstream oss; // this->m_Id++; // oss << this->m_Id; // std::string str = oss.str(); // auto complement = str.c_str(); // // std::string fileName(base); // fileName.append(complement); // fileName.append(".mhd"); // // std::string fileNameRaw(base); // fileNameRaw.append(complement); // fileNameRaw.append(".raw"); //// save(fileName, fileNameRaw, _img); // // // vtkSmartPointer writer = // vtkSmartPointer::New(); // // auto img = TPluginImage::New(); // img->SetSource(_do); // // // writer->SetInputData(_do->GetVTK()); // writer->SetInputData(img->GetVTK()); // // writer->SetFileName(fileName.c_str()); // writer->SetRAWFileName(fileNameRaw.c_str()); // writer->Write(); // // return true; //} // // bool cpExtensions::IO::MementoState::SetToMemento(cpPlugins::Interface::Image* _img) { char base[] = "state"; std::ostringstream oss; this->m_Id++; oss << this->m_Id; std::string str = oss.str(); auto complement = str.c_str(); std::string fileName(base); fileName.append(complement); fileName.append(".mhd"); std::string fileNameRaw(base); fileNameRaw.append(complement); fileNameRaw.append(".raw"); save(fileName, fileNameRaw, _img); return true; } // // //// ------------------------------------------------------------------------- //vtkSmartPointer //cpExtensions::IO::MementoState::getMemento(long id) //{ // char base[] = "state"; // std::ostringstream oss; // oss << id; // std::string str = oss.str(); // auto complement = str.c_str(); // // std::string fileName(base); // fileName.append(complement); // fileName.append(".mhd"); // return load(fileName); //} // // ------------------------------------------------------------------------- void cpExtensions::IO::MementoState:: save(const std::string& filename, const std::string& filenameRaw, cpPlugins::Interface::Image* img) { vtkSmartPointer writer = vtkSmartPointer::New(); writer->SetInputData(img->GetVTK< vtkImageData >()); writer->SetFileName(filename.c_str()); writer->SetRAWFileName(filenameRaw.c_str()); writer->Write(); } // ------------------------------------------------------------------------- vtkSmartPointer cpExtensions::IO::MementoState::load(const std::string& filename) { vtkSmartPointer reader = vtkSmartPointer::New(); reader->SetFileName(filename.c_str()); reader->Update(); return reader; //return( NULL ); } // eof - $RCSfile$