maliput_sys/utility/
mod.rs

1// BSD 3-Clause License
2//
3// Copyright (c) 2024, Woven by Toyota.
4// All rights reserved.
5//
6// Redistribution and use in source and binary forms, with or without
7// modification, are permitted provided that the following conditions are met:
8//
9// * Redistributions of source code must retain the above copyright notice, this
10//   list of conditions and the following disclaimer.
11//
12// * Redistributions in binary form must reproduce the above copyright notice,
13//   this list of conditions and the following disclaimer in the documentation
14//   and/or other materials provided with the distribution.
15//
16// * Neither the name of the copyright holder nor the names of its
17//   contributors may be used to endorse or promote products derived from
18//   this software without specific prior written permission.
19//
20// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
31#[cxx::bridge(namespace = "maliput::utility")]
32#[allow(clippy::missing_safety_doc)]
33pub mod ffi {
34
35    pub struct Features {
36        /// Maximum distance between rendered vertices, in either s- or r-dimension,
37        /// along a lane's surface
38        pub max_grid_unit: f64,
39        /// Minimum number of vertices, in either s- or r-dimension, along a lane's
40        /// surface.
41        pub min_grid_resolution: f64,
42        /// Draw stripes along lane_bounds() of each lane?
43        pub draw_stripes: bool,
44        /// Draw arrows at start/finish of each lane?
45        pub draw_arrows: bool,
46        /// Draw highlighting swath with lane_bounds() of each lane?
47        pub draw_lane_haze: bool,
48        /// Draw branching at BranchPoints?
49        pub draw_branch_points: bool,
50        /// Draw highlighting of elevation_bounds of each lane?
51        pub draw_elevation_bounds: bool,
52        /// Reduce the amount of vertices from the road by creating
53        /// quads big enough which don't violate some tolerance. This could affect
54        /// the accuracy of curved roads.
55        pub off_grid_mesh_generation: bool,
56        /// Tolerance for mesh simplification, or the distance from a vertex to an
57        /// edge line or to a face plane at which said vertex is considered redundant
58        /// (i.e. it is not necessary to further define those geometrical entities),
59        /// in meters. If equal to 0, no mesh simplification will take place. If equal
60        /// to the road linear tolerance, mesh simplification will be constrained
61        /// enough so as to keep mesh geometrical accuracy. If greater than the road
62        /// linear tolerance, mesh size reductions will come at the expense of
63        /// geometrical accuracy.
64        pub simplify_mesh_threshold: f64,
65        /// Absolute width of stripes
66        pub stripe_width: f64,
67        /// Absolute elevation (h) of stripes above road surface
68        pub stripe_elevation: f64,
69        /// Absolute elevation (h) of arrows above road surface
70        pub arrow_elevation: f64,
71        /// Absolute elevation (h) of lane-haze above road surface
72        pub lane_haze_elevation: f64,
73        /// Absolute elevation (h) of branch-points above road surface
74        pub branch_point_elevation: f64,
75        /// Height of rendered branch-point arrows
76        pub branch_point_height: f64,
77        /// Origin of OBJ coordinates relative to `Inertial`-frame
78        pub origin: [f64; 3],
79        /// ID's of specific segments to be highlighted.  (If non-empty, then the
80        /// Segments *not* specified on this list will be rendered as grayed-out.)
81        pub highlighted_segments: Vec<String>,
82    }
83    unsafe extern "C++" {
84        include!("utility/utility.h");
85
86        #[namespace = "maliput::api"]
87        type RoadNetwork = crate::api::ffi::RoadNetwork;
88
89        /// Generates an .obj and .mtl files named `fileroot` under the `dirpath` directory.
90        ///
91        /// # Safety
92        ///
93        /// The caller must ensure the `road_network` pointer is valid during the method execution.
94        unsafe fn Utility_GenerateObjFile(
95            road_network: *const RoadNetwork,
96            dirpath: &String,
97            fileroot: &String,
98            features: &Features,
99        );
100    }
101}