Heightmap.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2020 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 SDF_HEIGHTMAP_HH_
18 #define SDF_HEIGHTMAP_HH_
19 
20 #include <string>
21 #include <gz/math/Vector3.hh>
22 #include <gz/utils/ImplPtr.hh>
23 #include <sdf/Element.hh>
24 #include <sdf/Error.hh>
25 #include <sdf/sdf_config.h>
26 
27 namespace sdf
28 {
29  // Inline bracket to help doxygen filtering.
30  inline namespace SDF_VERSION_NAMESPACE {
31  //
32 
33  // Forward declarations.
34  class ParserConfig;
35 
38  {
40  public: HeightmapTexture();
41 
48  public: Errors Load(ElementPtr _sdf);
49 
57  public: Errors Load(sdf::ElementPtr _sdf, const ParserConfig &_config);
58 
61  public: double Size() const;
62 
65  public: void SetSize(double _size);
66 
69  public: std::string Diffuse() const;
70 
73  public: void SetDiffuse(const std::string &_diffuse);
74 
77  public: std::string Normal() const;
78 
81  public: void SetNormal(const std::string &_normal);
82 
86  public: sdf::ElementPtr Element() const;
87 
89  GZ_UTILS_IMPL_PTR(dataPtr)
90  };
91 
94  {
96  public: HeightmapBlend();
97 
104  public: Errors Load(ElementPtr _sdf);
105 
108  public: double MinHeight() const;
109 
112  public: void SetMinHeight(double _minHeight);
113 
116  public: double FadeDistance() const;
117 
120  public: void SetFadeDistance(double _fadeDistance);
121 
125  public: sdf::ElementPtr Element() const;
126 
128  GZ_UTILS_IMPL_PTR(dataPtr)
129  };
130 
134  {
136  public: Heightmap();
137 
144  public: Errors Load(ElementPtr _sdf);
145 
153  public: Errors Load(ElementPtr _sdf, const ParserConfig &_config);
154 
157  public: std::string Uri() const;
158 
161  public: void SetUri(const std::string &_uri);
162 
165  public: const std::string &FilePath() const;
166 
169  public: void SetFilePath(const std::string &_filePath);
170 
173  public: gz::math::Vector3d Size() const;
174 
177  public: void SetSize(const gz::math::Vector3d &_size);
178 
181  public: gz::math::Vector3d Position() const;
182 
185  public: void SetPosition(const gz::math::Vector3d &_position);
186 
189  public: bool UseTerrainPaging() const;
190 
193  public: void SetUseTerrainPaging(bool _use);
194 
197  public: unsigned int Sampling() const;
198 
201  public: void SetSampling(unsigned int _sampling);
202 
205  public: uint64_t TextureCount() const;
206 
213  public: const HeightmapTexture *TextureByIndex(uint64_t _index) const;
214 
217  public: void AddTexture(const HeightmapTexture &_texture);
218 
221  public: uint64_t BlendCount() const;
222 
229  public: const HeightmapBlend *BlendByIndex(uint64_t _index) const;
230 
233  public: void AddBlend(const HeightmapBlend &_blend);
234 
238  public: sdf::ElementPtr Element() const;
239 
245  public: sdf::ElementPtr ToElement() const;
246 
253  public: sdf::ElementPtr ToElement(sdf::Errors &_errors) const;
254 
256  GZ_UTILS_IMPL_PTR(dataPtr)
257  };
258  }
259 }
260 #endif
Blend information to be used between textures on heightmaps.
Definition: Heightmap.hh:94
void SetFadeDistance(double _fadeDistance)
Set the distance over which the blend occurs.
double FadeDistance() const
Get the heightmap blend's fade distance.
void SetMinHeight(double _minHeight)
Set the minimum height of the blend in meters.
sdf::ElementPtr Element() const
Get a pointer to the SDF element that was used during load.
Errors Load(ElementPtr _sdf)
Load the heightmap blend geometry based on a element pointer.
double MinHeight() const
Get the heightmap blend's minimum height.
Texture to be used on heightmaps.
Definition: Heightmap.hh:38
Errors Load(sdf::ElementPtr _sdf, const ParserConfig &_config)
Load the heightmap texture geometry based on a element pointer.
void SetNormal(const std::string &_normal)
Set the filename of the normal map.
void SetDiffuse(const std::string &_diffuse)
Set the filename of the diffuse map.
Errors Load(ElementPtr _sdf)
Load the heightmap texture geometry based on a element pointer.
void SetSize(double _size)
Set the size of the texture in meters.
sdf::ElementPtr Element() const
Get a pointer to the SDF element that was used during load.
std::string Diffuse() const
Get the heightmap texture's diffuse map.
std::string Normal() const
Get the heightmap texture's normal map.
double Size() const
Get the heightmap texture's size.
Heightmap represents a shape defined by a 2D field, and is usually accessed through a Geometry.
Definition: Heightmap.hh:134
sdf::ElementPtr Element() const
Get a pointer to the SDF element that was used during load.
bool UseTerrainPaging() const
Get whether the heightmap uses terrain paging.
gz::math::Vector3d Size() const
Get the heightmap's scaling factor.
uint64_t TextureCount() const
Get the number of heightmap textures.
void SetSampling(unsigned int _sampling)
Set the heightmap's sampling.
sdf::ElementPtr ToElement() const
Create and return an SDF element filled with data from this heightmap.
void AddTexture(const HeightmapTexture &_texture)
Add a heightmap texture.
void SetPosition(const gz::math::Vector3d &_position)
Set the heightmap's position offset.
sdf::ElementPtr ToElement(sdf::Errors &_errors) const
Create and return an SDF element filled with data from this heightmap.
void SetFilePath(const std::string &_filePath)
Set the path to the file where this element was loaded from.
unsigned int Sampling() const
Get the heightmap's sampling per datum.
void SetUseTerrainPaging(bool _use)
Set whether the heightmap uses terrain paging.
void AddBlend(const HeightmapBlend &_blend)
Add a heightmap blend.
const HeightmapBlend * BlendByIndex(uint64_t _index) const
Get a heightmap blend based on an index.
void SetSize(const gz::math::Vector3d &_size)
Set the heightmap's scaling factor.
void SetUri(const std::string &_uri)
Set the URI to a grayscale image.
gz::math::Vector3d Position() const
Get the heightmap's position offset.
const HeightmapTexture * TextureByIndex(uint64_t _index) const
Get a heightmap texture based on an index.
uint64_t BlendCount() const
Get the number of heightmap blends.
Errors Load(ElementPtr _sdf, const ParserConfig &_config)
Load the heightmap geometry based on a element pointer.
Errors Load(ElementPtr _sdf)
Load the heightmap geometry based on a element pointer.
const std::string & FilePath() const
The path to the file where this element was loaded from.
std::string Uri() const
Get the heightmap's URI.
This class contains configuration options for the libsdformat parser.
Definition: ParserConfig.hh:100
std::vector< Error > Errors
A vector of Error.
Definition: Types.hh:95
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:55
namespace for Simulation Description Format parser
Definition: Actor.hh:35
#define SDFORMAT_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system_util.hh:25