Apollo  6.0
Open source self driving car software
i_util.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2018 The Apollo Authors. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *****************************************************************************/
16 #pragma once
17 
18 #include <limits>
19 
21 
22 namespace apollo {
23 namespace perception {
24 namespace common {
25 
26 template <typename T>
27 inline void IGetPointcloudsDimWBound(const T *threeds, int n, int start_offset,
28  int element_size, T *dim_min_x,
29  T *dim_max_x, T *dim_min_y, T *dim_max_y,
30  T *dim_min_z, T *dim_max_z, T bound_min_x,
31  T bound_max_x, T bound_min_y,
32  T bound_max_y, T bound_min_z,
33  T bound_max_z) {
34  int i;
35  T x, y, z;
36 
37  *dim_min_x = *dim_min_y = *dim_min_z = std::numeric_limits<T>::max() / 2;
38  *dim_max_x = *dim_max_y = *dim_max_z = -(std::numeric_limits<T>::max() / 2);
39  const T *cptr = threeds + start_offset;
40  for (i = 0; i < n; i++) {
41  x = cptr[0];
42  y = cptr[1];
43  z = cptr[2];
44  cptr += element_size;
45 
46  if (x < bound_min_x || x > bound_max_x || y < bound_min_y ||
47  y > bound_max_y || z < bound_min_z || z > bound_max_z) {
48  continue;
49  } else {
50  *dim_min_x = IMin(dim_min_x, x);
51  *dim_max_x = IMax(dim_max_x, x);
52  *dim_min_y = IMin(dim_min_y, y);
53  *dim_max_y = IMax(dim_max_y, y);
54  *dim_min_z = IMin(dim_min_z, z);
55  *dim_max_z = IMax(dim_max_z, z);
56  }
57  }
58 }
59 
60 } // namespace common
61 } // namespace perception
62 } // namespace apollo
void IGetPointcloudsDimWBound(const T *threeds, int n, int start_offset, int element_size, T *dim_min_x, T *dim_max_x, T *dim_min_y, T *dim_max_y, T *dim_min_z, T *dim_max_z, T bound_min_x, T bound_max_x, T bound_min_y, T bound_max_y, T bound_min_z, T bound_max_z)
Definition: i_util.h:27
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
T IMax(T a, T b)
Definition: i_basic.h:161
T IMin(T a, T b)
Definition: i_basic.h:155