Gazebo Common

API Reference

4.7.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 IGNITION_COMMON_SVGLOADER_HH_
18 #define IGNITION_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 <ignition/utils/ImplPtr.hh>
28 
29 #include <gz/common/config.hh>
30 #include <gz/common/graphics/Export.hh>
31 #include <gz/common/Console.hh>
32 
33 namespace ignition
34 {
35  namespace common
36  {
38  class IGNITION_COMMON_GRAPHICS_VISIBLE SVGCommand
39  {
41  public: SVGCommand() : cmd(' ') {}
42 
44  public: virtual ~SVGCommand() = default;
45 
47  public: char cmd;
48 
49 #ifdef _WIN32
50 // Disable warning C4251
51 #pragma warning(push)
52 #pragma warning(disable: 4251)
53 #endif
54  public: std::vector<double> numbers;
56 #ifdef _WIN32
57 #pragma warning(pop)
58 #endif
59  };
60 
62  struct IGNITION_COMMON_GRAPHICS_VISIBLE SVGPath
63  {
64 #ifdef _WIN32
65 // Disable warning C4251
66 #pragma warning(push)
67 #pragma warning(disable: 4251)
68 #endif
69 
72 
75 
78 
81 
84 #ifdef _WIN32
85 #pragma warning(pop)
86 #endif
87  };
88 
90  class IGNITION_COMMON_GRAPHICS_VISIBLE SVGLoader
91  {
96  public: explicit SVGLoader(const unsigned int _samples);
97 
99  public: ~SVGLoader();
100 
105  public: bool Parse(const std::string &_filename,
106  std::vector<SVGPath> &_paths);
107 
113  public: static void PathsToClosedPolylines(
114  const std::vector<common::SVGPath> &_paths,
115  const double _tol,
118 
122  public: void DumpPaths(const std::vector<SVGPath> &_paths,
123  std::ostream &_out) const;
124 
127  IGN_UTILS_IMPL_PTR(dataPtr)
128  };
129  }
130 }
131 
132 #endif
A loader for SVG files.
Definition: gz/common/SVGLoader.hh:90
std::string id
An id or name.
Definition: gz/common/SVGLoader.hh:71
ignition::math::Matrix3d transform
A 2D transform (or a list of transforms)
Definition: gz/common/SVGLoader.hh:77
std::vector< std::vector< SVGCommand > > subpaths
A list of subpaths (as lists of commands)
Definition: gz/common/SVGLoader.hh:80
Forward declarations for the common classes.
STL class.
An SVG path element data structure.
Definition: gz/common/SVGLoader.hh:62
SVGCommand()
Constructor.
Definition: gz/common/SVGLoader.hh:41
std::string style
The style (i.e. stroke style, color, thickness etc)
Definition: gz/common/SVGLoader.hh:74
STL class.
char cmd
A letter that describe the segment.
Definition: gz/common/SVGLoader.hh:47
std::vector< std::vector< ignition::math::Vector2d > > polylines
The polylines described by the commands.
Definition: gz/common/SVGLoader.hh:83
SVG command data structure.
Definition: gz/common/SVGLoader.hh:38