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.

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