Skip to content

Commit

Permalink
Added SetHeightMap and Heighmap to Geometry Python binding (#1440)
Browse files Browse the repository at this point in the history
Signed-off-by: Alejandro Hernandez Cordero <[email protected]>
  • Loading branch information
ahcorde authored Jun 28, 2024
1 parent 24a6e9a commit 0ecfcc3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
6 changes: 6 additions & 0 deletions python/src/sdf/pyGeometry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "sdf/Cylinder.hh"
#include "sdf/Ellipsoid.hh"
#include "sdf/Geometry.hh"
#include "sdf/Heightmap.hh"
#include "sdf/Mesh.hh"
#include "sdf/Plane.hh"
#include "sdf/Sphere.hh"
Expand Down Expand Up @@ -101,6 +102,11 @@ void defineGeometry(pybind11::object module)
"geometry is not a mesh.")
.def("set_mesh_shape", &sdf::Geometry::SetMeshShape,
"Set the mesh shape.")
.def("set_heightmap_shape", &sdf::Geometry::SetHeightmapShape,
"Set the heightmap shape.")
.def("heightmap_shape", &sdf::Geometry::HeightmapShape,
pybind11::return_value_policy::reference,
"Get the heightmap geometry.")
.def("__copy__", [](const sdf::Geometry &self) {
return sdf::Geometry(self);
})
Expand Down
19 changes: 18 additions & 1 deletion python/test/pyGeometry_TEST.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import copy
from gz_test_deps.sdformat import (Element, Error, Geometry, Box, Capsule, Cone, Cylinder, Ellipsoid,
Mesh, ParserConfig, Plane, Sphere)
Heightmap, Mesh, ParserConfig, Plane, Sphere)
from gz_test_deps.math import Inertiald, MassMatrix3d, Pose3d, Vector3d, Vector2d
import gz_test_deps.sdformat as sdf
import math
Expand Down Expand Up @@ -188,6 +188,23 @@ def test_mesh(self):
self.assertEqual("orange", geom.mesh_shape().submesh())
self.assertTrue(geom.mesh_shape().center_submesh())

def test_heighmap(self):
geom = Geometry()

geom.set_type(sdf.GeometryType.HEIGHTMAP)
heightmap = Heightmap()
geom.set_heightmap_shape(heightmap)

self.assertEqual(sdf.GeometryType.HEIGHTMAP, geom.type())
self.assertEqual(None, geom.box_shape())
self.assertEqual(None, geom.capsule_shape())
self.assertEqual(None, geom.cylinder_shape())
self.assertEqual(None, geom.ellipsoid_shape())
self.assertEqual(None, geom.sphere_shape())
self.assertEqual(None, geom.plane_shape())
self.assertEqual(None, geom.mesh_shape())
self.assertNotEqual(None, geom.heightmap_shape())


def test_plane(self):
geom = Geometry()
Expand Down

0 comments on commit 0ecfcc3

Please sign in to comment.