Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[geometry] Move RenderEngineVtk into its own directory #17169

Merged
merged 1 commit into from
May 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions bindings/pydrake/geometry_py_render.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#include "drake/bindings/pydrake/documentation_pybind.h"
#include "drake/geometry/render/gl_renderer/render_engine_gl_factory.h"
#include "drake/geometry/render/render_engine.h"
#include "drake/geometry/render/render_engine_vtk_factory.h"
#include "drake/geometry/render/render_label.h"
#include "drake/geometry/render_vtk/factory.h"

namespace drake {
namespace pydrake {
Expand Down Expand Up @@ -108,7 +108,8 @@ void DoScalarIndependentDefinitions(py::module m) {
using namespace drake::geometry;
// NOLINTNEXTLINE(build/namespaces): Emulate placement in namespace.
using namespace drake::geometry::render;
constexpr auto& doc = pydrake_doc.drake.geometry.render;
constexpr auto& doc_geometry = pydrake_doc.drake.geometry;
constexpr auto& doc = doc_geometry.render;

{
using Class = ClippingRange;
Expand Down Expand Up @@ -292,16 +293,19 @@ void DoScalarIndependentDefinitions(py::module m) {
cls_doc.ThrowIfInvalid.doc);
}

py::class_<RenderEngineVtkParams>(
m, "RenderEngineVtkParams", doc.RenderEngineVtkParams.doc)
.def(ParamInit<RenderEngineVtkParams>())
.def_readwrite("default_label", &RenderEngineVtkParams::default_label,
doc.RenderEngineVtkParams.default_label.doc)
.def_readwrite("default_diffuse", &RenderEngineVtkParams::default_diffuse,
doc.RenderEngineVtkParams.default_diffuse.doc);
{
using Class = geometry::RenderEngineVtkParams;
constexpr auto& cls_doc = doc_geometry.RenderEngineVtkParams;
py::class_<Class>(m, "RenderEngineVtkParams", cls_doc.doc)
.def(ParamInit<Class>())
.def_readwrite(
"default_label", &Class::default_label, cls_doc.default_label.doc)
.def_readwrite("default_diffuse", &Class::default_diffuse,
cls_doc.default_diffuse.doc);
}

m.def("MakeRenderEngineVtk", &MakeRenderEngineVtk, py::arg("params"),
doc.MakeRenderEngineVtk.doc);
m.def("MakeRenderEngineVtk", &geometry::MakeRenderEngineVtk,
py::arg("params"), doc_geometry.MakeRenderEngineVtk.doc);

{
using Class = RenderEngineGlParams;
Expand Down
2 changes: 1 addition & 1 deletion examples/manipulation_station/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ drake_cc_library(
deps = [
"//common:find_resource",
"//geometry:scene_graph",
"//geometry/render:render_engine_vtk",
"//geometry/render_vtk",
"//manipulation/schunk_wsg:schunk_wsg_constants",
"//manipulation/schunk_wsg:schunk_wsg_position_controller",
"//math:geometric_transform",
Expand Down
6 changes: 3 additions & 3 deletions examples/manipulation_station/manipulation_station.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <utility>

#include "drake/common/find_resource.h"
#include "drake/geometry/render/render_engine_vtk_factory.h"
#include "drake/geometry/render_vtk/factory.h"
#include "drake/manipulation/schunk_wsg/schunk_wsg_constants.h"
#include "drake/manipulation/schunk_wsg/schunk_wsg_position_controller.h"
#include "drake/math/rigid_transform.h"
Expand All @@ -33,9 +33,9 @@ namespace manipulation_station {

using Eigen::Vector3d;
using Eigen::VectorXd;
using geometry::MakeRenderEngineVtk;
using geometry::RenderEngineVtkParams;
using geometry::SceneGraph;
using geometry::render::MakeRenderEngineVtk;
using geometry::render::RenderEngineVtkParams;
using math::RigidTransform;
using math::RigidTransformd;
using math::RollPitchYaw;
Expand Down
2 changes: 1 addition & 1 deletion examples/scene_graph/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ drake_cc_binary(
":bouncing_ball_plant",
"//geometry:drake_visualizer",
"//geometry:scene_graph",
"//geometry/render:render_engine_vtk",
"//geometry/render_vtk",
"//systems/analysis:simulator",
"//systems/framework:diagram",
"//systems/lcm:lcm_pubsub_system",
Expand Down
4 changes: 2 additions & 2 deletions examples/scene_graph/bouncing_ball_run_dynamics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "drake/examples/scene_graph/bouncing_ball_plant.h"
#include "drake/geometry/drake_visualizer.h"
#include "drake/geometry/geometry_instance.h"
#include "drake/geometry/render/render_engine_vtk_factory.h"
#include "drake/geometry/render_vtk/factory.h"
#include "drake/geometry/scene_graph.h"
#include "drake/geometry/shape_specification.h"
#include "drake/lcm/drake_lcm.h"
Expand Down Expand Up @@ -46,8 +46,8 @@ using geometry::PerceptionProperties;
using geometry::ProximityProperties;
using geometry::render::ColorRenderCamera;
using geometry::render::DepthRenderCamera;
using geometry::render::RenderEngineVtkParams;
using geometry::render::RenderLabel;
using geometry::RenderEngineVtkParams;
using geometry::SceneGraph;
using geometry::SourceId;
using lcm::DrakeLcm;
Expand Down
1 change: 1 addition & 0 deletions geometry/benchmarking/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ drake_cc_binary(
"//common:filesystem",
"//geometry/render",
"//geometry/render/gl_renderer",
"//geometry/render_vtk",
"//systems/sensors:image_writer",
"@fmt",
"@gflags",
Expand Down
6 changes: 3 additions & 3 deletions geometry/benchmarking/render_benchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "drake/common/filesystem.h"
#include "drake/geometry/render/gl_renderer/render_engine_gl_factory.h"
#include "drake/geometry/render/render_engine_vtk_factory.h"
#include "drake/geometry/render_vtk/factory.h"
#include "drake/systems/sensors/image_writer.h"

namespace drake {
Expand Down Expand Up @@ -370,8 +370,8 @@ BENCHMARK_REGISTER_F(RenderBenchmark, Renderer##ImageT) \
template <>
std::unique_ptr<RenderEngine> MakeEngine<EngineType::Vtk>(
const Vector3d& bg_rgb) {
RenderEngineVtkParams params{{}, {}, bg_rgb};
return MakeRenderEngineVtk(params);
geometry::RenderEngineVtkParams params{{}, {}, bg_rgb};
return geometry::MakeRenderEngineVtk(params);
}

MAKE_BENCHMARK(Vtk, Color);
Expand Down
121 changes: 40 additions & 81 deletions geometry/render/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ drake_cc_package_library(
":render_camera",
":render_engine",
":render_engine_vtk",
":render_engine_vtk_base",
":render_label",
":vtk_util",
],
)

Expand Down Expand Up @@ -56,56 +54,44 @@ drake_cc_library(
],
)

# The VTK-OpenGL-based render engine implementation.
# TODO(jwnimmer-tri) Remove this along with deprecation on 2022-09-01.
_STUB_HDRS = [
"render_engine_vtk.h",
"render_engine_vtk_base.h",
"render_engine_vtk_factory.h",
"vtk_util.h",
]

# TODO(jwnimmer-tri) Remove this along with deprecation on 2022-09-01.
[
genrule(
name = "_cp_" + hdr,
srcs = ["stub/" + hdr],
outs = [hdr],
cmd = "cp $< $@",
tags = ["nolint"],
visibility = ["//visibility:private"],
)
for hdr in _STUB_HDRS
]

# TODO(jwnimmer-tri) Remove this along with deprecation on 2022-09-01.
drake_cc_library(
name = "render_engine_vtk",
srcs = [
"render_engine_vtk.cc",
"render_engine_vtk_factory.cc",
],
hdrs = [
"render_engine_vtk.h",
"render_engine_vtk_factory.h",
],
# render_engine_vtk.h directly pulls in VTK headers; leave it out of the
# install.
install_hdrs_exclude = ["render_engine_vtk.h"],
deps = [
":render_engine",
":render_engine_vtk_base",
":vtk_util",
"//common",
"//geometry/render/shaders:depth_shaders",
"//systems/sensors:color_palette",
"@eigen",
"@vtk//:vtkIOGeometry",
"@vtk//:vtkIOImage",
"@vtk//:vtkRenderingCore",
"@vtk//:vtkRenderingOpenGL2",
],
)

# Common functionality for VTK-based render engine implementations.
drake_cc_library(
name = "render_engine_vtk_base",
srcs = [
"render_engine_vtk_base.cc",
],
hdrs = [
"render_engine_vtk_base.h",
],
# render_engine_vtk_base.h directly pulls in VTK headers; leave it out of
# the install.
hdrs = _STUB_HDRS,
install_hdrs_exclude = [
# Since these directly use VTK headers, leave them out of the install.
"render_engine_vtk.h",
"render_engine_vtk_base.h",
"vtk_util.h",
],
visibility = ["//visibility:private"],
tags = ["nolint"],
deps = [
"//common:scope_exit",
"//geometry:geometry_roles",
"//geometry:shape_specification",
"@vtk//:vtkCommonCore",
"@vtk//:vtkFiltersSources",
"//geometry/render_vtk:factory",
"//geometry/render_vtk:internal_render_engine_vtk",
"//geometry/render_vtk:internal_render_engine_vtk_base",
"//geometry/render_vtk:internal_vtk_util",
"//geometry/render_vtk:render_engine_vtk_params",
],
)

Expand All @@ -120,24 +106,6 @@ drake_cc_library(
],
)

drake_cc_library(
name = "vtk_util",
srcs = ["vtk_util.cc"],
hdrs = ["vtk_util.h"],
# We must not expose `#include <vtk/...>` in any of our installed headers;
# vtk_util.h is only included internally within this package.
install_hdrs_exclude = ["vtk_util.h"],
visibility = ["//visibility:private"],
deps = [
"//common:essential",
"//math:geometric_transform",
"@eigen",
"@vtk//:vtkCommonCore",
"@vtk//:vtkCommonTransforms",
"@vtk//:vtkFiltersSources",
],
)

# === test/ ===

filegroup(
Expand Down Expand Up @@ -170,21 +138,6 @@ drake_cc_googletest(
],
)

drake_cc_googletest(
name = "render_engine_vtk_test",
data = [
":test_models",
],
tags = vtk_test_tags(),
deps = [
":render_engine_vtk",
"//common:find_resource",
"//common/test_utilities",
"//geometry/test_utilities:dummy_render_engine",
"//math:geometric_transform",
],
)

drake_cc_googletest(
name = "render_label_test",
deps = [
Expand All @@ -195,8 +148,14 @@ drake_cc_googletest(
)

drake_cc_googletest(
name = "vtk_util_test",
deps = [":vtk_util"],
name = "deprecation_test",
copts = [
"-Wno-cpp",
"-Wno-deprecated-declarations",
],
deps = [
":render",
],
)

add_lint_tests()
7 changes: 4 additions & 3 deletions geometry/render/dev/render_gltf_client/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ drake_cc_library(
":internal_render_client",
"//common:filesystem",
"//geometry/render:render_camera",
"//geometry/render:render_engine_vtk",
"//geometry/render_vtk:internal_render_engine_vtk",
"//systems/sensors:image",
"@vtk//:vtkIOExport",
],
Expand Down Expand Up @@ -171,9 +171,10 @@ drake_cc_binary(
srcs = ["test/gltf_render_server_backend.cc"],
deps = [
"//common:filesystem",
"//geometry/render:render_engine_vtk",
"//geometry/render:render_label",
"//geometry/render/shaders:depth_shaders",
"//geometry/render_vtk:factory",
"//geometry/render_vtk:internal_render_engine_vtk",
"//math:geometric_transform",
"//systems/sensors:color_palette",
"//systems/sensors:image",
Expand Down Expand Up @@ -209,7 +210,7 @@ drake_cc_binary(
"//common:filesystem",
"//geometry:drake_visualizer",
"//geometry:scene_graph",
"//geometry/render:render_engine_vtk",
"//geometry/render_vtk",
"//multibody/parsing",
"//multibody/plant",
"//systems/analysis:simulator",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include "drake/geometry/render/dev/render_gltf_client/factory.h"
#include "drake/geometry/render/dev/render_gltf_client/internal_render_client.h"
#include "drake/geometry/render/render_engine_vtk.h"
#include "drake/geometry/render_vtk/internal_render_engine_vtk.h"

namespace drake {
namespace geometry {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
#include "drake/systems/sensors/color_palette.h"
#include "drake/systems/sensors/image.h"
// Depth shaders need to use the same callback.
#include "drake/geometry/render/render_engine_vtk.h"
#include "drake/geometry/render_vtk/factory.h"
#include "drake/geometry/render_vtk/internal_render_engine_vtk.h"

VTK_MODULE_INIT(vtkRenderingOpenGL2);

Expand Down Expand Up @@ -289,7 +290,7 @@ int do_main() {
if (FLAGS_image_type == "color") {
renderer->SetUseDepthPeeling(1);
renderer->UseFXAAOn();
// Same default as defined in render_engine_vtk_factory.h.
// Same default as defined in render_vtk/factory.h.
renderer->SetBackground(204.0 / 255.0, 229.0 / 255.0, 255.0 / 255.0);
renderer->SetBackgroundAlpha(1.0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "drake/common/find_resource.h"
#include "drake/geometry/drake_visualizer.h"
#include "drake/geometry/render/dev/render_gltf_client/factory.h"
#include "drake/geometry/render/render_engine_vtk_factory.h"
#include "drake/geometry/render_vtk/factory.h"
#include "drake/geometry/scene_graph.h"
#include "drake/lcm/drake_lcm.h"
#include "drake/math/rigid_transform.h"
Expand Down Expand Up @@ -282,8 +282,7 @@ int do_main() {
const std::string render_name("renderer");
if (FLAGS_render_engine == "vtk") {
scene_graph->AddRenderer(render_name,
geometry::render::MakeRenderEngineVtk(
geometry::render::RenderEngineVtkParams()));
geometry::MakeRenderEngineVtk({}));
} else { // FLAGS_render_engine == "client"
scene_graph->AddRenderer(render_name,
geometry::MakeRenderEngineGltfClient(
Expand Down
16 changes: 0 additions & 16 deletions geometry/render/render_engine_vtk_factory.cc

This file was deleted.

6 changes: 6 additions & 0 deletions geometry/render/stub/render_engine_vtk.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once

#warning The include path drake/geometry/render/render_engine_vtk.h is deprecated and will be removed on 2022-09-01; instead, you use drake/geometry/render_vtk/factory.h and call MakeRenderEngineVtk() instead of directly constructing the RenderEngineVtk class yourself.

#include "drake/geometry/render_vtk/factory.h"
#include "drake/geometry/render_vtk/internal_render_engine_vtk.h"
Loading