Error HunspellCustomDictionaries::add(const FilePath& dicPath) const { // validate .dic extension if (!dicPath.hasExtensionLowerCase(".dic")) { return systemError(boost::system::errc::invalid_argument, ERROR_LOCATION); } // remove existing with same name std::string name = dicPath.stem(); Error error = remove(name); if (error) LOG_ERROR(error); // add it return dicPath.copy(dictionaryPath(name)); }
Error HunspellCustomDictionaries::remove(const std::string& name) const { return dictionaryPath(name).removeIfExists(); }
void DicomSurfaceWriter::write() throw (::fwTools::Failed) { ::fwData::Acquisition::csptr series = this->getConcreteObject(); SLM_ASSERT("fwData::Acquisition not instanced", series); //***** Get the dictionary *****// // Reading of the dictionary ::fwData::StructureTraitsDictionary::NewSptr structDico; // Ready of the dictionary file. ::fwDataIO::reader::DictionaryReader::NewSptr dictionaryReader; dictionaryReader->setObject(structDico); std::string dictionaryPath("./share/fwDataIO_0-2/OrganDictionary.dic"); dictionaryReader->setFile(dictionaryPath); try { dictionaryReader->read(); } catch(const std::exception & e) { OSLM_ERROR(e.what()); } //***** Write surface segmentations *****// unsigned int skippedSegment = 0; // Number of segmentation not written const uint32_t nbSegmentation = series->getNumberOfReconstructions(); for (unsigned int i = 0; i < nbSegmentation; ++i) { try { // Get the info of the struture type ::fwData::Reconstruction::csptr reconstruction = series->getReconstructions()[i]; const std::string & segmentLabel = reconstruction->getStructureType(); ::fwData::StructureTraitsDictionary::StructureTypeNameContainer segmentLabels = structDico->getStructureTypeNames(); ::fwData::StructureTraitsDictionary::StructureTypeNameContainer::const_iterator itr = std::find(segmentLabels.begin(), segmentLabels.end(),segmentLabel); ::fwData::StructureTraits::sptr structure; ::fwData::StructureTraits::NewSptr emptyStructure; if(itr != segmentLabels.end()) { structure = structDico->getStructure(segmentLabel); } else { structure = emptyStructure; } // Write segmentation DicomSegmentWriter::writeSurfaceSegmentation(i, structure); // Here, the segment is identified and its surface can be written. this->writeSurfaceMesh(i); } catch(::fwTools::Failed & e) { ++skippedSegment; OSLM_ERROR(e.what()); } } if (skippedSegment == nbSegmentation) { throw ::fwTools::Failed("All 3D reconstructions have been rejected"); } else if (skippedSegment > 0) { OSLM_WARN(skippedSegment<<" 3D reconstruction(s) have been rejected"); } ::boost::shared_ptr< ::gdcm::SurfaceWriter > gSurfaceWriter = ::boost::static_pointer_cast< ::gdcm::SurfaceWriter >( this->getWriter() ); ::gdcm::DataSet & gDsRoot = this->getDataSet(); // Number of Surfaces Tag(0x0066,0x0001) gSurfaceWriter->SetNumberOfSurfaces( nbSegmentation - skippedSegment ); // Type 1 OSLM_TRACE("Number of Surfaces : " << nbSegmentation - skippedSegment); //***** Write Enhanced General Equipement Module *****// //See: PS 3.3 C.7.5.2 { DicomEquipmentWriter equipmentWriter; equipmentWriter.writeEnhancedGeneralEquipement(gDsRoot); } //***** Write Content Identification Module *****// //See: PS 3.3 Table 10-12 this->writeContentIdentification(); //***** Complete the file *****// // Set the instance to surface segmentation storage ::boost::shared_ptr< DicomInstance > dicomInstance = this->getDicomInstance(); const char * SOPClassUID = ::gdcm::MediaStorage::GetMSString( ::gdcm::MediaStorage::SurfaceSegmentationStorage ); std::string SOPClassUIDStr; if (SOPClassUID == 0) SOPClassUIDStr = "1.2.840.10008.5.1.4.1.1.66.5"; else SOPClassUIDStr = SOPClassUID; dicomInstance->setSOPClassUID( SOPClassUIDStr ); ::gdcm::UIDGenerator gUIDgen; gUIDgen.SetRoot( SOPClassUIDStr.c_str() ); dicomInstance->setSOPInstanceUID( gUIDgen.Generate() ); dicomInstance->setModality("SEG"); //***** Write the file *****// DicomRefInstanceWriter< ::fwData::Acquisition >::write(); }