Ignition Common

API Reference

4.4.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/utils/ImplPtr.hh>
28 
29 #include <ignition/common/graphics/Export.hh>
31 
32 namespace ignition
33 {
34  namespace common
35  {
37  class IGNITION_COMMON_GRAPHICS_VISIBLE SVGCommand
38  {
40  public: SVGCommand() : cmd(' ') {}
41 
43  public: virtual ~SVGCommand() = default;
44 
46  public: char cmd;
47 
48 #ifdef _WIN32
49 // Disable warning C4251
50 #pragma warning(push)
51 #pragma warning(disable: 4251)
52 #endif
53  public: std::vector<double> numbers;
55 #ifdef _WIN32
56 #pragma warning(pop)
57 #endif
58  };
59 
61  struct IGNITION_COMMON_GRAPHICS_VISIBLE SVGPath
62  {
63 #ifdef _WIN32
64 // Disable warning C4251
65 #pragma warning(push)
66 #pragma warning(disable: 4251)
67 #endif
68 
71 
74 
77 
80 
83 #ifdef _WIN32
84 #pragma warning(pop)
85 #endif
86  };
87 
89  class IGNITION_COMMON_GRAPHICS_VISIBLE SVGLoader
90  {
95  public: explicit SVGLoader(const unsigned int _samples);
96 
98  public: ~SVGLoader();
99 
104  public: bool Parse(const std::string &_filename,
105  std::vector<SVGPath> &_paths);
106 
112  public: static void PathsToClosedPolylines(
113  const std::vector<common::SVGPath> &_paths,
114  const double _tol,
117 
121  public: void DumpPaths(const std::vector<SVGPath> &_paths,
122  std::ostream &_out) const;
123 
126  IGN_UTILS_IMPL_PTR(dataPtr)
127  };
128  }
129 }
130 
131 #endif
A loader for SVG files.
Definition: SVGLoader.hh:89
std::string style
The style (i.e. stroke style, color, thickness etc)
Definition: SVGLoader.hh:73
std::vector< std::vector< ignition::math::Vector2d > > polylines
The polylines described by the commands.
Definition: SVGLoader.hh:82
char cmd
A letter that describe the segment.
Definition: SVGLoader.hh:46
std::vector< std::vector< SVGCommand > > subpaths
A list of subpaths (as lists of commands)
Definition: SVGLoader.hh:79
STL class.
SVGCommand()
Constructor.
Definition: SVGLoader.hh:40
An SVG path element data structure.
Definition: SVGLoader.hh:61
SVG command data structure.
Definition: SVGLoader.hh:37
ignition::math::Matrix3d transform
A 2D transform (or a list of transforms)
Definition: SVGLoader.hh:76
Forward declarations for the common classes.
std::string id
An id or name.
Definition: SVGLoader.hh:70
STL class.