Skip to content

Commit

Permalink
[vtk] Unify include spelling, add comments, fix deps
Browse files Browse the repository at this point in the history
VTK splits its code into libraries, but doesn't use subdir include
paths to reflect the which library has which header. This makes it
difficult to properly update BUILD files as the include statements
evolve. For clarity, we now mark all VTK includes with the library
they come from. We can also add some missing deps now as a result.
  • Loading branch information
jwnimmer-tri committed Aug 21, 2023
1 parent 570897c commit 495a1bf
Show file tree
Hide file tree
Showing 27 changed files with 183 additions and 115 deletions.
4 changes: 3 additions & 1 deletion geometry/proximity/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,9 @@ drake_cc_library(
],
deps = [
"@fmt",
"@vtk//:vtkIOGeometry",
"@vtk//:vtkCommonCore",
"@vtk//:vtkCommonDataModel",
"@vtk//:vtkIOLegacy",
],
)

Expand Down
10 changes: 6 additions & 4 deletions geometry/proximity/vtk_to_volume_mesh.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
#include <vector>

#include <fmt/format.h>
#include <vtkCellIterator.h>
#include <vtkNew.h>
#include <vtkUnstructuredGrid.h>
#include <vtkUnstructuredGridReader.h>

// To ease build system upkeep, we annotate VTK includes with their deps.
#include <vtkCellIterator.h> // vtkCommonDataModel
#include <vtkNew.h> // vtkCommonCore
#include <vtkUnstructuredGrid.h> // vtkCommonDataModel
#include <vtkUnstructuredGridReader.h> // vtkIOLegacy

#include "drake/common/eigen_types.h"

Expand Down
5 changes: 5 additions & 0 deletions geometry/render_gl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,10 @@ drake_cc_library_ubuntu_only(
":internal_opengl_context",
],
deps = [
"@vtk//:vtkCommonCore",
"@vtk//:vtkCommonDataModel",
"@vtk//:vtkIOImage",
"@vtk//:vtkImagingCore",
],
)

Expand Down Expand Up @@ -239,6 +242,8 @@ drake_cc_googletest_ubuntu_only(
"//common/test_utilities:expect_throws_message",
"//geometry/render:render_label",
"//systems/sensors:color_palette",
"@vtk//:vtkCommonCore",
"@vtk//:vtkCommonDataModel",
"@vtk//:vtkIOImage",
],
)
Expand Down
12 changes: 7 additions & 5 deletions geometry/render_gl/internal_texture_library.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
#include <filesystem>

#include <fmt/format.h>
#include <vtkImageCast.h>
#include <vtkImageData.h>
#include <vtkImageExport.h>
#include <vtkNew.h>
#include <vtkPNGReader.h>

// To ease build system upkeep, we annotate VTK includes with their deps.
#include <vtkImageCast.h> // vtkImagingCore
#include <vtkImageData.h> // vtkCommonDataModel
#include <vtkImageExport.h> // vtkIOImage
#include <vtkNew.h> // vtkCommonCore
#include <vtkPNGReader.h> // vtkIOImage

#include "drake/common/drake_assert.h"
#include "drake/common/text_logging.h"
Expand Down
8 changes: 5 additions & 3 deletions geometry/render_gl/test/internal_render_engine_gl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
#include <unordered_map>

#include <gtest/gtest.h>
#include <vtkImageData.h>
#include <vtkNew.h>
#include <vtkPNGReader.h>

// To ease build system upkeep, we annotate VTK includes with their deps.
#include <vtkImageData.h> // vtkCommonDataModel
#include <vtkNew.h> // vtkCommonCore
#include <vtkPNGReader.h> // vtkIOImage

#include "drake/common/find_resource.h"
#include "drake/common/fmt_eigen.h"
Expand Down
9 changes: 9 additions & 0 deletions geometry/render_gltf_client/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ drake_cc_library(
"//geometry/render:render_engine",
"//systems/sensors:image",
"@picosha2_internal//:picosha2",
"@vtk//:vtkCommonCore",
"@vtk//:vtkCommonDataModel",
"@vtk//:vtkIOImage",
],
)
Expand All @@ -121,7 +123,10 @@ drake_cc_library(
"//geometry/render_vtk:internal_render_engine_vtk",
"//systems/sensors:image",
"@nlohmann_internal//:nlohmann",
"@vtk//:vtkCommonCore",
"@vtk//:vtkCommonMath",
"@vtk//:vtkIOExport",
"@vtk//:vtkRenderingCore",
],
)

