Ignition Common

API Reference

3.14.0
SVGLoader.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 #ifndef IGNITION_COMMON_SVGLOADER_HH_
18 #define IGNITION_COMMON_SVGLOADER_HH_
19 
20 #include <memory>
21 #include <string>
22 #include <vector>
23 
24 #include <ignition/math/Vector2.hh>
25 #include <ignition/math/Matrix3.hh>
26 
27 #include <ignition/common/graphics/Export.hh>
30 
31 namespace ignition
32 {
33  namespace common
34  {
35  // Forward declare private data class
36  class SVGLoaderPrivate;
37 
39  class IGNITION_COMMON_GRAPHICS_VISIBLE SVGCommand
40  {
42  public: SVGCommand() : cmd(' ') {}
43 
45  public: virtual ~SVGCommand() = default;
46 
48  public: char cmd;
49 
50 #ifdef _WIN32
51 // Disable warning C4251
52 #pragma warning(push)
53 #pragma warning(disable: 4251)
54 #endif
57 #ifdef _WIN32
58 #pragma warning(pop)
59 #endif
60  };
61 
63  struct IGNITION_COMMON_GRAPHICS_VISIBLE SVGPath
64  {
65 #ifdef _WIN32
66 // Disable warning C4251
67 #pragma warning(push)
68 #pragma warning(disable: 4251)
69 #endif
70 
73 
76 
79 
82 
85 #ifdef _WIN32
86 #pragma warning(pop)
87 #endif
88  };
89 
91  class IGNITION_COMMON_GRAPHICS_VISIBLE SVGLoader
92  {
97  public: explicit SVGLoader(const unsigned int _samples);
98 
100  public: ~SVGLoader();
101 
106  public: bool Parse(const std::string &_filename,
107  std::vector<SVGPath> &_paths);
108 
114  public: static void PathsToClosedPolylines(
115  const std::vector<common::SVGPath> &_paths,
116  const double _tol,
119 
123  public: void DumpPaths(const std::vector<SVGPath> &_paths,
124  std::ostream &_out) const;
125 
129  private: std::unique_ptr<SVGLoaderPrivate> dataPtr;
131  };
132  }
133 }
134 
135 #endif
#define IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
Microsoft Visual Studio does not automatically export the interface information for member variables ...
Definition: SuppressWarning.hh:64
#define IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING
Definition: SuppressWarning.hh:67
SVG command data structure.
Definition: SVGLoader.hh:40
std::vector< double > numbers
Coordinates for the command.
Definition: SVGLoader.hh:56
SVGCommand()
Constructor.
Definition: SVGLoader.hh:42
char cmd
A letter that describe the segment.
Definition: SVGLoader.hh:48
virtual ~SVGCommand()=default
Destructor.
A loader for SVG files.
Definition: SVGLoader.hh:92
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, const 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(const unsigned int _samples)
Constructor.
bool Parse(const std::string &_filename, std::vector< SVGPath > &_paths)
Reads an SVG file and loads all the paths.
Forward declarations for the common classes.
An SVG path element data structure.
Definition: SVGLoader.hh:64
std::vector< std::vector< ignition::math::Vector2d > > polylines
The polylines described by the commands.
Definition: SVGLoader.hh:84
std::vector< std::vector< SVGCommand > > subpaths
A list of subpaths (as lists of commands)
Definition: SVGLoader.hh:81
ignition::math::Matrix3d transform
A 2D transform (or a list of transforms)
Definition: SVGLoader.hh:78
std::string style
The style (i.e. stroke style, color, thickness etc)
Definition: SVGLoader.hh:75
std::string id
An id or name.
Definition: SVGLoader.hh:72