Exemple #1
0
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];
}
Exemple #2
0
	/***************************************************************
	* 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;
	}
Exemple #3
0
	/***************************************************************
	* 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;
	}
Exemple #4
0
const char *CVImage::getStringAttrib( const char *name )const
{
	return images.empty() ? 0 : getStringAttrib( name, *images.begin() );
}