Expand Down Expand Up @@ -240,6 +245,8 @@ drake_cc_googletest(
"//common/test_utilities:expect_throws_message",
"//systems/sensors/test_utilities:image_compare",
"@nlohmann_internal//:nlohmann",
"@vtk//:vtkCommonMath",
"@vtk//:vtkRenderingCore",
],
)

Expand All @@ -265,6 +272,8 @@ drake_cc_binary(
"//systems/sensors:color_palette",
"//systems/sensors:image",
"@gflags",
"@vtk//:vtkCommonCore",
"@vtk//:vtkCommonMath",
"@vtk//:vtkIOImage",
"@vtk//:vtkIOImport",
"@vtk//:vtkRenderingCore",
Expand Down
12 changes: 7 additions & 5 deletions geometry/render_gltf_client/internal_render_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@

#include <fmt/format.h>
#include <picosha2.h>
#include <vtkImageData.h>
#include <vtkImageExport.h>
#include <vtkNew.h>
#include <vtkPNGReader.h>
#include <vtkTIFFReader.h>

// To ease build system upkeep, we annotate VTK includes with their deps.
#include <vtkImageData.h> // vtkCommonDataModel
#include <vtkImageExport.h> // vtkIOImage
#include <vtkNew.h> // vtkCommonCore
#include <vtkPNGReader.h> // vtkIOImage
#include <vtkTIFFReader.h> // vtkIOImage

#include "drake/common/temp_directory.h"
#include "drake/common/text_logging.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
#include <string_view>
#include <utility>

#include <vtkCamera.h>
#include <vtkGLTFExporter.h>
#include <vtkMatrix4x4.h>
#include <vtkVersionMacros.h>
// To ease build system upkeep, we annotate VTK includes with their deps.
#include <vtkCamera.h> // vtkRenderingCore
#include <vtkGLTFExporter.h> // vtkIOExport
#include <vtkMatrix4x4.h> // vtkCommonMath
#include <vtkVersionMacros.h> // vtkCommonCore

#include "drake/common/never_destroyed.h"
#include "drake/common/ssize.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@

#include <gtest/gtest.h>
#include <nlohmann/json.hpp>
#include <vtkCamera.h>
#include <vtkMatrix4x4.h>

// To ease build system upkeep, we annotate VTK includes with their deps.
#include <vtkCamera.h> // vtkRenderingCore
#include <vtkMatrix4x4.h> // vtkCommonMath

#include "drake/common/find_resource.h"
#include "drake/common/fmt_eigen.h"
Expand Down
32 changes: 17 additions & 15 deletions geometry/render_gltf_client/test/server_vtk_backend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,23 @@ programs for the glTF Render Client-Server integration test. */
#include <string>

#include <gflags/gflags.h>
#include <vtkActorCollection.h>
#include <vtkAutoInit.h>
#include <vtkCamera.h>
#include <vtkGLTFImporter.h>
#include <vtkImageExport.h>
#include <vtkLight.h>
#include <vtkMatrix4x4.h>
#include <vtkOpenGLPolyDataMapper.h>
#include <vtkOpenGLShaderProperty.h>
#include <vtkPNGWriter.h>
#include <vtkProperty.h>
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkTIFFWriter.h>
#include <vtkWindowToImageFilter.h>

// To ease build system upkeep, we annotate VTK includes with their deps.
#include <vtkActorCollection.h> // vtkRenderingCore
#include <vtkAutoInit.h> // vtkCommonCore
#include <vtkCamera.h> // vtkRenderingCore
#include <vtkGLTFImporter.h> // vtkIOImport
#include <vtkImageExport.h> // vtkIOImage
#include <vtkLight.h> // vtkRenderingCore
#include <vtkMatrix4x4.h> // vtkCommonMath
#include <vtkOpenGLPolyDataMapper.h> // vtkRenderingOpenGL2
#include <vtkOpenGLShaderProperty.h> // vtkRenderingOpenGL2
#include <vtkPNGWriter.h> // vtkIOImage
#include <vtkProperty.h> // vtkRenderingCore
#include <vtkRenderWindow.h> // vtkRenderingCore
#include <vtkRenderer.h> // vtkRenderingCore
#include <vtkTIFFWriter.h> // vtkIOImage
#include <vtkWindowToImageFilter.h> // vtkRenderingCore

#include "drake/common/drake_assert.h"
#include "drake/common/text_logging.h"
Expand Down
14 changes: 14 additions & 0 deletions geometry/render_vtk/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,14 @@ drake_cc_library(
"//geometry/render_vtk:render_engine_vtk_params",
"//systems/sensors:color_palette",
"@eigen",
"@vtk//:vtkCommonCore",
"@vtk//:vtkCommonExecutionModel",
"@vtk//:vtkCommonTransforms",
"@vtk//:vtkFiltersSources",
"@vtk//:vtkIOGeometry",
"@vtk//:vtkIOImage",
"@vtk//:vtkIOImport",
"@vtk//:vtkImagingCore",
"@vtk//:vtkRenderingCore",
"@vtk//:vtkRenderingOpenGL2",
],
Expand All @@ -83,6 +88,10 @@ drake_cc_library(
"//geometry/render:render_material",
"//geometry/render:render_mesh",
"@vtk//:vtkCommonCore",
"@vtk//:vtkCommonDataModel",
"@vtk//:vtkCommonExecutionModel",
"@vtk//:vtkCommonTransforms",
"@vtk//:vtkFiltersGeneral",
"@vtk//:vtkFiltersSources",
],
)
Expand Down Expand Up @@ -145,13 +154,18 @@ drake_cc_googletest(
"//geometry/test_utilities:dummy_render_engine",
"//math:geometric_transform",
"@vtk//:vtkIOImage",
"@vtk//:vtkRenderingCore",
"@vtk//:vtkRenderingOpenGL2",
],
)

