# -*- python -*-

load(
    "@drake//tools/skylark:drake_cc.bzl",
    "drake_cc_googletest",
    "drake_cc_library",
    "drake_cc_package_library",
)
load("//tools/lint:lint.bzl", "add_lint_tests")

package(default_visibility = ["//visibility:public"])

drake_cc_package_library(
    name = "geometry",
    deps = [
        ":frame_kinematics",
        ":geometry_context",
        ":geometry_frame",
        ":geometry_ids",
        ":geometry_index",
        ":geometry_instance",
        ":geometry_set",
        ":geometry_state",
        ":geometry_visualization",
        ":identifier",
        ":internal_frame",
        ":internal_geometry",
        ":materials",
        ":proximity_engine",
        ":scene_graph",
        ":scene_graph_inspector",
        ":shape_specification",
        ":utilities",
    ],
)

drake_cc_library(
    name = "proximity_engine",
    srcs = [
        "proximity_engine.cc",
    ],
    hdrs = [
        "proximity_engine.h",
    ],
    deps = [
        ":geometry_ids",
        ":geometry_index",
        ":shape_specification",
        "//common",
        "//common:default_scalars",
        "//geometry/query_results:penetration_as_point_pair",
        "//geometry/query_results:signed_distance_pair",
        "@fcl",
        "@tinyobjloader",
    ],
)

drake_cc_library(
    name = "frame_kinematics",
    srcs = [
        "frame_kinematics_vector.cc",
    ],
    hdrs = [
        "frame_kinematics_vector.h",
    ],
    deps = [
        ":geometry_ids",
        "//common:autodiff",
        "//common:essential",
        "//common:symbolic",
    ],
)

drake_cc_library(
    name = "geometry_context",
    srcs = ["geometry_context.cc"],
    hdrs = ["geometry_context.h"],
    deps = [
        ":geometry_state",
        "//systems/framework:leaf_context",
    ],
)

drake_cc_library(
    name = "geometry_frame",
    srcs = [],
    hdrs = ["geometry_frame.h"],
    deps = [
        ":geometry_ids",
        "//common:essential",
    ],
)

drake_cc_library(
    name = "geometry_ids",
    srcs = [],
    hdrs = ["geometry_ids.h"],
    deps = [":identifier"],
)

drake_cc_library(
    name = "geometry_index",
    srcs = [],
    hdrs = ["geometry_index.h"],
    deps = ["//common:type_safe_index"],
)

drake_cc_library(
    name = "geometry_instance",
    srcs = ["geometry_instance.cc"],
    hdrs = ["geometry_instance.h"],
    deps = [
        ":geometry_ids",
        ":materials",
        ":shape_specification",
        ":utilities",
        "//common:copyable_unique_ptr",
        "//common:essential",
    ],
)

drake_cc_library(
    name = "geometry_set",
    hdrs = ["geometry_set.h"],
    deps = [":geometry_ids"],
)

drake_cc_library(
    # NOTE: The material library and file name don't appear to match. This
    # library will eventually contain multiple types of materials (e.g.,
    # contact, rendering, depth, etc.)
    name = "materials",
    srcs = ["visual_material.cc"],
    hdrs = ["visual_material.h"],
    deps = ["//common"],
)

drake_cc_library(
    name = "geometry_state",
    srcs = ["geometry_state.cc"],
    hdrs = ["geometry_state.h"],
    deps = [
        ":frame_kinematics",
        ":geometry_frame",
        ":geometry_ids",
        ":geometry_index",
        ":geometry_instance",
        ":geometry_set",
        ":internal_frame",
        ":internal_geometry",
        ":proximity_engine",
    ],
)

drake_cc_library(
    name = "scene_graph",
    srcs = [
        "query_object.cc",
        "scene_graph.cc",
    ],
    hdrs = [
        "query_object.h",
        "scene_graph.h",
    ],
    deps = [
        ":geometry_context",
        ":geometry_state",
        ":scene_graph_inspector",
        "//common:essential",
        "//geometry/query_results:penetration_as_point_pair",
        "//geometry/query_results:signed_distance_pair",
        "//systems/framework",
        "//systems/rendering:pose_bundle",
    ],
)

drake_cc_library(
    name = "scene_graph_inspector",
    hdrs = ["scene_graph_inspector.h"],
    deps = [":geometry_state"],
)

drake_cc_library(
    name = "geometry_visualization",
    srcs = ["geometry_visualization.cc"],
    hdrs = ["geometry_visualization.h"],
    deps = [
        ":geometry_state",
        ":scene_graph",
        "//lcm",
        "//lcmtypes:viewer",
        "//math:geometric_transform",
        "//systems/framework:diagram_builder",
        "//systems/lcm",
        "//systems/rendering:pose_bundle_to_draw_message",
    ],
)

drake_cc_library(
    name = "internal_frame",
    srcs = ["internal_frame.cc"],
    hdrs = ["internal_frame.h"],
    deps = [
        ":geometry_ids",
        ":geometry_index",
        "//common:essential",
    ],
)

drake_cc_library(
    name = "internal_geometry",
    srcs = ["internal_geometry.cc"],
    hdrs = ["internal_geometry.h"],
    deps = [
        ":geometry_ids",
        ":geometry_index",
        ":materials",
        ":shape_specification",
        "//common:copyable_unique_ptr",
        "//common:essential",
    ],
)

drake_cc_library(
    name = "identifier",
    srcs = [],
    hdrs = ["identifier.h"],
    deps = ["//common:essential"],
)

drake_cc_library(
    name = "shape_specification",
    srcs = ["shape_specification.cc"],
    hdrs = ["shape_specification.h"],
    deps = ["//common:essential"],
)

drake_cc_library(
    name = "utilities",
    srcs = ["utilities.cc"],
    hdrs = ["utilities.h"],
    deps = ["//common"],
)

# -----------------------------------------------------

drake_cc_googletest(
    name = "proximity_engine_test",
    data = [
        "test/forbidden_two_cubes.obj",
        "test/quad_cube.obj",
    ],
    deps = [
        ":proximity_engine",
        ":shape_specification",
        "//common/test_utilities:eigen_matrix_compare",
        "//common/test_utilities:expect_throws_message",
    ],
)

drake_cc_googletest(
    name = "frame_kinematics_vector_test",
    deps = [
        ":frame_kinematics",
        "//common/test_utilities",
    ],
)

drake_cc_googletest(
    name = "geometry_frame_test",
    deps = [
        ":geometry_frame",
        "//common:essential",
    ],
)

drake_cc_googletest(
    name = "geometry_instance_test",
    deps = [
        ":geometry_instance",
        "//common/test_utilities",
    ],
)

drake_cc_googletest(
    name = "geometry_set_test",
    deps = [
        ":geometry_ids",
        ":geometry_set",
    ],
)

drake_cc_googletest(
    name = "geometry_state_test",
    deps = [
        ":geometry_state",
        "//common/test_utilities",
    ],
)

drake_cc_googletest(
    name = "scene_graph_test",
    deps = [
        ":geometry_visualization",
        ":scene_graph",
        "//common/test_utilities:expect_throws_message",
    ],
)

drake_cc_googletest(
    name = "geometry_visualization_test",
    deps = [
        ":geometry_visualization",
        "//common/test_utilities:expect_throws_message",
    ],
)

drake_cc_googletest(
    name = "identifier_test",
    deps = [":identifier"],
)

drake_cc_googletest(
    name = "query_object_test",
    deps = [
        ":geometry_frame",
        ":geometry_instance",
        ":scene_graph",
        "//common/test_utilities:expect_throws_message",
    ],
)

drake_cc_googletest(
    name = "shape_specification_test",
    deps = [
        ":shape_specification",
        "//common/test_utilities",
    ],
)

drake_cc_googletest(
    name = "utilities_test",
    deps = ["utilities"],
)

drake_cc_googletest(
    name = "visual_material_test",
    deps = [
        ":materials",
    ],
)

add_lint_tests()
