18#ifndef _GAZEBO_SVGLOADER_HH_
19#define _GAZEBO_SVGLOADER_HH_
25#include <ignition/math/Vector2.hh>
26#include <ignition/math/Matrix3.hh>
37 class SVGLoaderPrivate;
40 class GZ_COMMON_VISIBLE
SvgError:
public std::runtime_error
44 public:
explicit SvgError(
const std::string &_what);
76 std::vector< std::vector<SVGCommand> >
subpaths;
79 std::vector< std::vector<ignition::math::Vector2d> >
polylines;
96 public:
bool Parse(
const std::string &_filename,
97 std::vector<SVGPath> &_paths);
105 const std::vector<common::SVGPath> &_paths,
107 std::vector< std::vector<ignition::math::Vector2d> > &_closedPolys,
108 std::vector< std::vector<ignition::math::Vector2d> > &_openPolys);
113 public:
void DumpPaths(
const std::vector<SVGPath> &_paths,
114 std::ostream &_out)
const;
119 private:
void GetPathCommands(
const std::vector<std::string> &_tokens,
125 private:
void GetPathAttribs(TiXmlElement *_pElement,
SVGPath &_path);
130 private:
void GetSvgPaths(TiXmlNode *_pParent,
131 std::vector<SVGPath> &_paths);
136 private:
void ExpandCommands(
137 const std::vector< std::vector<SVGCommand> > &_subpaths,
144 private:
void SplitSubpaths(
const std::vector<SVGCommand> &_cmds,
145 std::vector< std::vector<SVGCommand> > &_subpaths);
151 private:
void PathToPoints(
const SVGPath &_path,
153 std::vector< std::vector<ignition::math::Vector2d> > &_polys);
160 private: ignition::math::Vector2d SubpathToPolyline(
161 const std::vector<SVGCommand> &_subpath,
162 ignition::math::Vector2d _last,
163 std::vector<ignition::math::Vector2d> &_polyline);
167 private: SVGLoaderPrivate *dataPtr;
common
Definition FuelModelDatabase.hh:37
SVG command data structure.
Definition SVGLoader.hh:49
std::vector< double > numbers
Coordinates for the command.
Definition SVGLoader.hh:60
SVGCommand()
Constructor.
Definition SVGLoader.hh:51
char cmd
A letter that describe the segment.
Definition SVGLoader.hh:57
virtual ~SVGCommand()=default
Destructor.
A loader for SVG files.
Definition SVGLoader.hh:84
void DumpPaths(const std::vector< SVGPath > &_paths, std::ostream &_out) const
Outputs the content of the paths to file (or console)
static void PathsToClosedPolylines(const std::vector< common::SVGPath > &_paths, double _tol, std::vector< std::vector< ignition::math::Vector2d > > &_closedPolys, std::vector< std::vector< ignition::math::Vector2d > > &_openPolys)
Reads in paths and outputs closed polylines and open polylines.
SVGLoader(unsigned int _samples)
Constructor.
bool Parse(const std::string &_filename, std::vector< SVGPath > &_paths)
Reads an SVG file and loads all the paths.
Handles errors during SVG parsing.
Definition SVGLoader.hh:41
SvgError(const std::string &_what)
constructor
Forward declarations for the common classes.
Definition Animation.hh:27
An SVG path element data structure.
Definition SVGLoader.hh:65
std::vector< std::vector< ignition::math::Vector2d > > polylines
The polylines described by the commands.
Definition SVGLoader.hh:79
std::vector< std::vector< SVGCommand > > subpaths
A list of subpaths (as lists of commands)
Definition SVGLoader.hh:76
ignition::math::Matrix3d transform
A 2D transform (or a list of transforms)
Definition SVGLoader.hh:73
std::string style
The style (i.e. stroke style, color, thickness etc)
Definition SVGLoader.hh:70
std::string id
An id or name.
Definition SVGLoader.hh:67