drake_cc_googletest(
name = "internal_vtk_util_test",
deps = [
":internal_vtk_util",
"@vtk//:vtkCommonCore",
"@vtk//:vtkCommonDataModel",
"@vtk//:vtkFiltersSources",
],
)

Expand Down
31 changes: 16 additions & 15 deletions geometry/render_vtk/internal_render_engine_vtk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,22 @@
#include <stdexcept>
#include <utility>

#include <vtkActor.h>
#include <vtkAssembly.h>
#include <vtkCamera.h>
#include <vtkCylinderSource.h>
#include <vtkGLTFImporter.h>
#include <vtkImageCast.h>
#include <vtkOpenGLPolyDataMapper.h>
#include <vtkOpenGLShaderProperty.h>
#include <vtkOpenGLTexture.h>
#include <vtkPNGReader.h>
#include <vtkPlaneSource.h>
#include <vtkProperty.h>
#include <vtkTexturedSphereSource.h>
#include <vtkTransform.h>
#include <vtkTransformPolyDataFilter.h>
// To ease build system upkeep, we annotate VTK includes with their deps.
#include <vtkActor.h> // vtkRenderingCore
#include <vtkAssembly.h> // vtkRenderingCore
#include <vtkCamera.h> // vtkRenderingCore
#include <vtkCylinderSource.h> // vtkFiltersSources
#include <vtkGLTFImporter.h> // vtkIOImport
#include <vtkImageCast.h> // vtkImagingCore
#include <vtkOpenGLPolyDataMapper.h> // vtkRenderingOpenGL2
#include <vtkOpenGLShaderProperty.h> // vtkRenderingOpenGL2
#include <vtkOpenGLTexture.h> // vtkRenderingOpenGL2
#include <vtkPNGReader.h> // vtkIOImage
#include <vtkPlaneSource.h> // vtkFiltersSources
#include <vtkProperty.h> // vtkRenderingCore
#include <vtkTexturedSphereSource.h> // vtkFiltersSources
#include <vtkTransform.h> // vtkCommonTransforms
#include <vtkTransformPolyDataFilter.h> // vtkFiltersGeneral

#include "drake/common/diagnostic_policy.h"
#include "drake/common/text_logging.h"
Expand Down
25 changes: 13 additions & 12 deletions geometry/render_vtk/internal_render_engine_vtk.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@
#include <unordered_map>
#include <vector>

