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.

13093 {
13094  const tinyxml2::XMLElement* root = doc.RootElement();
13095  const tinyxml2::XMLAttribute* pAttrib = root->FirstAttribute();
13096  double w = -1., h = -1.;
13097  while( pAttrib )
13098  {
13099  auto attr = std::string( pAttrib->Name() );
13100  if( attr == "width" )
13101  w = std::stod( pAttrib->Value() );
13102  if( attr == "height" )
13103  h = std::stod( pAttrib->Value() );
13104  pAttrib=pAttrib->Next();
13105  }
13106  if( w == -1. || h == -1. )
13107  HOMOG2D_THROW_ERROR_1( "unable to find size in SVG file" );
13108  return std::make_pair( w, h );
13109 }
#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
13078 {
13079  const tinyxml2::XMLElement* root = doc.RootElement();
13080  const tinyxml2::XMLAttribute* pAttrib = root->FirstAttribute();
13081  size_t i=0;
13082  while( pAttrib )
13083  {
13084  std::cout << "Attrib " << i++ << ": Name=" << pAttrib->Name() << "; Value=" << pAttrib->Value() << '\n';
13085  pAttrib=pAttrib->Next();
13086  }
13087 }
Here is the caller graph for this function: