bool ResourceManager::CreateDirectoryPath(const String& DirectoryPath) { bool Result = true; StringVector FolderNames; CountedPtr<StringVector> FolderVec = StringTools::Split(DirectoryPath,"/\\"); size_t StartIndex = 0; String PathAttempt; char SysSlash = GetDirectorySeparator(); #ifdef WINDOWS // For windows and windows like machines, see if the first entry is a drive, because attempting to make a drive is silly. if(FolderVec->at(0).find(':') != String::npos) { PathAttempt.append( FolderVec->at(0) ); PathAttempt.append( 1, SysSlash ); StartIndex++; } #else PathAttempt.append( 1, SysSlash ); #endif for( size_t VecIndex = StartIndex ; VecIndex < FolderVec->size() ; ++VecIndex ) { PathAttempt.append( FolderVec->at(VecIndex) ); PathAttempt.append( 1, SysSlash ); Result = this->CreateDirectory( PathAttempt ); } return Result; }
ColourValue StringTools::ConvertToColourValue(const String& ToConvert) { CountedPtr<StringVector> Digits = Split(ToConvert); if(4 == Digits->size()) { return ColourValue(ConvertToReal(Digits->at(0)),ConvertToReal(Digits->at(1)),ConvertToReal(Digits->at(2)),ConvertToReal(Digits->at(3))); }else{ MEZZ_EXCEPTION(Exception::PARAMETERS_EXCEPTION,"String does not contain 4 digits when attempting to convert."); } }
int chooseSurface ( const po::variables_map& vm, //< command-line parameters const KSpace& K, //< cellular grid space const ImplicitShape& shape, //< implicit shape "ground truth" const ImplicitDigitalShape& dshape ) //< analysed implicit digital shape { // Selecting a model of surface depending on noise / not noise. typedef double Scalar; Scalar noiseLevel = vm[ "noise" ].as<double>(); if ( noiseLevel == 0.0 ) { // no noise trace.beginBlock( "Make digital surface..." ); typedef LightImplicitDigitalSurface<KSpace,ImplicitDigitalShape> SurfaceContainer; typedef DigitalSurface< SurfaceContainer > Surface; typedef typename Surface::Surfel Surfel; SurfelAdjacency< KSpace::dimension > surfAdj( true ); Surfel bel; try { bel = Surfaces<KSpace>::findABel( K, dshape, 10000 ); } catch (DGtal::InputException e) { trace.error() << "ERROR Unable to find bel." << std::endl; return 3; } SurfaceContainer* surfaceContainer = new SurfaceContainer( K, dshape, surfAdj, bel ); CountedPtr<Surface> ptrSurface( new Surface( surfaceContainer ) ); // acquired trace.info() << "- surface component has " << ptrSurface->size() << " surfels." << std::endl; trace.endBlock(); chooseKernel( vm, K, shape, *ptrSurface, dshape ); } else { // noise trace.beginBlock( "Make digital surface..." ); typedef typename ImplicitDigitalShape::Domain Domain; typedef KanungoNoise< ImplicitDigitalShape, Domain > KanungoPredicate; typedef LightImplicitDigitalSurface< KSpace, KanungoPredicate > SurfaceContainer; typedef DigitalSurface< SurfaceContainer > Surface; typedef typename Surface::Surfel Surfel; SurfelAdjacency< KSpace::dimension > surfAdj( true ); Surfel bel; KanungoPredicate* noisified_dshape = new KanungoPredicate( dshape, dshape.getDomain(), noiseLevel ); // We have to search for a big connected component. CountedPtr<Surface> ptrSurface; double minsize = dshape.getUpperBound()[0] - dshape.getLowerBound()[0]; unsigned int nb_surfels = 0; unsigned int tries = 0; do { try { // Search initial bel bel = Surfaces<KSpace>::findABel( K, *noisified_dshape, 10000 ); } catch (DGtal::InputException e) { trace.error() << "ERROR Unable to find bel." << std::endl; return 3; } SurfaceContainer* surfaceContainer = new SurfaceContainer( K, *noisified_dshape, surfAdj, bel ); ptrSurface = CountedPtr<Surface>( new Surface( surfaceContainer ) ); // acquired nb_surfels = ptrSurface->size(); } while ( ( nb_surfels < 2 * minsize ) && ( tries++ < 150 ) ); if( tries >= 150 ) { trace.error() << "ERROR cannot find a proper bel in a big enough component." << std::endl; return 4; } trace.info() << "- surface component has " << nb_surfels << " surfels." << std::endl; trace.endBlock(); chooseKernel( vm, K, shape, *ptrSurface, *noisified_dshape ); } return 0; }