#include <vtkAutoInit.h>
#include <vtkCommand.h>
#include <vtkImageExport.h>
#include <vtkLight.h>
#include <vtkNew.h>
#include <vtkPolyDataAlgorithm.h>
#include <vtkProp3D.h>
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkShaderProgram.h>
#include <vtkSmartPointer.h>
#include <vtkWindowToImageFilter.h>
// To ease build system upkeep, we annotate VTK includes with their deps.
#include <vtkAutoInit.h> // vtkCommonCore
#include <vtkCommand.h> // vtkCommonCore
#include <vtkImageExport.h> // vtkIOImage
#include <vtkLight.h> // vtkRenderingCore
#include <vtkNew.h> // vtkCommonCore
#include <vtkPolyDataAlgorithm.h> // vtkCommonExecutionModel
#include <vtkProp3D.h> // vtkRenderingCore
#include <vtkRenderWindow.h> // vtkRenderingCore
#include <vtkRenderer.h> // vtkRenderingCore
#include <vtkShaderProgram.h> // vtkRenderingOpenGL2
#include <vtkSmartPointer.h> // vtkCommonCore
#include <vtkWindowToImageFilter.h> // vtkRenderingCore

#include "drake/common/drake_copyable.h"
#include "drake/common/drake_export.h"
Expand Down
24 changes: 13 additions & 11 deletions geometry/render_vtk/internal_render_engine_vtk_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@
#include <vector>

#include <fmt/format.h>
#include <vtkCapsuleSource.h>
#include <vtkCellArray.h>
#include <vtkFloatArray.h>
#include <vtkInformation.h>
#include <vtkInformationVector.h>
#include <vtkObjectFactory.h>
#include <vtkPointData.h>
#include <vtkPoints.h>
#include <vtkPolyData.h>
#include <vtkPolyDataAlgorithm.h>
#include <vtkStreamingDemandDrivenPipeline.h>

// To ease build system upkeep, we annotate VTK includes with their deps.
#include <vtkCapsuleSource.h> // vtkFiltersSources
#include <vtkCellArray.h> // vtkCommonDataModel
#include <vtkFloatArray.h> // vtkCommonCore
#include <vtkInformation.h> // vtkCommonCore
#include <vtkInformationVector.h> // vtkCommonCore
#include <vtkObjectFactory.h> // vtkCommonCore
#include <vtkPointData.h> // vtkCommonDataModel
#include <vtkPoints.h> // vtkCommonCore
#include <vtkPolyData.h> // vtkCommonDataModel
#include <vtkPolyDataAlgorithm.h> // vtkCommonExecutionModel
#include <vtkStreamingDemandDrivenPipeline.h> // vtkCommonExecutionModel

#include "drake/common/fmt_eigen.h"
#include "drake/common/scope_exit.h"
Expand Down
11 changes: 6 additions & 5 deletions geometry/render_vtk/internal_render_engine_vtk_base.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#pragma once

#include <vtkCylinderSource.h>
#include <vtkSmartPointer.h>
#include <vtkTexturedSphereSource.h>
#include <vtkTransform.h>
#include <vtkTransformPolyDataFilter.h>
// To ease build system upkeep, we annotate VTK includes with their deps.
#include <vtkCylinderSource.h> // vtkFiltersSources
#include <vtkSmartPointer.h> // vtkCommonCore
#include <vtkTexturedSphereSource.h> // vtkFiltersSources
#include <vtkTransform.h> // vtkCommonTransforms
#include <vtkTransformPolyDataFilter.h> // vtkFiltersGeneral

#include "drake/geometry/geometry_roles.h"
#include "drake/geometry/render/render_mesh.h"
Expand Down
10 changes: 6 additions & 4 deletions geometry/render_vtk/internal_vtk_util.cc
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#include "drake/geometry/render_vtk/internal_vtk_util.h"

#include <Eigen/Dense>
#include <vtkNew.h>
#include <vtkPlaneSource.h>
#include <vtkSmartPointer.h>
#include <vtkTransform.h>

// To ease build system upkeep, we annotate VTK includes with their deps.
#include <vtkNew.h> // vtkCommonCore
#include <vtkPlaneSource.h> // vtkFiltersSources
#include <vtkSmartPointer.h> // vtkCommonCore
#include <vtkTransform.h> // vtkCommonTransforms

#include "drake/math/rotation_matrix.h"

Expand Down
Loading

0 comments on commit 495a1bf

Please sign in to comment.