Gazebo Common

API Reference

3.17.0
gz/common/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 GZ_COMMON_SVGLOADER_HH_
18 #define GZ_COMMON_SVGLOADER_HH_
19 
20 #include <memory>
21 #include <string>
22 #include <vector>
23 
24 #include <gz/math/Vector2.hh>
25 #include <gz/math/Matrix3.hh>
26 
27 #include <gz/common/graphics/Export.hh>
28 #include <gz/common/Console.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
55  public: std::vector<double> numbers;
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 
78  gz::math::Matrix3d transform;
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
A loader for SVG files.
Definition: gz/common/SVGLoader.hh:91
std::string id
An id or name.
Definition: gz/common/SVGLoader.hh:72
std::vector< std::vector< SVGCommand > > subpaths
A list of subpaths (as lists of commands)
Definition: gz/common/SVGLoader.hh:81
Forward declarations for the common classes.
STL class.
#define IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
Microsoft Visual Studio does not automatically export the interface information for member variables ...
Definition: gz/common/SuppressWarning.hh:65
An SVG path element data structure.
Definition: gz/common/SVGLoader.hh:63
gz::math::Matrix3d transform
A 2D transform (or a list of transforms)
Definition: gz/common/SVGLoader.hh:78
SVGCommand()
Constructor.
Definition: gz/common/SVGLoader.hh:42
std::string style
The style (i.e. stroke style, color, thickness etc)
Definition: gz/common/SVGLoader.hh:75
STL class.
char cmd
A letter that describe the segment.
Definition: gz/common/SVGLoader.hh:48
std::vector< std::vector< gz::math::Vector2d > > polylines
The polylines described by the commands.
Definition: gz/common/SVGLoader.hh:84
SVG command data structure.
Definition: gz/common/SVGLoader.hh:39
#define IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING
Definition: gz/common/SuppressWarning.hh:68