points_batch.cc
Go to the documentation of this file.
1 /*
2  * Copyright 2016 The Cartographer Authors
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 
18 
19 namespace cartographer {
20 namespace io {
21 
22 void RemovePoints(std::unordered_set<int> to_remove, PointsBatch* batch) {
23  const int new_num_points = batch->points.size() - to_remove.size();
24  std::vector<Eigen::Vector3f> points;
25  points.reserve(new_num_points);
26  std::vector<float> intensities;
27  if (!batch->intensities.empty()) {
28  intensities.reserve(new_num_points);
29  }
30  std::vector<FloatColor> colors;
31  if (!batch->colors.empty()) {
32  colors.reserve(new_num_points);
33  }
34 
35  for (size_t i = 0; i < batch->points.size(); ++i) {
36  if (to_remove.count(i) == 1) {
37  continue;
38  }
39  points.push_back(batch->points[i]);
40  if (!batch->colors.empty()) {
41  colors.push_back(batch->colors[i]);
42  }
43  if (!batch->intensities.empty()) {
44  intensities.push_back(batch->intensities[i]);
45  }
46  }
47  batch->points = std::move(points);
48  batch->intensities = std::move(intensities);
49  batch->colors = std::move(colors);
50 }
51 
52 } // namespace io
53 } // namespace cartographer
void RemovePoints(std::unordered_set< int > to_remove, PointsBatch *batch)
Definition: points_batch.cc:22
std::vector< FloatColor > colors
Definition: points_batch.h:65
std::vector< float > intensities
Definition: points_batch.h:62
std::vector< Eigen::Vector3f > points
Definition: points_batch.h:55


cartographer
Author(s): The Cartographer Authors
autogenerated on Mon Feb 28 2022 22:00:58