float CVImage::getVoxelSize( Direction dir, VImage img ) { float res[3]; char *value; const char *voxel = getStringAttrib( "voxel", img ); if( !voxel || !sscanf( voxel, "%f %f %f", &res[0], &res[1], &res[2] ) ) { VWarning( "Cannot find voxel attribute. Using \"1 1 1\"" ); std::fill_n( res, 3, 1 ); } return res[dir]; }
/*************************************************************** * Function: Element::getBoolAttrib() * Purpose : Get the boolean value of an attribute * Initial : Maxime Chevalier-Boisvert on October 20, 2008 **************************************************************** Revisions and bug fixes: */ bool Element::getBoolAttrib(const std::string& name) const { // Attempt to find the string value of the attribute std::string stringAttrib = getStringAttrib(name); // Compute the boolean value bool boolValue = ( stringAttrib == "true" || stringAttrib == "True" || stringAttrib == "TRUE" || stringAttrib == "1" ); // Return the boolean value return boolValue; }
/*************************************************************** * Function: Element::getStringAttrib() * Purpose : Get the integer value of an attribute * Initial : Maxime Chevalier-Boisvert on October 20, 2008 **************************************************************** Revisions and bug fixes: */ int Element::getIntAttrib(const std::string& name) const { // Declare a stringstream object for parsing std::stringstream stringStream; // Attempt to find the string value of the attribute std::string stringAttrib = getStringAttrib(name); // Set the string value of the attribute stringStream.str(stringAttrib); // Declare an integer to extract the integer value int intValue; // Extract the integer value stringStream >> intValue; // Return the integer value return intValue; }
const char *CVImage::getStringAttrib( const char *name )const { return images.empty() ? 0 : getStringAttrib( name, *images.begin() ); }