homog2d library
Namespaces | Classes | Functions
h2d::svg Namespace Reference

Holds stuff related to SVG import. More...

Namespaces

 svgp
 Private functions related to the SVG import code.
 

Classes

class  Visitor
 Visitor class, derived from the tinyxml2 visitor class. Used to import SVG data. More...
 

Functions

auto getImgSize (const tinyxml2::XMLDocument &doc)
 Fetch size of image in SVG file. More...
 
void printFileAttrib (const tinyxml2::XMLDocument &doc)
 

Detailed Description

Holds stuff related to SVG import.

Function Documentation

◆ getImgSize()

auto h2d::svg::getImgSize ( const tinyxml2::XMLDocument &  doc)
inline

Fetch size of image in SVG file.

13094 {
13095  const tinyxml2::XMLElement* root = doc.RootElement();
13096  const tinyxml2::XMLAttribute* pAttrib = root->FirstAttribute();
13097  double w = -1., h = -1.;
13098  while( pAttrib )
13099  {
13100  auto attr = std::string( pAttrib->Name() );
13101  if( attr == "width" )
13102  w = std::stod( pAttrib->Value() );
13103  if( attr == "height" )
13104  h = std::stod( pAttrib->Value() );
13105  pAttrib=pAttrib->Next();
13106  }
13107  if( w == -1. || h == -1. )
13108  HOMOG2D_THROW_ERROR_1( "unable to find size in SVG file" );
13109  return std::make_pair( w, h );
13110 }
#define HOMOG2D_THROW_ERROR_1(msg)
Error throw wrapper macro.
Definition: homog2d.hpp:181
Here is the caller graph for this function:

◆ printFileAttrib()

void h2d::svg::printFileAttrib ( const tinyxml2::XMLDocument &  doc)
inline
13079 {
13080  const tinyxml2::XMLElement* root = doc.RootElement();
13081  const tinyxml2::XMLAttribute* pAttrib = root->FirstAttribute();
13082  size_t i=0;
13083  while( pAttrib )
13084  {
13085  std::cout << "Attrib " << i++ << ": Name=" << pAttrib->Name() << "; Value=" << pAttrib->Value() << '\n';
13086  pAttrib=pAttrib->Next();
13087  }
13088 }
Here is the caller graph for this function: